-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathcountrycode.h
More file actions
73 lines (67 loc) · 3.28 KB
/
Copy pathcountrycode.h
File metadata and controls
73 lines (67 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* File extends GeoIP C API functionality with additional table
* covering couples of ISO 3166 codes (NumCode and Alpha2Code)
*
* Copyright (C) 2012 Masaryk University, Institute of Computer Science
* All rights reserved.
*
* LICENSE TERMS
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the Masaryk University nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* This software is provided ``as is'', and any express or implied
* warranties, including, but not limited to, the implied warranties of
* merchantability and fitness for a particular purpose are disclaimed.
* In no event shall the company or contributors be liable for any
* direct, indirect, incidental, special, exemplary, or consequential
* damages (including, but not limited to, procurement of substitute
* goods or services; loss of use, data, or profits; or business
* interruption) however caused and on any theory of liability, whether
* in contract, strict liability, or tort (including negligence or
* otherwise) arising in any way out of the use of this software, even
* if advised of the possibility of such damage.
*
* $Id: countrycode.h 604 2012-10-09 14:33:38Z 374632 $
*/
/**
* \file countrycode.h
* \brief File extends GeoIP C API functionality with additional table covering couples of ISO 3166 codes (NumCode and Alpha2Code)
* \author Martin Rabek <xrabek1@mail.muni.cz>
* \date 2012
*
* ISO 3166-1 Standard defines three basic sets of country codes: Alpha-2 code, Alpha-3 code and
* Numeric code. Numeric (int) code is the best choice to store ctry code in our new extension,
* however Maxmind C API, GeoIP, does not support it.
*
* That is the reason for this auxiliary file which defines own iso3166_GeoIP_country_codes[254] array,
* where both NumCode and Alpha2Code exists in a defined country_code_iso3166_t structure. This array
* is generated by a simple tool - numCodeTool (with newer versions of GeoIP C API it can be necessary
* to generate it again). Superior advantage of using iso3166_GeoIP_country_codes[254] is that NumCode
* is found out as fast as other GeoIP functions does.
*
* Next, there are declared two global variables for GeoIP database access because definition and using
* for geolocation is not in one .c file so it must be a global variable.
*/
#ifndef COUNTRYCODE_H_
#define COUNTRYCODE_H_
/**
* \brief Structure to store both Numeric code and Alpha-2 code according to ISO 3166-1
*/
typedef struct {
uint16_t num_code; /**< \brief numeric ctry code ISO3166 */
char alpha_code[3]; /**< \brief alpha-2 ctry code ISO3166 */
} country_code_iso3166_t;
extern const country_code_iso3166_t iso3166_GeoIP_country_codes[254];
extern const char* geo_country_alpha[900];
#endif /* COUNTRYCODE_H_ */