version 1.3, 2003/11/15 09:06:20 |
version 1.5, 2003/11/27 14:18:43 |
|
|
/* $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.4 2003/11/17 09:55:52 iwane Exp $ */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
Line 50 dprintf(const char *fmt, ...) |
|
Line 50 dprintf(const char *fmt, ...) |
|
do { \ |
do { \ |
if (c != NULL) { \ |
if (c != NULL) { \ |
if (G_DeleteCmo != NULL) \ |
if (G_DeleteCmo != NULL) \ |
G_DeleteCmo(c); \ |
G_DeleteCmo((cmo *)c); \ |
else \ |
else \ |
c = NULL; \ |
c = NULL; \ |
} \ |
} \ |
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 186 oxserv_sm_popString(OXFILE *fd) |
|
Line 188 oxserv_sm_popString(OXFILE *fd) |
|
send_ox_cmo(fd, (cmo *)m_str); |
send_ox_cmo(fd, (cmo *)m_str); |
|
|
oxserv_delete_cmo(m); |
oxserv_delete_cmo(m); |
oxserv_delete_cmo((cmo *)m_str); |
oxserv_delete_cmo(m_str); |
|
|
/* free(str); */ |
/* free(str); */ |
} |
} |
Line 221 oxserv_sm_pops() |
|
Line 223 oxserv_sm_pops() |
|
oxserv_delete_cmo(m); |
oxserv_delete_cmo(m); |
} |
} |
|
|
oxserv_delete_cmo((cmo *)c); |
oxserv_delete_cmo(c); |
|
|
} |
} |
|
|
Line 322 oxserv_mathcap_init(int ver, char *vstr, char *sysname |
|
Line 324 oxserv_mathcap_init(int ver, char *vstr, char *sysname |
|
|
|
mathcap_init(ver, vstr, sysname, cmos, sms); |
mathcap_init(ver, vstr, sysname, cmos, sms); |
|
|
oxserv_delete_cmo((cmo *)G_oxserv_mathcap); |
oxserv_delete_cmo(G_oxserv_mathcap); |
|
|
G_oxserv_mathcap = mathcap_get(new_mathcap()); |
G_oxserv_mathcap = mathcap_get(new_mathcap()); |
} |
} |
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 423 oxserv_sm_executeFunction(void) |
|
Line 431 oxserv_sm_executeFunction(void) |
|
oxserv_delete_cmo(arg[i]); |
oxserv_delete_cmo(arg[i]); |
} |
} |
|
|
oxserv_delete_cmo((cmo *)name); |
oxserv_delete_cmo(name); |
oxserv_delete_cmo((cmo *)cnt); |
oxserv_delete_cmo(cnt); |
|
|
free(arg); |
free(arg); |
} |
} |
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(G_oxserv_mathcap); |
|
|
oxstack_dest(); |
oxstack_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); |
} |
} |