/[cvs]/eggdrop1.9/src/core_config.c
ViewVC logotype

Contents of /eggdrop1.9/src/core_config.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.24 - (show annotations) (download) (as text)
Sun Oct 17 05:14:07 2004 UTC (14 years, 5 months ago) by stdarg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.23: +1 -2 lines
File MIME type: text/x-chdr
* Added a few includs to common.h
* Removed duplicate includes from a bunch of files
* Added tcl date parsing a la "clock scan"
* Fixed some issues with configure (maybe)

1 /* core_config.c: config file
2 *
3 * Copyright (C) 2003, 2004 Eggheads Development Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #ifndef lint
21 static const char rcsid[] = "$Id: core_config.c,v 1.23 2004/10/06 02:35:15 stdarg Exp $";
22 #endif
23
24 #include <eggdrop/eggdrop.h>
25 #include "core_config.h"
26
27 extern char *configfile;
28 core_config_t core_config = {0};
29 void *config_root = NULL;
30
31 static config_var_t core_config_vars[] = {
32 /* General bot stuff. */
33 {"botname", &core_config.botname, CONFIG_STRING}, /* DDC */
34 {"userfile", &core_config.userfile, CONFIG_STRING}, /* DDC */
35 {"lockfile", &core_config.lockfile, CONFIG_STRING}, /* DDC */
36
37 /* The owner. */
38 {"owner", &core_config.owner, CONFIG_STRING}, /* DDC */
39 {"admin", &core_config.admin, CONFIG_STRING}, /* DDC */
40
41 /* Paths. */
42 {"help_path", &core_config.help_path, CONFIG_STRING}, /* DDD */
43 {"temp_path", &core_config.temp_path, CONFIG_STRING}, /* DDD */
44 {"text_path", &core_config.text_path, CONFIG_STRING}, /* DDD */
45 {"module_path", &core_config.module_path, CONFIG_STRING},/* DDD */
46
47 /* Whois. */
48 {"whois_items", &core_config.whois_items, CONFIG_STRING},/* DDD */
49
50 /* Logging. */
51 {"logging.keep_all", &core_config.logging.keep_all, CONFIG_INT},
52 {"logging.quick", &core_config.logging.quick, CONFIG_INT},
53 {"logging.max_size", &core_config.logging.max_size, CONFIG_INT},
54 {"logging.switch_at", &core_config.logging.switch_at, CONFIG_INT},
55 {"logging.suffix", &core_config.logging.suffix, CONFIG_STRING},
56
57 /* Other. */
58 {"die_on_sigterm", &core_config.die_on_sigterm, CONFIG_INT},/* DDD*/
59 {0}
60 };
61
62
63 int core_config_init(const char *fname)
64 {
65 /* Set default vals. */
66 memset(&core_config, 0, sizeof(core_config));
67
68 /* Hook the owner variable into libeggdrop. */
69 egg_setowner(&core_config.owner);
70
71 config_root = config_load(fname);
72 if (config_root == NULL) return -1;
73
74 config_set_root("eggdrop", config_root);
75 config_link_table(core_config_vars, config_root, "eggdrop", 0, NULL);
76 if (!core_config.botname) core_config.botname = strdup("eggdrop");
77 if (!core_config.userfile) core_config.userfile = strdup("users.xml");
78 if (!core_config.lockfile) core_config.lockfile = strdup("lock");
79 if (!core_config.help_path) core_config.help_path = strdup("help/");
80 if (!core_config.logging.suffix) core_config.logging.suffix = strdup(".%d%b%Y");
81
82 config_update_table(core_config_vars, config_root, "eggdrop", 0, NULL);
83
84 return (0);
85 }
86
87 int core_config_save(void)
88 {
89 config_update_table(core_config_vars, config_root, "eggdrop", 0, NULL);
90
91 config_save("eggdrop", configfile);
92
93 return (0);
94 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23