]>
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 | ||
20 | #include <loc/libloc.h> | |
21 | #include <loc/format.h> | |
22 | #include <loc/stringpool.h> | |
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 | ||
39 | #ifdef LIBLOC_PRIVATE | |
40 | ||
41 | int loc_country_new_from_database_v0(struct loc_ctx* ctx, struct loc_stringpool* pool, | |
42 | struct loc_country** country, const struct loc_database_country_v0* dbobj); | |
43 | int loc_country_to_database_v0(struct loc_country* country, | |
44 | struct loc_stringpool* pool, struct loc_database_country_v0* dbobj); | |
45 | ||
46 | static inline void loc_country_copy_code(char* dst, const char* src) { | |
47 | for (unsigned int i = 0; i < 2; i++) { | |
48 | dst[i] = src[i]; | |
49 | } | |
50 | ||
51 | // Terminate the string | |
52 | dst[3] = '\0'; | |
53 | } | |
54 | ||
55 | #endif | |
56 | ||
57 | #endif |