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

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

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


Revision 1.24 - (hide annotations) (download) (as text)
Sun Oct 17 05:14:07 2004 UTC (14 years, 7 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 wcc 1.10 /* 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 stdarg 1.24 static const char rcsid[] = "$Id: core_config.c,v 1.23 2004/10/06 02:35:15 stdarg Exp $";
22 wcc 1.10 #endif
23    
24 stdarg 1.1 #include <eggdrop/eggdrop.h>
25     #include "core_config.h"
26    
27 stdarg 1.15 extern char *configfile;
28 stdarg 1.1 core_config_t core_config = {0};
29     void *config_root = NULL;
30    
31     static config_var_t core_config_vars[] = {
32 stdarg 1.2 /* General bot stuff. */
33 stdarg 1.22 {"botname", &core_config.botname, CONFIG_STRING}, /* DDC */
34     {"userfile", &core_config.userfile, CONFIG_STRING}, /* DDC */
35     {"lockfile", &core_config.lockfile, CONFIG_STRING}, /* DDC */
36 stdarg 1.1
37 stdarg 1.5 /* The owner. */
38 stdarg 1.22 {"owner", &core_config.owner, CONFIG_STRING}, /* DDC */
39     {"admin", &core_config.admin, CONFIG_STRING}, /* DDC */
40 stdarg 1.5
41     /* Paths. */
42 stdarg 1.22 {"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 stdarg 1.5
47 stdarg 1.13 /* Whois. */
48 stdarg 1.22 {"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 stdarg 1.23 {"logging.suffix", &core_config.logging.suffix, CONFIG_STRING},
56 stdarg 1.13
57 wcc 1.9 /* Other. */
58 stdarg 1.22 {"die_on_sigterm", &core_config.die_on_sigterm, CONFIG_INT},/* DDD*/
59 stdarg 1.1 {0}
60     };
61    
62 wingman 1.21
63 wingman 1.20 int core_config_init(const char *fname)
64 stdarg 1.1 {
65     /* Set default vals. */
66 stdarg 1.5 memset(&core_config, 0, sizeof(core_config));
67 stdarg 1.6
68     /* Hook the owner variable into libeggdrop. */
69     egg_setowner(&core_config.owner);
70 stdarg 1.5
71 stdarg 1.4 config_root = config_load(fname);
72 stdarg 1.22 if (config_root == NULL) return -1;
73 wingman 1.20
74 stdarg 1.3 config_set_root("eggdrop", config_root);
75 stdarg 1.5 config_link_table(core_config_vars, config_root, "eggdrop", 0, NULL);
76 stdarg 1.18 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 stdarg 1.23 if (!core_config.logging.suffix) core_config.logging.suffix = strdup(".%d%b%Y");
81 stdarg 1.18
82     config_update_table(core_config_vars, config_root, "eggdrop", 0, NULL);
83 wingman 1.20
84     return (0);
85 stdarg 1.1 }
86    
87 wingman 1.20 int core_config_save(void)
88 stdarg 1.1 {
89 stdarg 1.5 config_update_table(core_config_vars, config_root, "eggdrop", 0, NULL);
90 wingman 1.21
91 stdarg 1.12 config_save("eggdrop", configfile);
92 wingman 1.20
93     return (0);
94 stdarg 1.1 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23