annotate th_config.h @ 363:94e1f57614d3

Bump version again.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Jun 2011 11:13:59 +0300
parents 0db02b8d2d11
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
133
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Very simple configuration file handling
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * (C) Copyright 2004-2008 Tecnic Software productions (TNSP)
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 */
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #ifndef _TH_CONFIG_H
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 #define _TH_CONFIG_H
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #ifdef __cplusplus
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 extern "C" {
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #endif
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 #include "th_util.h"
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 #include <stdio.h>
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 /* Definitions
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 */
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 enum ITEM_TYPE {
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 ITEM_SECTION = 1,
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 ITEM_COMMENT,
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 ITEM_STRING,
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 ITEM_INT,
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 ITEM_UINT,
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 ITEM_BOOL,
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 };
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 typedef struct _cfgitem_t {
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 int type;
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 char *name;
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 union {
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 int *val_int;
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 struct _cfgitem_t *section;
261
0db02b8d2d11 ISO C99 compatibility fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
48 } v;
133
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 struct _cfgitem_t *next, *prev;
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 } cfgitem_t;
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 /* Functions
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 */
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 int th_cfg_read(FILE *, char *, cfgitem_t *);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 void th_cfg_free(cfgitem_t *);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 int th_cfg_write(FILE *, char *, cfgitem_t *);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 int th_cfg_add_section(cfgitem_t **cfg, char *name, cfgitem_t *data);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 int th_cfg_add_comment(cfgitem_t **cfg, char *comment);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 int th_cfg_add_int(cfgitem_t **cfg, char *name, int *data, int itemDef);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 int th_cfg_add_uint(cfgitem_t **cfg, char *name, unsigned int *data, unsigned int itemDef);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 int th_cfg_add_string(cfgitem_t **cfg, char *name, char **data, char *itemDef);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 int th_cfg_add_bool(cfgitem_t **cfg, char *name, BOOL *data, BOOL itemDef);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 int th_cfg_add_float(cfgitem_t **cfg, char *name, float *data, float itemDef);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 int th_cfg_add_hexvalue(cfgitem_t **cfg, char *name, int *data, int itemDef);
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 #ifdef __cplusplus
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 }
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 #endif
ffe8bbd429fa Config file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 #endif /* _TH_CONFIG_H */