/[svn]/hopm/branches/1.0.x/src/config.c
ViewVC logotype

Annotation of /hopm/branches/1.0.x/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5201 - (hide annotations)
Mon Dec 29 17:49:44 2014 UTC (5 years ago) by michael
File MIME type: text/x-chdr
File size: 3848 byte(s)
- Moved OPT_DEBUG prototype to main.h (where it belongs to) and removed extern.h

1 michael 5052 /*
2     * Copyright (C) 2002 Erik Fears
3     *
4     * This program is free software; you can redistribute it and/or
5     * modify it under the terms of the GNU General Public License
6     * as published by the Free Software Foundation; either version 2
7     * of the License, or (at your option) any later version.
8     *
9     * This program is distributed in the hope that it will be useful,
10     * but WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12     * GNU General Public License for more details.
13     *
14     * You should have received a copy of the GNU General Public License
15     * along with this program; if not, write to
16     *
17     * The Free Software Foundation, Inc.
18     * 59 Temple Place - Suite 330
19     * Boston, MA 02111-1307, USA.
20     *
21     *
22     */
23    
24     #include "setup.h"
25    
26     #include <stdio.h>
27    
28     #ifdef HAVE_STRING_H
29     # include <string.h>
30     #endif
31    
32     #include "config.h"
33     #include "malloc.h"
34     #include "log.h"
35     #include "scan.h"
36     #include "irc.h"
37     #include "opercmd.h"
38     #include "stats.h"
39     #include "firedns.h"
40    
41     extern FILE *yyin;
42     extern int yyparse(void);
43    
44     void config_setup(void);
45     void config_init(void);
46    
47    
48    
49     struct OptionsConf *OptionsItem = NULL;
50     struct IRCConf *IRCItem = NULL;
51     struct OpmConf *OpmItem = NULL;
52     struct ExemptConf *ExemptItem = NULL;
53     list_t *UserItemList = NULL;
54     list_t *ScannerItemList = NULL;
55    
56    
57     /* Rehash or load new configuration from filename, via flex/bison parser */
58 michael 5114 void
59     config_load(const char *filename)
60 michael 5052 {
61 michael 5114 config_init();
62     config_setup(); /* Setup/clear current configuration */
63 michael 5052
64 michael 5114 log_printf("CONFIG -> Loading %s", filename);
65 michael 5052
66 michael 5114 if ((yyin = fopen(filename, "r")) == NULL)
67     {
68     log_printf("CONFIG -> Error opening %s", filename);
69 michael 5150 exit(EXIT_FAILURE);
70 michael 5114 }
71 michael 5052
72 michael 5114 yyparse();
73 michael 5052
74 michael 5114 scan_init(); /* Initialize the scanners once we have the configuration */
75     command_init(); /* Initialize the command queue */
76     stats_init(); /* Initialize stats (UPTIME) */
77     firedns_init(); /* Initialize adns */
78 michael 5052
79 michael 5114 fclose(yyin);
80 michael 5052 }
81    
82     /* Malloc and initialize configuration data to NULL */
83 michael 5114 void
84     config_init(void)
85 michael 5052 {
86 michael 5114 /* Init IRC block */
87     IRCItem = MyMalloc(sizeof *IRCItem);
88     IRCItem->channels = list_create();
89     IRCItem->performs = list_create();
90 michael 5052
91 michael 5114 /* Init Options block */
92     OptionsItem = MyMalloc(sizeof *OptionsItem);
93 michael 5052
94 michael 5114 /* Init OPM block */
95     OpmItem = MyMalloc(sizeof *OpmItem);
96     OpmItem->blacklists = list_create();
97 michael 5052
98 michael 5114 /* Init list of User blocks */
99     UserItemList = list_create();
100 michael 5052
101 michael 5114 /* Init list of Scanner blocks */
102     ScannerItemList = list_create();
103 michael 5052
104 michael 5114 /* Init list of Exempts */
105     ExemptItem = MyMalloc(sizeof *ExemptItem);
106     ExemptItem->masks = list_create();
107 michael 5052 }
108    
109     /* Setup structs that hold configuration data and then reset default values */
110 michael 5114 void
111     config_setup(void)
112 michael 5052 {
113 michael 5114 /* Setup IRC Block Defaults */
114 michael 5149 IRCItem->mode = xstrdup("+c");
115 michael 5114 IRCItem->nick = xstrdup("hopm");
116     IRCItem->nickserv = xstrdup("");
117     IRCItem->password = xstrdup("");
118     IRCItem->port = 6667;
119 michael 5197 IRCItem->readtimeout = 900;
120 michael 5114 IRCItem->oper = xstrdup("undefined");
121     IRCItem->username = xstrdup("hopm");
122     IRCItem->realname = xstrdup("Hybrid Open Proxy Monitor");
123     IRCItem->server = xstrdup("irc.example.org");
124     IRCItem->vhost = xstrdup("");
125     IRCItem->connregex = xstrdup("\\*\\*\\* Notice -- Client connecting: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9\\.]+)\\].*");
126     IRCItem->kline = xstrdup("KLINE %u@%h :Open Proxy found on your host.");
127 michael 5052
128    
129 michael 5114 /* Setup options block defaults */
130     OptionsItem->negcache = 0; /* 0 disabled negcache */
131     OptionsItem->pidfile = xstrdup("hopm.pid");
132     OptionsItem->dns_fdlimit = 50;
133     OptionsItem->scanlog = NULL;
134 michael 5052
135 michael 5114 /* Setup OPM block defaults */
136     OpmItem->sendmail = xstrdup("/usr/sbin/sendmail");
137     OpmItem->dnsbl_from = xstrdup("");
138     OpmItem->dnsbl_to = xstrdup("");
139 michael 5052 }
140    
141 michael 5114 void
142     yyerror(const char *str)
143 michael 5052 {
144 michael 5114 log_printf("CONFIG -> %s: line %d", str, linenum);
145     exit(EXIT_FAILURE);
146 michael 5052 }

Properties

Name Value
svn:eol-style native
svn:keywords Id

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26