]>
git.ipfire.org Git - people/ms/libloc.git/blob - src/loc/country.h
2 libloc - A library to determine the location of someone on the Internet
4 Copyright (C) 2019 IPFire Development Team <info@ipfire.org>
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.
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.
17 #ifndef LIBLOC_COUNTRY_H
18 #define LIBLOC_COUNTRY_H
20 #include <loc/libloc.h>
21 #include <loc/format.h>
22 #include <loc/stringpool.h>
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
);
29 const char* loc_country_get_code(struct loc_country
* country
);
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
);
34 const char* loc_country_get_name(struct loc_country
* country
);
35 int loc_country_set_name(struct loc_country
* country
, const char* name
);
37 int loc_country_cmp(struct loc_country
* country1
, struct loc_country
* country2
);
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
);
46 static inline void loc_country_copy_code(char* dst
, const char* src
) {
47 for (unsigned int i
= 0; i
< 2; i
++) {
51 // Terminate the string