/[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.18 - (hide annotations) (download) (as text)
Mon Jun 21 19:04:51 2004 UTC (14 years, 11 months ago) by stdarg
Branch: MAIN
Changes since 1.17: +9 -7 lines
File MIME type: text/x-chdr
* Trying a simpler method of forking into the background.
* Trying a lockfile approach -- seems to work well so far.

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.18 static const char rcsid[] = "$Id: core_config.c,v 1.17 2004/06/19 17:19:25 wingman Exp $";
22 wcc 1.10 #endif
23    
24 stdarg 1.1 #include <eggdrop/eggdrop.h>
25 wcc 1.11 #include <string.h>
26 stdarg 1.1 #include "core_config.h"
27    
28 stdarg 1.15 extern char *configfile;
29 stdarg 1.1 core_config_t core_config = {0};
30     void *config_root = NULL;
31    
32     static config_var_t core_config_vars[] = {
33 stdarg 1.2 /* General bot stuff. */
34 wingman 1.16 {"botname", &core_config.botname, CONFIG_STRING}, /* DDC */
35     {"userfile", &core_config.userfile, CONFIG_STRING}, /* DDC */
36 stdarg 1.18 {"lockfile", &core_config.lockfile, CONFIG_STRING}, /* DDC */
37 stdarg 1.1
38 stdarg 1.5 /* The owner. */
39 wingman 1.17 {"owner", &core_config.owner, CONFIG_STRING}, /* DDC */
40     {"admin", &core_config.admin, CONFIG_STRING}, /* DDC */
41 stdarg 1.5
42     /* Paths. */
43 wingman 1.16 {"help_path", &core_config.help_path, CONFIG_STRING}, /* DDD */
44     {"temp_path", &core_config.temp_path, CONFIG_STRING}, /* DDD */
45     {"text_path", &core_config.text_path, CONFIG_STRING}, /* DDD */
46     {"module_path", &core_config.module_path, CONFIG_STRING}, /* DDD */
47 stdarg 1.5
48 stdarg 1.2 /* Logfile. */
49 wingman 1.16 {"logfile_suffix", &core_config.logfile_suffix, CONFIG_STRING}, /* DDD */
50     {"max_logsize", &core_config.max_logsize, CONFIG_INT}, /* DDD */
51     {"switch_logfiles_at", &core_config.switch_logfiles_at, CONFIG_INT}, /* DDD */
52     {"keep_all_logs", &core_config.keep_all_logs, CONFIG_INT}, /* DDD */
53     {"quick_logs", &core_config.quick_logs, CONFIG_INT}, /* DDD */
54 stdarg 1.2
55 stdarg 1.13 /* Whois. */
56 wingman 1.16 {"whois_items", &core_config.whois_items, CONFIG_STRING}, /* DDD */
57 stdarg 1.13
58 wcc 1.9 /* Other. */
59 wingman 1.16 {"die_on_sigterm", &core_config.die_on_sigterm, CONFIG_INT}, /* DDD */
60 stdarg 1.1 {0}
61     };
62    
63 stdarg 1.4 void 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.3 config_set_root("eggdrop", config_root);
73 stdarg 1.5 config_link_table(core_config_vars, config_root, "eggdrop", 0, NULL);
74 stdarg 1.18 if (!core_config.botname) core_config.botname = strdup("eggdrop");
75     if (!core_config.userfile) core_config.userfile = strdup("users.xml");
76     if (!core_config.lockfile) core_config.lockfile = strdup("lock");
77     if (!core_config.help_path) core_config.help_path = strdup("help/");
78     if (!core_config.logfile_suffix) core_config.logfile_suffix = strdup(".%d%b%Y");
79    
80     config_update_table(core_config_vars, config_root, "eggdrop", 0, NULL);
81 stdarg 1.1 }
82    
83     void core_config_save()
84     {
85 stdarg 1.5 config_update_table(core_config_vars, config_root, "eggdrop", 0, NULL);
86 stdarg 1.12 config_save("eggdrop", configfile);
87 stdarg 1.1 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23