version 1.1.1.1, 1999/10/08 02:12:13 |
version 1.4, 1999/12/15 11:40:23 |
|
|
|
/*$OpenXM: OpenXM/src/kxx/oxlog.c,v 1.3 1999/12/15 11:31:57 takayama Exp $*/ |
#include <stdio.h> |
#include <stdio.h> |
#include <signal.h> |
#include <signal.h> |
|
#include <string.h> |
|
#include <stdlib.h> |
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <fcntl.h> |
#include <fcntl.h> |
|
|
-ox /home/nobuki/kxx/ox_asir >& /dev/null |
-ox /home/nobuki/kxx/ox_asir >& /dev/null |
2 3 |
2 3 |
*/ |
*/ |
|
char *toFullPath(char *s); |
|
char *which(char *s,char *env); |
main(int argc, char *argv[]) { |
main(int argc, char *argv[]) { |
sigset_t sss; |
sigset_t sss; |
int i; |
int i; |
|
char *oxname; |
/* char *env[2]; |
/* char *env[2]; |
env[0] = NULL;*/ |
env[0] = NULL;*/ |
sigemptyset(&sss); |
sigemptyset(&sss); |
sigaddset(&sss,SIGINT); |
sigaddset(&sss,SIGINT); |
sigprocmask(SIG_BLOCK,&sss,NULL); |
sigprocmask(SIG_BLOCK,&sss,NULL); |
|
if (argc > 1) { |
|
oxname = argv[1]; |
|
oxname = toFullPath(oxname); |
|
} |
if (argc == 4) { |
if (argc == 4) { |
execl(argv[1],argv[1],argv[2],argv[3],NULL); |
execl(oxname,oxname,argv[2],argv[3],NULL); |
}else if (argc == 5) { |
}else if (argc == 5) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],NULL); |
execl(oxname,oxname,argv[2],argv[3],argv[4],NULL); |
}else if (argc == 6) { |
}else if (argc == 6) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],NULL); |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],NULL); |
}else if (argc == 7) { |
}else if (argc == 7) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6],NULL); |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6],NULL); |
}else if (argc == 8) { |
}else if (argc == 8) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6], |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
argv[7],NULL); |
argv[7],NULL); |
}else if (argc == 9) { |
}else if (argc == 9) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6], |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
argv[7],argv[8],NULL); |
argv[7],argv[8],NULL); |
}else if (argc == 10) { |
}else if (argc == 10) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6], |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
argv[7],argv[8],argv[9],NULL); |
argv[7],argv[8],argv[9],NULL); |
}else if (argc == 11) { |
}else if (argc == 11) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6], |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
argv[7],argv[8],argv[9],argv[10],NULL); |
argv[7],argv[8],argv[9],argv[10],NULL); |
}else if (argc == 12) { |
}else if (argc == 12) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6], |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
argv[7],argv[8],argv[9],argv[10],argv[11],NULL); |
argv[7],argv[8],argv[9],argv[10],argv[11],NULL); |
}else if (argc == 13) { |
}else if (argc == 13) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6], |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
argv[7],argv[8],argv[9],argv[10],argv[11], argv[12],NULL); |
argv[7],argv[8],argv[9],argv[10],argv[11], argv[12],NULL); |
}else if (argc == 14) { |
}else if (argc == 14) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6], |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
argv[7],argv[8],argv[9],argv[10],argv[11], argv[12],argv[13],NULL); |
argv[7],argv[8],argv[9],argv[10],argv[11], argv[12],argv[13],NULL); |
}else if (argc == 15) { |
}else if (argc == 15) { |
execl(argv[1],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6], |
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
argv[7],argv[8],argv[9],argv[10],argv[11], argv[12],argv[13],argv[14],NULL); |
argv[7],argv[8],argv[9],argv[10],argv[11], argv[12],argv[13],argv[14],NULL); |
|
}else if (argc == 16) { |
|
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
|
argv[7],argv[8],argv[9],argv[10],argv[11], argv[12],argv[13],argv[14],argv[15],NULL); |
|
}else if (argc == 17) { |
|
execl(oxname,oxname,argv[2],argv[3],argv[4],argv[5],argv[6], |
|
argv[7],argv[8],argv[9],argv[10],argv[11], argv[12],argv[13],argv[14],argv[15],argv[16],NULL); |
}else { |
}else { |
fprintf(stderr,"Error in oxlog: cannot handle argc=%d\n",argc); |
fprintf(stderr,"Error in oxlog: cannot handle argc=%d\n",argc); |
|
fprintf(stderr,"oxname=%s\n",oxname); |
for (i=0; i<argc; i++) { |
for (i=0; i<argc; i++) { |
fprintf(stderr,"argv[%d]=%s ",i,argv[i]); |
fprintf(stderr,"argv[%d]=%s ",i,argv[i]); |
} |
} |
Line 70 main(int argc, char *argv[]) { |
|
Line 86 main(int argc, char *argv[]) { |
|
exit(10); |
exit(10); |
} |
} |
fprintf(stderr,"\nError in oxlog: Failed to start the process.\n"); |
fprintf(stderr,"\nError in oxlog: Failed to start the process.\n"); |
|
fprintf(stderr,"oxname=%s\n",oxname); |
for (i=0; i<argc; i++) { |
for (i=0; i<argc; i++) { |
fprintf(stderr,"argv[%d]=%s ",i,argv[i]); |
fprintf(stderr,"argv[%d]=%s ",i,argv[i]); |
} |
} |
|
|
execl("/usr/X11R6/bin/xterm","/usr/X11R6/bin/xterm", |
execl("/usr/X11R6/bin/xterm","/usr/X11R6/bin/xterm", |
"-e","/home/nobuki/kxx/ox","-ox","/home/nobuki/kxx/ox_asir",NULL); |
"-e","/home/nobuki/kxx/ox","-ox","/home/nobuki/kxx/ox_asir",NULL); |
/* execl("/home/nobuki/kxx/ox","/home/nobuki/kxx/ox","-ox","/home/nobuki/kxx/ox_asir",NULL);*/ |
/* execl("/home/nobuki/kxx/ox","/home/nobuki/kxx/ox","-ox","/home/nobuki/kxx/ox_asir",NULL);*/ |
|
} |
|
|
|
char *toFullPath(char *s) { |
|
if (strlen(s) == 0) { |
|
return(s); |
|
} |
|
if (strchr(s,'/') != NULL) return(s); |
|
else { |
|
s = which(s,getenv("PATH")); |
|
} |
|
} |
|
|
|
/*which("xterm", getenv("PATH"));*/ |
|
char *which(char *prog, char *path_env) |
|
{ |
|
char *tok; |
|
char *path; |
|
char delim[] = ":"; |
|
char *e = alloca(strlen(path_env)+1); |
|
strcpy(e, path_env); |
|
tok = strtok(e, delim); |
|
while (tok != NULL) { |
|
char *path = malloc(strlen(tok)+strlen(prog)+2); |
|
sprintf(path, "%s/%s", tok, prog); |
|
if (access(path, X_OK&R_OK) == 0) { |
|
return path; |
|
} |
|
free(path); |
|
tok = strtok(NULL, delim); |
|
} |
|
return NULL; |
} |
} |
|
|