Mercurial > hg > nnchat
annotate th_config.h @ 273:4d106ad65f26
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 03 Jun 2011 14:07:14 +0300 |
parents | 0db02b8d2d11 |
children |
rev | line source |
---|---|
133 | 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, | |
138
3e221c16b087
Improvements in configuration file handing.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
29 ITEM_HEX_TRIPLET, |
3e221c16b087
Improvements in configuration file handing.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
30 |
3e221c16b087
Improvements in configuration file handing.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
31 ITEM_STRING_LIST, |
3e221c16b087
Improvements in configuration file handing.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
32 ITEM_HEX_TRIPLET_LIST |
133 | 33 }; |
34 | |
35 | |
36 typedef struct _cfgitem_t { | |
37 int type; | |
38 char *name; | |
39 union { | |
40 int *val_int; | |
41 unsigned int *val_uint; | |
138
3e221c16b087
Improvements in configuration file handing.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
42 char **val_str; |
133 | 43 BOOL *val_bool; |
138
3e221c16b087
Improvements in configuration file handing.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
44 |
3e221c16b087
Improvements in configuration file handing.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
45 void *data; |
3e221c16b087
Improvements in configuration file handing.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
46 qlist_t **list; |
133 | 47 struct _cfgitem_t *section; |
261
0db02b8d2d11
ISO C99 compatibility fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
48 } v; |
133 | 49 |
50 struct _cfgitem_t *next, *prev; | |
51 } cfgitem_t; | |
52 | |
53 | |
54 /* Functions | |
55 */ | |
56 int th_cfg_read(FILE *, char *, cfgitem_t *); | |
57 void th_cfg_free(cfgitem_t *); | |
58 int th_cfg_write(FILE *, char *, cfgitem_t *); | |
59 | |
60 int th_cfg_add_section(cfgitem_t **cfg, char *name, cfgitem_t *data); | |
61 int th_cfg_add_comment(cfgitem_t **cfg, char *comment); | |
62 int th_cfg_add_int(cfgitem_t **cfg, char *name, int *data, int itemDef); | |
63 int th_cfg_add_uint(cfgitem_t **cfg, char *name, unsigned int *data, unsigned int itemDef); | |
64 int th_cfg_add_string(cfgitem_t **cfg, char *name, char **data, char *itemDef); | |
65 int th_cfg_add_bool(cfgitem_t **cfg, char *name, BOOL *data, BOOL itemDef); | |
66 int th_cfg_add_float(cfgitem_t **cfg, char *name, float *data, float itemDef); | |
67 int th_cfg_add_hexvalue(cfgitem_t **cfg, char *name, int *data, int itemDef); | |
68 | |
138
3e221c16b087
Improvements in configuration file handing.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
69 int th_cfg_add_string_list(cfgitem_t **cfg, char *name, qlist_t **list); |
133 | 70 |
71 #ifdef __cplusplus | |
72 } | |
73 #endif | |
74 #endif /* _TH_CONFIG_H */ |