]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
Initial revision
authorhades <hades>
Thu, 10 Aug 2000 15:31:52 +0000 (15:31 +0000)
committerhades <hades>
Thu, 10 Aug 2000 15:31:52 +0000 (15:31 +0000)
allParam/Makefile [new file with mode: 0644]
allParam/file/Makefile [new file with mode: 0644]
allParam/file/fileParam.cc [new file with mode: 0644]
allParam/ora/Makefile [new file with mode: 0644]

diff --git a/allParam/Makefile b/allParam/Makefile
new file mode 100644 (file)
index 0000000..8bb8d65
--- /dev/null
@@ -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 (file)
index 0000000..52fda24
--- /dev/null
@@ -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 (file)
index 0000000..56918f0
--- /dev/null
@@ -0,0 +1,120 @@
+#define _POSIX_C_SOURCE 199509L
+
+extern "C" {
+  #include <errno.h>
+  #include <stdio.h>
+  #include <stdlib.h>
+  #include <string.h>
+
+  #include <hadesstd.h>
+}
+
+#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 (file)
index 0000000..edf69b6
--- /dev/null
@@ -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
+