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

Diff for /OpenXM/src/oxc/sm_ext.c between version 1.10 and 1.11

version 1.10, 2003/05/07 04:00:30 version 1.11, 2016/04/01 18:12:39
Line 1 
Line 1 
 /* -*- mode: C; coding: euc-japan -*- */  /* -*- mode: C; coding: euc-japan -*- */
 /* $OpenXM: OpenXM/src/oxc/sm_ext.c,v 1.9 2000/12/14 01:35:58 ohara Exp $ */  /* $OpenXM: OpenXM/src/oxc/sm_ext.c,v 1.10 2003/05/07 04:00:30 ohara Exp $ */
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 11 
Line 11 
 #include "sm.h"  #include "sm.h"
   
 static int  sm_control_spawn();  static int  sm_control_spawn();
 static void sm_control_terminate();  static int  sm_control_terminate();
 static void sm_control_kill();  static int  sm_control_kill();
 static void sm_control_reset_pid();  static int  sm_control_reset_pid();
   
 static void pid_extend();  static void pid_extend();
 static int  pid_lookup(pid_t pid);  static int  pid_lookup(pid_t pid);
Line 41  static struct { int (*func_ptr)(); int key; } tbl_smcm
Line 41  static struct { int (*func_ptr)(); int key; } tbl_smcm
     {sm_pops,            SM_pops},      {sm_pops,            SM_pops},
     {sm_control_reset_pid, SM_control_reset_connection_server},      {sm_control_reset_pid, SM_control_reset_connection_server},
     {sm_control_kill, SM_control_kill},      {sm_control_kill, SM_control_kill},
     {NULL, NULL}      {NULL, 0}
 };  };
   
 extern OXFILE *stack_oxfp;  extern OXFILE *stack_oxfp;
Line 49  extern OXFILE *stack_oxfp;
Line 49  extern OXFILE *stack_oxfp;
 int (*sm_search_f(int code))()  int (*sm_search_f(int code))()
 {  {
     int i;      int i;
     for (i=0; tbl_smcmd[i].key != NULL; i++) {      for (i=0; tbl_smcmd[i].key != 0; i++) {
         if (code == tbl_smcmd[i].key) {          if (code == tbl_smcmd[i].key) {
             return tbl_smcmd[i].func_ptr;              return tbl_smcmd[i].func_ptr;
         }          }
Line 73  Normally local functions push a return value to the st
Line 73  Normally local functions push a return value to the st
 but, if error occurs, then these return non-positive numbers and  but, if error occurs, then these return non-positive numbers and
 the sm_executeFunction push an error object.  the sm_executeFunction push an error object.
 */  */
 void sm_executeFunction()  int sm_executeFunction()
 {  {
     int (*func)();      int (*func)();
     int retcode = 0;      int retcode = 0;
Line 82  void sm_executeFunction()
Line 82  void sm_executeFunction()
         func = lookup_localfunction(((cmo_string *)ob)->s);          func = lookup_localfunction(((cmo_string *)ob)->s);
         if (func != NULL) {          if (func != NULL) {
             if ((retcode = func()) > 0) {              if ((retcode = func()) > 0) {
                 return;                  return 0;
             }              }
         }          }
     }      }
     push_error(retcode, ob);      push_error(retcode, ob);
       return 0;
 }  }
   
 /* getargs() set number of popped objects to argc. */  /* getargs() set number of popped objects to argc. */
Line 198  cmo_error2 *type_checker(cmo *ob, int type)
Line 199  cmo_error2 *type_checker(cmo *ob, int type)
   
 int lf_oxc_open()  int lf_oxc_open()
 {  {
     cmo_int32 *argc = pop();      cmo_int32 *argc = (cmo_int32 *)pop();
         if (argc->tag == CMO_INT32 && argc->i == 1) {          if (argc->tag == CMO_INT32 && argc->i == 1) {
                 return sm_control_spawn();                  return sm_control_spawn();
         }          }
         push_error(-1, argc);          push_error(-1, (cmo *)argc);
         return -1;          return -1;
 }  }
   
Line 222  int sm_control_spawn_typecheck(cmo_list *args, cmo_lis
Line 223  int sm_control_spawn_typecheck(cmo_list *args, cmo_lis
   
 static int sm_control_spawn()  static int sm_control_spawn()
 {  {
         cmo_list *args    = pop();          cmo_list *args    = (cmo_list *)pop();
         cmo_list *ports   = list_first_cmo(args);          cmo_list *ports   = (cmo_list *)list_first_cmo(args);
         cmo_int32 *port   = list_first_cmo(ports);          cmo_int32 *port   = (cmo_int32 *)list_first_cmo(ports);
         cmo_string *sname = list_nth(args, 1);          cmo_string *sname = (cmo_string *)list_nth(args, 1);
         pid_t pid;          pid_t pid;
   
         if (sm_control_spawn_typecheck(args, ports, port, sname)) {          if (sm_control_spawn_typecheck(args, ports, port, sname)) {
                 pid = lf_oxc_open_main(sname->s, port->i);                  pid = lf_oxc_open_main(sname->s, (short)port->i);
                 if (pid > 0) {                  if (pid > 0) {
                         push(new_cmo_int32(pid));                          push((cmo *)new_cmo_int32(pid));
                         pid_regist(pid);                          pid_regist(pid);
                         ox_printf("oxc: spawns %s\n", sname->s);                          ox_printf("oxc: spawns %s\n", sname->s);
                         return pid;                          return pid;
                 }                  }
         }          }
         push_error(-1, args);          push_error(-1, (cmo *)args);
         return 0;          return 0;
   
 }  }
   
 void sm_mathcap()  int sm_mathcap()
 {  {
     push((cmo *)oxf_cmo_mathcap(stack_oxfp));      push((cmo *)oxf_cmo_mathcap(stack_oxfp));
       return 0;
 }  }
   
 void sm_set_mathcap()  int sm_set_mathcap()
 {  {
     cmo_mathcap *m = (cmo_mathcap *)pop();      cmo_mathcap *m = (cmo_mathcap *)pop();
     if (m->tag == CMO_MATHCAP) {      if (m->tag == CMO_MATHCAP) {
         oxf_mathcap_update(stack_oxfp, m);          oxf_mathcap_update(stack_oxfp, m);
     }else {      }else {
         push_error(-1, m);          push_error(-1, (cmo *)m);
         /* an error object must be pushed */          /* an error object must be pushed */
     }      }
       return 0;
 }  }
   
 static void sm_control_kill()  static int sm_control_kill()
 {  {
     pid_kill_all();      pid_kill_all();
       return 0;
 }  }
   
 static void sm_control_terminate()  static int sm_control_terminate()
 {  {
     cmo_int32 *m = (cmo_int32 *)pop();      cmo_int32 *m = (cmo_int32 *)pop();
     pid_t pid = m->i;      pid_t pid = m->i;
     if (m->tag != CMO_INT32 || !pid_kill(pid)) {      if (m->tag != CMO_INT32 || !pid_kill(pid)) {
         push_error(-1, m);          push_error(-1, (cmo *)m);
     }      }
       return 0;
 }  }
   
 static void sm_control_reset_pid()  static int sm_control_reset_pid()
 {  {
     cmo_int32 *m = (cmo_int32 *)pop();      cmo_int32 *m = (cmo_int32 *)pop();
     pid_t pid = m->i;      pid_t pid = m->i;
     if (m->tag != CMO_INT32 || !pid_reset(pid)) {      if (m->tag != CMO_INT32 || !pid_reset(pid)) {
         push_error(-1, m);          push_error(-1, (cmo *)m);
         return;          return 0;
     }      }
     /* ... */      /* ... */
       return 0;
 }  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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