00001 /* 00002 Copyright Remco Bras 2007,2008 00003 This file is part of RPGE. 00004 00005 RPGE is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 RPGE is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/> 00017 */ 00018 00019 /* 00020 config_file.h: Here because config_file.c needs an accompanying header. 00021 */ 00022 00023 #ifndef CONFIG_FILE_H 00024 #define CONFIG_FILE_H 00025 00026 #include <stdio.h> 00027 #include <stdlib.h> 00028 #include <string.h> 00029 #include <libguile.h> 00030 #include <ctype.h> 00031 #include "xalloc.h" 00032 #include "sequence.h" 00033 #include "path.h" 00034 #include "guile.h" /*We need scm_c_safe_load*/ 00035 00036 /* 00037 Define a few structs so we can use either a guile procedure or C function to handle 00038 config file directives. 00039 */ 00040 struct directive_t_func 00041 { 00042 char scmp; 00043 void (*func)(char *); 00044 }; 00045 00046 struct directive_t_scm 00047 { 00048 char scmp; 00049 SCM lambda; 00050 }; 00051 00052 typedef union 00053 { 00054 char scmp; 00055 struct directive_t_func cfunc; 00056 struct directive_t_scm scmfunc; 00057 } directive_t_callee; 00058 00059 typedef struct 00060 { 00061 char* name; 00062 directive_t_callee func; 00063 } directive_t; 00064 00065 extern sequence directives; 00066 00067 #define BLOCK_SIZE 256 00068 00069 char* getline(FILE* stream); 00070 void exec_config_file(char* filename); 00071 void directives_init(); 00072 void register_scm_directive(char* name, SCM func); 00073 void register_directive(char* name,void (*func)(char*)); 00074 void remove_directive(char* name); 00075 directive_t get_obj_directive_t(object o); 00076 object make_directive_t_obj(directive_t d); 00077 00078 #endif