1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
2/* GeoIPCity.h
3 *
4 * Copyright (C) 2006 MaxMind LLC
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 */
20
21#ifndef GEOIPCITY_H
22#define GEOIPCITY_H
23
24#include "GeoIP.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#define  GEOIP_UNKNOWN_CONF  ( 0x7f )
31
32typedef struct GeoIPRecordTag {
33	char *country_code;
34	char *country_code3;
35	char *country_name;
36	char *region;
37	char *city;
38	char *postal_code;
39	float latitude;
40	float longitude;
41	union {
42	  int metro_code; /* metro_code is a alias for dma_code */
43	  int dma_code;
44        };
45	int area_code;
46	int charset;
47	char *continent_code;
48        int netmask;
49} GeoIPRecord;
50
51GeoIPRecord * GeoIP_record_by_ipnum (GeoIP* gi, unsigned long ipnum);
52GeoIPRecord * GeoIP_record_by_addr (GeoIP* gi, const char *addr);
53GeoIPRecord * GeoIP_record_by_name (GeoIP* gi, const char *host);
54
55GeoIPRecord * GeoIP_record_by_ipnum_v6 (GeoIP* gi, geoipv6_t ipnum);
56GeoIPRecord * GeoIP_record_by_addr_v6 (GeoIP* gi, const char *addr);
57GeoIPRecord * GeoIP_record_by_name_v6 (GeoIP* gi, const char *host);
58
59int GeoIP_record_id_by_addr (GeoIP* gi, const char *addr);
60int GeoIP_record_id_by_addr_v6 (GeoIP* gi, const char *addr);
61
62int GeoIP_init_record_iter (GeoIP* gi);
63/* returns 0 on success, 1 on failure */
64int GeoIP_next_record (GeoIP* gi, GeoIPRecord **gir, int *record_iter);
65
66void GeoIPRecord_delete (GeoIPRecord *gir);
67
68/* NULL on failure otherwise a malloced string in utf8 */
69/* char * GeoIP_iso_8859_1__utf8(const char *); */
70
71#ifdef __cplusplus
72}
73#endif
74
75#endif /* GEOIPCITY_H */
76