Mercurial > hg > th-libs
annotate th_config.h @ 448:57a3472131fd
Typofix.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 25 Oct 2017 21:47:30 +0300 |
parents | 6cfa9bc91ee6 |
children | efd33accdc81 |
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 |
144 | 4 * (C) Copyright 2004-2015 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 |
155
23a79bd6c9d6
Use th_llist for th_config module as well instead of duped linked list
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
11 #include "th_util.h" |
270
6cfa9bc91ee6
Remember to include th_datastruct.h where needed.
Matti Hamalainen <ccr@tnsp.org>
parents:
203
diff
changeset
|
12 #include "th_datastruct.h" |
153
4cd94649475d
Move header includes before C++ guard.
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
13 #include "th_ioctx.h" |
4cd94649475d
Move header includes before C++ guard.
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
14 |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 #ifdef __cplusplus |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 extern "C" { |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 #endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 |
10 | 19 /* Definitions |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 */ |
69 | 21 enum ITEM_TYPE |
22 { | |
16 | 23 ITEM_SECTION = 1, |
11 | 24 ITEM_COMMENT, |
10 | 25 ITEM_STRING, |
26 ITEM_INT, | |
27 ITEM_UINT, | |
28 ITEM_BOOL, | |
11 | 29 ITEM_FLOAT, |
16 | 30 ITEM_HEX_TRIPLET, |
31 | |
32 ITEM_STRING_LIST, | |
33 ITEM_HEX_TRIPLET_LIST | |
0
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 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
37 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
|
38 { |
155
23a79bd6c9d6
Use th_llist for th_config module as well instead of duped linked list
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
39 th_llist_t node; |
23a79bd6c9d6
Use th_llist for th_config module as well instead of duped linked list
Matti Hamalainen <ccr@tnsp.org>
parents:
153
diff
changeset
|
40 |
15 | 41 int type; |
11 | 42 char *name; |
15 | 43 union { |
44 int *val_int; | |
45 unsigned int *val_uint; | |
16 | 46 char **val_str; |
15 | 47 BOOL *val_bool; |
172
eb2c073d93b3
Adding floating point configuration item support.
Matti Hamalainen <ccr@tnsp.org>
parents:
170
diff
changeset
|
48 float *val_float; |
16 | 49 |
50 void *data; | |
152
b4e1b15a64e1
Rename qlist_t doubly linked list structure to th_llist_t.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
51 th_llist_t **list; |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
52 struct _th_cfgitem_t *section; |
22
1ac2449c4df7
ISO C99 compatibility fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
53 } v; |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
54 } th_cfgitem_t; |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 |
10 | 57 /* Functions |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 */ |
203
7acdd3ab6900
Fix th_config for new th_ioctx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
59 int th_cfg_read(th_ioctx *, th_cfgitem_t *); |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
60 void th_cfg_free(th_cfgitem_t *); |
203
7acdd3ab6900
Fix th_config for new th_ioctx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
61 int th_cfg_write(th_ioctx *, const th_cfgitem_t *); |
70
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
62 |
a0e1b29be35d
Refactor configuration file handling module rather thoroughly. The API is
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
63 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
|
64 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
|
65 |
170 | 66 int th_cfg_add_int(th_cfgitem_t **cfg, const char *name, int *data, int defValue); |
67 int th_cfg_add_uint(th_cfgitem_t **cfg, const char *name, unsigned int *data, unsigned int defValue); | |
68 int th_cfg_add_float(th_cfgitem_t **cfg, const char *name, float *data, float defValue); | |
69 int th_cfg_add_string(th_cfgitem_t **cfg, const char *name, char **data, char *defValue); | |
70 int th_cfg_add_bool(th_cfgitem_t **cfg, const char *name, BOOL *data, BOOL defValue); | |
71 int th_cfg_add_float(th_cfgitem_t **cfg, const char *name, float *data, float defValue); | |
72 int th_cfg_add_hexvalue(th_cfgitem_t **cfg, const char *name, int *data, int defValue); | |
152
b4e1b15a64e1
Rename qlist_t doubly linked list structure to th_llist_t.
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
73 int th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, th_llist_t **list); |
15 | 74 |
83
50006067bcd1
Add new function, th_cfg_find().
Matti Hamalainen <ccr@tnsp.org>
parents:
70
diff
changeset
|
75 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
|
76 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 #ifdef __cplusplus |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 #endif |
129 | 80 #endif // TH_CONFIG_H |