diff options
Diffstat (limited to 'ini.h')
-rw-r--r-- | ini.h | 106 |
1 files changed, 106 insertions, 0 deletions
@@ -0,0 +1,106 @@ +/* + + viDOOM - level editor for DOOM + + Copyright (C) 2000 Ian Cowburn (ianc@noddybox.demon.co.uk) + + 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 + + ------------------------------------------------------------------------- + + Routines and common keys used to read an INI file + Format of INI file: + + [key] + value_key=value + + $Id$ + +*/ + +#ifndef _INI_H + +#define _INI_H + + +/* Types for table filling queries +*/ +#define INI_INT 0 +#define INI_STR 1 +#define INI_TOK 2 +#define INI_DOUBLE 3 + + +/* Defines the possible values and the corresponding string token for the + value. +*/ +typedef struct + { + char *token; + int val; + } TokenTable; + +/* .data is treated as (int *) for INI_INT and INI_TOK. It is treated as + (char *) for INI_TOK and (double *) INI_DOUBLE. Tokens can be NULL for + non-INI_TOK types. +*/ +typedef struct + { + int type; + char *key; + char *valkey; + void *data; + TokenTable *tokens; + } INI_Table; + + +/* General yes/no token definitions +*/ +extern TokenTable ini_yesno[]; + +/* Macro for calculating table size +*/ +#define INI_TAB_SIZE(x) (sizeof(x)/sizeof(INI_Table)) + + +/* Note all returns are static +*/ +int INI_ReadInt(char *key,char *value_key); +char *INI_ReadStr(char *key,char *value_key); +int INI_ReadToken(char *key,char *value_key,TokenTable tokens[]); +double INI_ReadDouble(char *key,char *value_key); + +void INI_SaveInt(char *key,char *value_key,int val); +void INI_SaveStr(char *key,char *value_key,char *val); +void INI_SaveToken(char *key,char *value_key,int val,TokenTable tokens[]); +void INI_SaveDouble(char *key,char *value_key,double val); + +void INI_DeleteKey(char *key,char *value_key); + +void INI_Load(char *name); +void INI_Save(void); + +void INI_GetTable(INI_Table table[],int no); +void INI_PutTable(INI_Table table[],int no); + +/* This automatically takes iyase_dir from [config] and dir from [key]{iyase} + and adds on the passed filename. Note that return is static. +*/ +char *INI_FileName(char *key,char *fname); + +#endif + + +/* END OF FILE */ |