Mercurial > code
comparison ini.h @ 105:eac1f370910a
English review (thanks afranke@)
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 24 Jan 2012 16:26:25 +0100 |
parents | 735d6c774f7a |
children | 07800b7af208 |
comparison
equal
deleted
inserted
replaced
104:c66fb578a7c4 | 105:eac1f370910a |
---|---|
29 typedef struct ini_handler INI_Handler; | 29 typedef struct ini_handler INI_Handler; |
30 | 30 |
31 typedef void (*INI_ConvertFunc)(void *, const char *, void *); | 31 typedef void (*INI_ConvertFunc)(void *, const char *, void *); |
32 | 32 |
33 /* -------------------------------------------------------- | 33 /* -------------------------------------------------------- |
34 * structure definitions | 34 * Structure definitions |
35 * -------------------------------------------------------- */ | 35 * -------------------------------------------------------- */ |
36 | 36 |
37 struct ini_config { | 37 struct ini_config { |
38 /* General settings */ | 38 /* General settings */ |
39 const char *path; /* file path */ | 39 const char *path; /* file path */ |
43 INI_Section *sections; /* linked-list of sections */ | 43 INI_Section *sections; /* linked-list of sections */ |
44 | 44 |
45 /* Private fields */ | 45 /* Private fields */ |
46 INI_Section *_current; /* current working section */ | 46 INI_Section *_current; /* current working section */ |
47 char *_line; /* line buffer */ | 47 char *_line; /* line buffer */ |
48 int _lineno; /* number of line */ | 48 int _lineno; /* number of current line */ |
49 int _linesize; /* initial line size */ | 49 int _linesize; /* initial line size */ |
50 int _ignore; /* must ignore (no redefine) */ | 50 int _ignore; /* must ignore (no redefine) */ |
51 }; | 51 }; |
52 | 52 |
53 struct ini_option { | 53 struct ini_option { |
70 INI_ConvertFunc handler; | 70 INI_ConvertFunc handler; |
71 void *userdata; /* optional user data */ | 71 void *userdata; /* optional user data */ |
72 }; | 72 }; |
73 | 73 |
74 /* -------------------------------------------------------- | 74 /* -------------------------------------------------------- |
75 * INI_Config functions. | 75 * Main functions |
76 * -------------------------------------------------------- */ | 76 * -------------------------------------------------------- */ |
77 | 77 |
78 INI_Config * | 78 INI_Config * |
79 ini_load(const char *, int); | 79 ini_load(const char *, int); |
80 | 80 |
92 | 92 |
93 void | 93 void |
94 ini_free(INI_Config *, int, int); | 94 ini_free(INI_Config *, int, int); |
95 | 95 |
96 /* -------------------------------------------------------- | 96 /* -------------------------------------------------------- |
97 * convenient api to query and convert data | 97 * Convenient api to query and convert data |
98 * -------------------------------------------------------- */ | 98 * -------------------------------------------------------- */ |
99 | 99 |
100 /* | 100 /* |
101 * For the config, read all available value and store them in | 101 * For the config, read all available values and store them in |
102 * the array ini_handler. | 102 * the array ini_handler. |
103 */ | 103 */ |
104 | 104 |
105 void | 105 void |
106 ini_dispatch(INI_Section *, INI_Handler *, int); | 106 ini_dispatch(INI_Section *, INI_Handler *, int); |
113 | 113 |
114 void | 114 void |
115 ini_convert_bool(void *, const char *, void *); | 115 ini_convert_bool(void *, const char *, void *); |
116 | 116 |
117 /* | 117 /* |
118 * Convert to a int. dst must be (int *). | 118 * Convert to an int. dst must be (int *). |
119 */ | 119 */ |
120 | 120 |
121 void | 121 void |
122 ini_convert_int(void *, const char *, void *); | 122 ini_convert_int(void *, const char *, void *); |
123 | 123 |
128 void | 128 void |
129 ini_convert_short(void *, const char *, void *); | 129 ini_convert_short(void *, const char *, void *); |
130 | 130 |
131 /* | 131 /* |
132 * Convert to a char *. dst must be (char **). This | 132 * Convert to a char *. dst must be (char **). This |
133 * function use strdup() you need to free the dst | 133 * function uses strdup(). You need to free the dst |
134 * pointer. | 134 * pointer. |
135 */ | 135 */ |
136 | 136 |
137 void | 137 void |
138 ini_convert_string(void *, const char *, void *); | 138 ini_convert_string(void *, const char *, void *); |