=================================================================== RCS file: /home/cvs/OpenXM/src/kxx/oxd.c,v retrieving revision 1.1 retrieving revision 1.6 diff -u -p -r1.1 -r1.6 --- OpenXM/src/kxx/oxd.c 2002/10/20 13:13:35 1.1 +++ OpenXM/src/kxx/oxd.c 2002/10/28 08:57:28 1.6 @@ -1,5 +1,5 @@ /* - $OpenXM$ + $OpenXM: OpenXM/src/kxx/oxd.c,v 1.5 2002/10/28 00:38:32 takayama Exp $ */ #include @@ -17,9 +17,13 @@ #include "ox_kan.h" #include "serversm.h" +/* #define DEBUG */ + char *getTag(char *s); char *getKeyValue(char *s,char *key); char *getBody(char *s); +char *getOpenXMpath(void); +void *xtagMalloc(int n); int MyServerPid; #define SERVERNAME_SIZE 4096 @@ -32,6 +36,7 @@ static void couldNotFind(char *s); #if defined(__CYGWIN__) int errno; #endif +#define NOBODY 65534 main(int argc, char *argv[]) { char sname[1024]; @@ -39,23 +44,18 @@ main(int argc, char *argv[]) { int fdControl = -1; int portControl = 8089; extern int OpenedSocket; extern int Serial; - int sleepingTime = 0; int result; int fd; + int uid; strcpy(sname,"localhost"); i = 1; while (i SIZE*2) exitServer2(fp,"too big body."); - sprintf(ccc,"/usr/local/bin/openxm %s",body); - fprintf(stderr,"Serial=%d : Executing command=%s\n",ccc); + openxm = getOpenXMpath(); + sprintf(ccc,"%s %s",openxm,body); + fprintf(stderr,"Serial=%d : Executing command=%s\n",Serial,ccc); + /* Old code. fprintf(fp,"\n"); fflush(NULL); - fclose(fp); /* close the connection */ + fclose(fp); system(ccc); - fprintf(stderr,"Serial=%d : The following command is finished : %s\n",ccc); + fprintf(stderr,"Serial=%d : The following command is finished : %s\n",Serial,ccc); + */ + /* New code. It requires ox with -finish option. */ + resultCode = system(ccc); + fprintf(stderr,"Serial=%d : The following command is finished : %s, resultCode=%d\n",Serial,ccc,resultCode); + if (resultCode == 0) { + fprintf(fp,"\n"); + }else{ + fprintf(fp,"\n",resultCode); + } + + GET_COMMAND /* expect */ + + fclose(fp); /* close the connection */ + fprintf(stderr,"Waiting the termination of the child process (ox server).\n"); + fflush(NULL); + wait(&st); + fprintf(stderr,"%d: The child process is terminated.\n",Serial); + exit(0); } +char *getOpenXMpath() { + char *s; + char *sss; + s = getenv("OpenXM_HOME"); + if (s == NULL) { + s = getenv("OPENXM_HOME"); + } + if (s == NULL) sss="/usr/local/bin/openxm"; + else { + sss = (char *) xtagMalloc(strlen(s)+20); + sprintf(sss,"%s/bin/openxm",s); + } + if (access(sss,X_OK&R_OK) == 0) { + }else{ + oxdError("The shell script openxm does not exists. It is usually generated under OpenXM/rc"); + } + return sss; +} /* These are dummy. It is defined in stackmachine.c */ unlockCtrlCForOx() { ; }