=================================================================== RCS file: /home/cvs/OpenXM/src/kxx/oxserver00.c,v retrieving revision 1.1.1.1 retrieving revision 1.8 diff -u -p -r1.1.1.1 -r1.8 --- OpenXM/src/kxx/oxserver00.c 1999/10/08 02:12:13 1.1.1.1 +++ OpenXM/src/kxx/oxserver00.c 2002/11/04 10:53:57 1.8 @@ -1,3 +1,4 @@ +/* $OpenXM: OpenXM/src/kxx/oxserver00.c,v 1.7 2002/02/24 10:27:21 takayama Exp $ */ /* nullserver01 */ #include #include @@ -19,7 +20,11 @@ extern int SerialOX; /* Serial number of the packets extern int SerialCurrent; /* Current Serial number of the recieved packet. */ extern int OXprintMessage; /* print oxmessages? */ +#if defined(__CYGWIN__) +sigjmp_buf EnvOfChildServer; +#else jmp_buf EnvOfChildServer; +#endif int JmpMessage = 0; @@ -32,7 +37,7 @@ main(int argc, char *argv[]) { char *tigers[] = {"callsm1.sm1","tigers.sm1"}; char *basicCD[] = {"basicCD.sm1"}; /* If you change the above, you need to change the argc of Sm1_start below. - */ + */ if (argc > 1) { if (strcmp(argv[1],"-monitor")==0) { @@ -63,9 +68,13 @@ main(int argc, char *argv[]) { static char *getSuffix(char *s) { /* getSuffix("ox_sm1_forAsir") returns "forAsir" */ + /* getSuffix("ox_sm1_forAsir.exe") returns "forAsir" */ /* getSuffix("ox_sm1_gnuplot") returns "gnuplot" */ int n,i,k; n = strlen(s); + if (n > 5 && (strcmp(".exe",&(s[n-4]))==0 || strcmp(".EXE",&(s[n-4]))==0)) { + s[n-4] = '\0'; + } for (i=n-1; i>=0; i--) { if (s[i] == '_') { return( s+i+1 ); @@ -79,9 +88,14 @@ nullserver(int fdStream) { ox_stream ostream; char sreason[1024]; extern void controlResetHandler(); +#if defined(__CYGWIN__) + extern sigjmp_buf EnvOfStackMachine; +#else extern jmp_buf EnvOfStackMachine; +#endif int engineByteOrder; + fflush(NULL); engineByteOrder = oxTellMyByteOrder(fdStream); /* Set the network byte order. */ fprintf(stderr,"engineByteOrder=%x\n",engineByteOrder); @@ -95,7 +109,11 @@ nullserver(int fdStream) { if (PacketMonitor) fp2watch(ostream,stdout); } aaa : ; +#if defined(__CYGWIN__) + if (sigsetjmp(EnvOfChildServer,1)) { +#else if (setjmp(EnvOfChildServer)) { +#endif fprintf(stderr,"childServerMain: jump here.\n"); if (OxInterruptFlag == 0) { fprintf(stderr," ?! \n"); fflush(NULL); @@ -105,8 +123,11 @@ nullserver(int fdStream) { if (JmpMessage) fprintf(stderr,"Set EnvOfChildServer.\n"); signal(SIGUSR1,controlResetHandler); } - +#if defined(__CYGWIN__) + if (sigsetjmp(EnvOfStackMachine,1)) { +#else if (setjmp(EnvOfStackMachine)) { +#endif fprintf(stderr,"childServerMain: jump here by EnvOfStackMachine.\n"); if (OxInterruptFlag == 0) { fprintf(stderr," ?! \n"); fflush(NULL); @@ -114,10 +135,10 @@ nullserver(int fdStream) { /* In case of error in the stack machine, pop the error info and send the error packet. */ /* oxSendOXheader(ostream,OX_DATA,SerialOX++); - oxSendCmoError(ostream); - oxSendOXheader(ostream,OX_DATA,SerialOX++); - sprintf(sreason,"Jump here by sm1 error."); - oxSendCmoError2(ostream,sreason); + oxSendCmoError(ostream); + oxSendOXheader(ostream,OX_DATA,SerialOX++); + sprintf(sreason,"Jump here by sm1 error."); + oxSendCmoError2(ostream,sreason); */ Sm1_pushError2(SerialCurrent,-1,"Global jump by sm1 error"); @@ -162,7 +183,7 @@ nullserver(int fdStream) { case OX_DATA: fprintf(stderr," OX_DATA \n"); break; case OX_SYNC_BALL: fprintf(stderr," OX_SYNC_BALL \n"); break; case -1: fprintf(stderr," End of file. Exiting the server child.\n"); - exit(); break; + exit(); break; default: fprintf(stderr," ?! \n"); break; } } @@ -223,6 +244,10 @@ nullserverCommand(ox_stream ostream) { if (message) fprintf(stderr," dupErrors \n"); Sm1_dupErrors(); break; + case SM_pushCMOtag: + if (message) fprintf(stderr," pushCMOtag \n"); + Sm1_pushCMOtag(SerialCurrent); + break; case SM_setName: if (message) fprintf(stderr," setName \n"); iresult = Sm1_setName(); @@ -272,6 +297,9 @@ nullserverCommand(ox_stream ostream) { if (message) fprintf(stderr,"Done.\n"); break; case SM_shutdown: + fprintf(stderr,"Shutting down the engine.\n"); + exit(0); + break; case SM_beginBlock: case SM_endBlock: fprintf(stderr,"This command has not yet been implemented.\n"); @@ -296,15 +324,20 @@ nullserver_simplest(int fd) { void controlResetHandler(sig) -int sig; + int sig; { signal(sig,SIG_IGN); + cancelAlarm(); fprintf(stderr,"From controlResetHandler. OxCritical = %d\n",OxCritical); OxInterruptFlag = 1; if (OxCritical) { return; }else{ +#if defined(__CYGWIN__) + siglongjmp(EnvOfChildServer,2); /* returns 2 for ctrl-C */ +#else longjmp(EnvOfChildServer,2); /* returns 2 for ctrl-C */ +#endif } }