Mercurial > hg > th-libs
view th_config.h @ 3:5a327a2988fa
Breaking the API a bit, cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 26 Mar 2008 05:03:16 +0200 |
parents | bd61a80a6c54 |
children | a25f5d22483e |
line wrap: on
line source
/* * Very simple configuration file parsing functions * 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> /* * Type definations */ enum ITEM_TYPE { ITEM_BLOCK = 1, ITEM_STRING, ITEM_INT, ITEM_UINT, ITEM_BOOL }; typedef struct _th_cfgitem_t { char *itemName; /* Config item name */ int itemType; /* Type of the item */ void *itemData; /* Data / value */ BOOL (*itemValidate)(struct _th_cfgitem_t *); struct _th_cfgitem_t *next, *prev; } th_cfgitem_t; typedef struct { th_cfgitem_t *items; } th_config_t; /* * Functions */ th_config_t * th_config_new(void); int th_config_read(char *, th_config_t *); void th_config_free(th_config_t *); int th_config_write(FILE *, th_config_t *); int th_config_add_int(th_config_t *cfg, char *itemName, BOOL (*itemValidate)(th_cfgitem_t *), int *itemData, int itemDef); int th_config_add_uint(th_config_t *cfg, char *itemName, BOOL (*itemValidate)(th_cfgitem_t *), unsigned int *itemData, unsigned int itemDef); int th_config_add_str(th_config_t *cfg, char *itemName, BOOL (*itemValidate)(th_cfgitem_t *), char **itemData, char *itemDef); int th_config_add_bool(th_config_t *cfg, char *itemName, BOOL (*itemValidate)(th_cfgitem_t *), BOOL *itemData, BOOL itemDef); #ifdef __cplusplus } #endif #endif /* _TH_CONFIG_H */