Mercurial > hg > th-libs
annotate th_config.h @ 69:28156333ef4c
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 15 Nov 2012 19:22:42 +0200 |
parents | 34d58b0f2d52 |
children | a0e1b29be35d |
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 |
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 */ |
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 |
10 | 37 typedef struct _cfgitem_t { |
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; | |
15 | 48 struct _cfgitem_t *section; |
22
1ac2449c4df7
ISO C99 compatibility fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
49 } v; |
11 | 50 |
10 | 51 struct _cfgitem_t *next, *prev; |
52 } 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 */ |
16 | 57 int th_cfg_read(FILE *, char *, cfgitem_t *); |
58 void th_cfg_free(cfgitem_t *); | |
59 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
|
60 |
16 | 61 int th_cfg_add_section(cfgitem_t **cfg, char *name, cfgitem_t *data); |
62 int th_cfg_add_comment(cfgitem_t **cfg, char *comment); | |
63 int th_cfg_add_int(cfgitem_t **cfg, char *name, int *data, int itemDef); | |
64 int th_cfg_add_uint(cfgitem_t **cfg, char *name, unsigned int *data, unsigned int itemDef); | |
65 int th_cfg_add_string(cfgitem_t **cfg, char *name, char **data, char *itemDef); | |
66 int th_cfg_add_bool(cfgitem_t **cfg, char *name, BOOL *data, BOOL itemDef); | |
67 int th_cfg_add_float(cfgitem_t **cfg, char *name, float *data, float itemDef); | |
68 int th_cfg_add_hexvalue(cfgitem_t **cfg, char *name, int *data, int itemDef); | |
15 | 69 |
16 | 70 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
|
71 |
bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 #ifdef __cplusplus |
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 #endif |
49
598609fb49b0
Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
75 #endif /* TH_CONFIG_H */ |