www.pudn.com > rDUNclientBeta1.zip > cfg.h
////
// File: cfg.h
// Desc: See cfg.c
////
//Copyright (C) Chris Barnaby 2002
//This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
//This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
//warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//You should have received a copy of the GNU General Public License along with this program; if not, write to the
//Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef _CFG_H_
#define _CFG_H_
extern "C" {
// Parser states
#define STATE_GLOBAL 0
#define STATE_CATEGORY 1
#define STATE_ENTRY 2
#define STATE_VALUE 3
// A variable entry under a category
typedef struct cfgentry_t
{
char name[16];
char val[16];
struct cfgentry_t *next;
struct cfgentry_t *prev;
}cfgentry_t, *cfgentry_ptr;
// A category for variables
typedef struct cfgcategory_t
{
char name[16];
cfgentry_t *entries;
struct cfgcategory_t *next;
struct cfgcategory_t *prev;
}cfgcategory_t, *cfgcategory_ptr;
// Main config structure
typedef struct cfg_t
{
char filename[30];
cfgcategory_t *categories;
}cfg_t, *cfg_ptr;
const char *cfgGetString( cfg_ptr cfg, const char *category, const char *variable, const char *def );
void cfgSetString( cfg_ptr cfg, const char *category, const char *variable, const char *val );
int cfgGetBoolean( cfg_ptr cfg, const char *category, const char *variable, int def );
void cfgSetBoolean( cfg_ptr cfg, const char *category, const char *variable, int val );
int cfgGetInt( cfg_ptr cfg, const char *category, const char *variable, int def );
void cfgSetInt( cfg_ptr cfg, const char *category, const char *variable, int val );
cfg_ptr cfgParse( const char *filename );
cfgentry_ptr _cfgFindEntry( cfg_ptr cfg, const char *category, const char *variable );
void cfgRelease( cfg_ptr cfg );
void cfgWrite( cfg_ptr cfg );
}
#endif