/[cvs]/eggdrop1.9/src/main.c
ViewVC logotype

Annotation of /eggdrop1.9/src/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.147 - (hide annotations) (download) (as text)
Sun May 11 02:30:54 2003 UTC (16 years, 6 months ago) by stdarg
Branch: MAIN
Changes since 1.146: +4 -1 lines
File MIME type: text/x-chdr
* Trying out the autoconf way of detecting tcl (test)

1 guppy 1.56 /*
2 tothwolf 1.117 * main.c --
3 guppy 1.56 *
4 tothwolf 1.117 * core event handling
5     * signal handling
6     * command line arguments
7 segfault 1.1 */
8 guppy 1.56 /*
9     * Copyright (C) 1997 Robey Pointer
10 wcc 1.128 * Copyright (C) 1999, 2000, 2001, 2002, 2003 Eggheads Development Team
11 guppy 1.56 *
12 fabian 1.14 * This program is free software; you can redistribute it and/or
13     * modify it under the terms of the GNU General Public License
14     * as published by the Free Software Foundation; either version 2
15     * of the License, or (at your option) any later version.
16 guppy 1.56 *
17 segfault 1.1 * This program is distributed in the hope that it will be useful,
18     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20     * GNU General Public License for more details.
21 guppy 1.56 *
22 segfault 1.1 * You should have received a copy of the GNU General Public License
23     * along with this program; if not, write to the Free Software
24 fabian 1.14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25     */
26 guppy 1.56 /*
27 segfault 1.1 * The author (Robey Pointer) can be reached at: robey@netcom.com
28 tothwolf 1.117 * NOTE: Robey is no longer working on this code, there is a discussion
29 guppy 1.60 * list available at eggheads@eggheads.org.
30 segfault 1.1 */
31 tothwolf 1.117
32     #ifndef lint
33 stdarg 1.147 static const char rcsid[] = "$Id: main.c,v 1.146 2003/04/15 18:05:01 stdarg Exp $";
34 tothwolf 1.117 #endif
35 segfault 1.1
36 stdarg 1.145 #include <unistd.h>
37 stdarg 1.125 #include <eggdrop/eggdrop.h>
38 fabian 1.28 #include "main.h"
39 stdarg 1.133 #include "core_config.h"
40 fabian 1.27 #include <fcntl.h>
41 wcc 1.129 #ifdef TIME_WITH_SYS_TIME
42     # include <sys/time.h>
43     # include <time.h>
44     #else
45     # ifdef HAVE_SYS_TIME_H
46     # include <sys/time.h>
47     # else
48     # include <time.h>
49     # endif
50     #endif
51 stdarg 1.142 #include <sys/stat.h>
52 segfault 1.1 #include <errno.h>
53     #include <signal.h>
54     #include <netdb.h>
55     #include <setjmp.h>
56 ite 1.76 #include <locale.h>
57 stdarg 1.142 #include <ctype.h>
58 stdarg 1.145 #include <ltdl.h>
59 ite 1.76
60 fabian 1.27 #ifdef STOP_UAC /* osf/1 complains a lot */
61 segfault 1.1 #include <sys/sysinfo.h>
62     #define UAC_NOPRINT 0x00000001 /* Don't report unaligned fixups */
63     #endif
64 fabian 1.27 /* Some systems have a working sys/wait.h even though configure will
65     * decide it's not bsd compatable. Oh well.
66     */
67 guppy 1.49
68 fabian 1.43 #include "bg.h"
69 stdarg 1.85 #include "core_binds.h"
70 ite 1.105 #include "logfile.h"
71 drummer 1.71
72 poptix 1.62 #ifdef CYGWIN_HACKS
73     #include <windows.h>
74     #endif
75    
76 segfault 1.1 #ifndef _POSIX_SOURCE
77 fabian 1.27 /* Solaris needs this */
78 segfault 1.1 #define _POSIX_SOURCE 1
79     #endif
80    
81 ite 1.76 char egg_version[1024] = VERSION;
82     int egg_numver = VERSION_NUM;
83 segfault 1.1
84 ite 1.109 eggdrop_t *egg = NULL; /* Eggdrop's context */
85    
86 fabian 1.27 char notify_new[121] = ""; /* Person to send a note to for new users */
87     int default_flags = 0; /* Default user flags and */
88     int default_uflags = 0; /* Default userdefinied flags for people
89     who say 'hello' or for .adduser */
90    
91     int backgrd = 1; /* Run in the background? */
92     int con_chan = 0; /* Foreground: constantly display channel
93     stats? */
94     int term_z = 0; /* Foreground: use the terminal as a party
95     line? */
96 stdarg 1.134 char configfile[121] = "config.xml"; /* Name of the config file */
97 wcc 1.127 char helpdir[121] = "help/"; /* Directory of help files (if used) */
98     char textdir[121] = "text/"; /* Directory for text files that get dumped */
99 fabian 1.27 time_t online_since; /* Unix-time that the bot loaded up */
100     int make_userfile = 0; /* Using bot in make-userfile mode? (first
101     user to 'hello' becomes master) */
102 guppy 1.92 char pid_file[120]; /* Name of the file for the pid to be
103 fabian 1.27 stored in */
104     int save_users_at = 0; /* How many minutes past the hour to
105     save the userfile? */
106     int notify_users_at = 0; /* How many minutes past the hour to
107     notify users of notes? */
108     char version[81]; /* Version info (long form) */
109     char ver[41]; /* Version info (short form) */
110     int use_stderr = 1; /* Send stuff to stderr instead of logfiles? */
111     int do_restart = 0; /* .restart has been called, restart asap */
112     int die_on_sighup = 0; /* die if bot receives SIGHUP */
113 guppy 1.52 int die_on_sigterm = 1; /* die if bot receives SIGTERM */
114 fabian 1.27 int resolve_timeout = 15; /* hostname/address lookup timeout */
115 guppy 1.72 char quit_msg[1024]; /* quit message */
116 fabian 1.27 time_t now; /* duh, now :) */
117 stdarg 1.108 egg_timeval_t egg_timeval_now; /* Same thing, but seconds and microseconds. */
118 fabian 1.27
119 fabian 1.44 void fatal(const char *s, int recoverable)
120 segfault 1.1 {
121     putlog(LOG_MISC, "*", "* %s", s);
122     flushlogs();
123     unlink(pid_file);
124 fabian 1.43 if (!recoverable) {
125     bg_send_quit(BG_ABORT);
126 segfault 1.1 exit(1);
127 fabian 1.43 }
128 segfault 1.1 }
129    
130     static void got_bus(int z)
131     {
132     fatal("BUS ERROR -- CRASHING!", 1);
133     #ifdef SA_RESETHAND
134     kill(getpid(), SIGBUS);
135     #else
136 fabian 1.43 bg_send_quit(BG_ABORT);
137 segfault 1.1 exit(1);
138     #endif
139     }
140    
141     static void got_segv(int z)
142     {
143     fatal("SEGMENT VIOLATION -- CRASHING!", 1);
144     #ifdef SA_RESETHAND
145     kill(getpid(), SIGSEGV);
146     #else
147 fabian 1.43 bg_send_quit(BG_ABORT);
148 segfault 1.1 exit(1);
149     #endif
150     }
151    
152     static void got_fpe(int z)
153     {
154     fatal("FLOATING POINT ERROR -- CRASHING!", 0);
155     }
156    
157     static void got_term(int z)
158     {
159 stdarg 1.85 check_bind_event("sigterm");
160 segfault 1.1 if (die_on_sigterm) {
161     fatal("TERMINATE SIGNAL -- SIGNING OFF", 0);
162     } else {
163     putlog(LOG_MISC, "*", "RECEIVED TERMINATE SIGNAL (IGNORING)");
164     }
165     }
166    
167     static void got_quit(int z)
168     {
169 stdarg 1.85 check_bind_event("sigquit");
170 segfault 1.1 putlog(LOG_MISC, "*", "RECEIVED QUIT SIGNAL (IGNORING)");
171     return;
172     }
173    
174     static void got_hup(int z)
175     {
176 stdarg 1.85 check_bind_event("sighup");
177 segfault 1.1 if (die_on_sighup) {
178     fatal("HANGUP SIGNAL -- SIGNING OFF", 0);
179     } else
180     putlog(LOG_MISC, "*", "Received HUP signal: rehashing...");
181     do_restart = -2;
182     return;
183     }
184    
185 guppy 1.101 /* Got ILL signal
186 fabian 1.27 */
187 segfault 1.1 static void got_ill(int z)
188     {
189 stdarg 1.85 check_bind_event("sigill");
190 fabian 1.10 }
191    
192 ite 1.114
193 wcc 1.135 static void print_version(void)
194 segfault 1.1 {
195 wcc 1.143 char x[1024];
196 ite 1.114
197     strlcpy(x, egg_version, sizeof x);
198     printf("%s\n", version);
199     }
200    
201 wcc 1.135 static void print_help(void)
202 ite 1.114 {
203     print_version ();
204     printf("\n\
205     Usage: %s [OPTIONS]... [FILE]\n", PACKAGE);
206     printf(_("\n\
207     -h, --help Print help and exit\n\
208     -v, --version Print version and exit\n\
209     -n, --foreground Don't go into the background (default=off)\n\
210     -c --channel-stats (with -n) Display channel stats every 10 seconds\n\
211     -t --terminal (with -n) Use terminal to simulate dcc-chat\n\
212     -m --make-userfile Userfile creation mode\n\
213 wcc 1.135 FILE optional config filename (default 'config.xml')\n"));
214 ite 1.114 printf("\n");
215     }
216 segfault 1.1
217 ite 1.114 static void do_args(int argc, char * const *argv)
218     {
219     int c;
220    
221     optarg = 0;
222     optind = 1;
223     opterr = 1;
224     optopt = '?';
225    
226     while (1) {
227     int option_index = 0;
228     static struct option long_options[] = {
229     { "help", 0, NULL, 'h' },
230     { "version", 0, NULL, 'v' },
231     { "load-module", 1, NULL, 'p' },
232     { "foreground", 0, NULL, 'n' },
233     { "channel-stats", 0, NULL, 'c' },
234     { "terminal", 0, NULL, 't' },
235     { "make-userfile", 0, NULL, 'm' },
236     { NULL, 0, NULL, 0 }
237     };
238    
239     c = getopt_long (argc, argv, "hvp:nctm", long_options, &option_index);
240    
241     if (c == -1) break;
242    
243     switch (c) {
244     case 'n':
245 segfault 1.1 backgrd = 0;
246 ite 1.114 break;
247    
248     case 'c':
249 segfault 1.1 con_chan = 1;
250     term_z = 0;
251 ite 1.114 break;
252    
253     case 't':
254 segfault 1.1 con_chan = 0;
255     term_z = 1;
256 ite 1.114 break;
257    
258     case 'm':
259 segfault 1.1 make_userfile = 1;
260 ite 1.114 break;
261    
262     case 'v':
263     print_version();
264 fabian 1.43 bg_send_quit(BG_ABORT);
265 segfault 1.1 exit(0);
266 ite 1.114 break; /* this should never be reached */
267    
268     case 'h':
269     print_help();
270 fabian 1.43 bg_send_quit(BG_ABORT);
271 segfault 1.1 exit(0);
272 ite 1.114 break; /* this should never be reached */
273    
274     case 0: /* Long option with no short option */
275     case '?': /* Invalid option. */
276     /* getopt_long() already printed an error message. */
277     bg_send_quit(BG_ABORT);
278     exit(1);
279    
280     default: /* bug: option not considered. */
281     fprintf (stderr, "%s: option unknown: %c\n", PACKAGE, c);
282     bg_send_quit(BG_ABORT);
283     exit(1);
284     break; /* this should never be reached */
285     }
286     }
287     if (optind < argc)
288     strlcpy(configfile, argv[optind], sizeof configfile);
289 segfault 1.1 }
290    
291 fabian 1.27 /* Timer info */
292     static int lastmin = 99;
293     static struct tm nowtm;
294 segfault 1.1
295 fabian 1.34 /* Called once a second.
296 fabian 1.27 */
297 stdarg 1.139 static int core_secondly()
298 segfault 1.1 {
299     static int cnt = 0;
300     int miltime;
301    
302 stdarg 1.145 check_bind_secondly();
303 segfault 1.1 cnt++;
304 tothwolf 1.79 memcpy(&nowtm, localtime(&now), sizeof(struct tm));
305 fabian 1.17 if (nowtm.tm_min != lastmin) {
306 segfault 1.1 int i = 0;
307    
308 fabian 1.27 /* Once a minute */
309 segfault 1.1 lastmin = (lastmin + 1) % 60;
310 stdarg 1.145 check_bind_event("minutely");
311     check_bind_time(&nowtm);
312 fabian 1.27 /* In case for some reason more than 1 min has passed: */
313 fabian 1.17 while (nowtm.tm_min != lastmin) {
314 fabian 1.27 /* Timer drift, dammit */
315 wcc 1.141 putlog(LOG_DEBUG, "*", "timer: drift (lastmin=%d, now=%d)", lastmin,
316     nowtm.tm_min);
317 segfault 1.1 i++;
318     lastmin = (lastmin + 1) % 60;
319 stdarg 1.145 check_bind_event("minutely");
320 segfault 1.1 }
321     if (i > 1)
322     putlog(LOG_MISC, "*", "(!) timer drift -- spun %d minutes", i);
323 fabian 1.17 miltime = (nowtm.tm_hour * 100) + (nowtm.tm_min);
324     if (((int) (nowtm.tm_min / 5) * 5) == (nowtm.tm_min)) { /* 5 min */
325 stdarg 1.145 check_bind_event("5minutely");
326 guppy 1.49 if (!miltime) { /* At midnight */
327     char s[25];
328 segfault 1.1
329 ite 1.111 strlcpy(s, ctime(&now), sizeof s);
330 fabian 1.4 putlog(LOG_ALL, "*", "--- %.11s%s", s, s + 20);
331 stdarg 1.145 check_bind_event("backup");
332     check_bind_event("daily");
333 segfault 1.1 }
334     }
335 stdarg 1.145 if (nowtm.tm_min == notify_users_at) check_bind_event("hourly");
336 segfault 1.1 }
337 stdarg 1.139 return(0);
338 segfault 1.1 }
339    
340 stdarg 1.130 void core_party_init();
341 stdarg 1.133 void core_config_init();
342 stdarg 1.130 void telnet_init();
343 stdarg 1.140
344 stdarg 1.142 int file_check(const char *filename)
345     {
346     struct stat sbuf = {0};
347     int r;
348    
349     r = stat(filename, &sbuf);
350     if (r) return(-1);
351     errno = 0;
352     if (sbuf.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) return(-1);
353     return(0);
354     }
355    
356 segfault 1.1 int main(int argc, char **argv)
357     {
358     int xx, i;
359 stdarg 1.138 char s[25];
360 stdarg 1.147 char *a;
361 segfault 1.1 FILE *f;
362     struct sigaction sv;
363 stdarg 1.82 egg_timeval_t howlong;
364 stdarg 1.131 int timeout;
365 stdarg 1.137 void *config_root, *entry;
366 stdarg 1.134 char *modname, *scriptname;
367 segfault 1.1
368 tothwolf 1.81 #ifdef DEBUG
369 fabian 1.21 /* Make sure it can write core, if you make debug. Else it's pretty
370     * useless (dw)
371     */
372 fabian 1.15 {
373     #include <sys/resource.h>
374     struct rlimit cdlim;
375 fabian 1.21
376 fabian 1.15 cdlim.rlim_cur = RLIM_INFINITY;
377     cdlim.rlim_max = RLIM_INFINITY;
378 fabian 1.32 setrlimit(RLIMIT_CORE, &cdlim);
379 fabian 1.15 }
380     #endif
381 fabian 1.32
382 ite 1.99 #ifdef ENABLE_NLS
383 ite 1.76 setlocale(LC_MESSAGES, "");
384     bindtextdomain(PACKAGE, LOCALEDIR);
385     textdomain(PACKAGE);
386 ite 1.99 #endif
387 wcc 1.143
388 stdarg 1.145 /* Initialize ltdl. */
389     LTDL_SET_PRELOADED_SYMBOLS();
390     if (lt_dlinit()) {
391     printf("Fatal error initializing ltdl: %s\n", lt_dlerror());
392     return(-1);
393     }
394    
395 fabian 1.27 /* Version info! */
396 ite 1.114 snprintf(ver, sizeof ver, "%s v%s", PACKAGE, egg_version);
397 wcc 1.128 snprintf(version, sizeof version, "Eggdrop v%s (C) 1997 Robey Pointer (C) 2003 Eggheads",
398 guppy 1.56 egg_version);
399 fabian 1.27 /* Now add on the patchlevel (for Tcl) */
400 fabian 1.2 sprintf(&egg_version[strlen(egg_version)], " %u", egg_numver);
401 segfault 1.1 #ifdef STOP_UAC
402     {
403     int nvpair[2];
404    
405     nvpair[0] = SSIN_UACPROC;
406     nvpair[1] = UAC_NOPRINT;
407     setsysinfo(SSI_NVPAIRS, (char *) nvpair, 1, NULL, 0);
408     }
409     #endif
410 fabian 1.27
411     /* Set up error traps: */
412 segfault 1.1 sv.sa_handler = got_bus;
413     sigemptyset(&sv.sa_mask);
414     #ifdef SA_RESETHAND
415     sv.sa_flags = SA_RESETHAND;
416     #else
417     sv.sa_flags = 0;
418     #endif
419     sigaction(SIGBUS, &sv, NULL);
420     sv.sa_handler = got_segv;
421     sigaction(SIGSEGV, &sv, NULL);
422     #ifdef SA_RESETHAND
423     sv.sa_flags = 0;
424     #endif
425     sv.sa_handler = got_fpe;
426     sigaction(SIGFPE, &sv, NULL);
427     sv.sa_handler = got_term;
428     sigaction(SIGTERM, &sv, NULL);
429     sv.sa_handler = got_hup;
430     sigaction(SIGHUP, &sv, NULL);
431     sv.sa_handler = got_quit;
432     sigaction(SIGQUIT, &sv, NULL);
433     sv.sa_handler = SIG_IGN;
434     sigaction(SIGPIPE, &sv, NULL);
435     sv.sa_handler = got_ill;
436     sigaction(SIGILL, &sv, NULL);
437 fabian 1.27
438     /* Initialize variables and stuff */
439 stdarg 1.121 timer_update_now(&egg_timeval_now);
440 stdarg 1.108 now = egg_timeval_now.sec;
441 tothwolf 1.79 memcpy(&nowtm, localtime(&now), sizeof(struct tm));
442 fabian 1.17 lastmin = nowtm.tm_min;
443 poptix 1.63 srandom(now % (getpid() + getppid()));
444 ite 1.114
445     do_args(argc, argv);
446    
447 segfault 1.1 printf("\n%s\n", version);
448 guppy 1.93 printf(" *** WARNING: Do NOT run this DEVELOPMENT version for any purpose other than testing.\n\n");
449 guppy 1.53
450     /* Don't allow eggdrop to run as root */
451     if (((int) getuid() == 0) || ((int) geteuid() == 0))
452 ite 1.76 fatal(_("ERROR: Eggdrop will not run as root!"), 0);
453 stdarg 1.142
454     if (file_check(configfile)) {
455     if (errno) perror(configfile);
456     else fprintf(stderr, "ERROR\n\nCheck file permissions on your config file!\nMake sure other groups and users cannot read/write it.\n");
457     exit(-1);
458     }
459 guppy 1.53
460 ite 1.109 egg = eggdrop_new();
461 stdarg 1.136 config_init();
462 stdarg 1.134 core_config_init(configfile);
463 stdarg 1.130 egglog_init();
464     logfile_init();
465 ite 1.110 script_init();
466 stdarg 1.124 user_init();
467 stdarg 1.133 if (core_config.userfile) user_load(core_config.userfile);
468 stdarg 1.126 partyline_init();
469 stdarg 1.130 core_party_init();
470 stdarg 1.126 telnet_init();
471 stdarg 1.145 module_init();
472 stdarg 1.139 egg_net_init();
473 stdarg 1.85 core_binds_init();
474 stdarg 1.80
475 fabian 1.43 if (backgrd)
476     bg_prepare_split();
477 stdarg 1.80
478 ite 1.111 strlcpy(s, ctime(&now), sizeof s);
479 segfault 1.1 strcpy(&s[11], &s[20]);
480     putlog(LOG_ALL, "*", "--- Loading %s (%s)", ver, s);
481 stdarg 1.134
482 stdarg 1.145 /* Put the module directory in the ltdl search path. */
483     if (core_config.module_path) module_add_dir(core_config.module_path);
484    
485 stdarg 1.134 /* Scan the autoload section of config. */
486     config_root = config_get_root("eggdrop");
487 stdarg 1.137 for (i = 0; (entry = config_exists(config_root, "eggdrop", 0, "autoload", 0, "module", i, NULL)); i++) {
488 stdarg 1.134 modname = NULL;
489 stdarg 1.137 config_get_str(&modname, entry, NULL);
490 stdarg 1.134 module_load(modname);
491     }
492 stdarg 1.137 for (i = 0; (entry = config_exists(config_root, "eggdrop", 0, "autoload", 0, "script", i, NULL)); i++) {
493 stdarg 1.134 scriptname = NULL;
494 stdarg 1.137 config_get_str(&scriptname, entry, NULL);
495 stdarg 1.134 script_load(scriptname);
496     }
497    
498    
499 guppy 1.92
500     if (!pid_file[0])
501 stdarg 1.139 snprintf(pid_file, sizeof pid_file, "pid.%s", core_config.botname);
502 fabian 1.27
503     /* Check for pre-existing eggdrop! */
504 segfault 1.1 f = fopen(pid_file, "r");
505     if (f != NULL) {
506     fgets(s, 10, f);
507     xx = atoi(s);
508 fabian 1.27 kill(xx, SIGCHLD); /* Meaningless kill to determine if pid
509     is used */
510 segfault 1.1 if (errno != ESRCH) {
511 stdarg 1.139 printf(_("I detect %s already running from this directory.\n"), core_config.botname);
512 ite 1.73 printf(_("If this is incorrect, erase the %s\n"), pid_file);
513 fabian 1.43 bg_send_quit(BG_ABORT);
514 segfault 1.1 exit(1);
515     }
516     }
517 fabian 1.27
518     /* Move into background? */
519 segfault 1.1 if (backgrd) {
520 fabian 1.38 #ifndef CYGWIN_HACKS
521 fabian 1.43 bg_do_split();
522 fabian 1.38 } else { /* !backgrd */
523 fabian 1.5 #endif
524 fabian 1.38 xx = getpid();
525     if (xx != 0) {
526     FILE *fp;
527    
528     /* Write pid to file */
529     unlink(pid_file);
530     fp = fopen(pid_file, "w");
531     if (fp != NULL) {
532     fprintf(fp, "%u\n", xx);
533     if (fflush(fp)) {
534     /* Let the bot live since this doesn't appear to be a botchk */
535 ite 1.73 printf(_("* Warning! Could not write %s file!\n"), pid_file);
536 fabian 1.38 fclose(fp);
537     unlink(pid_file);
538     } else
539     fclose(fp);
540 fabian 1.27 } else
541 ite 1.73 printf(_("* Warning! Could not write %s file!\n"), pid_file);
542 fabian 1.38 #ifdef CYGWIN_HACKS
543 guppy 1.68 printf("Launched into the background (pid: %d)\n\n", xx);
544 fabian 1.38 #endif
545     }
546 segfault 1.1 }
547 fabian 1.38
548     use_stderr = 0; /* Stop writing to stderr now */
549 segfault 1.1 if (backgrd) {
550 fabian 1.27 /* Ok, try to disassociate from controlling terminal (finger cross) */
551 fabian 1.5 #if HAVE_SETPGID && !defined(CYGWIN_HACKS)
552 segfault 1.1 setpgid(0, 0);
553     #endif
554 fabian 1.38 /* Tcl wants the stdin, stdout and stderr file handles kept open. */
555 segfault 1.1 freopen("/dev/null", "r", stdin);
556     freopen("/dev/null", "w", stdout);
557     freopen("/dev/null", "w", stderr);
558 poptix 1.62 #ifdef CYGWIN_HACKS
559     FreeConsole();
560     #endif
561 segfault 1.1 }
562 fabian 1.27
563 segfault 1.1 online_since = now;
564 stdarg 1.82 howlong.sec = 1;
565     howlong.usec = 0;
566 stdarg 1.144 timer_create_repeater(&howlong, "main loop", core_secondly);
567 segfault 1.1
568 wcc 1.141 putlog(LOG_DEBUG, "*", "main: entering loop");
569 stdarg 1.139 while (1) {
570     timer_update_now(&egg_timeval_now);
571     now = egg_timeval_now.sec;
572     random(); /* Woop, lets really jumble things */
573     timer_run();
574    
575     if (timer_get_shortest(&howlong)) {
576     timeout = 1000;
577     }
578     else {
579     timeout = howlong.sec * 1000 + howlong.usec / 1000;
580     }
581     sockbuf_update_all(timeout);
582 stdarg 1.147 a = malloc(20);
583     free(a);
584 stdarg 1.131 }
585 segfault 1.1 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23