Streamer fluid modeling - An overview of ARCoS  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
libconfig.h
Go to the documentation of this file.
1 
5 /* ----------------------------------------------------------------------------
6  libconfig - A library for processing structured configuration files
7  Copyright (C) 2005-2010 Mark A Lindner
8 
9  This file is part of libconfig.
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public License
13  as published by the Free Software Foundation; either version 2.1 of
14  the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Library General Public
22  License along with this library; if not, see
23  <http://www.gnu.org/licenses/>.
24  ----------------------------------------------------------------------------
25 */
26 
27 #ifndef __libconfig_h
28 #define __libconfig_h
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33 
34 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
35 #if defined(LIBCONFIG_STATIC)
36 #define LIBCONFIG_API
37 #elif defined(LIBCONFIG_EXPORTS)
38 #define LIBCONFIG_API __declspec(dllexport)
39 #else /* ! LIBCONFIG_EXPORTS */
40 #define LIBCONFIG_API __declspec(dllimport)
41 #endif /* LIBCONFIG_STATIC */
42 #else /* ! WIN32 */
43 #define LIBCONFIG_API
44 #endif /* WIN32 */
45 
46 #define LIBCONFIG_VER_MAJOR 1
47 #define LIBCONFIG_VER_MINOR 4
48 #define LIBCONFIG_VER_REVISION 9
49 
50 #include <stdio.h>
51 
52 #define CONFIG_TYPE_NONE 0
53 #define CONFIG_TYPE_GROUP 1
54 #define CONFIG_TYPE_INT 2
55 #define CONFIG_TYPE_INT64 3
56 #define CONFIG_TYPE_FLOAT 4
57 #define CONFIG_TYPE_STRING 5
58 #define CONFIG_TYPE_BOOL 6
59 #define CONFIG_TYPE_ARRAY 7
60 #define CONFIG_TYPE_LIST 8
61 
62 #define CONFIG_FORMAT_DEFAULT 0
63 #define CONFIG_FORMAT_HEX 1
64 
65 #define CONFIG_OPTION_AUTOCONVERT 0x01
66 
67 #define CONFIG_TRUE (1)
68 #define CONFIG_FALSE (0)
69 
70 typedef union config_value_t
71 {
72  int ival;
73  long long llval;
74  double fval;
75  char *sval;
78 
79 typedef struct config_setting_t
80 {
81  char *name;
82  short type;
83  short format;
86  struct config_t *config;
87  void *hook;
88  unsigned int line;
89  const char *file;
91 
92 typedef enum
93 {
98 
99 typedef struct config_list_t
100 {
101  unsigned int length;
103 } config_list_t;
104 
105 typedef struct config_t
106 {
108  void (*destructor)(void *);
109  unsigned short flags;
110  unsigned short tab_width;
112  const char *include_dir;
113  const char *error_text;
114  const char *error_file;
117  const char **filenames;
118  unsigned int num_filenames;
119 } config_t;
120 
121 extern LIBCONFIG_API int config_read(config_t *config, FILE *stream);
122 extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream);
123 
125  short format);
126 
127 extern LIBCONFIG_API void config_set_auto_convert(config_t *config, int flag);
128 extern LIBCONFIG_API int config_get_auto_convert(const config_t *config);
129 
130 extern LIBCONFIG_API int config_read_string(config_t *config, const char *str);
131 
132 extern LIBCONFIG_API int config_read_file(config_t *config,
133  const char *filename);
134 extern LIBCONFIG_API int config_write_file(config_t *config,
135  const char *filename);
136 
137 extern LIBCONFIG_API void config_set_destructor(config_t *config,
138  void (*destructor)(void *));
139 extern LIBCONFIG_API void config_set_include_dir(config_t *config,
140  const char *include_dir);
141 
142 extern LIBCONFIG_API void config_init(config_t *config);
143 extern LIBCONFIG_API void config_destroy(config_t *config);
144 
146  const config_setting_t *setting);
147 extern LIBCONFIG_API long long config_setting_get_int64(
148  const config_setting_t *setting);
150  const config_setting_t *setting);
152  const config_setting_t *setting);
153 extern LIBCONFIG_API const char *config_setting_get_string(
154  const config_setting_t *setting);
155 
157  const config_setting_t *setting, const char *name, int *value);
159  const config_setting_t *setting, const char *name, long long *value);
161  const config_setting_t *setting, const char *name, double *value);
163  const config_setting_t *setting, const char *name, int *value);
165  const config_setting_t *setting, const char *name, const char **value);
166 
168  int value);
170  long long value);
172  double value);
174  int value);
176  const char *value);
177 
179  short format);
181  const config_setting_t *setting);
182 
184  const config_setting_t *setting, int idx);
186  const config_setting_t *setting, int idx);
188  const config_setting_t *setting, int idx);
190  const config_setting_t *setting, int idx);
192  const config_setting_t *setting, int idx);
193 
195  config_setting_t *setting, int idx, int value);
197  config_setting_t *setting, int idx, long long value);
199  config_setting_t *setting, int idx, double value);
201  config_setting_t *setting, int idx, int value);
203  config_setting_t *setting, int idx, const char *value);
204 
205 #define /* const char * */ config_get_include_dir(/* const config_t * */ C) \
206  ((C)->include_dir)
207 
208 #define /* int */ config_setting_type(/* const config_setting_t * */ S) \
209  ((S)->type)
210 
211 #define /* int */ config_setting_is_group(/* const config_setting_t * */ S) \
212  ((S)->type == CONFIG_TYPE_GROUP)
213 #define /* int */ config_setting_is_array(/* const config_setting_t * */ S) \
214  ((S)->type == CONFIG_TYPE_ARRAY)
215 #define /* int */ config_setting_is_list(/* const config_setting_t * */ S) \
216  ((S)->type == CONFIG_TYPE_LIST)
217 
218 #define /* int */ config_setting_is_aggregate( \
219  /* const config_setting_t * */ S) \
220  (((S)->type == CONFIG_TYPE_GROUP) || ((S)->type == CONFIG_TYPE_LIST) \
221  || ((S)->type == CONFIG_TYPE_ARRAY))
222 
223 #define /* int */ config_setting_is_number(/* const config_setting_t * */ S) \
224  (((S)->type == CONFIG_TYPE_INT) \
225  || ((S)->type == CONFIG_TYPE_INT64) \
226  || ((S)->type == CONFIG_TYPE_FLOAT))
227 
228 #define /* int */ config_setting_is_scalar(/* const config_setting_t * */ S) \
229  (((S)->type == CONFIG_TYPE_BOOL) || ((S)->type == CONFIG_TYPE_STRING) \
230  || config_setting_is_number(S))
231 
232 #define /* const char * */ config_setting_name( \
233  /* const config_setting_t * */ S) \
234  ((S)->name)
235 
236 #define /* config_setting_t * */ config_setting_parent( \
237  /* const config_setting_t * */ S) \
238  ((S)->parent)
239 
240 #define /* int */ config_setting_is_root( \
241  /* const config_setting_t * */ S) \
242  ((S)->parent ? CONFIG_FALSE : CONFIG_TRUE)
243 
244 extern LIBCONFIG_API int config_setting_index(const config_setting_t *setting);
245 
247  const config_setting_t *setting);
249  const config_setting_t *setting, unsigned int idx);
250 
252  const config_setting_t *setting, const char *name);
253 
255  config_setting_t *parent, const char *name, int type);
257  const char *name);
259  unsigned int idx);
261  void *hook);
262 
263 #define config_setting_get_hook(S) ((S)->hook)
264 
266  const char *path);
268  config_setting_t *setting, const char *path);
269 
270 extern LIBCONFIG_API int config_lookup_int(const config_t *config,
271  const char *path, int *value);
272 extern LIBCONFIG_API int config_lookup_int64(const config_t *config,
273  const char *path,
274  long long *value);
275 extern LIBCONFIG_API int config_lookup_float(const config_t *config,
276  const char *path, double *value);
277 extern LIBCONFIG_API int config_lookup_bool(const config_t *config,
278  const char *path, int *value);
279 extern LIBCONFIG_API int config_lookup_string(const config_t *config,
280  const char *path,
281  const char **value);
282 
283 #define /* config_setting_t * */ config_root_setting( \
284  /* const config_t * */ C) \
285  ((C)->root)
286 
287 #define /* void */ config_set_default_format(/* config_t * */ C, \
288  /* short */ F) \
289  (C)->default_format = (F)
290 
291 #define /* short */ config_get_default_format(/* config_t * */ C) \
292  ((C)->default_format)
293 
294 #define /* void */ config_set_tab_width(/* config_t * */ C, \
295  /* unsigned short */ W) \
296  (C)->tab_width = ((W) & 0x0F)
297 
298 #define /* unsigned char */ config_get_tab_width(/* const config_t * */ C) \
299  ((C)->tab_width)
300 
301 #define /* unsigned short */ config_setting_source_line( \
302  /* const config_setting_t * */ S) \
303  ((S)->line)
304 
305 #define /* const char */ config_setting_source_file( \
306  /* const config_setting_t * */ S) \
307  ((S)->file)
308 
309 #define /* const char * */ config_error_text(/* const config_t * */ C) \
310  ((C)->error_text)
311 
312 #define /* const char * */ config_error_file(/* const config_t * */ C) \
313  ((C)->error_file)
314 
315 #define /* int */ config_error_line(/* const config_t * */ C) \
316  ((C)->error_line)
317 
318 #define /* config_error_t */ config_error_type(/* const config_t * */ C) \
319  ((C)->error_type)
320 
321 #ifdef __cplusplus
322 }
323 #endif /* __cplusplus */
324 
325 #endif /* __libconfig_h */