00001 /* This file is part of confloader 00002 * 00003 * Copyright (c) 2004 Nicolas Bernard <n.bernard@lafraze.net> 00004 * 00005 * Permission to use, copy, modify, and distribute this software for any 00006 * purpose with or without fee is hereby granted, provided that the above 00007 * copyright notice and this permission notice appear in all copies. 00008 * 00009 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 00010 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 00011 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 00012 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00013 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00014 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00015 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00016 */ 00017 00018 /* (confloader users: please, don't remove the present notice, or indicates 00019 another way to the user of your software to access confloader's 00020 documentation) 00021 00022 Confloader's main documentation is in the file confloader.dox 00023 As this documentation file is not necessary at compile time it may be 00024 omitted in the distribution of a program using confloader. 00025 If so, you can still look at the documentation at 00026 http://www.lafraze.net/nbernard/projects/confloader/ 00027 */ 00028 00031 #ifndef _CONFLOADER_H_ 00032 #define _CONFLOADER_H_ 00033 00034 #include <stdio.h> 00035 00037 typedef enum { 00038 YESNO, 00039 INTOPT, 00040 FLOATOPT, 00041 STRINGOPT, 00042 COMMENTOPT, 00045 LOGOPT, 00046 FILEOPT, 00047 UNKNOWNOPT 00050 } ltype; 00051 00052 typedef enum { 00053 LOG__NOTDEF, 00054 LOG__NONE, 00055 LOG__SYSLOG, 00056 LOG__FILE, 00057 LOG__STDERR, 00058 LOG__STDOUT, 00059 ELOG = 10 00060 } log_t; 00061 00062 typedef struct { 00063 log_t logtype; 00064 char* filename; 00065 } logt; 00066 00068 typedef struct { 00069 char* name; 00070 ltype type; 00071 int mandatory; /*< 0: non mandatory, 1: mandatory [and not set, 2 mandatory and set]. */ 00072 union { 00073 int yn; 00074 long int i; 00075 double f; 00076 char* str; 00077 logt log; 00078 } value; 00079 } option; 00080 00081 extern option conf[]; 00082 00084 int confparse(char* conffile, FILE* fderr); 00085 00087 option getconf(const char* name); 00088 00089 #endif /* _CONFLOADER_H_ */