Changed dbExpandInclude to dbExpand

This commit is contained in:
Marty Kraimer
1996-07-10 14:46:01 +00:00
parent b40676fe20
commit b1450980b5
2 changed files with 34 additions and 25 deletions
+3 -3
View File
@@ -24,7 +24,7 @@ INC += guigroup.h
SRCS.c = \
dbYacc.c \
../dbReadTest.c\
../dbExpandInclude.c\
../dbExpand.c\
../dbPvdLib.c\
../dbStaticNoRun.c\
../dbStaticLib.c\
@@ -33,7 +33,7 @@ SRCS.c = \
OBJS = \
dbReadTest.o\
dbExpandInclude.o\
dbExpand.o\
dbToMenuH.o\
dbToRecordtypeH.o
@@ -42,7 +42,7 @@ LIBNAME = libDb.a
PROD = \
dbReadTest\
dbExpandInclude\
dbExpand\
dbToMenuH\
dbToRecordtypeH
@@ -1,4 +1,4 @@
/* dbExpandInclude.c */
/* dbExpand.c */
/* Author: Marty Kraimer Date: 30NOV95 */
/*****************************************************************
COPYRIGHT NOTIFICATION
@@ -28,33 +28,38 @@ of this distribution.
#include <gpHash.h>
DBBASE *pdbbase = NULL;
#define MAX_PATH_LENGTH 256
static void addPath(char *path,char *newdir)
{
if((strlen(path)+strlen(newdir)+2) > (size_t)MAX_PATH_LENGTH) {
fprintf(stderr,"path > 256 characters\n");
exit(-1);
}
if(strlen(path) > (size_t)0) strcat(path,":");
strcat(path,newdir);
}
int main(int argc,char **argv)
{
int strip;
char path[MAX_PATH_LENGTH];
long status;
int i;
int strip;
char *path = NULL;
char *sub = NULL;
int pathLength = 0;
int subLength = 0;
char **pstr;
char *psep;
int *len;
long status;
static char *pathSep = ":";
static char *subSep = ",";
/*Look for path, i.e. -I dir or -Idir*/
path[0] = 0;
while(strncmp(argv[1],"-I",2)==0) {
/*Look for options*/
while((strncmp(argv[1],"-I",2)==0)||(strncmp(argv[1],"-S",2)==0)) {
if(strncmp(argv[1],"-I",2)==0) {
pstr = &path;
psep = pathSep;
len = &pathLength;
} else {
pstr = &sub;
psep = subSep;
len = &subLength;
}
if(strlen(argv[1])==2) {
addPath(path,argv[2]);
dbCatString(pstr,len,argv[2],psep);
strip = 2;
} else {
addPath(path,argv[1]+2);
dbCatString(pstr,len,argv[1]+2,psep);
strip = 1;
}
argc -= strip;
@@ -62,11 +67,13 @@ int main(int argc,char **argv)
}
if(argc<2 || (strncmp(argv[1],"-",1)==0)) {
fprintf(stderr,
"usage: dbExpandInclude -Idir -Idir file1.dbd file2.dbd ...\n");
"usage: dbExpand -Idir -Idir "
"-S substitutions -S substitutions"
" file1.dbd file2.dbd ...\n");
exit(0);
}
for(i=1; i<argc; i++) {
status = dbReadDatabase(&pdbbase,argv[i],path);
status = dbReadDatabase(&pdbbase,argv[i],path,sub);
if(!status) continue;
fprintf(stderr,"For input file %s",argv[i]);
errMessage(status,"from dbReadDatabase");
@@ -77,5 +84,7 @@ int main(int argc,char **argv)
dbWriteDriverFP(pdbbase,stdout);
dbWriteBreaktableFP(pdbbase,stdout);
dbWriteRecordFP(pdbbase,stdout,0,0);
free((void *)path);
free((void *)sub);
return(0);
}