ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/branches/1.0.x/src/config.c
(Generate patch)

Comparing hopm/trunk/src/config.c (file contents):
Revision 5052 by michael, Mon Dec 22 11:56:03 2014 UTC vs.
Revision 5135 by michael, Thu Dec 25 18:51:51 2014 UTC

# Line 47 | Line 47 | void config_init(void);
47  
48  
49  
50 /* Configuration     */
51
50   struct OptionsConf *OptionsItem = NULL;
51   struct IRCConf *IRCItem = NULL;
52   struct OpmConf *OpmItem = NULL;
# Line 56 | Line 54 | struct ExemptConf *ExemptItem = NULL;
54   list_t *UserItemList = NULL;
55   list_t *ScannerItemList = NULL;
56  
59 /* End Configuration */
60
61
57  
58   /* Rehash or load new configuration from filename, via flex/bison parser */
59 < void config_load(const char *filename)
59 > void
60 > config_load(const char *filename)
61   {
62 +  config_init();
63 +  config_setup();  /* Setup/clear current configuration */
64  
65 <   config_init();
68 <   config_setup(); /* Setup/clear current configuration */
65 >  log_printf("CONFIG -> Loading %s", filename);
66  
67 <   log_printf("CONFIG -> Loading %s", filename);
67 >  if ((yyin = fopen(filename, "r")) == NULL)
68 >  {
69 >    log_printf("CONFIG -> Error opening %s", filename);
70 >    exit(1);
71 >  }
72  
73 <   if((yyin = fopen(filename, "r")) == NULL)
73 <   {
74 <      log_printf("CONFIG -> Error opening %s", filename);
75 <      exit(1);
76 <   }
73 >  yyparse();
74  
75 <   yyparse();
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 <   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);
80 >  fclose(yyin);
81   }
82  
83   /* Malloc and initialize configuration data to NULL */
84 < void config_init()
84 > void
85 > config_init(void)
86   {
87 <   /* Init IRC block */
88 <   IRCItem = MyMalloc(sizeof *IRCItem);
89 <   memset(IRCItem, 0, sizeof *IRCItem);
90 <   IRCItem->channels = list_create();
91 <   IRCItem->performs = list_create();
92 <
93 <   /* Init Options block */
94 <   OptionsItem = MyMalloc(sizeof *OptionsItem);
95 <   memset(OptionsItem, 0, sizeof *OptionsItem);
96 <
97 <   /* Init OPM block */
98 <   OpmItem = MyMalloc(sizeof *OpmItem);
99 <   memset(OpmItem, 0, sizeof *OpmItem);
100 <   OpmItem->blacklists = list_create();
101 <
102 <   /* Init list of User blocks */
103 <   UserItemList = list_create();
104 <
105 <   /* Init list of Scanner blocks */
106 <   ScannerItemList = list_create();
107 <
112 <   /* Init list of Exempts */
113 <   ExemptItem = MyMalloc(sizeof *ExemptItem);
114 <   ExemptItem->masks = list_create();
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 <
112 < void config_setup()
111 > void
112 > config_setup(void)
113   {
114 <
115 <   /* Setup IRC Block Defaults */
116 <   IRCItem->away = DupString("I'm a bot, don't message me");
117 <   IRCItem->mode = DupString("+cs");
118 <   IRCItem->nick = DupString("bopm");
119 <   IRCItem->nickserv = DupString("");
120 <   IRCItem->password = DupString("");
121 <   IRCItem->port = 6667;
122 <   IRCItem->oper = DupString("undefined");
123 <   IRCItem->username = DupString("bopm");
124 <   IRCItem->realname = DupString("Blitzed Open Proxy Monitor");
125 <   IRCItem->server = DupString("myserver.blitzed.org");
126 <   IRCItem->vhost = DupString("");
127 <   IRCItem->connregex = DupString("\\*\\*\\* Notice -- Client connecting: ([^ ]+) \\(([^@]+)@([^\\)]+)\\) \\[([0-9\\.]+)\\].*");
128 <   IRCItem->kline = DupString("KLINE %u@%h :Open Proxy found on your host. Please visit www.blitzed.org/proxy?ip=%i for more information.");
129 <
130 <
131 <   /* Setup options block defaults */
132 <   OptionsItem->negcache = 0;   /* 0 disabled negcache */
133 <   OptionsItem->pidfile = DupString("bopm.pid");
134 <   OptionsItem->dns_fdlimit = 50;
135 <   OptionsItem->scanlog = NULL;
136 <
137 <   /* Setup OPM block defaults */
138 <   OpmItem->sendmail = DupString("/usr/sbin/sendmail");
146 <   OpmItem->dnsbl_from = DupString("");
147 <   OpmItem->dnsbl_to = DupString("");
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 yyerror(const char *str)
141 > void
142 > yyerror(const char *str)
143   {
144 <   log_printf("CONFIG -> %s: line %d", str, linenum);
145 <   exit(EXIT_FAILURE);
144 >  log_printf("CONFIG -> %s: line %d", str, linenum);
145 >  exit(EXIT_FAILURE);
146   }

Comparing hopm/trunk/src/config.c (property svn:eol-style):
Revision 5052 by michael, Mon Dec 22 11:56:03 2014 UTC vs.
Revision 5135 by michael, Thu Dec 25 18:51:51 2014 UTC

# Line 0 | Line 1
1 + native

Comparing hopm/trunk/src/config.c (property svn:keywords):
Revision 5052 by michael, Mon Dec 22 11:56:03 2014 UTC vs.
Revision 5135 by michael, Thu Dec 25 18:51:51 2014 UTC

# Line 0 | Line 1
1 + Id

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines