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

Diff for /OpenXM/src/ox_ntl/oxserv.c between version 1.3 and 1.4

version 1.3, 2003/11/15 09:06:20 version 1.4, 2003/11/17 09:55:52
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/ox_ntl/oxserv.c,v 1.2 2003/11/08 12:34:00 iwane Exp $ */  /* $OpenXM: OpenXM/src/ox_ntl/oxserv.c,v 1.3 2003/11/15 09:06:20 iwane Exp $ */
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 65  static OXFILE *G_oxfilep = NULL;
Line 65  static OXFILE *G_oxfilep = NULL;
 static cmo_mathcap *G_oxserv_mathcap = NULL;  static cmo_mathcap *G_oxserv_mathcap = NULL;
   
 /* signal */  /* signal */
 sigset_t        G_oxserv_sigusr1;  int             G_oxserv_sigusr1flag = 0;
   int             G_oxserv_sigusr1cnt = 0;
 static jmp_buf  G_jmpbuf;  static jmp_buf  G_jmpbuf;
   
 /* User Function */  /* User Function */
Line 149  oxserv_sm_popCMO(OXFILE *fd)
Line 150  oxserv_sm_popCMO(OXFILE *fd)
                 m = new_cmo_null();                  m = new_cmo_null();
         } else if (G_convertCmo) {          } else if (G_convertCmo) {
                 n = G_convertCmo(m);                  n = G_convertCmo(m);
                 if (m != n)                  if (m != n) {
                         oxserv_delete_cmo(m);                          oxserv_delete_cmo(m);
                 m = n;                          m = n;
                   }
         }          }
   
         send_ox_cmo(fd, m);          send_ox_cmo(fd, m);
Line 389  oxserv_sm_executeStringByLocalParser(void)
Line 391  oxserv_sm_executeStringByLocalParser(void)
  * pop s as a function name, pop n as the number of arguments and to execute a   * pop s as a function name, pop n as the number of arguments and to execute a
  * local function s with n arguments poped from the stack.   * local function s with n arguments poped from the stack.
  *   *
    * suppose G_userExecuteFunction not equal NULL
    *
  * PARAM : NONE   * PARAM : NONE
  * RETURN: NONE   * RETURN: NONE
  *****************************************************************************/   *****************************************************************************/
Line 400  oxserv_sm_executeFunction(void)
Line 404  oxserv_sm_executeFunction(void)
         cmo_int32 *cnt = (cmo_int32 *)oxstack_pop();          cmo_int32 *cnt = (cmo_int32 *)oxstack_pop();
         cmo **arg;          cmo **arg;
   
         arg = (cmo **)malloc(cnt->i * sizeof(cmo *));  
   
         if (name == NULL || cnt == NULL) {          if (name == NULL || cnt == NULL) {
                 oxserv_push_errormes("stack underflow in executeFunction");                  oxserv_push_errormes("stack underflow in executeFunction");
                 return ;                  return ;
         }          }
   
           arg = (cmo **)malloc(cnt->i * sizeof(cmo *));
         for (i = 0; i < cnt->i; i++) {          for (i = 0; i < cnt->i; i++) {
                 arg[i] = oxstack_pop();                  arg[i] = oxstack_pop();
                 if (arg[i] == NULL) {                  if (arg[i] == NULL) {
                         oxserv_push_errormes("stack underflow in executeFunction");                          oxserv_push_errormes("stack underflow in executeFunction");
   
                           for (i--; i >= 0; i--)
                                   oxserv_delete_cmo(arg[i]);
                           free(arg);
                         return ;                          return ;
                 }                  }
         }          }
Line 477  oxserv_sm_dupErrors()
Line 485  oxserv_sm_dupErrors()
  * -- SM_control_reset_connection -- signal handler for SIGUSR1 --   * -- SM_control_reset_connection -- signal handler for SIGUSR1 --
  *   *
  * PARAM : NONE   * PARAM : NONE
    *
    *       : if (sig == 0) called UNBLOCK_INPUT()
  * RETURN: NONE   * RETURN: NONE
  *****************************************************************************/   *****************************************************************************/
 static void  void
 oxserv_sm_control_reset_connection(int sig)  oxserv_sm_control_reset_connection(int sig)
 {  {
         int tag;          int tag;
         OXFILE *fd = G_oxfilep;          OXFILE *fd = G_oxfilep;
   
           if (G_oxserv_sigusr1cnt > 0) {
                   G_oxserv_sigusr1flag = 1;
                   return ;
           }
   
   
         DPRINTF(("reset -- start ==> "));          DPRINTF(("reset -- start ==> "));
           G_oxserv_sigusr1flag = 0;
   
         send_ox_tag(fd, OX_SYNC_BALL);          send_ox_tag(fd, OX_SYNC_BALL);
   
         oxstack_init_stack();          oxstack_init_stack();
Line 502  oxserv_sm_control_reset_connection(int sig)
Line 520  oxserv_sm_control_reset_connection(int sig)
         }          }
         DPRINTF((" <== end.\n"));          DPRINTF((" <== end.\n"));
   
   
         longjmp(G_jmpbuf, sig);          longjmp(G_jmpbuf, sig);
 }  }
   
Line 591  oxserv_ox_receive(OXFILE *fd)
Line 610  oxserv_ox_receive(OXFILE *fd)
   
         switch (tag) {          switch (tag) {
         case OX_DATA:          case OX_DATA:
                   BLOCK_INPUT();
                 c = receive_cmo(fd);                  c = receive_cmo(fd);
                   UNBLOCK_INPUT();
                 DPRINTF(("[CMO:%d=0x%x]", c->tag, c->tag));                  DPRINTF(("[CMO:%d=0x%x]", c->tag, c->tag));
                 oxstack_push(c);                  oxstack_push(c);
                 break;                  break;
Line 655  oxserv_init(OXFILE *oxfp, int ver, char *vstr, char *s
Line 676  oxserv_init(OXFILE *oxfp, int ver, char *vstr, char *s
   
         oxserv_mathcap_init(ver, vstr, sysname, cmos, sms);          oxserv_mathcap_init(ver, vstr, sysname, cmos, sms);
   
         /* signal */  
         sigemptyset(&G_oxserv_sigusr1);  
         sigaddset(&G_oxserv_sigusr1, SIGUSR1);  
         signal(SIGUSR1, oxserv_sm_control_reset_connection);          signal(SIGUSR1, oxserv_sm_control_reset_connection);
   
         /* initialize GMP memory functions. */          /* initialize GMP memory functions. */
Line 718  oxserv_set(int mode, void *ptr, void *rsv)
Line 736  oxserv_set(int mode, void *ptr, void *rsv)
 void  void
 oxserv_dest()  oxserv_dest()
 {  {
           oxserv_delete_cmo((cmo *)G_oxserv_mathcap);
   
         oxstack_dest();          oxstack_dest();
 }  }
   
Line 728  oxserv_dest()
Line 748  oxserv_dest()
  *===========================================================================*/   *===========================================================================*/
   
   
 cmo *  void
 oxserv_executeFunction(const char *func, cmo **arg, int argc)  oxserv_executeFunction(const char *func, cmo **arg, int argc)
 {  {
         int i;          int i;
Line 739  oxserv_executeFunction(const char *func, cmo **arg, in
Line 759  oxserv_executeFunction(const char *func, cmo **arg, in
                 printf("\t%2d: %s\n", i, new_string_set_cmo(arg[i]));                  printf("\t%2d: %s\n", i, new_string_set_cmo(arg[i]));
         }          }
   
         return ((cmo *)new_cmo_int32(0));          return ;
 }  }
   
 /*****************************************************************************  /*****************************************************************************
Line 759  main(int argc, char *argv[])
Line 779  main(int argc, char *argv[])
   
         ox_stderr_init(stderr);          ox_stderr_init(stderr);
   
           oxserv_set(OXSERV_SET_EXECUTE_FUNCTION, oxserv_executeFunction, NULL);
   
         oxserv_init(oxfp, 0, "$Date$", "oxserv", NULL, NULL);          oxserv_init(oxfp, 0, "$Date$", "oxserv", NULL, NULL);
   
         DPRINTF(("main - start\n"));          ret = oxserv_receive(oxfp);
         for (i = 0;; i++) {  
                 DPRINTF(("@"));  
                 ret = oxserv_receive(oxfp);  
                 if (ret != OXSERV_SUCCESS)  
                         break;  
         }  
   
           oxserv_dest();
         oxf_close(oxfp);          oxf_close(oxfp);
         oxserv_delete_cmo((cmo *)G_oxserv_mathcap);  
   
         return (0);          return (0);
 }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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