X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=main.c;h=ce054520d2ed762f5c3ab92bf3f742bd4eea9e55;hp=e2d3f136f07c653b3b7ec4818f25b736fa607c50;hb=27ade6eeb9859a0702e77b27ca0abed63d298cda;hpb=882882e0e2f6c451c4b9a5aa8209aa60352049c9 diff --git a/main.c b/main.c index e2d3f13..ce05452 100644 --- a/main.c +++ b/main.c @@ -10,6 +10,10 @@ \*****************************************************************************/ #include "main.h" +#ifdef PACKAGE_VERSION +#undef PACKAGE_VERSION +#endif +#include "config.h" //MESSAGES @@ -22,7 +26,7 @@ struct timezone now_tz; } FILE *debug_fp = NULL; -int quit=0; +int quit = 0; #if 0 struct lcr_fdset lcr_fdset[FD_SETSIZE]; @@ -142,6 +146,8 @@ void sighandler(int sigset) return; if (sigset == SIGPIPE) return; + fprintf(stderr, "LCR: Signal received: %d\n", sigset); + PDEBUG(DEBUG_LOG, "Signal received: %d\n", sigset); if (!quit) { quit = sigset; /* set scheduler & priority */ @@ -150,8 +156,6 @@ void sighandler(int sigset) schedp.sched_priority = 0; sched_setscheduler(0, SCHED_OTHER, &schedp); } - fprintf(stderr, "LCR: Signal received: %d\n", sigset); - PDEBUG(DEBUG_LOG, "Signal received: %d\n", sigset); } } @@ -161,7 +165,7 @@ void sighandler(int sigset) */ int main(int argc, char *argv[]) { -#ifdef WITH_GSM +#if 0 double now_d, last_d; int all_idle; #endif @@ -362,15 +366,25 @@ int main(int argc, char *argv[]) goto free; } -#ifdef WITH_GSM - /* handle gsm */ - if (options.gsm && gsm_init()) { +#if defined WITH_GSM_BS || defined WITH_GSM_MS + /* init gsm */ + if (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"); +#endif +#if 0 +init is done when interface is up +#ifdef WITH_GSM_BS + if (gsm_bs_init()) { + fprintf(stderr, "GSM BS initialization failed.\n"); + goto free; + } +#endif +#endif +#ifdef WITH_GSM_MS + if (gsm_ms_init()) { + fprintf(stderr, "GSM MS initialization failed.\n"); goto free; } #endif @@ -436,11 +450,11 @@ int main(int argc, char *argv[]) printf("%s\n", tracetext); end_trace(); quit = 0; -#ifdef WITH_GSM +#if 0 GET_NOW(); #endif while(!quit) { -#ifdef WITH_GSM +#if 0 last_d = now_d; GET_NOW(); if (now_d-last_d > 1.0) { @@ -452,26 +466,24 @@ int main(int argc, char *argv[]) /* must be processed after all queues, so they are empty */ if (select_main(1, NULL, NULL, NULL)) all_idle = 0; - /* handle gsm */ - if (options.gsm) - while(handle_gsm()) - all_idle = 0; if (all_idle) { usleep(10000); } #else - if (options.polling) + if (options.polling) { if (!select_main(1, NULL, NULL, NULL)) usleep(10000); - else + } else select_main(0, NULL, NULL, NULL); #endif } SPRINT(tracetext, "%s terminated", NAME); printf("%s\n", tracetext); start_trace(-1, NULL, NULL, NULL, 0, 0, 0, tracetext); - if (quit) + if (quit > 0) add_trace((char *)"signal", NULL, "%d", quit); + if (quit < 0) + add_trace((char *)"errno", NULL, "%d", quit); end_trace(); ret=0; @@ -565,11 +577,23 @@ free: if (created_misdn) mISDN_deinitialize(); -#ifdef WITH_GSM /* free gsm */ - if (options.gsm) - gsm_exit(0); +#if 0 +exit is done when interface is down +#ifdef WITH_GSM_BS + gsm_bs_exit(0); #endif +#endif +#ifdef WITH_GSM_MS + gsm_ms_exit(0); +#endif +#if defined WITH_GSM_BS || defined WITH_GSM_MS + gsm_exit(0); +#endif + + /* close loopback, if used by GSM or remote */ + if (mISDNloop.sock > -1) + mISDNloop_close(); /* display memory leak */ #define MEMCHECK(a, b) \