/* main.c --------- Co. E.Benninghaus 78166 Donaueschingen created: 08.09.2000 last Work: 08.09.2000 */ #ifndef __main_c #define __main_c #include "elctr.c" void endall( void ); typedef void ( *sighandler_t)(int); sighandler_t sighandler_old = SIG_ERR; void sigterminate(int sig) { if(sig != SIGTERM)return; if(sighandler_old != SIG_ERR){ signal(SIGTERM,sighandler_old); sighandler_old = SIG_ERR; } endall(); exit(0); } void sigrestore(void) { if(sighandler_old == SIG_ERR)return; signal(SIGTERM,sighandler_old); sighandler_old = SIG_ERR; } int sigset(void) { sigrestore(); sighandler_old = signal(SIGTERM,sigterminate); if(sighandler_old == SIG_ERR)return(-1); return(0); } void endall( void ) { ctrendall(); sigrestore(); fprintf(stdout,"ELCTR END\n"); exit(0); } int main(int argc, char * argv[]) { int arg; fprintf(stdout,"ELCTR START\n"); if(! ctrparsecommandline( argc, argv )){ exit(0); } if(! ctrreadconfigfile( "elctrrc" )){ exit(0); } if( sigset() < 0){ fprintf(stderr,"Cannot install signalhandler\n"); exit(-1); } ctrSetCB_kp_high_follow( &endall ); ctrstartall( 0 ); endall(); } #endif /*__main_c*/