Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

parsecfg.h

Go to the documentation of this file.
00001 /**************************************************************************/
00002 /*                                                                        */
00003 /*  parsecfg - a library for parsing a configuration file                 */
00004 /*  Copyright (C) 1999-2001 Yuuki NINOMIYA <gm@debian.or.jp>              */
00005 /*                                                                        */
00006 /*  This program is free software; you can redistribute it and/or modify  */
00007 /*  it under the terms of the GNU General Public License as published by  */
00008 /*  the Free Software Foundation; either version 2, or (at your option)   */
00009 /*  any later version.                                                    */
00010 /*                                                                        */
00011 /*  This program is distributed in the hope that it will be useful,       */
00012 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of        */
00013 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         */
00014 /*  GNU General Public License for more details.                          */
00015 /*                                                                        */
00016 /*  You should have received a copy of the GNU General Public License     */
00017 /*  along with this program; if not, write to the                         */
00018 /*  Free Software Foundation, Inc., 59 Temple Place - Suite 330,          */
00019 /*  Boston, MA 02111-1307, USA.                                           */
00020 /*                                                                        */
00021 /**************************************************************************/
00022 
00023 /* $Id: parsecfg_8h-source.html,v 1.1.1.1 2003/10/05 17:40:13 sheldonl Exp $ */
00024 
00025 #ifndef PARSECFG_H_INCLUDED
00026 #define PARSECFG_H_INCLUDED
00027 
00028 
00029 #undef PARSECFG_VERSION
00030 #define PARSECFG_VERSION "3.6.7"
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 
00037 /* error code */
00038 typedef enum {
00039     CFG_NO_ERROR,
00040     CFG_OPEN_FAIL,
00041     CFG_CREATE_FAIL,
00042     CFG_SYNTAX_ERROR,
00043     CFG_WRONG_PARAMETER,
00044     CFG_INTERNAL_ERROR,
00045     CFG_INVALID_NUMBER,
00046     CFG_OUT_OF_RANGE,
00047     CFG_MEM_ALLOC_FAIL,
00048     CFG_BOOL_ERROR,
00049     CFG_USED_SECTION,
00050     CFG_NO_CLOSING_BRACE,
00051     CFG_JUST_RETURN_WITHOUT_MSG
00052 } cfgErrorCode;
00053 
00054 /* type of the configuration file */
00055 typedef enum {
00056     CFG_SIMPLE,
00057     CFG_INI
00058 } cfgFileType;
00059 
00060 /* constants for recognized value types */
00061 typedef enum {
00062     CFG_END,
00063     CFG_BOOL,
00064     CFG_STRING,
00065     CFG_INT,
00066     CFG_UINT,
00067     CFG_LONG,
00068     CFG_ULONG,
00069     CFG_STRING_LIST,
00070     CFG_FLOAT,
00071     CFG_DOUBLE
00072 } cfgValueType;
00073 
00074 typedef enum {
00075     CFG_PARAMETER,
00076     CFG_VALUE,
00077     CFG_SECTION
00078 } cfgKeywordValue;
00079 
00080 typedef enum {
00081     CFG_NO_QUOTE,
00082     CFG_SINGLE_QUOTE,
00083     CFG_DOUBLE_QUOTE
00084 } cfgQuote;
00085 
00086 
00087 typedef struct {
00088     char *parameterName;
00089     cfgValueType type;
00090     void *value;
00091 } cfgStruct;
00092 
00093 typedef struct cfgList_tag {
00094     char *str;
00095     struct cfgList_tag *next;
00096 } cfgList;
00097 
00098 
00099 /* proto type declaration of public functions */
00100 
00101 
00102 void cfgSetFatalFunc(void (*f) (cfgErrorCode, const char *, int, const char *));
00103 int cfgParse(const char *file, cfgStruct cfg[], cfgFileType type);
00104 int cfgDump(const char *file, cfgStruct cfg[], cfgFileType type, int max_section);
00105 int fetchVarFromCfgFile(const char *file, char *parameter_name, void *result_value, cfgValueType value_type, cfgFileType file_type, int section_num, const char *section_name);
00106 int cfgSectionNameToNumber(const char *name);
00107 char *cfgSectionNumberToName(int num);
00108 int cfgAllocForNewSection(cfgStruct cfg[], const char *name);
00109 int cfgStoreValue(cfgStruct cfg[], const char *parameter, const char *value, cfgFileType type, int section);
00110 void printconfdata(cfgStruct *dat, cfgFileType type);
00111 
00112 #ifdef __cplusplus
00113 }
00114 #endif
00115 
00116 #endif /* PARSECFG_H_INCLUDED */

Generated on Thu May 16 23:43:08 2002 for KLineakConfig by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002