Mercurial > hg > th-libs
view th_config.h @ 0:bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
here, because it's cluttered and commit messages are mostly crap.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 26 Mar 2008 04:41:58 +0200 |
parents | |
children | 5a327a2988fa |
line wrap: on
line source
/* * Very simple configuration file parsing functions * Programmed and designed by Matti 'ccr' Hamalainen * (C) Copyright 2004-2007 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> /* * Type definations */ enum ITEM_TYPE { ITEM_BLOCK = 1, ITEM_STRING, ITEM_INT, ITEM_UINT, ITEM_BOOL }; typedef struct tconfignode { char *itemName; /* Config item name */ int itemType; /* Type of the item */ void *itemData; /* Data / value */ BOOL (*itemValidate)(struct tconfignode *); struct tconfignode *pNext, *pPrev; } t_config_item; typedef struct { t_config_item *pItems; } t_config; /* * Functions */ t_config * th_config_new(void); int th_config_read(char *, t_config *); void th_config_free(t_config *); int th_config_write(FILE *, t_config *); int th_config_add_int(t_config *cfg, char *itemName, BOOL (*itemValidate)(t_config_item *), int *itemData, int itemDef); int th_config_add_uint(t_config *cfg, char *itemName, BOOL (*itemValidate)(t_config_item *), unsigned int *itemData, unsigned int itemDef); int th_config_add_str(t_config *cfg, char *itemName, BOOL (*itemValidate)(t_config_item *), char **itemData, char *itemDef); int th_config_add_bool(t_config *cfg, char *itemName, BOOL (*itemValidate)(t_config_item *), BOOL *itemData, BOOL itemDef); #ifdef __cplusplus } #endif #endif /* _TH_CONFIG_H */