[BACK]Return to oxserver00.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kxx

Diff for /OpenXM/src/kxx/oxserver00.c between version 1.12 and 1.22

version 1.12, 2003/11/19 01:02:40 version 1.22, 2015/10/10 11:29:46
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kxx/oxserver00.c,v 1.11 2003/11/18 11:08:27 takayama Exp $ */  /* $OpenXM: OpenXM/src/kxx/oxserver00.c,v 1.21 2015/10/09 23:46:18 takayama Exp $ */
 /* nullserver01 */  /* nullserver01 */
 #include <stdio.h>  #include <stdio.h>
 #include <sys/types.h>  #include <sys/types.h>
Line 8 
Line 8 
 #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 15 
Line 16 
 int OxCritical = 0;  int OxCritical = 0;
 int OxInterruptFlag = 0;  int OxInterruptFlag = 0;
 int PacketMonitor = 0;  int PacketMonitor = 0;
   int NoExecution = 0;
   
 extern int SerialOX;  /* Serial number of the packets sent. */  extern int SerialOX;  /* Serial number of the packets sent. */
 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 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;
Line 47  main(int argc, char *argv[]) {
Line 51  main(int argc, char *argv[]) {
     }else if (strcmp(argv[1],"-lispLike")==0) {      }else if (strcmp(argv[1],"-lispLike")==0) {
       fprintf(stderr,"Output lispLike expression.\n");        fprintf(stderr,"Output lispLike expression.\n");
       Lisplike = 1;        Lisplike = 1;
       }else if (strcmp(argv[1],"-noexec")==0) {
         fprintf(stderr,"I do not execute commands.\n");
         NoExecution = 1;
     }else{      }else{
       fprintf(stderr,"Unknown option. Possible options are -monitor\n");        fprintf(stderr,"Unknown option. Possible options are -monitor\n");
     }      }
Line 93  nullserver(int fdStreamIn,int fdStreamOut) {
Line 100  nullserver(int fdStreamIn,int fdStreamOut) {
   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 125  nullserver(int fdStreamIn,int fdStreamOut) {
Line 132  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);
     }      }
         KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */      if (!Calling_ctrlC_hook) {
         Calling_ctrlC_hook = 1; RestrictedMode = 0;
         KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */
         RestrictedMode = RestrictedMode_saved;
       }
       Calling_ctrlC_hook = 0;
         KSexecuteString(" (Computation is interrupted.) ");          KSexecuteString(" (Computation is interrupted.) ");
     signal(SIGUSR1,controlResetHandler); goto aaa;      signal(SIGUSR1,controlResetHandler); goto aaa;
   } else {    } else {
Line 143  nullserver(int fdStreamIn,int fdStreamOut) {
Line 158  nullserver(int fdStreamIn,int fdStreamOut) {
     signal(SIGUSR1,controlResetHandler);      signal(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 161  nullserver(int fdStreamIn,int fdStreamOut) {
Line 176  nullserver(int fdStreamIn,int fdStreamOut) {
     */      */
     Sm1_pushError2(SerialCurrent,-1,"Global jump by sm1 error");      Sm1_pushError2(SerialCurrent,-1,"Global jump by sm1 error");
   
         KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */      if (!Calling_ctrlC_hook) {
         Calling_ctrlC_hook = 1; RestrictedMode = 0;
         KSexecuteString(" ctrlC-hook "); /* Execute User Defined functions. */
         RestrictedMode = RestrictedMode_saved;
       }
       Calling_ctrlC_hook = 0;
     signal(SIGUSR1,controlResetHandler); goto aaa ;      signal(SIGUSR1,controlResetHandler); goto aaa ;
   } else {    } else {
     if (JmpMessage) fprintf(stderr,"Set EnvOfStackMachine.\n");      if (JmpMessage) fprintf(stderr,"Set EnvOfStackMachine.\n");
Line 244  nullserverCommand(ox_stream ostreamIn,ox_stream ostrea
Line 264  nullserverCommand(ox_stream ostreamIn,ox_stream ostrea
   if (message) {fprintf(stderr,"\nfunction_id is %d; %s\n",id,oxFIDtoStr(id));}    if (message) {fprintf(stderr,"\nfunction_id is %d; %s\n",id,oxFIDtoStr(id));}
   switch( id ) {    switch( id ) {
   case SM_mathcap:    case SM_mathcap:
     if (message) fprintf(stderr," mathcap\n");  
     mathresult = (struct mathCap *)Sm1_mathcap();      mathresult = (struct mathCap *)Sm1_mathcap();
     oxPushMathCap(mathresult);      oxPushMathCap(mathresult);
     break;      break;
   case SM_setMathCap:    case SM_setMathCap:
     if (message) fprintf(stderr," setMathCap\n");  
     Sm1_setMathCap(ostreamOut);      Sm1_setMathCap(ostreamOut);
     break;      break;
   case SM_pops:    case SM_pops:
     if (message) fprintf(stderr," pops \n");  
     Sm1_pops();      Sm1_pops();
     break;      break;
   case SM_getsp:    case SM_getsp:
     if (message) fprintf(stderr," getsp \n");  
     Sm1_getsp();      Sm1_getsp();
     break;      break;
   case SM_dupErrors:    case SM_dupErrors:
     if (message) fprintf(stderr," dupErrors \n");  
     Sm1_dupErrors();      Sm1_dupErrors();
     break;      break;
   case SM_pushCMOtag:    case SM_pushCMOtag:
     if (message) fprintf(stderr," pushCMOtag \n");  
     Sm1_pushCMOtag(SerialCurrent);      Sm1_pushCMOtag(SerialCurrent);
     break;      break;
   case SM_setName:    case SM_setName:
     if (message) fprintf(stderr," setName \n");  
     iresult = Sm1_setName();      iresult = Sm1_setName();
     if (iresult < 0) {      if (iresult < 0) {
       Sm1_pushError2(SerialCurrent,-1,"setName");        Sm1_pushError2(SerialCurrent,-1,"setName");
     }      }
     break;      break;
   case SM_evalName:    case SM_evalName:
     if (message) fprintf(stderr," evalName \n");  
     iresult = Sm1_evalName();      iresult = Sm1_evalName();
     if (iresult < 0) {      if (iresult < 0) {
       Sm1_pushError2(SerialCurrent,-1,"evalName");        Sm1_pushError2(SerialCurrent,-1,"evalName");
     }      }
     break;      break;
   case SM_executeStringByLocalParser:    case SM_executeStringByLocalParser:
     if (message) fprintf(stderr," executeStringByLocalParser\n");  
     OxCritical = 0;      OxCritical = 0;
     iresult = Sm1_executeStringByLocalParser();          if (NoExecution) {
             iresult = 0;
           }else{
             iresult = Sm1_executeStringByLocalParser();
           }
     OxCritical = 1; signal(SIGUSR1,controlResetHandler);      OxCritical = 1; signal(SIGUSR1,controlResetHandler);
     if (iresult < 0) {      if (iresult < 0) {
       emsg = Sm1_popErrorMessage("executeString: ");        emsg = Sm1_popErrorMessage("executeString: ");
Line 294  nullserverCommand(ox_stream ostreamIn,ox_stream ostrea
Line 309  nullserverCommand(ox_stream ostreamIn,ox_stream ostrea
     }      }
     break;      break;
   case SM_executeFunction:    case SM_executeFunction:
     if (message) fprintf(stderr," executeFunction\n");  
     OxCritical = 0;      OxCritical = 0;
     iresult = Sm1_executeStringByLocalParser();          if (NoExecution) {
             iresult = 0;
           }else{
             iresult = Sm1_executeStringByLocalParser();
           }
     OxCritical = 1; signal(SIGUSR1,controlResetHandler);      OxCritical = 1; signal(SIGUSR1,controlResetHandler);
     if (iresult < 0) {      if (iresult < 0) {
       emsg = Sm1_popErrorMessage("executeFunction: ");        emsg = Sm1_popErrorMessage("executeFunction: ");
Line 304  nullserverCommand(ox_stream ostreamIn,ox_stream ostrea
Line 322  nullserverCommand(ox_stream ostreamIn,ox_stream ostrea
       return(-1);        return(-1);
     }      }
     break;      break;
     case SM_executeFunctionWithOptionalArgument:
       OxCritical = 0;
           if (NoExecution) {
             iresult = 0;
           }else{
             iresult = Sm1_executeStringByLocalParser();
           }
       OxCritical = 1; signal(SIGUSR1,controlResetHandler);
       if (iresult < 0) {
         emsg = Sm1_popErrorMessage("executeFunctionWithOptionalArgument: ");
         Sm1_pushError2(SerialCurrent,-1,emsg);
         return(-1);
       }
       break;
   case SM_popCMO:    case SM_popCMO:
     if (message) fprintf(stderr,"popCMO.  Start to sending data.\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);  
     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  nullserver_simplest(int fd) {
Line 368  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 353  void controlResetHandler(sig)
Line 383  void controlResetHandler(sig)
   if (OxCritical) {    if (OxCritical) {
     return;      return;
   }else{    }else{
 #if defined(__CYGWIN__)      (void) traceShowStack(); traceClearStack();
     siglongjmp(EnvOfChildServer,2); /* returns 2 for ctrl-C */  #if defined(__CYGWIN__) || defined(__MSYS__)
       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
   }    }
 }  }

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.22

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>