Mercurial > hg > nnchat
comparison th_config.h @ 133:ffe8bbd429fa
Config file.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 30 Oct 2010 20:37:09 +0300 |
parents | |
children | 3e221c16b087 |
comparison
equal
deleted
inserted
replaced
132:10daf4660cae | 133:ffe8bbd429fa |
---|---|
1 /* | |
2 * Very simple configuration file handling | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2004-2008 Tecnic Software productions (TNSP) | |
5 * | |
6 * Please read file 'COPYING' for information on license and distribution. | |
7 */ | |
8 #ifndef _TH_CONFIG_H | |
9 #define _TH_CONFIG_H | |
10 | |
11 #ifdef __cplusplus | |
12 extern "C" { | |
13 #endif | |
14 | |
15 #include "th_util.h" | |
16 #include <stdio.h> | |
17 | |
18 | |
19 /* Definitions | |
20 */ | |
21 enum ITEM_TYPE { | |
22 ITEM_SECTION = 1, | |
23 ITEM_COMMENT, | |
24 ITEM_STRING, | |
25 ITEM_INT, | |
26 ITEM_UINT, | |
27 ITEM_BOOL, | |
28 ITEM_FLOAT, | |
29 ITEM_HEX_TRIPLET | |
30 }; | |
31 | |
32 | |
33 typedef struct _cfgitem_t { | |
34 int type; | |
35 char *name; | |
36 union { | |
37 void *data; | |
38 int *val_int; | |
39 unsigned int *val_uint; | |
40 char *val_str; | |
41 BOOL *val_bool; | |
42 struct _cfgitem_t *section; | |
43 }; | |
44 | |
45 struct _cfgitem_t *next, *prev; | |
46 } cfgitem_t; | |
47 | |
48 | |
49 /* Functions | |
50 */ | |
51 int th_cfg_read(FILE *, char *, cfgitem_t *); | |
52 void th_cfg_free(cfgitem_t *); | |
53 int th_cfg_write(FILE *, char *, cfgitem_t *); | |
54 | |
55 int th_cfg_add_section(cfgitem_t **cfg, char *name, cfgitem_t *data); | |
56 int th_cfg_add_comment(cfgitem_t **cfg, char *comment); | |
57 int th_cfg_add_int(cfgitem_t **cfg, char *name, int *data, int itemDef); | |
58 int th_cfg_add_uint(cfgitem_t **cfg, char *name, unsigned int *data, unsigned int itemDef); | |
59 int th_cfg_add_string(cfgitem_t **cfg, char *name, char **data, char *itemDef); | |
60 int th_cfg_add_bool(cfgitem_t **cfg, char *name, BOOL *data, BOOL itemDef); | |
61 int th_cfg_add_float(cfgitem_t **cfg, char *name, float *data, float itemDef); | |
62 int th_cfg_add_hexvalue(cfgitem_t **cfg, char *name, int *data, int itemDef); | |
63 | |
64 | |
65 #ifdef __cplusplus | |
66 } | |
67 #endif | |
68 #endif /* _TH_CONFIG_H */ |