| 1 | /* |
| 2 | * Copyright (C) 2004,2005 Dizzy |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __CONF_H_TYPES__ |
| 20 | #define __CONF_H_TYPES__ |
| 21 | |
| 22 | namespace pvpgn |
| 23 | { |
| 24 | |
| 25 | /* a conf entry object with a set and a get method */ |
| 26 | |
| 27 | typedef struct { |
| 28 | const char *name; |
| 29 | int(*set)(const char *valstr); /* called with NULL for cleanup */ |
| 30 | const char * (*get)(void); |
| 31 | int(*setdef)(void); |
| 32 | } t_conf_entry; |
| 33 | |
| 34 | } |
| 35 | |
| 36 | #endif /* __CONF_H_TYPES__ */ |
| 37 | |
| 38 | #ifndef __CONF_H_PROTOS__ |
| 39 | #define __CONF_H_PROTOS__ |
| 40 | |
| 41 | #include <cstdio> |
| 42 | #include <ctime> |
| 43 | |
| 44 | namespace pvpgn |
| 45 | { |
| 46 | |
| 47 | /* helpfull utility functions for common conf types like bool, int and str */ |
| 48 | extern int conf_set_bool(unsigned *pbool, const char *valstr, unsigned def); |
| 49 | extern int conf_set_int(unsigned *pint, const char *valstr, unsigned def); |
| 50 | extern int conf_set_str(const char **pstr, const char *valstr, const char *def); |
| 51 | extern int conf_set_timestr(std::time_t* ptime, const char *valstr, std::time_t def); |
| 52 | extern const char* conf_get_int(unsigned ival); |
| 53 | extern const char* conf_get_bool(unsigned ival); |
| 54 | |
| 55 | /* loading/unloading functions */ |
| 56 | extern int conf_load_file(std::FILE *fd, t_conf_entry *conftab); |
| 57 | extern int conf_load_cmdline(int argc, char **argv, t_conf_entry *conftab); |
| 58 | extern void conf_unload(t_conf_entry *conftab); |
| 59 | |
| 60 | } |
| 61 | |
| 62 | #endif /* __CONF_H_PROTOS__ */ |