00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef lint
00021 static const char rcsid[] = "$Id: core_config.c,v 1.24 2004-10-17 05:14:07 stdarg Exp $";
00022 #endif
00023
00024 #include <eggdrop/eggdrop.h>
00025 #include "core_config.h"
00026
00027 extern char *configfile;
00028 core_config_t core_config = {0};
00029 void *config_root = NULL;
00030
00031 static config_var_t core_config_vars[] = {
00032
00033 {"botname", &core_config.botname, CONFIG_STRING},
00034 {"userfile", &core_config.userfile, CONFIG_STRING},
00035 {"lockfile", &core_config.lockfile, CONFIG_STRING},
00036
00037
00038 {"owner", &core_config.owner, CONFIG_STRING},
00039 {"admin", &core_config.admin, CONFIG_STRING},
00040
00041
00042 {"help_path", &core_config.help_path, CONFIG_STRING},
00043 {"temp_path", &core_config.temp_path, CONFIG_STRING},
00044 {"text_path", &core_config.text_path, CONFIG_STRING},
00045 {"module_path", &core_config.module_path, CONFIG_STRING},
00046
00047
00048 {"whois_items", &core_config.whois_items, CONFIG_STRING},
00049
00050
00051 {"logging.keep_all", &core_config.logging.keep_all, CONFIG_INT},
00052 {"logging.quick", &core_config.logging.quick, CONFIG_INT},
00053 {"logging.max_size", &core_config.logging.max_size, CONFIG_INT},
00054 {"logging.switch_at", &core_config.logging.switch_at, CONFIG_INT},
00055 {"logging.suffix", &core_config.logging.suffix, CONFIG_STRING},
00056
00057
00058 {"die_on_sigterm", &core_config.die_on_sigterm, CONFIG_INT},
00059 {0}
00060 };
00061
00062
00063 int core_config_init(const char *fname)
00064 {
00065
00066 memset(&core_config, 0, sizeof(core_config));
00067
00068
00069 egg_setowner(&core_config.owner);
00070
00071 config_root = config_load(fname);
00072 if (config_root == NULL) return -1;
00073
00074 config_set_root("eggdrop", config_root);
00075 config_link_table(core_config_vars, config_root, "eggdrop", 0, NULL);
00076 if (!core_config.botname) core_config.botname = strdup("eggdrop");
00077 if (!core_config.userfile) core_config.userfile = strdup("users.xml");
00078 if (!core_config.lockfile) core_config.lockfile = strdup("lock");
00079 if (!core_config.help_path) core_config.help_path = strdup("help/");
00080 if (!core_config.logging.suffix) core_config.logging.suffix = strdup(".%d%b%Y");
00081
00082 config_update_table(core_config_vars, config_root, "eggdrop", 0, NULL);
00083
00084 return (0);
00085 }
00086
00087 int core_config_save(void)
00088 {
00089 config_update_table(core_config_vars, config_root, "eggdrop", 0, NULL);
00090
00091 config_save("eggdrop", configfile);
00092
00093 return (0);
00094 }