Mercurial > hg > th-libs
annotate th_config.h @ 22:1ac2449c4df7
ISO C99 compatibility fixes.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 22 May 2011 02:11:05 +0300 |
parents | 0cea9c0cfce7 |
children | 598609fb49b0 |
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 |
3
5a327a2988fa
Breaking the API a bit, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
4 * (C) Copyright 2004-2008 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 */ |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 #ifndef _TH_CONFIG_H |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #define _TH_CONFIG_H |
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 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 #include "th_util.h" |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 #include <stdio.h> |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 |
10 | 18 |
19 /* Definitions | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 */ |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 enum ITEM_TYPE { |
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 |
10 | 36 typedef struct _cfgitem_t { |
15 | 37 int type; |
11 | 38 char *name; |
15 | 39 union { |
40 int *val_int; | |
41 unsigned int *val_uint; | |
16 | 42 char **val_str; |
15 | 43 BOOL *val_bool; |
16 | 44 |
45 void *data; | |
46 qlist_t **list; | |
15 | 47 struct _cfgitem_t *section; |
22
1ac2449c4df7
ISO C99 compatibility fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
48 } v; |
11 | 49 |
10 | 50 struct _cfgitem_t *next, *prev; |
51 } cfgitem_t; | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 |
10 | 54 /* Functions |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 */ |
16 | 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 *); | |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 |
16 | 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); | |
15 | 68 |
16 | 69 int th_cfg_add_string_list(cfgitem_t **cfg, char *name, qlist_t **list); |
0
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 #ifdef __cplusplus |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 } |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 #endif |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 #endif /* _TH_CONFIG_H */ |