X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=main.c;h=522b2148379cfd14cce8a169fac46775e55feced;hp=73cfe49db1183a92522a2a4ff7301b05b7ac744e;hb=4ec1520c572c4099b478897e4a6ee3a28622ca44;hpb=c6a9035ac6bb8635922c72ba1b6ccf029adb5e17 diff --git a/main.c b/main.c index 73cfe49..522b214 100644 --- a/main.c +++ b/main.c @@ -348,8 +348,11 @@ int main(int argc, char *argv[]) /* write pid file */ pidfile = fopen("/var/run/lcr.pid","w"); - fprintf(pidfile, "%d\n", getpid()); - fclose(pidfile); + if (pidfile) + { + fprintf(pidfile, "%d\n", getpid()); + fclose(pidfile); + } } else /* if not start */ if (!!strcasecmp(argv[1],"start")) @@ -391,6 +394,21 @@ int main(int argc, char *argv[]) goto free; } +#ifdef WITH_GSM + /* handle gsm */ + if (options.gsm && gsm_init()) + { + fprintf(stderr, "GSM initialization failed.\n"); + goto free; + } +#else + if (options.gsm) + { + fprintf(stderr, "GSM is enabled, but not compiled. Use --with-gsm while configure!\n"); + goto free; + } +#endif + /* read interfaces and open ports */ if (!read_interfaces()) { @@ -611,6 +629,15 @@ BUDETECT all_idle = 0; BUDETECT +#ifdef WITH_GSM + /* handle gsm */ + if (options.gsm) + while(handle_gsm()) + all_idle = 0; +#endif + +BUDETECT + #if 0 /* check for child to exit (eliminate zombies) */ if (waitpid(-1, NULL, WNOHANG) > 0) @@ -743,6 +770,12 @@ free: if (created_misdn) mISDN_deinitialize(); +#ifdef WITH_GSM + /* free gsm */ + if (options.gsm) + gsm_exit(0); +#endif + /* display memory leak */ #define MEMCHECK(a, b) \ if (b) \