Mercurial > hg > th-libs
view th_config.h @ 139:4ca0af6dbcf8
Another fix in the option handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 26 Sep 2014 01:52:14 +0300 |
parents | aa2d608fb3f3 |
children | 51eec969b07a |
line wrap: on
line source
/* * Very simple configuration file handling * Programmed and designed by Matti 'ccr' Hamalainen * (C) Copyright 2004-2012 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_ioctx.h" /* Definitions */ enum ITEM_TYPE { ITEM_SECTION = 1, ITEM_COMMENT, ITEM_STRING, ITEM_INT, ITEM_UINT, ITEM_BOOL, ITEM_FLOAT, ITEM_HEX_TRIPLET, ITEM_STRING_LIST, ITEM_HEX_TRIPLET_LIST }; typedef struct _th_cfgitem_t { int type; char *name; union { int *val_int; unsigned int *val_uint; char **val_str; BOOL *val_bool; void *data; qlist_t **list; struct _th_cfgitem_t *section; } v; struct _th_cfgitem_t *next, *prev; } th_cfgitem_t; /* Functions */ int th_cfg_read(th_ioctx_t *, th_cfgitem_t *); void th_cfg_free(th_cfgitem_t *); int th_cfg_write(th_ioctx_t *, const th_cfgitem_t *); int th_cfg_add_section(th_cfgitem_t **cfg, const char *name, th_cfgitem_t *data); int th_cfg_add_comment(th_cfgitem_t **cfg, const char *comment); int th_cfg_add_int(th_cfgitem_t **cfg, const char *name, int *data, int itemDef); int th_cfg_add_uint(th_cfgitem_t **cfg, const char *name, unsigned int *data, unsigned int itemDef); int th_cfg_add_string(th_cfgitem_t **cfg, const char *name, char **data, char *itemDef); int th_cfg_add_bool(th_cfgitem_t **cfg, const char *name, BOOL *data, BOOL itemDef); int th_cfg_add_float(th_cfgitem_t **cfg, const char *name, float *data, float itemDef); int th_cfg_add_hexvalue(th_cfgitem_t **cfg, const char *name, int *data, int itemDef); int th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, qlist_t **list); th_cfgitem_t *th_cfg_find(th_cfgitem_t *cfg, const char *section, const char *name, const int type); #ifdef __cplusplus } #endif #endif // TH_CONFIG_H