version 1.8, 2000/12/14 03:14:01 |
version 1.10, 2000/12/16 01:52:32 |
|
|
/* -*- mode: C -*- */ |
/* -*- mode: C -*- */ |
/* $OpenXM: OpenXM/src/oxc/oxc.c,v 1.7 2000/12/14 01:35:58 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/oxc/oxc.c,v 1.9 2000/12/15 03:34:43 ohara Exp $ */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
Line 34 int lf_oxc_open_main(char *cmd, short port) |
|
Line 34 int lf_oxc_open_main(char *cmd, short port) |
|
return pid; /* if error, pid == 0 */ |
return pid; /* if error, pid == 0 */ |
} |
} |
|
|
|
#define MAX_RETRY 2000 |
|
|
OXFILE *connection() |
OXFILE *connection() |
{ |
{ |
OXFILE *oxfp = oxf_connect_active(remote_host, port); |
OXFILE *oxfp; |
if (oxfp != NULL) { |
int counter = MAX_RETRY; |
oxf_confirm_server(oxfp, password); |
while((oxfp = oxf_connect_active(remote_host, port)) == NULL) { |
oxf_determine_byteorder_server(oxfp); |
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; |
return oxfp; |
} |
} |
|
|
Line 78 int main(int argc, char *argv[]) |
|
Line 87 int main(int argc, char *argv[]) |
|
char *myname = argv[0]; |
char *myname = argv[0]; |
int oxlog = 0; |
int oxlog = 0; |
int c; |
int c; |
|
int delay = 0; |
|
char *delay_s = "0"; |
|
|
while ((c = getopt(argc, argv, "c:p:h:x")) != -1) { |
while ((c = getopt(argc, argv, "d:c:p:h:x")) != -1) { |
switch(c) { |
switch(c) { |
case 'h': |
case 'h': |
remote_host = optarg; |
remote_host = optarg; |
Line 97 int main(int argc, char *argv[]) |
|
Line 108 int main(int argc, char *argv[]) |
|
oxlog = 1; |
oxlog = 1; |
} |
} |
break; |
break; |
|
case 'd': |
|
delay_s = optarg; |
|
delay = atoi(optarg); |
|
break; |
default: |
default: |
} |
} |
} |
} |
Line 109 int main(int argc, char *argv[]) |
|
Line 124 int main(int argc, char *argv[]) |
|
sprintf(port_s, "%d", port); |
sprintf(port_s, "%d", port); |
} |
} |
if (oxlog) { |
if (oxlog) { |
execlp(xterm, xterm, "-e", myname, |
execlp(xterm, xterm, "-e", myname, "-d", delay_s, |
"-h", remote_host, "-p", port_s, "-c", password, NULL); |
"-h", remote_host, "-p", port_s, "-c", password, NULL); |
fprintf(stderr, "oxc:: cannot exec \"%s oxc ...\"\n", xterm); |
|
} |
} |
|
|
fprintf(stderr, "start connection!\n"); |
fprintf(stderr, "start connection!\n"); |
if ((oxfp = connection()) == NULL) { |
usleep(delay); |
fprintf(stderr, "oxc: cannot connect.\n"); |
if ((oxfp = connection()) != NULL) { |
}else { |
|
fprintf(stderr, "oxc: oxfp = %p, fd = %d\n", oxfp, oxfp->fd); |
fprintf(stderr, "oxc: oxfp = %p, fd = %d\n", oxfp, oxfp->fd); |
mathcap_init(20001006, "v2000.10.06", "oxc", basic0, NULL); |
mathcap_init(20001006, "v2000.10.06", "oxc", basic0, NULL); |
sm(oxfp); |
sm(oxfp); |