Mercurial > hg > th-libs
annotate th_config.h @ 129:aa2d608fb3f3
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 22 Jun 2014 07:23:54 +0300 |
parents | 50006067bcd1 |
children | 51eec969b07a |
rev | line source |
---|---|
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
10 | 2 * Very simple configuration file handling |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
66 | 4 * (C) Copyright 2004-2012 Tecnic Software productions (TNSP) |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 */ |
49
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
8 #ifndef TH_CONFIG_H |
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
9 #define TH_CONFIG_H |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 #ifdef __cplusplus |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 extern "C" { |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 #endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
15 #include "th_ioctx.h" |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 |
10 | 17 |
18 /* Definitions | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 */ |
69 | 20 enum ITEM_TYPE |
21 { | |
16 | 22 ITEM_SECTION = 1, |
11 | 23 ITEM_COMMENT, |
10 | 24 ITEM_STRING, |
25 ITEM_INT, | |
26 ITEM_UINT, | |
27 ITEM_BOOL, | |
11 | 28 ITEM_FLOAT, |
16 | 29 ITEM_HEX_TRIPLET, |
30 | |
31 ITEM_STRING_LIST, | |
32 ITEM_HEX_TRIPLET_LIST | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 }; |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
36 typedef struct _th_cfgitem_t |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
37 { |
15 | 38 int type; |
11 | 39 char *name; |
15 | 40 union { |
41 int *val_int; | |
42 unsigned int *val_uint; | |
16 | 43 char **val_str; |
15 | 44 BOOL *val_bool; |
16 | 45 |
46 void *data; | |
47 qlist_t **list; | |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
48 struct _th_cfgitem_t *section; |
22
1ac2449c4df7
ISO C99 compatibility fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
49 } v; |
11 | 50 |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
51 struct _th_cfgitem_t *next, *prev; |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
52 } th_cfgitem_t; |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 |
10 | 55 /* Functions |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 */ |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
57 int th_cfg_read(th_ioctx_t *, th_cfgitem_t *); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
58 void th_cfg_free(th_cfgitem_t *); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
59 int th_cfg_write(th_ioctx_t *, const th_cfgitem_t *); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
60 |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
61 int th_cfg_add_section(th_cfgitem_t **cfg, const char *name, th_cfgitem_t *data); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
62 int th_cfg_add_comment(th_cfgitem_t **cfg, const char *comment); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
64 int th_cfg_add_int(th_cfgitem_t **cfg, const char *name, int *data, int itemDef); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
65 int th_cfg_add_uint(th_cfgitem_t **cfg, const char *name, unsigned int *data, unsigned int itemDef); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
66 int th_cfg_add_string(th_cfgitem_t **cfg, const char *name, char **data, char *itemDef); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
67 int th_cfg_add_bool(th_cfgitem_t **cfg, const char *name, BOOL *data, BOOL itemDef); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
68 int th_cfg_add_float(th_cfgitem_t **cfg, const char *name, float *data, float itemDef); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
69 int th_cfg_add_hexvalue(th_cfgitem_t **cfg, const char *name, int *data, int itemDef); |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
70 int th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, qlist_t **list); |
15 | 71 |
83
50006067bcd1
Add new function, th_cfg_find().
Matti Hamalainen <ccr@tnsp.org>
parents:
70
diff
changeset
|
72 th_cfgitem_t *th_cfg_find(th_cfgitem_t *cfg, const char *section, const char *name, const int type); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 #ifdef __cplusplus |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 #endif |
129 | 77 #endif // TH_CONFIG_H |