=================================================================== RCS file: /home/cvs/OpenXM/src/oxc/sm.c,v retrieving revision 1.4 retrieving revision 1.7 diff -u -p -r1.4 -r1.7 --- OpenXM/src/oxc/sm.c 2000/11/30 10:27:02 1.4 +++ OpenXM/src/oxc/sm.c 2016/04/01 18:12:39 1.7 @@ -1,8 +1,9 @@ /* -*- mode: C -*- */ -/* $OpenXM: OpenXM/src/oxc/sm.c,v 1.3 2000/11/28 18:11:42 ohara Exp $ */ +/* $OpenXM: OpenXM/src/oxc/sm.c,v 1.6 2003/05/07 04:00:30 ohara Exp $ */ #include #include +#include #include #include #include @@ -17,6 +18,7 @@ static cmo **stack = NULL; static int stack_ptr = 0; static int stack_size = 0; OXFILE *stack_oxfp = NULL; +int oxf_error(OXFILE *oxfp); #define DIFFERENCE_OF_STACK 1024 @@ -59,27 +61,29 @@ void pops(int n) void push_error(int errcode, cmo* pushback) { - return push((cmo *)make_error_object(errcode, pushback)); + return push((cmo *)make_error_object(errcode, pushback)); } /* If error occurs, then an sm_* function, called by sm_run, pushes an error obect. */ -void sm_popCMO() +int sm_popCMO() { cmo* m = pop(); send_ox_cmo(stack_oxfp, m); + return 0; } -void sm_pops() +int sm_pops() { cmo* m = pop(); if (m->tag == CMO_INT32) { pops(((cmo_int32 *)m)->i); }else { - push_error(-1, m); /* m is invalid. */ - } + push_error(-1, m); /* m is invalid. */ + } + return 0; } void sm_run(int code) @@ -88,7 +92,7 @@ void sm_run(int code) if (func != NULL) { func(stack_oxfp); }else { - fprintf(stderr, "oxc: unknown SM code(%d).\n", code); + ox_printf("oxc: unknown SM code(%d).\n", code); } } @@ -107,11 +111,11 @@ int sm_receive_ox() break; case OX_COMMAND: code = receive_sm_command(stack_oxfp); - fprintf(stderr, "oxc: code = %d.\n", code); + ox_printf("oxc: code = %d.\n", code); sm_run(code); break; default: - fprintf(stderr, "illeagal message? ox_tag = (%d)\n", tag); + ox_printf("illeagal message? ox_tag = (%d)\n", tag); return 0; break; } @@ -129,9 +133,10 @@ int oxf_error(OXFILE *oxfp) int sm(OXFILE *oxfp) { - stack_oxfp = oxfp; + stack_oxfp = oxfp; stack_extend(); while (sm_receive_ox()) { } - fprintf(stderr, "oxc: socket(%d) is closed.\n", stack_oxfp->fd); + ox_printf("oxc: socket(%d) is closed.\n", stack_oxfp->fd); + return 0; }