version 1.1, 2008/09/19 13:01:05 |
version 1.2, 2013/10/17 07:49:48 |
|
|
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/ox_maple/main.c,v 1.1 2008/09/19 13:01:05 iwane Exp $ */ |
/* *********************************************************************** |
/* *********************************************************************** |
*********************************************************************** */ |
*********************************************************************** */ |
#define VERSION 0x00000001 |
#define VERSION 0x00000001 |
|
|
static void |
static void |
oxmpl_executeFunction(const char *func, oxstack_node **arg, int argc) |
oxmpl_executeFunction(const char *func, oxstack_node **arg, int argc) |
{ |
{ |
oxstack_node *ans; |
oxstack_node *ans; |
int i; |
int i; |
|
|
enum { |
enum { |
RET_CMO, |
RET_CMO, |
RET_USR, |
RET_USR, |
}; |
}; |
|
|
struct { |
struct { |
const char *name; |
const char *name; |
oxstack_node *(*func)(oxstack_node **, int); |
oxstack_node *(*func)(oxstack_node **, int); |
int return_type; |
int return_type; |
int argmin; |
int argmin; |
int argmax; |
int argmax; |
} funcs[] = { |
} funcs[] = { |
{"add", oxmpl_add, RET_USR, 2, 2}, |
{"add", oxmpl_add, RET_USR, 2, 2}, |
{"sleep", oxmpl_sleep, RET_USR, 1, 1}, |
{"sleep", oxmpl_sleep, RET_USR, 1, 1}, |
{"func", oxmpl_func, RET_USR, 1, INT_MAX}, /* $BG$0U$N4X?t$r<B9T(B */ |
{"func", oxmpl_func, RET_USR, 1, INT_MAX}, /* $BG$0U$N4X?t$r<B9T(B */ |
{"whattype", oxmpl_whattype, RET_USR, 1, 1}, |
{"whattype", oxmpl_whattype, RET_USR, 1, 1}, |
{NULL, NULL, 0} |
{NULL, NULL, 0} |
}; |
}; |
|
|
|
|
for (i = 0; funcs[i].name != NULL; i++) { |
for (i = 0; funcs[i].name != NULL; i++) { |
|
|
if (strcmp(func, funcs[i].name) == 0) { |
if (strcmp(func, funcs[i].name) == 0) { |
if (argc < funcs[i].argmin || argc > funcs[i].argmax) { |
if (argc < funcs[i].argmin || argc > funcs[i].argmax) { |
cmo_error2 *err = new_cmo_error2((cmo *)new_cmo_string("invalid arguments(#)")); |
cmo_error2 *err = new_cmo_error2((cmo *)new_cmo_string("invalid arguments(#)")); |
ans = oxstack_node_init((cmo *)err); |
ans = oxstack_node_init((cmo *)err); |
} else { |
} else { |
ans = funcs[i].func(arg, argc); |
ans = funcs[i].func(arg, argc); |
} |
} |
oxstack_push(ans); |
oxstack_push(ans); |
return ; |
return ; |
} |
} |
} |
} |
|
|
oxstack_push_cmo((cmo *)new_cmo_error2((cmo *)new_cmo_string("Unknown Function"))); |
oxstack_push_cmo((cmo *)new_cmo_error2((cmo *)new_cmo_string("Unknown Function"))); |
|
|
|
|
} |
} |
Line 81 int main( int argc, char *argv[] ) |
|
Line 81 int main( int argc, char *argv[] ) |
|
printf("argv[%2d] = %s\n", ret, argv[ret]); |
printf("argv[%2d] = %s\n", ret, argv[ret]); |
} |
} |
|
|
oxfp = oxf_open(fd); |
oxfp = oxf_open(fd); |
ox_stderr_init(stderr); |
ox_stderr_init(stderr); |
|
|
oxserv_set(OXSERV_SET_EXECUTE_STRING_PARSER, (void *)oxmpl_executeStringParser, NULL); |
oxserv_set(OXSERV_SET_EXECUTE_STRING_PARSER, (void *)oxmpl_executeStringParser, NULL); |
oxserv_set(OXSERV_SET_EXECUTE_FUNCTION, (void *)oxmpl_executeFunction, NULL); |
oxserv_set(OXSERV_SET_EXECUTE_FUNCTION, (void *)oxmpl_executeFunction, NULL); |
|
|
oxserv_set(OXSERV_SET_GET_CMOTAG, (void *)(void (*)())get_cmon_tag, NULL); |
oxserv_set(OXSERV_SET_GET_CMOTAG, (void *)(void (*)())get_cmon_tag, NULL); |
oxserv_set(OXSERV_SET_CONVERT_CMO, (void *)convert_maple2cmo_, NULL); |
oxserv_set(OXSERV_SET_CONVERT_CMO, (void *)convert_maple2cmo_, NULL); |
oxserv_set(OXSERV_SET_CONVERT_STR, (void *)convert_maple2str_, NULL); |
oxserv_set(OXSERV_SET_CONVERT_STR, (void *)convert_maple2str_, NULL); |
oxserv_init(oxfp, VERSION, ID_STRING, "ox_maple", NULL, NULL); |
oxserv_init(oxfp, VERSION, ID_STRING, "ox_maple", NULL, NULL); |
|
|
ret = oxmpl_init(1, argv); |
ret = oxmpl_init(1, argv); |
ret = oxserv_receive(oxfp); |
ret = oxserv_receive(oxfp); |
|
|
oxserv_dest(); |
oxserv_dest(); |
oxf_close(oxfp); |
oxf_close(oxfp); |
|
|
|
|
return( 0 ); |
return( 0 ); |