|
1 /** |
|
2 * Some helper functions for working with the iniparser functions - in particular, |
|
3 * for interoperability with the ini format used by the QtSettings class. |
|
4 */ |
|
5 |
|
6 #ifndef INIHELPER_H_ |
|
7 #define INIHELPER_H_ |
|
8 |
|
9 #include "../iniparser/iniparser.h" |
|
10 #include <stdbool.h> |
|
11 |
|
12 /** |
|
13 * Returned buffer must be free()d |
|
14 */ |
|
15 char *inihelper_strdupnull(const char *str); |
|
16 |
|
17 /** |
|
18 * Returned buffer must be free()d |
|
19 */ |
|
20 char *inihelper_urlencode(const char *inbuf); |
|
21 |
|
22 /** |
|
23 * Returned buffer must be free()d |
|
24 */ |
|
25 char *inihelper_urldecode(const char *inbuf); |
|
26 |
|
27 /** |
|
28 * Create a key in the format "sectionName:keyName" |
|
29 * Returned buffer must be free()d |
|
30 */ |
|
31 char *inihelper_createDictKey(const char *sectionName, const char *keyName); |
|
32 |
|
33 /** |
|
34 * Returns an internal buffer, don't modify or free |
|
35 * Sets error to true if something goes wrong, leaves it unchanged otherwise. |
|
36 */ |
|
37 char *inihelper_getstring(dictionary *inifile, bool *error, const char *sectionName, const char *keyName); |
|
38 |
|
39 /** |
|
40 * Returned buffer must be free()d |
|
41 * Sets error to true if something goes wrong, leaves it unchanged otherwise. |
|
42 */ |
|
43 char *inihelper_getstringdup(dictionary *inifile, bool *error, const char *sectionName, const char *keyName); |
|
44 |
|
45 /** |
|
46 * Sets error to true if something goes wrong, leaves it unchanged otherwise. |
|
47 */ |
|
48 int inihelper_getint(dictionary *inifile, bool *error, const char *sectionName, const char *keyName); |
|
49 |
|
50 /** |
|
51 * Sets error to true if something goes wrong, leaves it unchanged otherwise. |
|
52 */ |
|
53 bool inihelper_getbool(dictionary *inifile, bool *error, const char *sectionName, const char *keyName); |
|
54 |
|
55 int inihelper_setstr(dictionary *dict, const char *sectionName, const char *keyName, const char *value); |
|
56 int inihelper_setint(dictionary *dict, const char *sectionName, const char *keyName, int value); |
|
57 int inihelper_setbool(dictionary *dict, const char *sectionName, const char *keyName, bool value); |
|
58 #endif /* INIHELPER_H_ */ |