=================================================================== RCS file: /home/cvs/OpenXM/src/ox_toolkit/testclient.c,v retrieving revision 1.6 retrieving revision 1.15 diff -u -p -r1.6 -r1.15 --- OpenXM/src/ox_toolkit/testclient.c 2000/11/21 07:59:08 1.6 +++ OpenXM/src/ox_toolkit/testclient.c 2005/07/26 12:52:05 1.15 @@ -1,5 +1,5 @@ /* -*- mode: C -*- */ -/* $OpenXM: OpenXM/src/ox_toolkit/testclient.c,v 1.5 2000/10/10 05:23:21 ohara Exp $ */ +/* $OpenXM: OpenXM/src/ox_toolkit/testclient.c,v 1.14 2005/07/20 17:48:03 ohara Exp $ */ /* A sample implementation of an OpenXM client with OpenXM C library */ @@ -21,14 +21,14 @@ int dumpx(OXFILE *oxfp, int n) int i; int len = oxf_read(buff, 1, n, oxfp); - fprintf(stderr, "I have read %d byte from socket(%d).\n", len, oxfp->fd); + ox_printf("I have read %d byte from socket(%d).\n", len, oxfp->fd); for(i = 0; i < len; i++) { - fprintf(stderr, "%02x ", buff[i]); + ox_printf("%02x ", buff[i]); if (i%20 == 19) { - fprintf(stderr, "\n"); + ox_printf("\n"); } } - fprintf(stderr, "\n"); + ox_printf("\n"); return len; } @@ -37,31 +37,25 @@ int dumpx(OXFILE *oxfp, int n) static int size = SIZE_CMDLINE; static char cmdline[SIZE_CMDLINE]; -static int prompt() +static void prompt() { fprintf(stdout, "> "); fgets(cmdline, size, stdin); - init_parser(cmdline); } #define VERSION 0x11121500 #define ID_STRING "v0.11121500" -int test_0() +void test_0() { cmo* c = NULL; -#ifdef DEBUG - fprintf(stderr, "testclient:: calling ox_mathcap().\n"); - c = ox_mathcap(sv); - fprintf(stderr, "testclient:: cmo received.(%p)\n", c); -#else + ox_printf("testclient:: calling ox_mathcap().\n"); c = (cmo *)ox_mathcap(sv); -#endif + ox_printf("testclient:: cmo received.(%p)\n", c); print_cmo(c); - fflush(stderr); - mathcap_init(VERSION, ID_STRING, "testclient", NULL, NULL); - send_ox_cmo(sv, mathcap_get()); + mathcap_init(ID_STRING, "testclient"); + send_ox_cmo(sv, (cmo *)oxf_cmo_mathcap(sv)); ox_reset(sv); send_ox_cmo(sv, (cmo *)new_cmo_string("N[ArcTan[1]]")); @@ -69,24 +63,24 @@ int test_0() send_ox_command(sv, SM_popCMO); receive_ox_tag(sv); c = receive_cmo(sv); - fprintf(stderr, "testclient:: cmo received.\n"); + ox_printf("testclient:: cmo received.\n"); print_cmo(c); } -int test_1() +void test_1() { cmo *c, *m; - mathcap_init(1000, "test!", "testclient", NULL, NULL); - m = mathcap_get(); - fprintf(stderr, "testclient:: test cmo_mathcap.\n"); + mathcap_init("test!", "testclient"); + m = (cmo *)oxf_cmo_mathcap(sv); + ox_printf("testclient:: test cmo_mathcap.\n"); send_ox_cmo(sv, m); send_ox_command(sv, SM_popCMO); receive_ox_tag(sv); c = receive_cmo(sv); - fprintf(stderr, "testclient:: cmo received.(%p)\n", c); + ox_printf("testclient:: cmo received.(%p)\n", c); print_cmo(c); - fputc('\n', stderr); + ox_printf("\n"); } /* Example: @@ -102,15 +96,15 @@ int main(int argc, char* argv[]) int code; char *server = "ox_sm1"; - setbuf(stderr, NULL); + ox_stderr_init(stderr); if (argc>1) { server = argv[1]; } - fprintf(stderr, "testclient:: I use %s as an OX server.\n", server); + ox_printf("testclient:: I use %s as an OX server.\n", server); /* sv = ox_start("localhost", "ox", server); */ if (sv == NULL) { - fprintf(stderr, "testclient:: I cannot connect to servers.\n"); + ox_printf("testclient:: I cannot connect to servers.\n"); exit(1); } @@ -118,9 +112,7 @@ int main(int argc, char* argv[]) test_1(); } - setflag_parse(PFLAG_ADDREV); - - while(prompt(), (m = parse()) != NULL) { + while(prompt(), (m = ox_parse_lisp(cmdline)) != NULL) { send_ox(sv, m); if (m->tag == OX_COMMAND) { code = ((ox_command *)m)->command; @@ -129,16 +121,16 @@ int main(int argc, char* argv[]) }else if (code == SM_popCMO || code == SM_popString) { receive_ox_tag(sv); c = receive_cmo(sv); - fprintf(stderr, "testclient:: cmo received.\n"); + ox_printf("testclient:: cmo received.\n"); print_cmo(c); } } } ox_reset(sv); - fprintf(stderr, "The testclient resets.\n"); + ox_printf("The testclient resets.\n"); ox_close(sv); - fprintf(stderr, "The testclient halts.\n"); + ox_printf("The testclient halts.\n"); return 0; }