comparison th_config.h @ 11:e467b3586e4d

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 01 Jan 2010 05:43:28 +0200
parents a25f5d22483e
children 4adf7093060c
comparison
equal deleted inserted replaced
10:a25f5d22483e 11:e467b3586e4d
18 18
19 /* Definitions 19 /* Definitions
20 */ 20 */
21 enum ITEM_TYPE { 21 enum ITEM_TYPE {
22 ITEM_BLOCK = 1, 22 ITEM_BLOCK = 1,
23 ITEM_COMMENT,
23 ITEM_STRING, 24 ITEM_STRING,
24 ITEM_INT, 25 ITEM_INT,
25 ITEM_UINT, 26 ITEM_UINT,
26 ITEM_BOOL, 27 ITEM_BOOL,
27 ITEM_FLOAT 28 ITEM_FLOAT,
29 ITEM_HEX_TRIPLET
28 }; 30 };
29 31
30 32
31 typedef struct _cfgitem_t { 33 typedef struct _cfgitem_t {
32 char *name; /* Config item name */ 34 char *name;
33 int type; /* Type of the item */ 35 int type;
34 void *data; /* Data / value */ 36 void *data;
35
36 BOOL (*validate)(struct _cfgitem_t *); 37 BOOL (*validate)(struct _cfgitem_t *);
37 38
38 struct _cfgitem_t *next, *prev; 39 struct _cfgitem_t *next, *prev;
39 } cfgitem_t; 40 } cfgitem_t;
40 41
41 42
42 /* Functions 43 /* Functions
43 */ 44 */
44 cfgitem_t * th_config_new(void); 45 int th_config_read(FILE *, char *, cfgitem_t *);
45 int th_config_read(char *, cfgitem_t **); 46 void th_config_free(cfgitem_t *);
46 void th_config_free(cfgitem_t *); 47 int th_config_write(FILE *, char *, cfgitem_t *);
47 int th_config_write(FILE *, cfgitem_t *);
48 48
49 int th_config_add_block(cfgitem_t *cfg, char *name, BOOL (*validate)(cfgitem_t *)); 49 int th_config_add_section(cfgitem_t **cfg, char *name, cfgitem_t *data);
50 int th_config_add_int(cfgitem_t *cfg, char *name, BOOL (*validate)(cfgitem_t *), int *data, int itemDef); 50 int th_config_add_comment(cfgitem_t **cfg, char *comment);
51 int th_config_add_uint(cfgitem_t *cfg, char *name, BOOL (*validate)(cfgitem_t *), unsigned int *data, unsigned int itemDef); 51 int th_config_add_int(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), int *data, int itemDef);
52 int th_config_add_str(cfgitem_t *cfg, char *name, BOOL (*validate)(cfgitem_t *), char **data, char *itemDef); 52 int th_config_add_uint(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), unsigned int *data, unsigned int itemDef);
53 int th_config_add_bool(cfgitem_t *cfg, char *name, BOOL (*validate)(cfgitem_t *), BOOL *data, BOOL itemDef); 53 int th_config_add_string(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), char **data, char *itemDef);
54 int th_config_add_float(cfgitem_t *cfg, char *name, BOOL (*validate)(cfgitem_t *), float *data, float itemDef); 54 int th_config_add_bool(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), BOOL *data, BOOL itemDef);
55 int th_config_add_float(cfgitem_t **cfg, char *name, BOOL (*validate)(cfgitem_t *), float *data, float itemDef);
55 56
56 #ifdef __cplusplus 57 #ifdef __cplusplus
57 } 58 }
58 #endif 59 #endif
59 #endif /* _TH_CONFIG_H */ 60 #endif /* _TH_CONFIG_H */