| version 1.8, 2013/11/06 06:23:23 |
version 1.13, 2021/03/12 06:45:55 |
|
|
| /* $OpenXM: OpenXM/src/k097/ox_k0.c,v 1.7 2004/09/17 02:42:58 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/k097/ox_k0.c,v 1.12 2020/10/07 23:53:25 takayama Exp $ */ |
| #include <stdio.h> |
#include <stdio.h> |
| #include <sys/types.h> |
#include <sys/types.h> |
| #include <sys/socket.h> |
#include <sys/socket.h> |
|
|
| #include <netdb.h> |
#include <netdb.h> |
| #include <signal.h> |
#include <signal.h> |
| #include <setjmp.h> |
#include <setjmp.h> |
| |
#include <string.h> |
| |
#include <stdlib.h> |
| /* -lnsl -lsocket /usr/ucblib/libucb.a */ |
/* -lnsl -lsocket /usr/ucblib/libucb.a */ |
| #include "../kxx/ox_kan.h" |
#include "../kxx/ox_kan.h" |
| #include "../kxx/serversm.h" |
#include "../kxx/serversm.h" |
| |
#include "ox_k0.h" |
| |
#include "ki.h" |
| |
|
| |
|
| int OxCritical = 0; |
int OxCritical = 0; |
| int OxInterruptFlag = 0; |
int OxInterruptFlag = 0; |
| int PacketMonitor = 0; |
int PacketMonitor = 0; |
| Line 29 jmp_buf EnvOfChildServer; |
|
| Line 34 jmp_buf EnvOfChildServer; |
|
| int JmpMessage = 0; |
int JmpMessage = 0; |
| |
|
| static char *getSuffix(char *s); |
static char *getSuffix(char *s); |
| main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
| char *s; |
char *s; |
| |
|
| if (argc > 1) { |
if (argc > 1) { |
| Line 45 main(int argc, char *argv[]) { |
|
| Line 50 main(int argc, char *argv[]) { |
|
| K0_start(); |
K0_start(); |
| |
|
| nullserver(3,4); |
nullserver(3,4); |
| |
return 0; |
| } |
} |
| |
|
| static char *getSuffix(char *s) { |
static char *getSuffix(char *s) { |
| Line 63 static char *getSuffix(char *s) { |
|
| Line 69 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; |
| Line 128 nullserver(int fdStreamIn,int fdStreamOut) { |
|
| Line 134 nullserver(int fdStreamIn,int fdStreamOut) { |
|
| Calling_ctrlC_hook = 0; |
Calling_ctrlC_hook = 0; |
| KSexecuteString(" (Computation is interrupted.) "); |
KSexecuteString(" (Computation is interrupted.) "); |
| InSendmsg2 = 0; |
InSendmsg2 = 0; |
| 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 (sigsetjmp(EnvOfStackMachine,1)) { |
| Line 166 nullserver(int fdStreamIn,int fdStreamOut) { |
|
| Line 172 nullserver(int fdStreamIn,int fdStreamOut) { |
|
| } |
} |
| Calling_ctrlC_hook = 0; |
Calling_ctrlC_hook = 0; |
| InSendmsg2=0; |
InSendmsg2=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 211 nullserver(int fdStreamIn,int fdStreamOut) { |
|
| Line 217 nullserver(int fdStreamIn,int fdStreamOut) { |
|
| default: fprintf(stderr," ?! \n"); break; |
default: fprintf(stderr," ?! \n"); break; |
| } |
} |
| } |
} |
| /*sleep(2); /* for dubug OX_SYNC_BALL */ |
/*sleep(2); // for dubug OX_SYNC_BALL */ |
| switch(mtag) { |
switch(mtag) { |
| case OX_COMMAND: |
case OX_COMMAND: |
| nullserverCommand(ostreamIn,ostreamOut); |
nullserverCommand(ostreamIn,ostreamOut); |
| Line 230 nullserver(int fdStreamIn,int fdStreamOut) { |
|
| Line 236 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 290 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
| Line 296 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
| if (message) fprintf(stderr," executeStringByLocalParser\n"); |
if (message) fprintf(stderr," executeStringByLocalParser\n"); |
| OxCritical = 0; |
OxCritical = 0; |
| iresult = K0_executeStringByLocalParser(); |
iresult = K0_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 301 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
| Line 307 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
| if (message) fprintf(stderr," executeFunction\n"); |
if (message) fprintf(stderr," executeFunction\n"); |
| OxCritical = 0; |
OxCritical = 0; |
| iresult = K0_executeStringByLocalParser(); |
iresult = K0_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 309 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
| Line 315 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
| } |
} |
| break; |
break; |
| case SM_popCMO: |
case SM_popCMO: |
| if (message) fprintf(stderr,"popCMO. Start to sending data.\n",n); |
if (message) fprintf(stderr,"popCMO. Start to sending data %d\n",n); |
| oxSendOXheader(ostreamOut,OX_DATA,SerialOX++); |
oxSendOXheader(ostreamOut,OX_DATA,SerialOX++); |
| n=Sm1_popCMO(ostreamOut,SerialCurrent); |
n=Sm1_popCMO(ostreamOut,SerialCurrent); |
| if (message) fprintf(stderr,"Done.\n"); |
if (message) fprintf(stderr,"Done.\n"); |
| break; |
break; |
| case SM_popString: |
case SM_popString: |
| if (message) fprintf(stderr,"popString. send data from the stack.\n",n); |
if (message) fprintf(stderr,"popString. send data from the stack %d\n",n); |
| oxSendOXheader(ostreamOut,OX_DATA,SerialOX++); |
oxSendOXheader(ostreamOut,OX_DATA,SerialOX++); |
| oxSendCmoString(ostreamOut,Sm1_popString()); |
oxSendCmoString(ostreamOut,Sm1_popString()); |
| if (message) fprintf(stderr,"Done.\n"); |
if (message) fprintf(stderr,"Done.\n"); |
| Line 338 nullserverCommand(ox_stream ostreamIn,ox_stream ostrea |
|
| Line 344 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); |
| Line 350 nullserver_simplest(int fd) { |
|
| Line 356 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 381 extern int K00_verbose; |
|
| Line 387 extern int K00_verbose; |
|
| int Startupk2 = 1; |
int Startupk2 = 1; |
| |
|
| |
|
| K0_start() { |
void K0_start() { |
| extern int Saki; |
extern int Saki; |
| extern int Interactive; |
extern int Interactive; |
| int i; |
int i; |
|
|
| KSstop(); closing |
KSstop(); closing |
| */ |
*/ |
| |
|
| K0_executeStringByLocalParser() { |
int K0_executeStringByLocalParser() { |
| extern int Interactive; |
extern int Interactive; |
| char *s; |
char *s; |
| s = Sm1_popString(); |
s = Sm1_popString(); |