comparison th_config.h @ 16:0cea9c0cfce7

Sync.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Nov 2010 23:22:44 +0200
parents 4adf7093060c
children 1ac2449c4df7
comparison
equal deleted inserted replaced
15:4adf7093060c 16:0cea9c0cfce7
17 17
18 18
19 /* Definitions 19 /* Definitions
20 */ 20 */
21 enum ITEM_TYPE { 21 enum ITEM_TYPE {
22 ITEM_BLOCK = 1, 22 ITEM_SECTION = 1,
23 ITEM_COMMENT, 23 ITEM_COMMENT,
24 ITEM_STRING, 24 ITEM_STRING,
25 ITEM_INT, 25 ITEM_INT,
26 ITEM_UINT, 26 ITEM_UINT,
27 ITEM_BOOL, 27 ITEM_BOOL,
28 ITEM_FLOAT, 28 ITEM_FLOAT,
29 ITEM_HEX_TRIPLET 29 ITEM_HEX_TRIPLET,
30
31 ITEM_STRING_LIST,
32 ITEM_HEX_TRIPLET_LIST
30 }; 33 };
31 34
32 35
33 typedef struct _cfgitem_t { 36 typedef struct _cfgitem_t {
34 int type; 37 int type;
35 char *name; 38 char *name;
36 union { 39 union {
37 void *data;
38 int *val_int; 40 int *val_int;
39 unsigned int *val_uint; 41 unsigned int *val_uint;
40 char *val_str; 42 char **val_str;
41 BOOL *val_bool; 43 BOOL *val_bool;
44
45 void *data;
46 qlist_t **list;
42 struct _cfgitem_t *section; 47 struct _cfgitem_t *section;
43 }; 48 };
44 BOOL (*validate)(struct _cfgitem_t *);
45 49
46 struct _cfgitem_t *next, *prev; 50 struct _cfgitem_t *next, *prev;
47 } cfgitem_t; 51 } cfgitem_t;
48 52
49 53
50 /* Functions 54 /* Functions
51 */ 55 */
52 int th_config_read(FILE *, char *, cfgitem_t *); 56 int th_cfg_read(FILE *, char *, cfgitem_t *);
53 void th_config_free(cfgitem_t *); 57 void th_cfg_free(cfgitem_t *);
54 int th_config_write(FILE *, char *, cfgitem_t *); 58 int th_cfg_write(FILE *, char *, cfgitem_t *);
55 59
56 int th_config_add_section(cfgitem_t **cfg, char *name, cfgitem_t *data); 60 int th_cfg_add_section(cfgitem_t **cfg, char *name, cfgitem_t *data);
57 int th_config_add_comment(cfgitem_t **cfg, char *comment); 61 int th_cfg_add_comment(cfgitem_t **cfg, char *comment);
58 int th_config_add_int(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), int *data, int itemDef); 62 int th_cfg_add_int(cfgitem_t **cfg, char *name, int *data, int itemDef);
59 int th_config_add_uint(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), unsigned int *data, unsigned int itemDef); 63 int th_cfg_add_uint(cfgitem_t **cfg, char *name, unsigned int *data, unsigned int itemDef);
60 int th_config_add_string(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), char **data, char *itemDef); 64 int th_cfg_add_string(cfgitem_t **cfg, char *name, char **data, char *itemDef);
61 int th_config_add_bool(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), BOOL *data, BOOL itemDef); 65 int th_cfg_add_bool(cfgitem_t **cfg, char *name, BOOL *data, BOOL itemDef);
62 int th_config_add_float(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), float *data, float itemDef); 66 int th_cfg_add_float(cfgitem_t **cfg, char *name, float *data, float itemDef);
63 int th_config_add_hexvalue(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), int *data, int itemDef); 67 int th_cfg_add_hexvalue(cfgitem_t **cfg, char *name, int *data, int itemDef);
64 68
69 int th_cfg_add_string_list(cfgitem_t **cfg, char *name, qlist_t **list);
65 70
66 #ifdef __cplusplus 71 #ifdef __cplusplus
67 } 72 }
68 #endif 73 #endif
69 #endif /* _TH_CONFIG_H */ 74 #endif /* _TH_CONFIG_H */