/[svn]/hopm/trunk/src/config.c
ViewVC logotype

Contents of /hopm/trunk/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5114 - (show annotations)
Wed Dec 24 22:12:05 2014 UTC (4 years, 7 months ago) by michael
File MIME type: text/x-chdr
File size: 3828 byte(s)
- Style corrections

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 struct OptionsConf *OptionsItem = NULL;
51 struct IRCConf *IRCItem = NULL;
52 struct OpmConf *OpmItem = NULL;
53 struct ExemptConf *ExemptItem = NULL;
54 list_t *UserItemList = NULL;
55 list_t *ScannerItemList = NULL;
56
57
58 /* Rehash or load new configuration from filename, via flex/bison parser */
59 void
60 config_load(const char *filename)
61 {
62 config_init();
63 config_setup(); /* Setup/clear current configuration */
64
65 log_printf("CONFIG -> Loading %s", filename);
66
67 if ((yyin = fopen(filename, "r")) == NULL)
68 {
69 log_printf("CONFIG -> Error opening %s", filename);
70 exit(1);
71 }
72
73 yyparse();
74
75 scan_init(); /* Initialize the scanners once we have the configuration */
76 command_init(); /* Initialize the command queue */
77 stats_init(); /* Initialize stats (UPTIME) */
78 firedns_init(); /* Initialize adns */
79
80 fclose(yyin);
81 }
82
83 /* Malloc and initialize configuration data to NULL */
84 void
85 config_init(void)
86 {
87 /* Init IRC block */
88 IRCItem = MyMalloc(sizeof *IRCItem);
89 IRCItem->channels = list_create();
90 IRCItem->performs = list_create();
91
92 /* Init Options block */
93 OptionsItem = MyMalloc(sizeof *OptionsItem);
94
95 /* Init OPM block */
96 OpmItem = MyMalloc(sizeof *OpmItem);
97 OpmItem->blacklists = list_create();
98
99 /* Init list of User blocks */
100 UserItemList = list_create();
101
102 /* Init list of Scanner blocks */
103 ScannerItemList = list_create();
104
105 /* Init list of Exempts */
106 ExemptItem = MyMalloc(sizeof *ExemptItem);
107 ExemptItem->masks = list_create();
108 }
109
110 /* Setup structs that hold configuration data and then reset default values */
111 void
112 config_setup(void)
113 {
114 /* Setup IRC Block Defaults */
115 IRCItem->mode = xstrdup("+cs");
116 IRCItem->nick = xstrdup("hopm");
117 IRCItem->nickserv = xstrdup("");
118 IRCItem->password = xstrdup("");
119 IRCItem->port = 6667;
120 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
128
129 /* 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
135 /* Setup OPM block defaults */
136 OpmItem->sendmail = xstrdup("/usr/sbin/sendmail");
137 OpmItem->dnsbl_from = xstrdup("");
138 OpmItem->dnsbl_to = xstrdup("");
139 }
140
141 void
142 yyerror(const char *str)
143 {
144 log_printf("CONFIG -> %s: line %d", str, linenum);
145 exit(EXIT_FAILURE);
146 }

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