fixed some missing includes
[NeonServV5.git] / src / main.c
1 /* main.c - NeonServ v5.6
2  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (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, see <http://www.gnu.org/licenses/>. 
16  */
17
18 #define DEFAULT_PID_FILE "neonserv.pid"
19 #define DEFAULT_CONF_FILE "neonserv.conf"
20 #define DEFAULT_LOG_FILE "neonserv.log"
21
22 #include "main.h"
23 #include "signal.h"
24 #include "ClientSocket.h"
25 #include "UserNode.h"
26 #include "ChanNode.h"
27 #include "IRCEvents.h"
28 #include "IRCParser.h"
29 #include "modcmd.h"
30 #include "WHOHandler.h"
31 #include "bots.h"
32 #include "mysqlConn.h"
33 #include "HandleInfoHandler.h"
34 #include "lang.h"
35 #include "tools.h"
36 #include "timeq.h"
37 #include "EventLogger.h"
38 #include "ModeNode.h"
39 #include "IRCQueue.h"
40 #include "DBHelper.h"
41 #include "ConfigParser.h"
42 #include "QServer.h"
43 #include "version.h"
44 #include "modules.h"
45 #include "module_commands.h"
46 #include "ModuleFunctions.h"
47 #include "IOHandler.h"
48 #include "statistics.h"
49
50 struct ProcessState process_state;
51
52 static FILE *log_fptr = NULL;
53
54 #ifdef HAVE_THREADS
55 pthread_mutex_t cache_sync;
56 pthread_mutex_t whohandler_sync, whohandler_mass_sync;
57 static pthread_mutex_t log_sync;
58 static pthread_t *current_threads = NULL;
59 #endif
60
61 static void *main_tread(void *empty);
62 static TIMEQ_CALLBACK(clear_cache);
63 static TIMEQ_CALLBACK(main_checkauths);
64 static void check_firstrun();
65
66
67 static void main_parse_arguments() {
68     int c;
69     struct option options[] = {
70         {"show", 1, 0, 's'},
71         {"foreground", 0, 0, 'f'},
72         {"config", 1, 0, 'c'},
73         {"pid", 1, 0, 'p'},
74         {"help", 0, 0, 'h'},
75         {"version", 0, 0, 'v'},
76         {0, 0, 0, 0}
77     };
78     while ((c = getopt_long(process_state.argc, process_state.argv, "s:fvh", options, NULL)) != -1) {
79         switch (c) {
80         case 'c':
81             strncpy(process_state.config, optarg, MAXLEN-1);
82             break;
83         case 'p':
84             strncpy(process_state.pidfile, optarg, MAXLEN-1);
85             break;
86         case 's':
87             process_state.loglevel = atoi(optarg);
88             break;
89         case 'f':
90             process_state.run_as_daemon = 0;
91             break;
92         case 'v':
93             printf("Version: %s.%d (%s)\n", NEONSERV_VERSION, patchlevel, (strcmp(revision, "") ? revision : "-"));
94             printf("Build: #%s %s (%s lines, " COMPILER ")\n", compilation, creation, codelines);
95             exit(0);
96             break;
97         case 'h':
98             printf("Usage: ./neonserv [-c neonserv.conf] [-p neonserv.pid] [-s loglevel] [-f] [-h|-v]\n");
99             printf(" -c, --config         use this configuration file.\n");
100             printf(" -f, --foreground     run NeonServ in the foreground.\n");
101             printf(" -h, --help           prints this usage message.\n");
102             printf(" -p, --pid            use this pid file.\n");
103             printf(" -s, --show           show log lines matching loglevel in stdout.\n");
104             printf(" -v, --version        prints this program's version.\n");
105             exit(0);
106             break;
107         }
108     }
109 }
110
111 static void main_daemon_exit() {
112     remove(process_state.pidfile);
113 }
114
115 static void main_daemonize() {
116     #ifndef WIN32
117     /* Attempt to fork into the background if daemon mode is on. */
118     pid_t pid = fork();
119     if (pid < 0) {
120         fprintf(stderr, "Unable to fork: %s\n", strerror(errno));
121     } else if (pid > 0) {
122         printf("Forking into the background (pid: %d)...\n", pid);
123         putlog(LOGLEVEL_INFO, "Forking into the background (pid: %d)...\n", pid);
124         exit(0);
125     }
126     setsid();
127     process_state.daemonized = 1;
128     atexit(main_daemon_exit);
129     FILE *pidfile = fopen(process_state.pidfile, "w");
130     if (pidfile == NULL) {
131         fprintf(stderr, "Unable to create PID file: %s\n", strerror(errno));
132         putlog(LOGLEVEL_ERROR, "Unable to create PID file: %s\n", strerror(errno));
133     } else {
134         fprintf(pidfile, "%i\n", (int)getpid());
135         fclose(pidfile);
136     }
137     FILE *retn;
138     fclose(stdin); retn = fopen("/dev/null", "r");
139     fclose(stdout); retn = fopen("/dev/null", "w");
140     fclose(stderr); retn = fopen("/dev/null", "w");
141     #endif
142 }
143
144 static int reload_configuration() {
145     if(!loadConfig(process_state.config))
146         return 1;
147     if(process_state.loaded_config) {
148         if(!reload_mysql())
149             return 2;
150         char **modulelist = get_all_fieldnames("modules");
151         if(!modulelist || !modulelist[0]) {
152             free(modulelist);
153             return 3;
154         }
155         free(modulelist);
156         event_reload(0);
157     }
158     process_state.loaded_config = 1;
159     return 0;
160 }
161
162
163 /* INITIALISATION OF SUBSYSTEMS */
164 void initialize_subsystems() {
165     init_bind();
166     init_lang();
167     init_parser();
168     init_UserNode();
169     init_ChanNode();
170     init_ModeNode();
171     init_bind();
172         init_modcmd();
173     register_module_commands();
174     init_handleinfohandler();
175     init_tools();
176     init_modulefunctions();
177     loadModules();
178     init_bots();
179     init_DBHelper();
180     qserver_init();
181     load_languages();
182     init_statistics();
183 }
184
185 void shutdown_subsystems() {
186     free_sockets(1);
187     //wait 50ms (run iohandler)
188     {
189         struct timeval timeout, ctime1, ctime2;
190         gettimeofday(&ctime1, NULL);
191         ctime1.tv_usec += 50000;
192         if(ctime1.tv_usec > 1000000) {
193             ctime1.tv_usec -= 1000000;
194             ctime1.tv_sec++;
195         }
196         do {
197             timeout.tv_sec = 0;
198             timeout.tv_usec = 10000;
199             iohandler_poll_timeout(timeout);
200             gettimeofday(&ctime2, NULL);
201         } while(timeval_is_bigger(ctime1, ctime2));
202     }
203     stop_modules();
204     free_sockets(0);
205     qserver_free();
206     free_parser();
207     free_UserNode();
208     free_ChanNode();
209     free_bind();
210     free_modcmd();
211     free_whoqueue();
212     free_mysql();
213     free_handleinfohandler();
214     free_lang();
215 }
216
217 /* THREAD CONTROL */
218 #ifdef HAVE_THREADS
219 int getCurrentThreadID() {
220     if(!current_threads) return 0;
221     int i;
222     unsigned int my_tid = (unsigned int) pthread_self_tid();
223     for(i = 0; i < process_state.running_threads; i++) {
224         #ifdef WIN32
225         if((unsigned int) current_threads[i].p == my_tid)
226         #else
227         if((unsigned int) current_threads[i] == my_tid)
228         #endif
229             return i+1;
230     }
231     return 0;
232 }
233 #endif
234
235 int getRunningThreads() {
236         #ifdef HAVE_THREADS
237     return process_state.running_threads;
238         #else
239         return 1;
240         #endif
241 }
242
243 static void main_start_threads() {
244     int worker_threads = get_int_field("General.worker_threads");
245     if(!worker_threads) worker_threads = 1;
246     #ifdef HAVE_THREADS
247     int tid_id = 0;
248     {
249         current_threads = calloc(worker_threads, sizeof(*current_threads));
250         for(tid_id = 0; tid_id < worker_threads; tid_id++) {
251             process_state.running_threads++;
252             pthread_create(&current_threads[tid_id], NULL, main_tread, NULL);
253         }
254     }
255     #endif
256     main_tread(NULL);
257     #ifdef HAVE_THREADS
258     {
259         for(tid_id = 0; tid_id < worker_threads; tid_id++) {
260             pthread_join(current_threads[tid_id], NULL);
261         }
262         process_state.running_threads = 0;
263     }
264     #endif
265 }
266
267 /* MAIN FUNCTION(S) */
268
269 static void *main_tread(void *empty) {
270     while(process_state.running) {
271         iohandler_poll();
272     }
273     return NULL;
274 }
275
276 static void main_restart_process() {
277     /* Append a NULL to the end of argv[]. */
278     char **restart_argv = (char **)alloca((process_state.argc + 1) * sizeof(char *));
279     memcpy(restart_argv, process_state.argv, process_state.argc * sizeof(char *));
280     restart_argv[process_state.argc] = NULL;
281     #ifdef WIN32
282     execv(process_state.argv[0], (const char * const*)restart_argv);
283     #else
284     execv(process_state.argv[0], restart_argv);
285     #endif
286 }
287
288 int main(int argc, char *argv[]) {
289     memset(&process_state, 0, sizeof(process_state));
290     printf("NeonServ v%s\n\n", NEONSERV_VERSION);
291     
292     process_state.argv = argv;
293     process_state.argc = argc;
294     process_state.run_as_daemon = 1;
295     strcpy(process_state.config, DEFAULT_CONF_FILE);
296     strcpy(process_state.pidfile, DEFAULT_PID_FILE);
297     
298     //parse argv
299     main_parse_arguments();
300     
301     //initialize memory debugger BEFORE allocating memory
302     #ifdef ENABLE_MEMORY_DEBUG
303     initMemoryDebug();
304     #endif
305     
306     //deny root startup
307     #ifndef WIN32
308     if(geteuid() == 0 || getuid() == 0) {
309         fprintf(stderr, "NeonServ may not be run with super user privileges.\n");
310         exit(0);
311     }
312     #endif
313     
314     //load configuration
315     int errid;
316     if((errid = reload_configuration())) {
317         fprintf(stderr, "Unable to load configuration file `%s`. (errid: %d)\n", process_state.config, errid);
318         exit(0);
319     }
320     
321     //check mysql configuration
322     if(!reload_mysql()) {
323         fprintf(stderr, "Unable to load MySQL configuration.\n");
324         exit(0);
325     }
326     
327     //check module configuration
328     char **modulelist = get_all_fieldnames("modules");
329     if(!modulelist || !modulelist[0]) {
330         fprintf(stderr, "Unable to load Module configuration.\n");
331         exit(0);
332     }
333     free(modulelist);
334     
335     #if HAVE_THREADS
336     THREAD_MUTEX_INIT(log_sync);
337     THREAD_MUTEX_INIT(cache_sync);
338     THREAD_MUTEX_INIT(whohandler_sync);
339     THREAD_MUTEX_INIT(whohandler_mass_sync);
340     #endif
341     
342     //connect to mysql and check if it's the frst bot startup
343     init_mysql();
344     check_firstrun();
345     
346     //deamonize if wanted
347     if(process_state.run_as_daemon)
348         main_daemonize();
349     
350     //set signal handlers
351     signal(SIGABRT, sighandler);
352     signal(SIGFPE, sighandler);
353     signal(SIGILL, sighandler);
354     signal(SIGINT, sighandler);
355     signal(SIGSEGV, sighandler);
356     signal(SIGTERM, sighandler);
357     
358     //set start time and initialize other code parts
359     process_state.running = 1;
360     process_state.start_time = time(0);
361     initialize_subsystems();
362     
363     //start timers
364     timeq_add(CLEAR_CACHE_INTERVAL, 0, clear_cache, NULL);
365     timeq_add(90, 0, main_checkauths, NULL);
366     
367     //start worker threads
368     main_start_threads();  //BLOCKING
369     
370     //shutdown sequence...
371     shutdown_subsystems();
372     if(process_state.restart)
373         main_restart_process(); //terminates the current process on success
374     
375     //eop (end of program :P)
376     //trust me, thats the end!
377     exit(0);
378 }
379
380 /* BOT INFORMATION */
381 time_t getStartTime() {
382     return process_state.start_time;
383 }
384
385 /* BOT CONTROL */
386 void restart_bot(int crash) {
387     if(crash) {
388         main_daemon_exit();
389         main_restart_process();
390     } else {
391         process_state.restart = 1;
392         process_state.running = 0;
393     }
394 }
395
396 void stop_bot() {
397     process_state.running = 0;
398 }
399
400 void reload_config() {
401     reload_configuration();
402 }
403
404 /* TIMER FUNCTIONS */
405
406 static TIMEQ_CALLBACK(clear_cache) {
407     timeq_add(CLEAR_CACHE_INTERVAL, 0, clear_cache, NULL);
408     clearTempUsers();
409     destroyEvents();
410     mysql_free();
411 }
412
413 static AUTHLOOKUP_CALLBACK(main_checkauths_callback) {
414     //check if registered is still valid
415     MYSQL_RES *res;
416     MYSQL_ROW row;
417     printf_mysql_query("SELECT `user_id`, `user_registered` FROM `users` WHERE `user_user` = '%s'", escape_string(auth));
418     res = mysql_use();
419     if ((row = mysql_fetch_row(res)) != NULL) {
420         int diff = registered - atoi(row[1]);
421         if(diff < 0)
422             diff *= -1;
423         if(!exists || (strcmp(row[1], "0") && diff > 86400)) {
424             //User is no longer valid! Delete it...
425             deleteUser(atoi(row[0]));
426             char *alertchan = get_string_field("General.CheckAuths.alertchan");
427             if(alertchan) {
428                 char reason[MAXLEN];
429                 if(!exists) {
430                     strcpy(reason, "USER_NOT_EXISTS");
431                 } else {
432                     sprintf(reason, "USER_REGISTERED_MISSMATCH: %lu, expected %d (diff: %d)", (unsigned long) registered, atoi(row[1]), diff);
433                 }
434                 struct ChanNode *alertchan_chan = getChanByName(alertchan);
435                 struct ClientSocket *alertclient;
436                 if(alertchan_chan && (alertclient = getChannelBot(alertchan_chan, 0)) != NULL) {
437                     putsock(alertclient, "PRIVMSG %s :Deleted User %s (%s)", alertchan_chan->name, auth, reason);
438                 }
439             }
440         } else if(exists && !strcmp(row[1], "0")) {
441             printf_mysql_query("UPDATE `users` SET `user_registered` = '%lu', `user_lastcheck` = UNIX_TIMESTAMP() WHERE `user_id` = '%s'", (unsigned long) registered, row[0]);
442         } else {
443             printf_mysql_query("UPDATE `users` SET `user_lastcheck` = UNIX_TIMESTAMP() WHERE `user_id` = '%s'", row[0]);
444         }
445     }
446 }
447
448 static TIMEQ_CALLBACK(main_checkauths) {
449     int next_call = 600;
450     if(get_int_field("General.CheckAuths.enabled")) {
451         int check_start_time = get_int_field("General.CheckAuths.start_time") * 3600;
452         int duration = get_int_field("General.CheckAuths.duration") * 60;
453         int now = getCurrentSecondsOfDay();
454         if(now < check_start_time && check_start_time+duration >= 86400) {
455             check_start_time -= 86400;
456         }
457         if(now >= check_start_time && now < (check_start_time + duration)) {
458             next_call = get_int_field("General.CheckAuths.interval");
459             //get the "longest-unchecked-user"
460             MYSQL_RES *res;
461             MYSQL_ROW row;
462             int lastcheck;
463             time_t unixtime = time(0);
464             int min_unckecked = get_int_field("General.CheckAuths.min_unckecked");
465             printf_mysql_query("SELECT `user_user`, `user_lastcheck` FROM `users` ORDER BY `user_lastcheck` ASC LIMIT 1");
466             res = mysql_use();
467             if ((row = mysql_fetch_row(res)) != NULL) {
468                 lastcheck = atoi(row[1]);
469                 if(!lastcheck || unixtime - lastcheck >= min_unckecked) {
470                     lookup_authname(row[0], 0, main_checkauths_callback, NULL);
471                 } else 
472                     next_call = 300;
473             }
474         } else {
475             int pending;
476             if(now > check_start_time)
477                 pending = 86400 - now + check_start_time;
478             else
479                 pending = check_start_time - now;
480             if(pending < 600)
481                 next_call = pending;
482         }
483         
484     }
485     timeq_add(next_call, 0, main_checkauths, NULL);
486 }
487
488 /* LOG BACKEND */
489
490 void write_log(int loglevel, const char *line, int len) {
491     SYNCHRONIZE(log_sync);
492     if(!process_state.daemonized && (process_state.loglevel & loglevel)) {
493         printf("%s", line);
494     } else if(!process_state.daemonized && loglevel == LOGLEVEL_ERROR) {
495         fprintf(stderr, "%s", line);
496     }
497     if(get_int_field("log.loglevel") & loglevel) {
498         if(!log_fptr) {
499             log_fptr = fopen(DEFAULT_LOG_FILE, "a");
500             if(!log_fptr) goto write_log_end;
501         }
502         time_t rawtime;
503         struct tm *timeinfo;
504         time(&rawtime);
505         timeinfo = localtime(&rawtime);
506         char timestr[20];
507         int timepos = strftime(timestr, 20, "%x %X ", timeinfo);
508         fwrite(timestr, 1, timepos, log_fptr);
509         fwrite(line, 1, len, log_fptr);
510     }
511     write_log_end:
512     DESYNCHRONIZE(log_sync);
513 }
514
515 void putlog(int loglevel, const char *text, ...) {
516     va_list arg_list;
517     char logBuf[MAXLOGLEN];
518     int pos;
519     logBuf[0] = '\0';
520     va_start(arg_list, text);
521     pos = vsnprintf(logBuf, MAXLOGLEN - 1, text, arg_list);
522     va_end(arg_list);
523     if (pos < 0 || pos > (MAXLOGLEN - 1)) pos = MAXLOGLEN - 1;
524     logBuf[pos] = '\0';
525     write_log(loglevel, logBuf, pos);
526 }
527
528 /* INSTALLATION SCRIPT */
529
530 static void check_firstrun() {
531     MYSQL_RES *res;
532     MYSQL_ROW row;
533     printf_mysql_query("SELECT `user_id` FROM `users` WHERE `user_access` = 1000 LIMIT 1");
534     res = mysql_use();
535     if (mysql_fetch_row(res) == NULL) {
536         //first run!
537         printf("No superuser found...\n");
538         check_firstrun_admin:
539         printf("AuthServ account name of admin user: ");
540         char *ptr;
541         char adminuser[31];
542         ptr = fgets(adminuser, 30, stdin);
543         for(ptr = adminuser; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
544         if(strlen(adminuser) < 2) goto check_firstrun_admin;
545         printf_mysql_query("SELECT `user_id` FROM `users` WHERE `user_user` = '%s'", escape_string(adminuser));
546         res = mysql_use();
547         if ((row = mysql_fetch_row(res)) != NULL)
548             printf_mysql_query("UPDATE `users` SET `user_access` = 1000 WHERE `user_id` = '%s'", row[0]);
549         else
550             printf_mysql_query("INSERT INTO `users` (`user_user`, `user_access`) VALUES ('%s', 1000)", escape_string(adminuser));
551     }
552     printf_mysql_query("SELECT `id` FROM `bots` WHERE `active` = 1 LIMIT 1");
553     res = mysql_use();
554     if (mysql_fetch_row(res) == NULL) {
555         //no bot active
556         printf("No active bot found...\n\n");
557         printf("ADD NEW BOT\n");
558         char *ptr;
559         char bot_nick[31];
560         check_firstrun_bot_nick:
561         printf("Nick: ");
562         ptr = fgets(bot_nick, 30, stdin);
563         for(ptr = bot_nick; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
564         if(strlen(bot_nick) < 2) goto check_firstrun_bot_nick;
565         char bot_ident[16];
566         check_firstrun_bot_ident:
567         printf("Ident: ");
568         ptr = fgets(bot_ident, 15, stdin);
569         for(ptr = bot_ident; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
570         if(strlen(bot_ident) < 2) goto check_firstrun_bot_ident;
571         char bot_realname[101];
572         check_firstrun_bot_realname:
573         printf("Realname: ");
574         ptr = fgets(bot_realname, 100, stdin);
575         for(ptr = bot_realname; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
576         if(strlen(bot_realname) < 2) goto check_firstrun_bot_realname;
577         char bot_server[101];
578         check_firstrun_bot_server:
579         printf("Server: [irc.onlinegamesnet.net] ");
580         ptr = fgets(bot_server, 100, stdin);
581         for(ptr = bot_server; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
582         if(*bot_server && strlen(bot_nick) < 5) goto check_firstrun_bot_server;
583         if(!*bot_server)
584             strcpy(bot_server, "irc.onlinegamesnet.net");
585         int bot_port;
586         char bot_port_buf[7];
587         printf("Port: [6667] ");
588         ptr = fgets(bot_port_buf, 6, stdin);
589         for(ptr = bot_port_buf; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
590         if(!*bot_port_buf)
591             bot_port = 6667;
592         else
593             bot_port = atoi(bot_port_buf);
594         int bot_ssl;
595         char bot_ssl_buf[5];
596         check_firstrun_bot_ssl:
597         printf("SSL: [y/N] ");
598         ptr = fgets(bot_ssl_buf, 4, stdin);
599         for(ptr = bot_ssl_buf; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
600         if(!*bot_ssl_buf || tolower(*bot_ssl_buf) == 'n')
601             bot_ssl = 0;
602         else if(tolower(*bot_ssl_buf) == 'y')
603             bot_ssl = 1;
604         else
605             goto check_firstrun_bot_ssl;
606         char bot_pass[101];
607         printf("Server Password: [] ");
608         ptr = fgets(bot_pass, 100, stdin);
609         for(ptr = bot_pass; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
610         int bot_maxchan;
611         char bot_maxchan_buf[5];
612         printf("MaxChannel: [20] ");
613         ptr = fgets(bot_maxchan_buf, 5, stdin);
614         for(ptr = bot_maxchan_buf; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
615         if(*bot_maxchan_buf)
616             bot_maxchan = atoi(bot_maxchan_buf);
617         else
618             bot_maxchan = 20;
619         int bot_queue;
620         char bot_queue_buf[5];
621         check_firstrun_bot_queue:
622         printf("Queue (prevents excess floods): [Y/n] ");
623         ptr = fgets(bot_queue_buf, 4, stdin);
624         for(ptr = bot_queue_buf; *ptr; ptr++) { if(*ptr == '\n' || *ptr == '\r') *ptr = '\0'; }
625         if(!*bot_queue_buf || tolower(*bot_queue_buf) == 'y')
626             bot_queue = 1;
627         else if(tolower(*bot_queue_buf) == 'n')
628             bot_queue = 0;
629         else
630             goto check_firstrun_bot_queue;
631         printf_mysql_query("INSERT INTO `bots` (`active`, `nick`, `server`, `port`, `pass`, `ssl`, `ident`, `realname`, `botclass`, `textbot`, `queue`, `defaulttrigger`, `max_channels`) VALUES ('1', '%s', '%s', '%d', '%s', '%d', '%s', '%s', '1', '1', '%d', '+', '%d')", escape_string(bot_nick), escape_string(bot_server), bot_port, escape_string(bot_pass), bot_ssl, escape_string(bot_ident), escape_string(bot_realname), bot_queue, bot_maxchan);
632     }
633 }
634