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