[BACK]Return to shell.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan

Diff for /OpenXM/src/kan96xx/Kan/shell.c between version 1.5 and 1.12

version 1.5, 2003/12/04 05:27:19 version 1.12, 2004/10/14 10:08:09
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kan96xx/Kan/shell.c,v 1.4 2003/12/03 23:26:39 takayama Exp $ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/shell.c,v 1.11 2004/02/23 09:03:42 takayama Exp $ */
 #include <stdio.h>  #include <stdio.h>
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/stat.h>  #include <sys/stat.h>
Line 41  static int AfterPt=0;
Line 41  static int AfterPt=0;
 static char *AfterDeleteFile[MAXFILES];  static char *AfterDeleteFile[MAXFILES];
 static int AfterD=0;  static int AfterD=0;
   
 static int KeepTmpFiles = 1;  static int KeepTmpFiles = 0;
   
 extern int OX_P_stdin;  extern int OX_P_stdin;
 extern int OX_P_stdout;  extern int OX_P_stdout;
Line 53  struct object KoxShell(struct object ob) {
Line 53  struct object KoxShell(struct object ob) {
   
 /* A temporary help system */  /* A temporary help system */
 void KoxShellHelp(char *key,FILE *fp) {  void KoxShellHelp(char *key,FILE *fp) {
   char *keys[]={"command","export","which","redirect","@@@@gatekeeper"};    char *keys[]={"command","export","keep_tmp_files",
                   "killall","redirect","which","@@@@gatekeeper"};
   int i;    int i;
 #define HSIZE 20  #define HSIZE 20
   char *s[HSIZE];    char *s[HSIZE];
   if (key == NULL) {    if (key == NULL) {
         fprintf(fp,"\n");      fprintf(fp,"\n");
     for (i=0; strcmp(keys[i],"@@@@gatekeeper") != 0; i++) {      for (i=0; strcmp(keys[i],"@@@@gatekeeper") != 0; i++) {
           fprintf(fp,"%s\n",keys[i]);        fprintf(fp,"%s\n",keys[i]);
           KoxShellHelp(keys[i],fp);        KoxShellHelp(keys[i],fp);
           fprintf(fp,"\n",keys[i]);        fprintf(fp,"\n",keys[i]);
         }      }
         return;      return;
   }    }
   for (i=0; i<HSIZE; i++) s[i] = NULL;    for (i=0; i<HSIZE; i++) s[i] = NULL;
   if (strcmp(key,"export")==0) {    if (strcmp(key,"export")==0) {
         s[0] = "export env_name  =  value";      s[0] = "export env_name  =  value";
         s[1] = "export env_name = ";      s[1] = "export env_name = ";
         s[2] = "Example: [(export) (PATH) (=) (/usr/new/bin:${PATH})] oxshell";      s[2] = "Example: [(export) (PATH) (=) (/usr/new/bin:${PATH})] oxshell";
         s[3] = NULL;      s[3] = NULL;
   }else if (strcmp(key,"which")==0) {    }else if (strcmp(key,"which")==0) {
         s[0] = "which cmd_name";      s[0] = "which cmd_name";
         s[1] = "which cmd_name path";      s[1] = "which cmd_name path";
         s[2] = "Example: [(which) (ls)] oxshell";      s[2] = "Example: [(which) (ls)] oxshell";
     s[3] = NULL;      s[3] = NULL;
   }else if (strcmp(key,"command")==0) {    }else if (strcmp(key,"command")==0) {
         s[0] = "Executing a command";      s[0] = "Executing a command";
         s[1] = "cmdname arg1 arg2 ... ";      s[1] = "cmdname arg1 arg2 ... ";
         s[2] = "Example 1: /afo (Hello! ) def [(cat) (stringIn://afo)] oxshell";      s[2] = "Example 1: /afo (Hello! ) def [(cat) (stringIn://afo)] oxshell";
         s[3] = "Example 2: [(polymake) (stringInOut://afo.poly) (FACETS)] oxshell";      s[3] = "Example 2: [(polymake) (stringInOut://afo.poly) (FACETS)] oxshell";
     s[4] = NULL;      s[4] = NULL;
   }else if (strcmp(key,"redirect")==0) {    }else if (strcmp(key,"redirect")==0) {
         s[0] = "The following redirect operators are implemented.";      s[0] = "The following redirect operators are implemented.";
         s[1] = "< > 2>";      s[1] = "< > 2>";
         s[2] = "Example 1: [(ls) (hoge) (2>) (stringOut://afo)] oxshell\n    afo ::";      s[2] = "Example 1: [(ls) (hoge) (2>) (stringOut://afo)] oxshell\n    afo ::";
         s[3] = "Example 2: [(cp) ] addStdoutStderr oxshell\n      [@@@stdout @@@stderr] ::";      s[3] = "Example 2: [(cp) ] addStdoutStderr oxshell\n      [@@@stdout @@@stderr] ::";
     s[4] = NULL;      s[4] = NULL;
     }else if (strcmp(key,"killall")==0) {
       s[0] = "Kill all the processes envoked by oxshell";
       s[1] = NULL;
     }else if (strcmp(key,"keep_tmp_files")==0) {
       s[0] = "keep_tmp_files value";
       s[1] = "If value is zero, then temporary files are removed after execution.";
       s[2] = NULL;
   }else{    }else{
   }    }
   i = 0;    i = 0;
   while (s[i] != NULL) {    while (s[i] != NULL) {
         fprintf(fp,"%s\n",s[i++]);      fprintf(fp,"%s\n",s[i++]);
   }    }
 }  }
   
Line 108  static struct object KoxShell_test1(struct object ob) 
Line 116  static struct object KoxShell_test1(struct object ob) 
   if (ob.tag != Sarray) errorKan1("%s\n","KoxShell requires an array as an argument.");    if (ob.tag != Sarray) errorKan1("%s\n","KoxShell requires an array as an argument.");
   n = getoaSize(ob);    n = getoaSize(ob);
   for (i=0; i<n; i++) {    for (i=0; i<n; i++) {
         if (getoa(ob,i).tag != Sdollar) errorKan1("%s\n","KoxShell requires an array of string as an argument.");      if (getoa(ob,i).tag != Sdollar) errorKan1("%s\n","KoxShell requires an array of string as an argument.");
   }    }
   
   if (n == 0) return(rob);    if (n == 0) return(rob);
Line 116  static struct object KoxShell_test1(struct object ob) 
Line 124  static struct object KoxShell_test1(struct object ob) 
   if (strcmp(cmd,"testmain")==0) {    if (strcmp(cmd,"testmain")==0) {
     rob = testmain(ob);      rob = testmain(ob);
   }else if (strcmp(cmd,"which")==0) {    }else if (strcmp(cmd,"which")==0) {
         if (n == 2) {      if (n == 2) {
           rob = KoxWhich(getoa(ob,1),KpoInteger(0));        pathFinderErrorVerbose(0);
         }else if (n==3) {        rob = KoxWhich(getoa(ob,1),KpoInteger(0));
           rob = KoxWhich(getoa(ob,1),getoa(ob,2));        pathFinderErrorVerbose(-1);
         }else{      }else if (n==3) {
           errorKan1("%s\n","shell: << which command-name >> or << which command-name path >>");        pathFinderErrorVerbose(0);
         }        rob = KoxWhich(getoa(ob,1),getoa(ob,2));
         return(rob);        pathFinderErrorVerbose(-1);
       }else{
         errorKan1("%s\n","shell: << which command-name >> or << which command-name path >>");
       }
       return(rob);
   }else if (strcmp(cmd,"export")==0) {    }else if (strcmp(cmd,"export")==0) {
         rob=oxsSetenv(ob);      rob=oxsSetenv(ob);
     }else if (strcmp(cmd,"keep_tmp_files")==0) {
       if (n != 2) errorKan1("%s\n","shell: << keep_tmp_files value >>");
       if (strcmp("0",KopString(getoa(ob,1))) == 0) {
         KeepTmpFiles = 0;
       }else{
         KeepTmpFiles = 1;
       }
       rob = KpoInteger(KeepTmpFiles);
     }else if (strcmp(cmd,"killall")==0) {
           /* It is called from ctrl-C hook of oxrfc103.sm1 */
           fprintf(stderr,"Killing all child processes (oxshell) ...");
       rob = KpoInteger(oxKillAll());
           fprintf(stderr,"\nDone.\n");
   }else{    }else{
         rob = oxsExecuteBlocked(ob);      rob = oxsExecuteBlocked(ob);
   }    }
   return(rob);    return(rob);
 }  }
Line 152  struct object KoxWhich(struct object cmdo,struct objec
Line 177  struct object KoxWhich(struct object cmdo,struct objec
   return(rob);    return(rob);
 }  }
   
   static int mysetenv(char *name, char *value, int overwrite);
   static int myunsetenv(char *name);
   static int mysetenv(char *name, char *value, int overwrite) {
     char *s;
     char *orig;
     s = (char *)getenv(name);
     if ((s == NULL) || overwrite) {
           s = (char *) mymalloc(strlen(name)+strlen(value)+5);
           if (s == 0) { fprintf(stderr,"No more memory.\n"); exit(10); }
       strcpy(s,name);
           strcat(s,"="); strcat(s,value);
           return(putenv(s));
     }
     return (0);
   }
   
   /* bug on Solaris. It does not unsetenv.
      libc4, libc5, glibc. It does unsetenv. */
   static myunsetenv(char *name) {
     return(putenv(name));
   }
   
 /* Example. [(export)  (PATH)  (=)  (/usr/new/bin:$PATH)] */  /* Example. [(export)  (PATH)  (=)  (/usr/new/bin:$PATH)] */
 static struct object oxsSetenv(struct object ob) {  static struct object oxsSetenv(struct object ob) {
   struct object rob;    struct object rob;
Line 164  static struct object oxsSetenv(struct object ob) {
Line 211  static struct object oxsSetenv(struct object ob) {
   n = getoaSize(ob);    n = getoaSize(ob);
   if ((n != 4) && (n != 3)) errorKan1("%s\n","oxsSetenv requires an array of srings. Length must be 3 or 4.");    if ((n != 4) && (n != 3)) errorKan1("%s\n","oxsSetenv requires an array of srings. Length must be 3 or 4.");
   for (i=0; i<n; i++) {    for (i=0; i<n; i++) {
         if (getoa(ob,i).tag != Sdollar) errorKan1("%s\n","oxsSetenv requires an array of srings. Length must be 3 or 4.");      if (getoa(ob,i).tag != Sdollar) errorKan1("%s\n","oxsSetenv requires an array of srings. Length must be 3 or 4.");
   }    }
   
   if (strcmp(KopString(getoa(ob,2)),"=") != 0) {    if (strcmp(KopString(getoa(ob,2)),"=") != 0) {
         errorKan1("%s\n","oxsSetenv, example [(export)  (PATH)  (=)  (/usr/new/bin:$PATH)] oxshell");      errorKan1("%s\n","oxsSetenv, example [(export)  (PATH)  (=)  (/usr/new/bin:$PATH)] oxshell");
   }    }
   envp = KopString(getoa(ob,1));    envp = KopString(getoa(ob,1));
   if (n == 4) {    if (n == 4) {
         new = KopString(getoa(ob,3));      new = KopString(getoa(ob,3));
         /* printf("%s\n",new); */      /* printf("%s\n",new); */
         new = oxEvalEnvVar(new);      new = oxEvalEnvVar(new);
         /* printf("%s\n",new); */      /* printf("%s\n",new); */
         r = setenv(envp,new,1);      r = mysetenv(envp,new,1);
   }else{    }else{
         unsetenv(envp); r = 0;      myunsetenv(envp); r = 0;
       /* bug: On Solaris, unsetenv will not work. */
   }    }
   if (r != 0) errorKan1("%s\n","setenv failed.");    if (r != 0) errorKan1("%s\n","setenv failed.");
   new = (char *) getenv(envp);    new = (char *) getenv(envp);
   if (new != NULL) {    if (new != NULL) {
         rob = KpoString((char *) getenv(envp));      rob = KpoString((char *) getenv(envp));
   }    }
   return(rob);    return(rob);
 }  }
Line 342  static struct object testmain(struct object ob) {
Line 390  static struct object testmain(struct object ob) {
   getoa(ot,2)=KpoString("${HOME}/t.t");    getoa(ot,2)=KpoString("${HOME}/t.t");
   av=oxsBuildArgv(ot);    av=oxsBuildArgv(ot);
   for (i=0; av[i] != NULL; i++) {    for (i=0; av[i] != NULL; i++) {
         printf("%s\n",av[i]);      printf("%s\n",av[i]);
   }    }
   printf("------------------------------\n");    printf("------------------------------\n");
   
Line 378  char *oxsVarToFile(char *v,char *ext,char *command,int
Line 426  char *oxsVarToFile(char *v,char *ext,char *command,int
   n = strlen(prog);    n = strlen(prog);
   prevc = 0;    prevc = 0;
   for (i=0; i<n ; i++) {    for (i=0; i<n ; i++) {
         c = prog[i];      c = prog[i];
         if (winname) {      if (winname) {
           if ((c == '\n') && (prevc != 0xd)) {        if ((c == '\n') && (prevc != 0xd)) {
                 fputc(0xd,fp); fputc(c,fp);          fputc(0xd,fp); fputc(c,fp);
           }        }
         }else{      }else{
           fputc(c,fp);        fputc(c,fp);
         }      }
         prevc = c;      prevc = c;
   }    }
   if (fclose(fp) != 0) errorKan1("%s\n","oxsVarToFile(), fail to close the file.");    if (fclose(fp) != 0) errorKan1("%s\n","oxsVarToFile(), fail to close the file.");
   
Line 399  int oxsFileToVar(char *v,char *fname) {
Line 447  int oxsFileToVar(char *v,char *fname) {
   int limit;    int limit;
   int c,i;    int c,i;
   
   if (v == NULL) errorKan1("%s\n","oxsFileToVar(), v is NULL.");    if (v == NULL) {
           /* errorKan1("%s\n","oxsFileToVar(), v is NULL."); */
           fprintf(stderr,"oxsFileToVar(), v is NULL.");
           return(-1);
     }
   limit = 1024;    limit = 1024;
   fp = fopen(fname,"r");    fp = fopen(fname,"r");
   if (fp == NULL) {    if (fp == NULL) {
         fprintf(stderr,"Filename=%s\n",fname);      fprintf(stderr,"Filename=%s\n",fname);
         errorKan1("%s\n","oxsFileToVar(), the file cannot be opened.");      /* errorKan1("%s\n","oxsFileToVar(), the file cannot be opened."); */
           fprintf(stderr,"oxsFileToVar(), the file cannot be opened.");
           return(-1);
   }    }
   s = (char *)mymalloc(limit);    s = (char *)mymalloc(limit);
   if (s == NULL) errorKan1("%s\n","No more memory in oxsFileToVar().");    if (s == NULL) errorKan1("%s\n","No more memory in oxsFileToVar().");
   
   i = 0;    i = 0;
   while ((c=fgetc(fp)) != EOF) {    while ((c=fgetc(fp)) != EOF) {
         s[i] = c; s[i+1] = 0;      s[i] = c; s[i+1] = 0;
         if (i > limit - 10) {      if (i > limit - 10) {
           sold = s; limit *= 2;        sold = s; limit *= 2;
           s = (char *)mymalloc(limit);        s = (char *)mymalloc(limit);
           if (s == NULL) errorKan1("%s\n","No more memory in oxsFileToVar().");        if (s == NULL) errorKan1("%s\n","No more memory in oxsFileToVar().");
           strcpy(s,sold);        strcpy(s,sold);
         }      }
     i++;      i++;
   }    }
   fclose(fp);    fclose(fp);
Line 441  static char **oxsBuildArgv(struct object ob) {
Line 495  static char **oxsBuildArgv(struct object ob) {
   if (ob.tag != Sarray) errorKan1("%s\n","oxsBuildArgv() requires an array as an argument.");    if (ob.tag != Sarray) errorKan1("%s\n","oxsBuildArgv() requires an array as an argument.");
   n = getoaSize(ob);    n = getoaSize(ob);
   for (i=0; i<n; i++) {    for (i=0; i<n; i++) {
         if (getoa(ob,i).tag != Sdollar) errorKan1("%s\n","oxsBuildArgv() requires an array of string as an argument.");      if (getoa(ob,i).tag != Sdollar) errorKan1("%s\n","oxsBuildArgv() requires an array of string as an argument.");
   }    }
   
   argv = (char **) mymalloc(sizeof(char *)*(n+2));    argv = (char **) mymalloc(sizeof(char *)*(n+2));
Line 452  static char **oxsBuildArgv(struct object ob) {
Line 506  static char **oxsBuildArgv(struct object ob) {
   s = oxEvalEnvVar(s);    s = oxEvalEnvVar(s);
   ocmd = KoxWhich(KpoString(s),KpoInteger(0));    ocmd = KoxWhich(KpoString(s),KpoInteger(0));
   if (ocmd.tag != Sdollar) {    if (ocmd.tag != Sdollar) {
         argv[0] = NULL;      argv[0] = NULL;
   }else{    }else{
         argv[0] = KopString(ocmd);      argv[0] = KopString(ocmd);
   }    }
   argv[1] = (char *)NULL;    argv[1] = (char *)NULL;
   if (argv[0] == NULL) {    if (argv[0] == NULL) {
         fprintf(stderr,"cmdname=%s\n",s);      fprintf(stderr,"cmdname=%s\n",s);
         errorKan1("%s\n","oxsBuildArgv() Command is not found.\n");      errorKan1("%s\n","oxsBuildArgv() Command is not found.\n");
   }    }
   for (i=1; i<n; i++) {    for (i=1; i<n; i++) {
         argv[i] = argv[i+1] = NULL;      argv[i] = argv[i+1] = NULL;
         s = KopString(getoa(ob,i));      s = KopString(getoa(ob,i));
         s = oxEvalEnvVar(s);      s = oxEvalEnvVar(s);
         type = oxsIsURI(s);      type = oxsIsURI(s);
         if (type == NULL) {      if (type == NULL) {
           argv[i] = s;        argv[i] = s;
         }else{      }else{
           /* Case when argv[i] is like "stringInOut:abc.poly" */        /* Case when argv[i] is like "stringInOut:abc.poly" */
           v = oxsURIgetVarName(s);        v = oxsURIgetVarName(s);
           ext = oxsURIgetExtension(s);        ext = oxsURIgetExtension(s);
           if (strcmp(type,"stringIn") == 0) {        if (strcmp(type,"stringIn") == 0) {
                 argv[i] = oxsVarToFile(v,ext,argv[0],usetmp);          argv[i] = oxsVarToFile(v,ext,argv[0],usetmp);
                 AfterDeleteFile[AfterD++] = argv[i];          AfterDeleteFile[AfterD++] = argv[i];
           }else if (strcmp(type,"stringInOut") == 0) {        }else if (strcmp(type,"stringInOut") == 0) {
                 argv[i] = oxsVarToFile(v,ext,argv[0],usetmp);          argv[i] = oxsVarToFile(v,ext,argv[0],usetmp);
                 AfterDeleteFile[AfterD++] = argv[i];          AfterDeleteFile[AfterD++] = argv[i];
                 AfterReadFile[AfterPt] = argv[i];          AfterReadFile[AfterPt] = argv[i];
                 AfterSetVar[AfterPt] = v;          AfterSetVar[AfterPt] = v;
                 AfterPt++;          AfterPt++;
                 if (AfterPt >= MAXFILES) {          if (AfterPt >= MAXFILES) {
                   AfterPt=0;            AfterPt=0;
                   errorKan1("%s\n","oxsBuildArgv(), Too may files to open.");            errorKan1("%s\n","oxsBuildArgv(), Too may files to open.");
                 }          }
           }else if (strcmp(type,"stringOut") == 0) {        }else if (strcmp(type,"stringOut") == 0) {
                 argv[i] = generateTMPfileName2(v,ext,usetmp,win);          argv[i] = generateTMPfileName2(v,ext,usetmp,win);
                 AfterDeleteFile[AfterD++] = argv[i];          AfterDeleteFile[AfterD++] = argv[i];
                 AfterReadFile[AfterPt] = argv[i];          AfterReadFile[AfterPt] = argv[i];
                 AfterSetVar[AfterPt] = v;          AfterSetVar[AfterPt] = v;
                 AfterPt++;          AfterPt++;
                 if (AfterPt >= MAXFILES) {          if (AfterPt >= MAXFILES) {
                   AfterPt=0;            AfterPt=0;
                   errorKan1("%s\n","oxsBuildArgv(), Too may files to open.");            errorKan1("%s\n","oxsBuildArgv(), Too may files to open.");
                 }          }
           }else {        }else {
                 errorKan1("%s\n","This URI type has not yet been implemented.");          errorKan1("%s\n","This URI type has not yet been implemented.");
           }        }
           if (AfterD >= MAXFILES) {        if (AfterD >= MAXFILES) {
                   AfterD=0;            AfterD=0;
                   errorKan1("%s\n","oxsBuildArgv(), Too may files to open.");            errorKan1("%s\n","oxsBuildArgv(), Too may files to open.");
           }        }
         }      }
   }    }
   return(argv);    return(argv);
 }  }
Line 512  static struct object oxsExecuteBlocked(struct object o
Line 566  static struct object oxsExecuteBlocked(struct object o
 {  {
   int r,i,n;    int r,i,n;
   char **argv;    char **argv;
     int errorf;
   
   argv = oxsBuildArgv(ob);    argv = oxsBuildArgv(ob);
   argv = oxsBuildArgvRedirect(argv);    argv = oxsBuildArgvRedirect(argv);
   r=oxForkExecBlocked(argv);  /* bug: what happen when NoX? */    r=oxForkExecBlocked(argv);  /* bug: what happen when NoX? */
   /*    /*
   if (1) {    if (1) {
         for (i=0; argv[i] != NULL; i++) {      for (i=0; argv[i] != NULL; i++) {
           fprintf(stderr,"argv[%d]=%s\n",i,argv[i]);        fprintf(stderr,"argv[%d]=%s\n",i,argv[i]);
         }      }
         errorKan1("%s\n","ForkExecBlocked failed.");      errorKan1("%s\n","ForkExecBlocked failed.");
   }    }
   */    */
     errorf=0;
   if (AfterPt > 0) {    if (AfterPt > 0) {
         for (i=0; i< AfterPt; i++) {      for (i=0; i< AfterPt; i++) {
           oxsFileToVar(AfterSetVar[i],AfterReadFile[i]);        if (oxsFileToVar(AfterSetVar[i],AfterReadFile[i]) != 0) {
         }          errorf=1;
         }
       }
   }    }
   AfterPt = 0;    AfterPt = 0;
   
   if (AfterD > 0) {    if (AfterD > 0) {
         for (i=0; i< AfterD; i++) {      for (i=0; i< AfterD; i++) {
           if (!KeepTmpFiles) {        if (!KeepTmpFiles) {
             oxDeleteFile(AfterDeleteFile[i]);          oxDeleteFile(AfterDeleteFile[i]);
       }        }
         }      }
   }    }
   AfterD = 0;    AfterD = 0;
     if (errorf) errorKan1("%s\n","Some errors in oxsFileToVar().");
   
   return(KpoInteger(r));    return(KpoInteger(r));
 }  }
Line 555  static char **oxsBuildArgvRedirect(char **argv) {
Line 614  static char **oxsBuildArgvRedirect(char **argv) {
   j=0;    j=0;
   /* bug: Critical area, do not make an interruption. */    /* bug: Critical area, do not make an interruption. */
   for (i=0; i<n; i++) {    for (i=0; i<n; i++) {
         if (strcmp(argv[i],"<")==0) {      if (strcmp(argv[i],"<")==0) {
           fname=argv[i+1];        fname=argv[i+1];
           OX_P_stdin = open(fname,O_RDONLY);        OX_P_stdin = open(fname,O_RDONLY);
           if (OX_P_stdin < 0) {        if (OX_P_stdin < 0) {
                 OX_P_stdin = -1;          OX_P_stdin = -1;
                 oxResetRedirect();          oxResetRedirect();
                 errorKan1("%s\n","oxsBuildArgvRedirect fails to open the input file.");          errorKan1("%s\n","oxsBuildArgvRedirect fails to open the input file.");
           }        }
       i++;        i++;
         }else if (strcmp(argv[i],">")==0) {      }else if (strcmp(argv[i],">")==0) {
           fname = argv[i+1];        fname = argv[i+1];
           fp == NULL;        fp == NULL;
           if (fname != NULL) {        if (fname != NULL) {
                 fp = fopen(fname,"w");          fp = fopen(fname,"w");
           }        }
       if (fp == NULL) {        if (fp == NULL) {
                 oxResetRedirect();          oxResetRedirect();
                 errorKan1("%s\n","oxsBuildArgvRedirect, cannot open the output file.\n");          errorKan1("%s\n","oxsBuildArgvRedirect, cannot open the output file.\n");
           }        }
           fclose(fp); /* touch */        fclose(fp); /* touch */
           OX_P_stdout = open(fname,O_WRONLY);        OX_P_stdout = open(fname,O_WRONLY);
           i++;        i++;
         }else if (strcmp(argv[i],"2>") == 0) {      }else if (strcmp(argv[i],"2>") == 0) {
           fname = argv[i+1];        fname = argv[i+1];
           fp == NULL;        fp == NULL;
           if (fname != NULL) {        if (fname != NULL) {
                 fp = fopen(fname,"w");          fp = fopen(fname,"w");
           }        }
       if (fp == NULL) {        if (fp == NULL) {
                 oxResetRedirect();          oxResetRedirect();
                 errorKan1("%s\n","oxsBuildArgvRedirect, cannot open the output (stderr) file.\n");          errorKan1("%s\n","oxsBuildArgvRedirect, cannot open the output (stderr) file.\n");
           }        }
           fclose(fp); /* touch */        fclose(fp); /* touch */
           OX_P_stderr = open(fname,O_WRONLY);        OX_P_stderr = open(fname,O_WRONLY);
           i++;        i++;
         }else{      }else{
           newargv[j++] = argv[i];        newargv[j++] = argv[i];
         }      }
   }    }
   return( newargv );    return( newargv );
 }  }

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

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