Mercurial > hg > nnchat
diff th_config.h @ 133:ffe8bbd429fa
Config file.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 30 Oct 2010 20:37:09 +0300 |
parents | |
children | 3e221c16b087 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/th_config.h Sat Oct 30 20:37:09 2010 +0300 @@ -0,0 +1,68 @@ +/* + * Very simple configuration file handling + * Programmed and designed by Matti 'ccr' Hamalainen + * (C) Copyright 2004-2008 Tecnic Software productions (TNSP) + * + * Please read file 'COPYING' for information on license and distribution. + */ +#ifndef _TH_CONFIG_H +#define _TH_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "th_util.h" +#include <stdio.h> + + +/* Definitions + */ +enum ITEM_TYPE { + ITEM_SECTION = 1, + ITEM_COMMENT, + ITEM_STRING, + ITEM_INT, + ITEM_UINT, + ITEM_BOOL, + ITEM_FLOAT, + ITEM_HEX_TRIPLET +}; + + +typedef struct _cfgitem_t { + int type; + char *name; + union { + void *data; + int *val_int; + unsigned int *val_uint; + char *val_str; + BOOL *val_bool; + struct _cfgitem_t *section; + }; + + struct _cfgitem_t *next, *prev; +} cfgitem_t; + + +/* Functions + */ +int th_cfg_read(FILE *, char *, cfgitem_t *); +void th_cfg_free(cfgitem_t *); +int th_cfg_write(FILE *, char *, cfgitem_t *); + +int th_cfg_add_section(cfgitem_t **cfg, char *name, cfgitem_t *data); +int th_cfg_add_comment(cfgitem_t **cfg, char *comment); +int th_cfg_add_int(cfgitem_t **cfg, char *name, int *data, int itemDef); +int th_cfg_add_uint(cfgitem_t **cfg, char *name, unsigned int *data, unsigned int itemDef); +int th_cfg_add_string(cfgitem_t **cfg, char *name, char **data, char *itemDef); +int th_cfg_add_bool(cfgitem_t **cfg, char *name, BOOL *data, BOOL itemDef); +int th_cfg_add_float(cfgitem_t **cfg, char *name, float *data, float itemDef); +int th_cfg_add_hexvalue(cfgitem_t **cfg, char *name, int *data, int itemDef); + + +#ifdef __cplusplus +} +#endif +#endif /* _TH_CONFIG_H */