[BACK]Return to oxmain.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kxx

Diff for /OpenXM/src/kxx/oxmain.c between version 1.7 and 1.12

version 1.7, 2001/05/06 07:53:01 version 1.12, 2002/10/28 00:38:32
Line 1 
Line 1 
 /*  $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.6 2000/12/05 05:58:33 ohara Exp $  */  /*  $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.11 2002/05/02 08:33:47 ohara Exp $  */
 /* nullserver01 */  /* nullserver01 */
 #include <stdio.h>  #include <stdio.h>
 #include <fcntl.h>  #include <fcntl.h>
   #include <unistd.h>
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/socket.h>  #include <sys/socket.h>
 #include <sys/time.h>  #include <sys/time.h>
Line 17 
Line 18 
   
 int OxCritical = 0;  int OxCritical = 0;
 int OxInterruptFlag = 0;  int OxInterruptFlag = 0;
   int OxTerminateMode = 0;
   
 int SerialCurrentControl;  int SerialCurrentControl;
   
Line 32  int Do_not_use_control_stream_to_tell_no_server = 1;
Line 34  int Do_not_use_control_stream_to_tell_no_server = 1;
 static void errorToStartEngine(void);  static void errorToStartEngine(void);
 static int findOxServer(char *server);  static int findOxServer(char *server);
 static void couldNotFind(char *s);  static void couldNotFind(char *s);
   #if defined(__CYGWIN__)
   int errno;
   #endif
   /*  gcc -v -c hoge.c */
   
   
 main(int argc, char *argv[]) {  main(int argc, char *argv[]) {
   int fd;    int fd;
   int size;    int size;
Line 46  main(int argc, char *argv[]) {
Line 51  main(int argc, char *argv[]) {
   int reverse = 0;    int reverse = 0;
   extern int OpenedSocket;    extern int OpenedSocket;
   char portfile[1024];    char portfile[1024];
   char *pass;    char *pass = NULL;
   int result;    int result;
     int sleepingTime = 0;
     extern int OxTerminateMode;
   
   strcpy(sname,"localhost");    strcpy(sname,"localhost");
   strcpy(ServerName,SERVERNAME);    strcpy(ServerName,SERVERNAME);
   i = 1;    i = 1;
   if (argc == 1) {    if (argc == 1) {
     oxmainUsage();      oxmainUsage();
     exit();      exit(10);
   }    }
   while (i<argc) {    while (i<argc) {
     if (strcmp(argv[i],"-host") == 0) {      if (strcmp(argv[i],"-host") == 0) {
Line 75  main(int argc, char *argv[]) {
Line 82  main(int argc, char *argv[]) {
       LocalMode = 0;        LocalMode = 0;
     }else if (strcmp(argv[i],"-reverse") == 0) {      }else if (strcmp(argv[i],"-reverse") == 0) {
       reverse = 1;        reverse = 1;
       }else if (strcmp(argv[i],"-finish") == 0) {
         OxTerminateMode = 1;
     }else if (strcmp(argv[i],"-portfile") == 0) {      }else if (strcmp(argv[i],"-portfile") == 0) {
       i++;        i++;
       if (i<argc) {        if (i<argc) {
Line 88  main(int argc, char *argv[]) {
Line 97  main(int argc, char *argv[]) {
       if (i<argc) {        if (i<argc) {
         pass = argv[i];          pass = argv[i];
       }        }
       }else if (strcmp(argv[i],"-wait") == 0) {
         i++;
         if (i<argc) {
           sscanf(argv[i],"%d",&sleepingTime);
         }
     }else {      }else {
       fprintf(stderr,"Unknown option %s.\n",argv[i]);        fprintf(stderr,"Unknown option %s.\n",argv[i]);
       oxmainUsage(); exit(10);        oxmainUsage(); exit(10);
Line 103  main(int argc, char *argv[]) {
Line 117  main(int argc, char *argv[]) {
     }      }
   }    }
   
     if (sleepingTime) {
       fprintf(stderr,"Waiting to connect for %d seconds...\n",sleepingTime);
       sleep(sleepingTime);
       fprintf(stderr,"\nTrying to connect\n");
     }
   
   if (reverse) {    if (reverse) {
     /* The order is very important. */      /* The order is very important. */
     fdControl = socketConnectWithPass(sname,portControl,pass);      fdControl = socketConnectWithPass(sname,portControl,pass);
Line 201  oxmainUsage() {
Line 221  oxmainUsage() {
   fprintf(stderr,"Usage: \n");    fprintf(stderr,"Usage: \n");
   fprintf(stderr,"  ox [-ox serverprogram -host name -data portnum -control portnum -monitor]\n");    fprintf(stderr,"  ox [-ox serverprogram -host name -data portnum -control portnum -monitor]\n");
   fprintf(stderr," [-insecure -portfile fname -reverse -pass xxxyyyzzz]");    fprintf(stderr," [-insecure -portfile fname -reverse -pass xxxyyyzzz]");
     fprintf(stderr," [-finish]");
   fprintf(stderr,"\n");    fprintf(stderr,"\n");
   fprintf(stderr,"-reverse: ox server connects to the client.\n");    fprintf(stderr,"-reverse: ox server connects to the client.\n");
   fprintf(stderr,"          The client must give a one time password to ox server to connect to the client with -pass option.\n");    fprintf(stderr,"          The client must give a one time password to ox server to connect to the client with -pass option.\n");
Line 234  parentServerMain(int fdControl, int fdStream) {
Line 255  parentServerMain(int fdControl, int fdStream) {
   int r;    int r;
   int message = 1;    int message = 1;
   int controlByteOrder;    int controlByteOrder;
     extern OxTerminateMode;
   extern void myServerExit();    extern void myServerExit();
   
     if (OxTerminateMode) {
           /*
             OxTerminateMode cannot be used if you run ox by xterm -exec ox ...
            */
           if (fork()) {
             close(fdControl); close(fdStream);
             /* Parent */
             exit(0);  /*Tell the caller that launching is successfully finished.*/
           }
     }
   
   controlByteOrder = oxTellMyByteOrder(fdControl);    controlByteOrder = oxTellMyByteOrder(fdControl);
   /* Set the network byte order. */    /* Set the network byte order. */
   fprintf(stderr,"controlByteOrder=%x\n",controlByteOrder);    fprintf(stderr,"controlByteOrder=%x\n",controlByteOrder);
Line 276  parentServerMain(int fdControl, int fdStream) {
Line 308  parentServerMain(int fdControl, int fdStream) {
 void myServerExit() {  void myServerExit() {
   printf("Sending the kill signal to the child.\n");    printf("Sending the kill signal to the child.\n");
   kill(MyServerPid,SIGKILL);    kill(MyServerPid,SIGKILL);
   exit();    exit(0);
 }  }
   
 childServerMain(int fdControl, int fdStream) {  childServerMain(int fdControl, int fdStream) {
Line 318  restoreLockCtrlCForOx() { ; }
Line 350  restoreLockCtrlCForOx() { ; }
 static int findOxServer(char *server) {  static int findOxServer(char *server) {
   char *p;    char *p;
   char *p2;    char *p2;
   int fd;  
   char *getenv(char *s);    char *getenv(char *s);
   if (strlen(server) == 0) return(-1);    if (strlen(server) == 0) return(-1);
   fd = open(server,O_RDONLY);    /* fd = open(server,O_RDONLY); */
   if (fd >= 0) {    if (access(server,X_OK&R_OK) == 0) {
     fprintf(stderr,"Starting OX server : %s\n",server);      fprintf(stderr,"Starting OX server : %s\n",server);
     close(fd);  
     return(0);      return(0);
   }    }
   if (server[0] == '/') {    if (server[0] == '/') {
Line 339  static int findOxServer(char *server) {
Line 369  static int findOxServer(char *server) {
   p2 = (char *) malloc(sizeof(char)*(strlen(p)+strlen("/bin/")+3+strlen(server)));    p2 = (char *) malloc(sizeof(char)*(strlen(p)+strlen("/bin/")+3+strlen(server)));
   if (p2 == NULL) { fprintf(stderr,"No more memory.\n"); exit(10); }    if (p2 == NULL) { fprintf(stderr,"No more memory.\n"); exit(10); }
   strcpy(p2,p); strcat(p2,"/bin/"); strcat(p2,server);    strcpy(p2,p); strcat(p2,"/bin/"); strcat(p2,server);
   fd = open(p2,O_RDONLY);    /* fd = open(p2,O_RDONLY); */
   if (fd >= 0) {    if (access(p2,X_OK&R_OK) == 0) {
     fprintf(stderr,"Starting OX server : %s\n",p2);      fprintf(stderr,"Starting OX server : %s\n",p2);
     if (strlen(p2) < SERVERNAME_SIZE) strcpy(server,p2);      if (strlen(p2) < SERVERNAME_SIZE) strcpy(server,p2);
     else {      else {
       couldNotFind("Too long ox server name.");        couldNotFind("Too long ox server name.");
       return(-1);        return(-1);
     }      }
     close(fd);  
     return(0);      return(0);
   }    }
   couldNotFind(p2);    couldNotFind(p2);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.12

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>