=================================================================== RCS file: /home/cvs/OpenXM/src/oxc/oxc.c,v retrieving revision 1.7 retrieving revision 1.11 diff -u -p -r1.7 -r1.11 --- OpenXM/src/oxc/oxc.c 2000/12/14 01:35:58 1.7 +++ OpenXM/src/oxc/oxc.c 2001/01/10 06:54:36 1.11 @@ -1,9 +1,10 @@ /* -*- mode: C -*- */ -/* $OpenXM: OpenXM/src/oxc/oxc.c,v 1.6 2000/12/03 14:32:40 ohara Exp $ */ +/* $OpenXM: OpenXM/src/oxc/oxc.c,v 1.10 2000/12/16 01:52:32 ohara Exp $ */ #include #include #include +#include #include #include "mysocket.h" #include "ox_toolkit.h" @@ -34,21 +35,96 @@ int lf_oxc_open_main(char *cmd, short port) return pid; /* if error, pid == 0 */ } +#define MAX_RETRY 2000 + OXFILE *connection() { - OXFILE *oxfp = oxf_connect_active(remote_host, port); - if (oxfp != NULL) { - oxf_confirm_server(oxfp, password); - oxf_determine_byteorder_server(oxfp); + OXFILE *oxfp; + int counter = MAX_RETRY; + while((oxfp = oxf_connect_active(remote_host, port)) == NULL) { + if (--counter > 0) { + usleep(100); /* spends 100 micro seconds */ + }else { + fprintf(stderr, "oxc: cannot connect.\n"); + return NULL; + } } + oxf_confirm_server(oxfp, password); + oxf_determine_byteorder_server(oxfp); return oxfp; } +__inline__ +static char *sskip(char *s) +{ + while (isspace(*s)) { + s++; + } + return s; +} + +__inline__ +static char *wskip(char *s) +{ + while (!isspace(*s) && *s != '\0') { + s++; + } + return s; +} + +static int wc(char *s) +{ + int n = 0; + s = sskip(s); + while(*s != '\0') { + s = wskip(s); + s = sskip(s); + n++; + } + return n; +} + +static void word(char *str, int argc, char *argv[]) +{ + int i; + char *s = strcpy(malloc(strlen(str)+1), str); + for(i=0; ifd); mathcap_init(20001006, "v2000.10.06", "oxc", basic0, NULL); sm(oxfp);