=================================================================== RCS file: /home/cvs/OpenXM/src/kxx/oxmain.c,v retrieving revision 1.4 retrieving revision 1.10 diff -u -p -r1.4 -r1.10 --- OpenXM/src/kxx/oxmain.c 2000/01/31 01:34:23 1.4 +++ OpenXM/src/kxx/oxmain.c 2002/05/02 03:08:28 1.10 @@ -1,7 +1,8 @@ -/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.3 1999/11/04 02:12:31 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.9 2001/12/28 01:20:27 takayama Exp $ */ /* nullserver01 */ #include #include +#include #include #include #include @@ -32,8 +33,11 @@ int Do_not_use_control_stream_to_tell_no_server = 1; static void errorToStartEngine(void); static int findOxServer(char *server); static void couldNotFind(char *s); +#if defined(__CYGWIN__) +int errno; +#endif +/* gcc -v -c hoge.c */ - main(int argc, char *argv[]) { int fd; int size; @@ -48,6 +52,7 @@ main(int argc, char *argv[]) { char portfile[1024]; char *pass; int result; + int sleepingTime = 0; strcpy(sname,"localhost"); strcpy(ServerName,SERVERNAME); @@ -78,16 +83,21 @@ main(int argc, char *argv[]) { }else if (strcmp(argv[i],"-portfile") == 0) { i++; if (i 0 ) parentServerMain(fdControl,fdStream); @@ -118,9 +136,9 @@ main(int argc, char *argv[]) { result=childServerMain(fdControl,fdStream); } /* This line will be never executed in case of success */ - if (result < 0 ) { - errorToStartEngine(); - } + if (result < 0 ) { + errorToStartEngine(); + } } /* non-reverse case. */ @@ -135,7 +153,7 @@ main(int argc, char *argv[]) { fdControl = socketOpen(sname,portControl); portControl = OpenedSocket; if (NotifyPortnumber) { - oxWritePortFile(0,portControl,portfile); + oxWritePortFile(0,portControl,portfile); } fdControl = socketAcceptLocal(fdControl); fprintf(stderr,"\n control port %d : Connected.\n",portControl); @@ -144,7 +162,7 @@ main(int argc, char *argv[]) { fdStream = socketOpen(sname,portStream); portStream = OpenedSocket; if (NotifyPortnumber) { - oxWritePortFile(1,portStream,portfile); + oxWritePortFile(1,portStream,portfile); } fdStream = socketAcceptLocal(fdStream); fprintf(stderr,"\n stream port %d : Connected.\n",portStream); @@ -154,7 +172,7 @@ main(int argc, char *argv[]) { fdControl = socketOpen(sname,portControl); portControl = OpenedSocket; if (NotifyPortnumber) { - oxWritePortFile(0,portControl,portfile); + oxWritePortFile(0,portControl,portfile); } fdControl = socketAccept(fdControl); fprintf(stderr,"\n control port %d : Connected.\n",portControl); @@ -163,7 +181,7 @@ main(int argc, char *argv[]) { fdStream = socketOpen(sname,portStream); portStream = OpenedSocket; if (NotifyPortnumber) { - oxWritePortFile(1,portStream,portfile); + oxWritePortFile(1,portStream,portfile); } fdStream = socketAccept(fdStream); fprintf(stderr,"\n stream port %d : Connected.\n",portStream); @@ -185,12 +203,12 @@ main(int argc, char *argv[]) { static void errorToStartEngine(void) { fprintf(stderr,"Failed to start the engine. Childing process is terminating.\n"); /* You have to tell to the control server that there is no engine. - And, the control server must tell the client that there is no - engine. - This part has not yet been implemented. - If you implement this, set Do_not_use_control_stream_to_tell_no_server to - zero. - */ + And, the control server must tell the client that there is no + engine. + This part has not yet been implemented. + If you implement this, set Do_not_use_control_stream_to_tell_no_server to + zero. + */ sleep(2); exit(-1); } @@ -260,7 +278,7 @@ parentServerMain(int fdControl, int fdStream) { r=kill(MyServerPid,SIGUSR1); if (message) printf("Result = %d\n",r); fflush(NULL); - oxSendResultOfControlInt32(fdControl,0); + /* oxSendResultOfControlInt32(fdControl,0); */ break; default: fprintf(stderr,"[control] Unknown control message.\n"); @@ -283,23 +301,26 @@ childServerMain(int fdControl, int fdStream) { dup2(fdStream,3); dup2(fdStream,4); /*close(0); - #include - for (i=5; i + for (i=5; i= 0) { - fprintf(stderr,"Starting OX server : %s\n",server); - close(fd); - return(0); + fprintf(stderr,"Starting OX server : %s\n",server); + close(fd); + return(0); } if (server[0] == '/') { - couldNotFind(server); - return(-1); + couldNotFind(server); + return(-1); } fprintf(stderr,"The server %s was not found. Trying to find it under OpenXM/bin\n",server); p = getenv("OpenXM_HOME"); @@ -334,16 +356,17 @@ static int findOxServer(char *server) { p2 = (char *) malloc(sizeof(char)*(strlen(p)+strlen("/bin/")+3+strlen(server))); if (p2 == NULL) { fprintf(stderr,"No more memory.\n"); exit(10); } strcpy(p2,p); strcat(p2,"/bin/"); strcat(p2,server); - fd = open(p2,O_RDONLY); + /* fd = open(p2,O_RDONLY); */ + fd = access(p2,X_OK&R_OK); if (fd >= 0) { - fprintf(stderr,"Starting OX server : %s\n",p2); - if (strlen(p2) < SERVERNAME_SIZE) strcpy(server,p2); - else { - couldNotFind("Too long ox server name."); - return(-1); - } - close(fd); - return(0); + fprintf(stderr,"Starting OX server : %s\n",p2); + if (strlen(p2) < SERVERNAME_SIZE) strcpy(server,p2); + else { + couldNotFind("Too long ox server name."); + return(-1); + } + close(fd); + return(0); } couldNotFind(p2); return(-1);