| 1 |
/* IP2Location.h |
|---|
| 2 |
* |
|---|
| 3 |
* Copyright (C) 2005-2007 IP2Location.com All Rights Reserved. |
|---|
| 4 |
* |
|---|
| 5 |
* http://www.ip2location.com |
|---|
| 6 |
* |
|---|
| 7 |
* This library is free software; you can redistribute it and/or |
|---|
| 8 |
* modify it under the terms of the GNU General Public |
|---|
| 9 |
* License as published by the Free Software Foundation; either |
|---|
| 10 |
* version 2 of the License, or (at your option) any later version. |
|---|
| 11 |
* |
|---|
| 12 |
* This library is distributed in the hope that it will be useful, |
|---|
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 |
* General Public License for more details. |
|---|
| 16 |
* |
|---|
| 17 |
* You should have received a copy of the GNU General Public |
|---|
| 18 |
* License along with this library; if not, write to the Free Software |
|---|
| 19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 |
* |
|---|
| 21 |
*/ |
|---|
| 22 |
#ifndef HAVE_IP2LOCATION_H |
|---|
| 23 |
#define HAVE_IP2LOCATION_H |
|---|
| 24 |
|
|---|
| 25 |
#include <stdlib.h> |
|---|
| 26 |
#include <malloc.h> |
|---|
| 27 |
|
|---|
| 28 |
#include <whisperlib/common/math/imath.h> |
|---|
| 29 |
|
|---|
| 30 |
#define API_VERSION 2.1.3 |
|---|
| 31 |
#define MAX_IPV4_RANGE 4294967295U |
|---|
| 32 |
#define MAX_IPV6_RANGE "340282366920938463463374607431768211455" |
|---|
| 33 |
#define IPV4 0 |
|---|
| 34 |
#define IPV6 1 |
|---|
| 35 |
|
|---|
| 36 |
#define COUNTRYSHORT 0x0001 |
|---|
| 37 |
#define COUNTRYLONG 0x0002 |
|---|
| 38 |
#define REGION 0x0004 |
|---|
| 39 |
#define CITY 0x0008 |
|---|
| 40 |
#define ISP 0x0010 |
|---|
| 41 |
#define LATITUDE 0x0020 |
|---|
| 42 |
#define LONGITUDE 0x0040 |
|---|
| 43 |
#define DOMAIN 0x0080 |
|---|
| 44 |
#define ZIPCODE 0x0100 |
|---|
| 45 |
#define TIMEZONE 0x0200 |
|---|
| 46 |
#define NETSPEED 0x0400 |
|---|
| 47 |
#define ALL COUNTRYSHORT | COUNTRYLONG | REGION | CITY | ISP | LATITUDE | LONGITUDE | DOMAIN | ZIPCODE | TIMEZONE | NETSPEED |
|---|
| 48 |
|
|---|
| 49 |
#define DEFAULT 0x0001 |
|---|
| 50 |
#define NO_EMPTY_STRING 0x0002 |
|---|
| 51 |
#define NO_LEADING 0x0004 |
|---|
| 52 |
#define NO_TRAILING 0x0008 |
|---|
| 53 |
|
|---|
| 54 |
#define INVALID_IPV6_ADDRESS "INVALID IPV6 ADDRESS" |
|---|
| 55 |
#define INVALID_IPV4_ADDRESS "INVALID IPV4 ADDRESS" |
|---|
| 56 |
#define NOT_SUPPORTED "This parameter is unavailable for selected data file. Please upgrade the data file." |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
struct IP2Location { |
|---|
| 60 |
FILE *filehandle; |
|---|
| 61 |
uint8 databasetype; |
|---|
| 62 |
uint8 databasecolumn; |
|---|
| 63 |
uint8 databaseday; |
|---|
| 64 |
uint8 databasemonth; |
|---|
| 65 |
uint8 databaseyear; |
|---|
| 66 |
uint32 databasecount; |
|---|
| 67 |
uint32 databaseaddr; |
|---|
| 68 |
uint32 ipversion; |
|---|
| 69 |
}; |
|---|
| 70 |
|
|---|
| 71 |
struct IP2LocationRecord { |
|---|
| 72 |
char *country_short; |
|---|
| 73 |
char *country_long; |
|---|
| 74 |
char *region; |
|---|
| 75 |
char *city; |
|---|
| 76 |
char *isp; |
|---|
| 77 |
float latitude; |
|---|
| 78 |
float longitude; |
|---|
| 79 |
char *domain; |
|---|
| 80 |
char *zipcode; |
|---|
| 81 |
char *timezone; |
|---|
| 82 |
char *netspeed; |
|---|
| 83 |
}; |
|---|
| 84 |
|
|---|
| 85 |
struct StringList { |
|---|
| 86 |
char* data; |
|---|
| 87 |
struct StringList* next; |
|---|
| 88 |
}; |
|---|
| 89 |
|
|---|
| 90 |
IP2Location *IP2Location_open(const char *db); |
|---|
| 91 |
uint32 IP2Location_close(IP2Location *loc); |
|---|
| 92 |
IP2LocationRecord*IP2Location_get_country_short(IP2Location *loc, |
|---|
| 93 |
const char* ip); |
|---|
| 94 |
IP2LocationRecord* IP2Location_get_country_long(IP2Location *loc, |
|---|
| 95 |
const char* ip); |
|---|
| 96 |
IP2LocationRecord* IP2Location_get_region(IP2Location *loc, |
|---|
| 97 |
const char* ip); |
|---|
| 98 |
IP2LocationRecord* IP2Location_get_city (IP2Location *loc, |
|---|
| 99 |
const char* ip); |
|---|
| 100 |
IP2LocationRecord* IP2Location_get_isp(IP2Location *loc, |
|---|
| 101 |
const char* ip); |
|---|
| 102 |
IP2LocationRecord* IP2Location_get_latitude(IP2Location *loc, |
|---|
| 103 |
const char* ip); |
|---|
| 104 |
IP2LocationRecord* IP2Location_get_longitude(IP2Location *loc, |
|---|
| 105 |
const char* ip); |
|---|
| 106 |
IP2LocationRecord* IP2Location_get_domain(IP2Location *loc, |
|---|
| 107 |
const char* ip); |
|---|
| 108 |
IP2LocationRecord* IP2Location_get_zipcode(IP2Location *loc, |
|---|
| 109 |
const char* ip); |
|---|
| 110 |
IP2LocationRecord* IP2Location_get_timezone(IP2Location *loc, |
|---|
| 111 |
const char* ip); |
|---|
| 112 |
IP2LocationRecord* IP2Location_get_netspeed(IP2Location *loc, |
|---|
| 113 |
const char* ip); |
|---|
| 114 |
IP2LocationRecord* IP2Location_get_all(IP2Location *loc, |
|---|
| 115 |
const char* ip); |
|---|
| 116 |
void IP2Location_free_record(IP2LocationRecord *record); |
|---|
| 117 |
|
|---|
| 118 |
#endif |
|---|