ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config.c
Revision: 5726
Committed: Tue Mar 24 18:04:06 2015 UTC (11 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 3681 byte(s)
Log Message:
- Removed some irrelevant comments

File Contents

# User Rev Content
1 michael 5052 /*
2 michael 5351 * Copyright (c) 2002 Erik Fears
3     * Copyright (c) 2014-2015 ircd-hybrid development team
4 michael 5052 *
5 michael 5351 * This program is free software; you can redistribute it and/or modify
6     * it under the terms of the GNU General Public License as published by
7     * the Free Software Foundation; either version 2 of the License, or
8     * (at your option) any later version.
9 michael 5052 *
10 michael 5351 * 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 michael 5052 *
15 michael 5351 * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18     * USA
19 michael 5052 */
20    
21     #include "setup.h"
22    
23     #include <stdio.h>
24 michael 5254 #include <errno.h>
25 michael 5216 #include <string.h>
26 michael 5335 #include <stdlib.h>
27 michael 5052
28     #include "config.h"
29 michael 5270 #include "config-parser.h"
30 michael 5333 #include "memory.h"
31 michael 5052 #include "log.h"
32     #include "scan.h"
33     #include "irc.h"
34     #include "opercmd.h"
35     #include "stats.h"
36     #include "firedns.h"
37    
38     extern FILE *yyin;
39    
40     struct OptionsConf *OptionsItem = NULL;
41     struct IRCConf *IRCItem = NULL;
42     struct OpmConf *OpmItem = NULL;
43     struct ExemptConf *ExemptItem = NULL;
44     list_t *UserItemList = NULL;
45     list_t *ScannerItemList = NULL;
46    
47    
48     /* Malloc and initialize configuration data to NULL */
49 michael 5667 static void
50 michael 5114 config_init(void)
51 michael 5052 {
52 michael 5114 /* Init IRC block */
53 michael 5274 IRCItem = xcalloc(sizeof *IRCItem);
54 michael 5114 IRCItem->channels = list_create();
55     IRCItem->performs = list_create();
56 michael 5405 IRCItem->notices = list_create();
57 michael 5052
58 michael 5114 /* Init Options block */
59 michael 5274 OptionsItem = xcalloc(sizeof *OptionsItem);
60 michael 5052
61 michael 5114 /* Init OPM block */
62 michael 5274 OpmItem = xcalloc(sizeof *OpmItem);
63 michael 5114 OpmItem->blacklists = list_create();
64 michael 5052
65 michael 5114 /* Init list of User blocks */
66     UserItemList = list_create();
67 michael 5052
68 michael 5114 /* Init list of Scanner blocks */
69     ScannerItemList = list_create();
70 michael 5052
71 michael 5114 /* Init list of Exempts */
72 michael 5274 ExemptItem = xcalloc(sizeof *ExemptItem);
73 michael 5114 ExemptItem->masks = list_create();
74 michael 5052 }
75    
76     /* Setup structs that hold configuration data and then reset default values */
77 michael 5667 static void
78 michael 5114 config_setup(void)
79 michael 5052 {
80 michael 5114 /* Setup IRC Block Defaults */
81 michael 5148 IRCItem->mode = xstrdup("+c");
82 michael 5114 IRCItem->nick = xstrdup("hopm");
83     IRCItem->port = 6667;
84 michael 5198 IRCItem->readtimeout = 900;
85 michael 5114 IRCItem->oper = xstrdup("undefined");
86     IRCItem->username = xstrdup("hopm");
87     IRCItem->realname = xstrdup("Hybrid Open Proxy Monitor");
88     IRCItem->server = xstrdup("irc.example.org");
89     IRCItem->connregex = xstrdup("\\*\\*\\* Notice -- Client connecting: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9\\.]+)\\].*");
90     IRCItem->kline = xstrdup("KLINE %u@%h :Open Proxy found on your host.");
91 michael 5052
92 michael 5114 /* Setup options block defaults */
93     OptionsItem->negcache = 0; /* 0 disabled negcache */
94 michael 5332 OptionsItem->negcache_rebuild = 43200;
95 michael 5114 OptionsItem->pidfile = xstrdup("hopm.pid");
96     OptionsItem->dns_fdlimit = 50;
97     OptionsItem->scanlog = NULL;
98 michael 5052 }
99    
100 michael 5726 /* Load configuration from filename, via flex/bison parser */
101 michael 5114 void
102 michael 5270 config_load(const char *filename)
103     {
104     config_init();
105     config_setup(); /* Setup/clear current configuration */
106    
107     log_printf("CONFIG -> Loading %s", filename);
108    
109     if ((yyin = fopen(filename, "r")) == NULL)
110     {
111     log_printf("CONFIG -> Error opening %s: %s", filename, strerror(errno));
112     exit(EXIT_FAILURE);
113     }
114    
115     yyparse();
116    
117     scan_init(); /* Initialize the scanners once we have the configuration */
118     command_init(); /* Initialize the command queue */
119     stats_init(); /* Initialize stats (UPTIME) */
120     firedns_init(); /* Initialize adns */
121    
122     fclose(yyin);
123     }
124    
125     void
126 michael 5114 yyerror(const char *str)
127 michael 5052 {
128 michael 5114 log_printf("CONFIG -> %s: line %d", str, linenum);
129     exit(EXIT_FAILURE);
130 michael 5052 }

Properties

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