Added output file name as an optional command line param.

This commit is contained in:
Janet B. Anderson
2000-02-22 15:57:17 +00:00
parent ee38a74c9a
commit a96a3f7333
3 changed files with 25 additions and 7 deletions

View File

@@ -108,10 +108,11 @@ int main(argc, argv)
char *plastSlash;
if(argc!=2) {
fprintf(stderr,"usage: makeBpt file.data\n");
if(argc<2) {
fprintf(stderr,"usage: makeBpt file.data [outfile]\n");
exit(-1);
}
if (argc==2) {
plastSlash = strrchr(argv[1],'/');
plastSlash = (plastSlash ? plastSlash+1 : argv[1]);
outFilename = calloc(1,strlen(plastSlash)+2);
@@ -122,6 +123,10 @@ int main(argc, argv)
exit(-1);
}
strcpy(pext,".dbd");
} else {
outFilename = calloc(1,strlen(argv[2])+1);
strcpy(outFilename,argv[2]);
}
inFile = fopen(argv[1],"r");
if(!inFile) {
fprintf(stderr,"Error opening %s\n",argv[1]);

View File

@@ -53,7 +53,7 @@ int main(int argc,char **argv)
/*Look for options*/
if(argc<2) {
fprintf(stderr,"usage: dbToMenu -Idir -Idir file.dbd\n");
fprintf(stderr,"usage: dbToMenu -Idir -Idir file.dbd [outfile]\n");
exit(0);
}
while((strncmp(argv[1],"-I",2)==0)||(strncmp(argv[1],"-S",2)==0)) {
@@ -76,10 +76,11 @@ int main(int argc,char **argv)
argc -= strip;
for(i=1; i<argc; i++) argv[i] = argv[i + strip];
}
if(argc!=2 || (strncmp(argv[1],"-",1)==0)) {
fprintf(stderr,"usage: dbToMenu -Idir -Idir file.dbd\n");
if(argc<2 || (strncmp(argv[1],"-",1)==0)) {
fprintf(stderr,"usage: dbToMenu -Idir -Idir file.dbd [outfile]\n");
exit(0);
}
if (argc==2) {
/*remove path so that outFile is created where program is executed*/
plastSlash = strrchr(argv[1],'/');
if(!plastSlash) plastSlash = strrchr(argv[1],'\\');
@@ -92,6 +93,10 @@ int main(int argc,char **argv)
exit(-1);
}
strcpy(pext,".h");
} else {
outFilename = dbCalloc(1,strlen(argv[2])+1);
strcpy(outFilename,argv[2]);
}
outFile = fopen(outFilename,"w");
if(!outFile) {
errPrintf(0,__FILE__,__LINE__,"Error opening %s\n",outFilename);

View File

@@ -57,7 +57,7 @@ int main(int argc,char **argv)
/*Look for options*/
if(argc<2) {
fprintf(stderr,"usage: dbToRecordtypeH -Idir -Idir file.dbd\n");
fprintf(stderr,"usage: dbToRecordtypeH -Idir -Idir file.dbd [outfile]\n");
exit(0);
}
while((strncmp(argv[1],"-I",2)==0)||(strncmp(argv[1],"-S",2)==0)) {
@@ -81,9 +81,10 @@ int main(int argc,char **argv)
for(i=1; i<argc; i++) argv[i] = argv[i + strip];
}
if(argc<2 || (strncmp(argv[1],"-",1)==0)) {
fprintf(stderr,"usage: dbToRecordtypeH -Idir -Idir file.dbd\n");
fprintf(stderr,"usage: dbToRecordtypeH -Idir -Idir file.dbd [outfile]\n");
exit(0);
}
if(argc==2){
/*remove path so that outFile is created where program is executed*/
plastSlash = strrchr(argv[1],'/');
if(!plastSlash) plastSlash = strrchr(argv[1],'\\');
@@ -100,6 +101,13 @@ int main(int argc,char **argv)
strcpy(outFilename,"dbCommon.h");
isdbCommonRecord = TRUE;
}
}else {
outFilename = dbCalloc(1,strlen(argv[2])+1);
strcpy(outFilename,argv[2]);
if(strstr(outFilename,"dbCommon.h")!=0) {
isdbCommonRecord = TRUE;
}
}
outFile = fopen(outFilename,"w");
if(!outFile) {
errPrintf(0,__FILE__,__LINE__,"Error opening %s\n",outFilename);