version 1.15, 2004/09/05 00:51:18 |
version 1.25, 2020/10/07 07:47:23 |
|
|
/* $OpenXM: OpenXM/src/kxx/oxserver00.c,v 1.14 2004/03/08 08:24:42 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kxx/oxserver00.c,v 1.24 2016/08/28 02:43:15 takayama Exp $ */ |
/* nullserver01 */ |
/* nullserver01 */ |
#include <stdio.h> |
#include <stdio.h> |
#include <sys/types.h> |
#include <sys/types.h> |
|
|
#include <netdb.h> |
#include <netdb.h> |
#include <signal.h> |
#include <signal.h> |
#include <setjmp.h> |
#include <setjmp.h> |
|
#include <stdlib.h> |
/* -lnsl -lsocket /usr/ucblib/libucb.a */ |
/* -lnsl -lsocket /usr/ucblib/libucb.a */ |
#include "ox_kan.h" |
#include "ox_kan.h" |
#include "serversm.h" |
#include "serversm.h" |
Line 21 extern int SerialOX; /* Serial number of the packets |
|
Line 22 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? */ |
extern int Calling_ctrlC_hook; |
extern int Calling_ctrlC_hook; |
|
extern int RestrictedMode, RestrictedMode_saved; |
|
|
#if defined(__CYGWIN__) |
#if defined(__CYGWIN__) || defined(__MSYS__) |
sigjmp_buf EnvOfChildServer; |
sigjmp_buf EnvOfChildServer; |
#else |
#else |
jmp_buf EnvOfChildServer; |
jmp_buf EnvOfChildServer; |
#endif |
#endif |
|
|
|
void nullserver(int fdStreamIn,int fdStreamOut); |
|
int nullserverCommand(ox_stream ostreamIn,ox_stream ostreamOut); |
|
int nullserver_simplest(int fd); |
|
int KSexecuteString(char *s); // kan96xx/Kan/datatype.h |
|
void cancelAlarm(); // nullstackmachine.c |
|
char *traceShowStack(); // kan96xx/Kan/extern.h |
|
void traceClearStack(); // kan96xx/Kan/extern.h |
|
|
int JmpMessage = 0; |
int JmpMessage = 0; |
extern int Lisplike; |
extern int Lisplike; |
|
|
static char *getSuffix(char *s); |
static char *getSuffix(char *s); |
main(int argc, char *argv[]) { |
void main(int argc, char *argv[]) { |
char *s; |
char *s; |
char *forAsir[] = {"callsm1.sm1","callsm1b.sm1"}; |
char *forAsir[] = {"callsm1.sm1","callsm1b.sm1"}; |
char *gnuplot[] = {"callsm1.sm1","gnuplot.sm1"}; |
char *gnuplot[] = {"callsm1.sm1","gnuplot.sm1"}; |
Line 91 static char *getSuffix(char *s) { |
|
Line 101 static char *getSuffix(char *s) { |
|
} |
} |
return(s); |
return(s); |
} |
} |
nullserver(int fdStreamIn,int fdStreamOut) { |
void nullserver(int fdStreamIn,int fdStreamOut) { |
int mtag; |
int mtag; |
int message = 1; |
int message = 1; |
ox_stream ostreamIn; |
ox_stream ostreamIn; |
ox_stream ostreamOut; |
ox_stream ostreamOut; |
char sreason[1024]; |
char sreason[1024]; |
extern void controlResetHandler(); |
extern void controlResetHandler(); |
#if defined(__CYGWIN__) |
#if defined(__CYGWIN__) || defined(__MSYS__) |
extern sigjmp_buf EnvOfStackMachine; |
extern sigjmp_buf EnvOfStackMachine; |
#else |
#else |
extern jmp_buf EnvOfStackMachine; |
extern jmp_buf EnvOfStackMachine; |
Line 130 nullserver(int fdStreamIn,int fdStreamOut) { |
|
Line 140 nullserver(int fdStreamIn,int fdStreamOut) { |
|
if (PacketMonitor) fp2watch(ostreamOut,stdout); |
if (PacketMonitor) fp2watch(ostreamOut,stdout); |
} |
} |
|
|
|
/* fprintf(stderr,"Hello world.\n"); OXprintMessage = 1; |
|
JmpMessage = 1; */ |
|
|
aaa : ; |
aaa : ; |
#if defined(__CYGWIN__) |
#if defined(__CYGWIN__) |
if (sigsetjmp(EnvOfChildServer,1)) { |
if (MYSIGSETJMP(EnvOfChildServer,1)) { |
#else |
#else |
if (setjmp(EnvOfChildServer)) { |
if (MYSETJMP(EnvOfChildServer)) { |
#endif |
#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); |
} |
} |
if (!Calling_ctrlC_hook) { |
if (!Calling_ctrlC_hook) { |
Calling_ctrlC_hook = 1; |
Calling_ctrlC_hook = 1; RestrictedMode = 0; |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
|
RestrictedMode = RestrictedMode_saved; |
} |
} |
Calling_ctrlC_hook = 0; |
Calling_ctrlC_hook = 0; |
KSexecuteString(" (Computation is interrupted.) "); |
KSexecuteString(" (Computation is interrupted.) "); |
signal(SIGUSR1,controlResetHandler); goto aaa; |
mysignal(SIGUSR1,controlResetHandler); goto aaa; |
} else { |
} else { |
if (JmpMessage) fprintf(stderr,"Set EnvOfChildServer.\n"); |
if (JmpMessage) fprintf(stderr,"Set EnvOfChildServer.\n"); |
signal(SIGUSR1,controlResetHandler); |
mysignal(SIGUSR1,controlResetHandler); |
} |
} |
#if defined(__CYGWIN__) |
#if defined(__CYGWIN__) |
if (sigsetjmp(EnvOfStackMachine,1)) { |
if (MYSIGSETJMP(EnvOfStackMachine,1)) { |
#else |
#else |
if (setjmp(EnvOfStackMachine)) { |
if (MYSETJMP(EnvOfStackMachine)) { |
#endif |
#endif |
fprintf(stderr,"childServerMain: jump here by EnvOfStackMachine or timeout.\n"); |
fprintf(stderr,"childServerMain: jump here by EnvOfStackMachine or timeout.\n"); |
if (OxInterruptFlag == 0) { |
if (OxInterruptFlag == 0) { |
Line 171 nullserver(int fdStreamIn,int fdStreamOut) { |
|
Line 185 nullserver(int fdStreamIn,int fdStreamOut) { |
|
Sm1_pushError2(SerialCurrent,-1,"Global jump by sm1 error"); |
Sm1_pushError2(SerialCurrent,-1,"Global jump by sm1 error"); |
|
|
if (!Calling_ctrlC_hook) { |
if (!Calling_ctrlC_hook) { |
Calling_ctrlC_hook = 1; |
Calling_ctrlC_hook = 1; RestrictedMode = 0; |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */ |
|
RestrictedMode = RestrictedMode_saved; |
} |
} |
Calling_ctrlC_hook = 0; |
Calling_ctrlC_hook = 0; |
signal(SIGUSR1,controlResetHandler); goto aaa ; |
mysignal(SIGUSR1,controlResetHandler); goto aaa ; |
} else { |
} else { |
if (JmpMessage) fprintf(stderr,"Set EnvOfStackMachine.\n"); |
if (JmpMessage) fprintf(stderr,"Set EnvOfStackMachine.\n"); |
if (signal(SIGUSR1,SIG_IGN) != SIG_IGN) { |
if (mysignal(SIGUSR1,SIG_IGN) != SIG_IGN) { |
signal(SIGUSR1,controlResetHandler); |
mysignal(SIGUSR1,controlResetHandler); |
} |
} |
} |
} |
|
|
Line 239 nullserver(int fdStreamIn,int fdStreamOut) { |
|
Line 254 nullserver(int fdStreamIn,int fdStreamOut) { |
|
} |
} |
} |
} |
|
|
nullserverCommand(ox_stream ostreamIn,ox_stream ostreamOut) { |
int nullserverCommand(ox_stream ostreamIn,ox_stream ostreamOut) { |
int id; |
int id; |
int mtag; |
int mtag; |
int n; |
int n; |
Line 294 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
Line 309 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
}else{ |
}else{ |
iresult = Sm1_executeStringByLocalParser(); |
iresult = Sm1_executeStringByLocalParser(); |
} |
} |
OxCritical = 1; signal(SIGUSR1,controlResetHandler); |
OxCritical = 1; mysignal(SIGUSR1,controlResetHandler); |
if (iresult < 0) { |
if (iresult < 0) { |
emsg = Sm1_popErrorMessage("executeString: "); |
emsg = Sm1_popErrorMessage("executeString: "); |
Sm1_pushError2(SerialCurrent,-1,emsg); |
Sm1_pushError2(SerialCurrent,-1,emsg); |
Line 308 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
Line 323 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
}else{ |
}else{ |
iresult = Sm1_executeStringByLocalParser(); |
iresult = Sm1_executeStringByLocalParser(); |
} |
} |
OxCritical = 1; signal(SIGUSR1,controlResetHandler); |
OxCritical = 1; mysignal(SIGUSR1,controlResetHandler); |
if (iresult < 0) { |
if (iresult < 0) { |
emsg = Sm1_popErrorMessage("executeFunction: "); |
emsg = Sm1_popErrorMessage("executeFunction: "); |
Sm1_pushError2(SerialCurrent,-1,emsg); |
Sm1_pushError2(SerialCurrent,-1,emsg); |
Line 322 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
Line 337 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
}else{ |
}else{ |
iresult = Sm1_executeStringByLocalParser(); |
iresult = Sm1_executeStringByLocalParser(); |
} |
} |
OxCritical = 1; signal(SIGUSR1,controlResetHandler); |
OxCritical = 1; mysignal(SIGUSR1,controlResetHandler); |
if (iresult < 0) { |
if (iresult < 0) { |
emsg = Sm1_popErrorMessage("executeFunctionWithOptionalArgument: "); |
emsg = Sm1_popErrorMessage("executeFunctionWithOptionalArgument: "); |
Sm1_pushError2(SerialCurrent,-1,emsg); |
Sm1_pushError2(SerialCurrent,-1,emsg); |
Line 348 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
Line 363 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
fprintf(stderr,"This command has not yet been implemented.\n"); |
fprintf(stderr,"This command has not yet been implemented.\n"); |
return(-1); |
return(-1); |
break; |
break; |
|
case SM_nop: |
|
break; |
default: |
default: |
fprintf(stderr,"Fatal error. Unknown function_id %d\n",id); |
fprintf(stderr,"Fatal error. Unknown function_id %d\n",id); |
return(-1); |
return(-1); |
Line 357 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
Line 374 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
} |
} |
|
|
|
|
nullserver_simplest(int fd) { |
int nullserver_simplest(int fd) { |
int c; |
int c; |
while(1) { |
while(1) { |
c = readOneByte(fd); |
c = readOneByte(fd); |
if (c == '@') { return; } |
if (c == '@') { return 0; } |
} |
} |
} |
} |
|
|
Line 369 nullserver_simplest(int fd) { |
|
Line 386 nullserver_simplest(int fd) { |
|
void controlResetHandler(sig) |
void controlResetHandler(sig) |
int sig; |
int sig; |
{ |
{ |
signal(sig,SIG_IGN); |
mysignal(sig,SIG_IGN); |
cancelAlarm(); |
cancelAlarm(); |
fprintf(stderr,"From controlResetHandler. OxCritical = %d\n",OxCritical); |
fprintf(stderr,"From controlResetHandler. OxCritical = %d\n",OxCritical); |
OxInterruptFlag = 1; |
OxInterruptFlag = 1; |
Line 377 void controlResetHandler(sig) |
|
Line 394 void controlResetHandler(sig) |
|
return; |
return; |
}else{ |
}else{ |
(void) traceShowStack(); traceClearStack(); |
(void) traceShowStack(); traceClearStack(); |
#if defined(__CYGWIN__) |
#if defined(__CYGWIN__) || defined(__MSYS__) |
siglongjmp(EnvOfChildServer,2); /* returns 2 for ctrl-C */ |
MYSIGLONGJMP(EnvOfChildServer,2); /* returns 2 for ctrl-C */ |
#else |
#else |
longjmp(EnvOfChildServer,2); /* returns 2 for ctrl-C */ |
MYLONGJMP(EnvOfChildServer,2); /* returns 2 for ctrl-C */ |
#endif |
#endif |
} |
} |
} |
} |