=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/plugin/mytcpio.c,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -p -r1.1.1.1 -r1.3 --- OpenXM/src/kan96xx/plugin/mytcpio.c 1999/10/08 02:12:05 1.1.1.1 +++ OpenXM/src/kan96xx/plugin/mytcpio.c 2000/03/20 01:53:47 1.3 @@ -1,3 +1,4 @@ +/* $OpenXM: OpenXM/src/kan96xx/plugin/mytcpio.c,v 1.2 1999/10/30 02:22:16 takayama Exp $ */ #include #include #include @@ -22,7 +23,8 @@ static void errorMsg1s(char *s) { fprintf(stderr,"%s\n",s); } -FILE *TcpioError = stdout; +#define SET_TCPIOERROR { if (TcpioError == NULL) TcpioError = stdout; } +FILE *TcpioError = NULL; int OpenedSocket = 0; extern int Quiet; @@ -34,7 +36,7 @@ socketOpen(char *serverName,int portNumber) { extern int errno; int tt; - + SET_TCPIOERROR; fprintf(TcpioError,"Hello from open. serverName is %s and portnumber is %d\n", serverName,portNumber); if ((myhost = gethostbyname(serverName)) == NULL) { @@ -80,6 +82,7 @@ socketOpen(char *serverName,int portNumber) { socketAccept(int snum) { int s, news; + SET_TCPIOERROR; s = snum; fprintf(TcpioError,"Trying to accept... "); fflush(TcpioError); if ((news = accept(s,NULL,NULL)) < 0) { @@ -99,7 +102,8 @@ socketAcceptLocal(int snum) { struct sockaddr peer; int len; int i; - + + SET_TCPIOERROR; s = snum; fprintf(TcpioError,"Trying to accept from localhost... "); fflush(TcpioError); len = sizeof(struct sockaddr); @@ -138,6 +142,7 @@ int oxSocketSelect0(int fd,int t) { struct timeval timeout; int debug = 0; extern int errno; + SET_TCPIOERROR; FD_ZERO(&readfds); FD_SET(fd,&readfds); timeout.tv_sec = 0; @@ -170,6 +175,7 @@ oxSocketMultiSelect(int sid[],int size,int t,int resul int isdata = 0; extern errno; + SET_TCPIOERROR; FD_ZERO(&readfds); timeout.tv_sec = 0; timeout.tv_usec = (long)t; @@ -219,6 +225,7 @@ socketConnect(char *serverName,int portNumber) { int socketid; int on; + SET_TCPIOERROR; if ((servhost = gethostbyname(serverName)) == NULL) { errorMsg1s("bad server name.\n"); return(-1); @@ -249,10 +256,11 @@ socketConnectWithPass(char *servername,int port,char * { int fd; int m; + SET_TCPIOERROR; fd = socketConnect(servername,port); if (fd >= 0) { - m = write(fd,pass,strlen(pass)); - if (m != strlen(pass)) { + m = write(fd,pass,strlen(pass)+1); + if (m != strlen(pass)+1) { fprintf(TcpioError,"Fail to send password to fd=%d.\n",fd); return(-1); }