From: hades Date: Thu, 10 Aug 2000 15:31:52 +0000 (+0000) Subject: Initial revision X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=0955e372d5a6382dc84854cbe79b12f533c044dc;p=daqdata.git Initial revision --- diff --git a/allParam/Makefile b/allParam/Makefile new file mode 100644 index 0000000..8bb8d65 --- /dev/null +++ b/allParam/Makefile @@ -0,0 +1,29 @@ +ARFLAGS = -rc +PARAMLIBES = tclParam caParam +CXXPARAMOBJS = ora/ora tcl/tcl tcl/struct file/file param/enh + +all : $(patsubst %,lib%.a,$(PARAMLIBES)) libcxxParam.a + +libcxxParam.a : $(patsubst %,%Param.o,$(CXXPARAMOBJS)) + $(AR) $(ARFLAGS) $@ $? + +$(patsubst %,lib%.a,$(PARAMLIBES)) : + cd $(patsubst lib%Param.a,%,$@) ; $(MAKE) $@ + +$(patsubst %,%Param.o,$(CXXPARAMOBJS)) : + cd $(dir $@) ; $(MAKE) $(notdir $@) + +clean : + cd ca ; $(MAKE) $@ + cd tcl ; $(MAKE) $@ + cd param ; $(MAKE) $@ + cd file ; $(MAKE) $@ + cd ora ; $(MAKE) $@ + +lib_clean : + rm -f libcxxParam.a + cd ca ; $(MAKE) $@ + cd tcl ; $(MAKE) $@ + cd file ; $(MAKE) $@ + cd ora ; $(MAKE) $@ + diff --git a/allParam/file/Makefile b/allParam/file/Makefile new file mode 100644 index 0000000..52fda24 --- /dev/null +++ b/allParam/file/Makefile @@ -0,0 +1,10 @@ +CXXFLAGS = -g -I../param + +fileParam.o : fileParam.cc fileParam.h ../param/enhParam.h + +clean : + rm -f *.o + +lib_clean : + rm -f *.o *.a + diff --git a/allParam/file/fileParam.cc b/allParam/file/fileParam.cc new file mode 100644 index 0000000..56918f0 --- /dev/null +++ b/allParam/file/fileParam.cc @@ -0,0 +1,120 @@ +#define _POSIX_C_SOURCE 199509L + +extern "C" { + #include + #include + #include + #include + + #include +} + +#include "fileParam.h" + +FileParam::FileParam(const char *fn) : Param() +{ + int i = 0; + char fileName[PARAM_MAXNAMELEN]; + FILE *f; + char buf[BUFFERSIZE]; + + strcpy(fileName, fn); + if (fileName == NULL) { + strcmp(fileName, "param.tcl"); + } + if (NULL == (f = fopen(fileName, "r"))) { + msglog(LOG_ERR, "opening param file: %s\n", strerror(errno)); + exit (-1); + } else { + int oneMore = 1; + overFullParamFile = 0; + while (oneMore) { + oneMore = 0; + if (i < PARAM_MAXNVALS) { + if (fgets(buf, BUFFERSIZE, f) != NULL) { + oneMore = 1; + } + if (oneMore && (buf[0] != '#')) { + sscanf(buf, "set%s%s", name[i], val[i]); + i++; + } + } else { + oneMore = 0; + msglog(LOG_WARNING, "Too many parameters in file, ignoring the rest.\n"); + overFullParamFile = 1; + } + } + nVals = i; + fclose(f); + } +} + +FileParam::~FileParam() +{ +} + +int FileParam::getParamNumber(const char *n, const char *idx) const +{ + int retVal = -1; + int i; + char fullName[PARAM_MAXNAMELEN]; + + sprintf(fullName, "%s(%s)", n, idx); + for (i = 0; i < PARAM_MAXNVALS; i++) { + if (strcmp(name[i], fullName) == 0) { + retVal = i; + } + } + return retVal; +} + +int FileParam::isInteger(const char *n, const char *idx) const +{ + int retVal = 0; + char *endptr; + int num = getParamNumber(n, idx); +#if 0 + printf("Before strtoul:\n*endptr: %c\nendptr: %p\n&endptr: %p\n", *endptr, endptr, &endptr); +#endif + strtoul(val[num], &endptr, 0); +#if 0 + printf("After strtoul:\n*endptr: %c\nendptr: %p\n&endptr: %p\n", *endptr, endptr, &endptr); +#endif + if (*endptr == '\0') { + retVal = 1; + } + + return retVal; +} + +int FileParam::doesExistHere(const char *n, const char *idx) const +{ + int retVal = 1; + if(getParamNumber(n, idx) == -1) { + retVal = 0; + } + return retVal; +} + +const char *FileParam::getString(const char *n, const char *idx) const +{ + int num = getParamNumber(n, idx); + if (num == -1) { + msglog(LOG_WARNING, "Parameter %s(%s) not found, null pointer returned.\n", n, idx); + return NULL; + } else { + return val[num]; + } +} + +unsigned long int FileParam::getInt(const char *n, const char *idx) const +{ + int num = getParamNumber(n, idx); + if (num == -1) { + msglog(LOG_WARNING, "Parameter %s(%s) not found, 0 returned.\n", name, idx); + return 0; + } else { + return strtoul(val[num], NULL, 0); + } +} + diff --git a/allParam/ora/Makefile b/allParam/ora/Makefile new file mode 100644 index 0000000..edf69b6 --- /dev/null +++ b/allParam/ora/Makefile @@ -0,0 +1,23 @@ +CXXFLAGS = -g -I../param -I$(ORACLE_HOME)/precomp/public/ +ORACLE_HOME = /usr/local/oracle/product/8.0.5 +PROC = $(ORACLE_HOME)/bin/proc + +PROC_INCLUDES = include=/usr/include include=/usr/include/g++-2 \ + include=$(ORACLE_HOME)/precomp/public \ + include=$(ORACLE_HOME)/rdbms/public \ + include=$(ORACLE_HOME)/rdbms/demo \ + include=$(ORACLE_HOME)/plsql/public \ + include=$(ORACLE_HOME)/network/public + +oraParam.o : oraParam.cc oraParam.h ../param/enhParam.h + +oraParam.cc : oraParam.pc + cp $< $@ +# $(PROC) $(PROCINCLUDES) iname=$< oname=$@ + +clean : + rm -f *.o oraParam.cc oraParam.lis + +lib_clean : + rm -f *.o *.a oraParam.cc oraParam.lis +