ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config.c
Revision: 5085
Committed: Mon Dec 22 20:08:17 2014 UTC (9 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 3971 byte(s)
Log Message:
- Removed some useless memset()

File Contents

# Content
1 /*
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 "extern.h"
33 #include "config.h"
34 #include "malloc.h"
35 #include "log.h"
36 #include "scan.h"
37 #include "irc.h"
38 #include "opercmd.h"
39 #include "stats.h"
40 #include "firedns.h"
41
42 extern FILE *yyin;
43 extern int yyparse(void);
44
45 void config_setup(void);
46 void config_init(void);
47
48
49
50 /* Configuration */
51
52 struct OptionsConf *OptionsItem = NULL;
53 struct IRCConf *IRCItem = NULL;
54 struct OpmConf *OpmItem = NULL;
55 struct ExemptConf *ExemptItem = NULL;
56 list_t *UserItemList = NULL;
57 list_t *ScannerItemList = NULL;
58
59 /* End Configuration */
60
61
62
63 /* Rehash or load new configuration from filename, via flex/bison parser */
64 void config_load(const char *filename)
65 {
66
67 config_init();
68 config_setup(); /* Setup/clear current configuration */
69
70 log_printf("CONFIG -> Loading %s", filename);
71
72 if((yyin = fopen(filename, "r")) == NULL)
73 {
74 log_printf("CONFIG -> Error opening %s", filename);
75 exit(1);
76 }
77
78 yyparse();
79
80 scan_init(); /* Initialize the scanners once we have the configuration */
81 command_init(); /* Initialize the command queue */
82 stats_init(); /* Initialize stats (UPTIME) */
83 firedns_init(); /* Initialize adns */
84
85 fclose(yyin);
86 }
87
88 /* Malloc and initialize configuration data to NULL */
89 void config_init()
90 {
91 /* Init IRC block */
92 IRCItem = MyMalloc(sizeof *IRCItem);
93 IRCItem->channels = list_create();
94 IRCItem->performs = list_create();
95
96 /* Init Options block */
97 OptionsItem = MyMalloc(sizeof *OptionsItem);
98
99 /* Init OPM block */
100 OpmItem = MyMalloc(sizeof *OpmItem);
101 OpmItem->blacklists = list_create();
102
103 /* Init list of User blocks */
104 UserItemList = list_create();
105
106 /* Init list of Scanner blocks */
107 ScannerItemList = list_create();
108
109 /* Init list of Exempts */
110 ExemptItem = MyMalloc(sizeof *ExemptItem);
111 ExemptItem->masks = list_create();
112 }
113
114 /* Setup structs that hold configuration data and then reset default values */
115
116 void config_setup()
117 {
118
119 /* Setup IRC Block Defaults */
120 IRCItem->mode = DupString("+cs");
121 IRCItem->nick = DupString("hopm");
122 IRCItem->nickserv = DupString("");
123 IRCItem->password = DupString("");
124 IRCItem->port = 6667;
125 IRCItem->oper = DupString("undefined");
126 IRCItem->username = DupString("hopm");
127 IRCItem->realname = DupString("Hybrid Open Proxy Monitor");
128 IRCItem->server = DupString("myserver.blitzed.org");
129 IRCItem->vhost = DupString("");
130 IRCItem->connregex = DupString("\\*\\*\\* Notice -- Client connecting: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9\\.]+)\\].*");
131 IRCItem->kline = DupString("KLINE %u@%h :Open Proxy found on your host.");
132
133
134 /* Setup options block defaults */
135 OptionsItem->negcache = 0; /* 0 disabled negcache */
136 OptionsItem->pidfile = DupString("hopm.pid");
137 OptionsItem->dns_fdlimit = 50;
138 OptionsItem->scanlog = NULL;
139
140 /* Setup OPM block defaults */
141 OpmItem->sendmail = DupString("/usr/sbin/sendmail");
142 OpmItem->dnsbl_from = DupString("");
143 OpmItem->dnsbl_to = DupString("");
144 }
145
146 void yyerror(const char *str)
147 {
148 log_printf("CONFIG -> %s: line %d", str, linenum);
149 exit(EXIT_FAILURE);
150 }