]>
Commit | Line | Data |
---|---|---|
ec684c1a MT |
1 | /* |
2 | libloc - A library to determine the location of someone on the Internet | |
3 | ||
4 | Copyright (C) 2019 IPFire Development Team <info@ipfire.org> | |
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 | ||
17 | #ifndef LIBLOC_COUNTRY_H | |
18 | #define LIBLOC_COUNTRY_H | |
19 | ||
c12a1385 MT |
20 | #include <libloc/libloc.h> |
21 | #include <libloc/format.h> | |
22 | #include <libloc/stringpool.h> | |
ec684c1a MT |
23 | |
24 | struct loc_country; | |
25 | int loc_country_new(struct loc_ctx* ctx, struct loc_country** country, const char* country_code); | |
26 | struct loc_country* loc_country_ref(struct loc_country* country); | |
27 | struct loc_country* loc_country_unref(struct loc_country* country); | |
28 | ||
29 | const char* loc_country_get_code(struct loc_country* country); | |
30 | ||
31 | const char* loc_country_get_continent_code(struct loc_country* country); | |
32 | int loc_country_set_continent_code(struct loc_country* country, const char* continent_code); | |
33 | ||
34 | const char* loc_country_get_name(struct loc_country* country); | |
35 | int loc_country_set_name(struct loc_country* country, const char* name); | |
36 | ||
37 | int loc_country_cmp(struct loc_country* country1, struct loc_country* country2); | |
38 | ||
0f0829ef | 39 | int loc_country_code_is_valid(const char* cc); |
3eb1eed6 | 40 | int loc_country_special_code_to_flag(const char* cc); |
0f0829ef | 41 | |
ec684c1a MT |
42 | #ifdef LIBLOC_PRIVATE |
43 | ||
57146963 MT |
44 | #include <string.h> |
45 | ||
b904896a MT |
46 | int loc_country_new_from_database_v1(struct loc_ctx* ctx, struct loc_stringpool* pool, |
47 | struct loc_country** country, const struct loc_database_country_v1* dbobj); | |
48 | int loc_country_to_database_v1(struct loc_country* country, | |
49 | struct loc_stringpool* pool, struct loc_database_country_v1* dbobj); | |
ec684c1a | 50 | |
a7a3d958 | 51 | static inline void loc_country_code_copy(char* dst, const char* src) { |
ec684c1a MT |
52 | for (unsigned int i = 0; i < 2; i++) { |
53 | dst[i] = src[i]; | |
54 | } | |
ec684c1a MT |
55 | } |
56 | ||
57 | #endif | |
58 | ||
59 | #endif |