]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
*** empty log message ***
authorhades <hades>
Wed, 14 Mar 2001 13:27:03 +0000 (13:27 +0000)
committerhades <hades>
Wed, 14 Mar 2001 13:27:03 +0000 (13:27 +0000)
13 files changed:
allParam/Makefile
allParam/VERSION
allParam/WARNING [new file with mode: 0644]
allParam/ca/Makefile
allParam/ca/caParam.c [deleted file]
allParam/ca/client/Makefile [new file with mode: 0644]
allParam/ca/client/caParam.c [new file with mode: 0644]
allParam/ca/server/Makefile [new file with mode: 0644]
allParam/file/Makefile
allParam/include/allParam.h
allParam/ora/Makefile
allParam/psql/Makefile
allParam/tcl/Makefile

index bc5010e683594d0d8c15640fffc31269ccb95c4c..844e451ca36f800be5d28e51b3cac16a90eb2c7d 100644 (file)
@@ -1,10 +1,10 @@
-#LIBDIR = /usr/local/lib
 #INCDIR = /usr/local/include
+#LIBDIR = /usr/local/lib
+#BINDIR = /usr/local/bin
 
-LIBDIR = $(HOME)/lib/$(SYSTYPE)
 INCDIR = $(HOME)/include
-
-ARFLAGS = -rc
+LIBDIR = $(HOME)/lib/$(SYSTYPE)
+BINDIR = $(HOME)/bin/$(SYSTYPE)
 
 PARAMLIBES = ca file ora psql tcl
 INSTALLS = ca_install file_install ora_install psql_install tcl_install
@@ -13,41 +13,34 @@ ALLS = ca_all file_all ora_all psql_all tcl_all
 
 VPATH = ca:file:ora:psql:tcl
 
-all : $(ALLS)
-
-lib : $(PARAMLIBES)
-
-install : $(INSTALLS)
-
-test : $(TESTS)
+warning :
+       @cat WARNING
 
 # Some subsets to make
 
-hades05 : ca_all file_all tcl_all
-lxi001 : ca_all file_all ora_all tcl_all
-
-ca_all : ca ca_install ca_test
-file_all : file file_install file_test
-ora_all : ora ora_install ora_test
-psql_all : psql psql_install psql_test
-tcl_all : tcl tcl_install tcl_test
+ca_all : ca ca_test ca_install
+file_all : file file_test file_install
+ora_all : ora ora_test ora_install
+psql_all : psql psql_test psql_install
+tcl_all : tcl tcl_test tcl_install
 
 $(PARAMLIBES) :
        cd $@ ; $(MAKE)
 
+$(TESTS) :
+       cd test ; $(MAKE) $@
+
 ca_install :
-       cd ca ; $(MAKE) install "LIBDIR=$(LIBDIR)" "INCDIR=$(INCDIR)"
+       cd ca ; $(MAKE) install "INCDIR=$(INCDIR)" "LIBDIR=$(LIBDIR)" \
+         "BINDIR=$(BINDIR)"
 file_install :
-       cd file ; $(MAKE) install "LIBDIR=$(LIBDIR)" "INCDIR=$(INCDIR)"
+       cd file ; $(MAKE) install "INCDIR=$(INCDIR)" "LIBDIR=$(LIBDIR)"
 ora_install :
-       cd ora ; $(MAKE) install "LIBDIR=$(LIBDIR)" "INCDIR=$(INCDIR)"
+       cd ora ; $(MAKE) install "INCDIR=$(INCDIR)" "LIBDIR=$(LIBDIR)"
 psql_install :
-       cd psql ; $(MAKE) install "LIBDIR=$(LIBDIR)" "INCDIR=$(INCDIR)"
+       cd psql ; $(MAKE) install "INCDIR=$(INCDIR)" "LIBDIR=$(LIBDIR)"
 tcl_install :
-       cd tcl ; $(MAKE) install "LIBDIR=$(LIBDIR)" "INCDIR=$(INCDIR)"
-
-$(TESTS) :
-       cd test ; $(MAKE) $@
+       cd tcl ; $(MAKE) install "INCDIR=$(INCDIR)" "LIBDIR=$(LIBDIR)"
 
 clean :
        cd ca ; $(MAKE) $@
@@ -65,15 +58,17 @@ lib_clean :
        cd tcl ; $(MAKE) $@
        cd test ; $(MAKE) bin_clean
 
-tar : lib_clean
-       rm -rf old_ca/ old_tcl/ param/
-       ln -s caParam.h ca/allParam.h
-       ln -s fileParam.h file/allParam.h
-       ln -s oraParam.h ora/allParam.h
-       ln -s psqlParam.h psql/allParam.h
-       ln -s tclParam.h tcl/allParam.h
-       cd .. ; tar -cvZf allParam.0.1.tar.Z allParam/
-       rm -f */allParam.h
+dist :
+       $(MAKE) lib_clean
+       $(MAKE) tar "VERSION=`cat VERSION`"
+
+tar :
+       @echo making tar archive of current version $(VERSION)
+       cd .. ; tar -cvZf allParam-$(VERSION).tar.Z allParam/
+       @echo made tar archive allParam-$(VERSION).tar.Z of current version
+
+# These "dummy" dependencies are because of $(PARAMLIBES) and test are also
+# directories existing here.
 
 $(PARAMLIBES) test : dummy
 dummy :
index 3b04cfb60da13a716867848ebeb2191a164887d9..c946ee6160c206cd4cb88cda26cb6e6b6aa6ff52 100644 (file)
@@ -1 +1 @@
-0.2
+0.1.6
diff --git a/allParam/WARNING b/allParam/WARNING
new file mode 100644 (file)
index 0000000..1803d02
--- /dev/null
@@ -0,0 +1,12 @@
++------------------------------------------------------------------------------+
+| Making all the libraries is probably not the thing You want to do (as some   |
+| of them have very special requirements). So please specify the ones You      |
+| really want to be made. Possible choices are:                                |
+| - ca                                                                         |
+| - file                                                                       |
+| - ora                                                                        |
+| - psql                                                                       |
+| - tcl                                                                        |
+| For more detailed information please refer to the general README in this     |
+| directory and the special READMEs in the corresponding subdirectories.       |
++------------------------------------------------------------------------------+
index 4f3aae4e5f3b65558f9107a157b6dc99671e4df0..ed945f66f0ade9b3f311d8215f88262c1eb9f504 100644 (file)
@@ -1,20 +1,23 @@
-CFLAGS = -g -ansi -Wall -I$(EPICS_BASE)/include \
-  -I$(EPICS_BASE)/include/os/$(HOST_ARCH) -I../include
+SERVERS = daq_file_param_cas daq_ora_param_cas \
+  daq_psql_param_cas daq_tcl_param_cas
 
-libcaParam.a : caParam.o
-       $(AR) $(ARFLAGS) $@ $<
+default : libcaParam.a daq_tcl_param_cas
 
-caParam.o : caParam.c
+libcaParam.a :
+       cd client ; $(MAKE) $@
 
-install : libcaParam.a
-       -mkdir -p $(LIBDIR)
-       install -m 644 $< $(LIBDIR)
-       -mkdir -p $(INCDIR)
-       install -m 644 ../include/allParam.h $(INCDIR)
+$(SERVERS) :
+       cd server ; $(MAKE) $@ "SERVERS=$(SERVERS)"
+
+install :
+       cd client ; $(MAKE) $@ "INCDIR=$(INCDIR)" "LIBDIR=$(LIBDIR)"
+       cd server ; $(MAKE) $@ "INCDIR=$(INCDIR)" "BINDIR=$(BINDIR)"
 
 clean :
-       rm -f *.o
+       cd client ; $(MAKE) $@
+       cd server ; $(MAKE) $@
 
 lib_clean :
-       rm -f *.o *.a
+       cd client ; $(MAKE) $@
+       cd server ; $(MAKE) bin_clean
 
diff --git a/allParam/ca/caParam.c b/allParam/ca/caParam.c
deleted file mode 100644 (file)
index 16ab63c..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-#define _POSIX_C_SOURCE 199509L
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include <cadef.h>
-
-#include <allParam.h>
-
-#define TIMEOUT 0.2
-
-static void Param_copyToAllocMem(struct event_handler_args args);
-static void Param_returnPVName(const Param *my, const char *, const char *, const char *, char *);
-static void Param_strerror(Param *, const char *);
-
-typedef struct ParamResultS {
-       char **val;
-       int *rows;
-       int maxrows;
-       const Param *my;
-       int *retVal;
-} ParamResult;
-
-int conSetupParam(Param *my, const char *setup)
-{
-       my->strerror = NULL;
-       if(setup != NULL) {
-               my->setup = malloc(strlen(setup) + 1);
-               strcpy(my->setup, setup);
-       }
-       return 0;
-}
-
-int conParam(Param *my)
-{
-       my->strerror = NULL;
-       my->setup = NULL;
-       return 0;
-}
-
-void desParam(Param *my)
-{
-       if(my->setup != NULL) {
-               free(my->setup);
-       }
-}
-
-int Param_getInt(const Param *my, const char *name, const char *idx, int *row, unsigned long int *val)
-{
-       return Param_getIntArray(my, name, idx, 1, row, val);
-}
-
-int Param_getString(const Param *my, const char *name, const char *idx, int *row, char *val)
-{
-       return Param_getStringArray(my, name, idx, 1, row, &val);
-}
-
-int Param_getIntArray(const Param *my, const char *name, const char *idx, int maxrows, int *rows, unsigned long int *val)
-{
-       int retVal = 0;
-       int i;
-       char *endptr;
-       char *value[PARAM_MAX_ARRAY_LEN];
-
-       for (i = 0 ; i < PARAM_MAX_ARRAY_LEN ; i++) {
-               value[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
-       }
-
-       if((retVal = Param_getStringArray(my, name, idx, maxrows, rows, value)) == 0) {
-               for (i = 0 ; i < *rows ; i++) {
-                       val[i] = strtoul(value[i], &endptr, 0);
-                       if(*endptr != '\0') {
-                               Param_strerror((Param *) my, "Value seems not to be integer.");
-                               retVal = -1;
-                       }
-               }
-       }
-       if (retVal != 0) {
-               *rows = 0;
-       }
-
-       for (i = 0 ; i <  PARAM_MAX_ARRAY_LEN ; i++) {
-               free(value[i]);
-       }
-       return retVal;
-}
-
-int Param_getStringArray(const Param *my, const char *name, const char *idx, int maxrows, int *rows, char **val)
-{
-       int retVal = 0;
-       int status;
-       int found = 1;
-       chid chan;
-       char *pPVName;
-
-       *rows = 0;
-       if((status = ca_task_initialize()) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               retVal = -1;
-       }
-
-       pPVName = malloc((strlen("HAD:PG:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
-       Param_returnPVName(my, "PG", name, idx, pPVName);
-
-       if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
-               Param_strerror((Param *) my, ca_message(status));
-               found = 0;
-       } else if (status != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               retVal = -1;
-               found = -1;
-       }
-
-       if((status = ca_pend_io(TIMEOUT)) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               found = 0;
-               retVal = 0;
-       }
-       if(found == 1) {
-               ParamResult resultS, *result = &resultS;
-               result->val = val;
-               result->rows = rows;
-               result->maxrows = maxrows;
-               result->my = my;
-               result->retVal = &retVal;
-
-               status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyToAllocMem, result);
-               Param_strerror((Param *) my, ca_message(status));
-
-               if((status = ca_pend_event(TIMEOUT)) == ECA_TIMEOUT) {
-                       Param_strerror((Param *) my, ca_message(status));
-               } else if (status != ECA_NORMAL) {
-                       Param_strerror((Param *) my, ca_message(status));
-                       retVal = -1;
-               }
-       }
-
-       if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               retVal = -1;
-       }
-
-       free(pPVName);
-
-       if((status = ca_task_exit()) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-       }
-
-       return retVal;
-}
-
-int Param_storeInt(const Param *my, const char *name, const char *idx, unsigned long int value)
-{
-       int retVal = 0;
-       int status;
-       int found = 1;
-       chid chan;
-       char *pPVName;
-
-       if((status = ca_task_initialize()) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               retVal = -1;
-       }
-
-       pPVName = malloc((strlen("HAD:PS:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
-       Param_returnPVName(my, "PS", name, idx, pPVName);
-
-       if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
-               Param_strerror((Param *) my, ca_message(status));
-               found = 0;
-       } else if (status != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               retVal = -1;
-               found = -1;
-       }
-
-       if((status = ca_pend_io(TIMEOUT)) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               found = 0;
-               retVal = 0;
-       }
-       if(found == 1) {
-               status = ca_put(DBR_LONG, chan, &value);
-               Param_strerror((Param *) my, ca_message(status));
-
-               if((status = ca_pend_event(TIMEOUT)) == ECA_TIMEOUT) {
-                       Param_strerror((Param *) my, ca_message(status));
-               } else if (status != ECA_NORMAL) {
-                       Param_strerror((Param *) my, ca_message(status));
-                       retVal = -1;
-               }
-       }
-
-       if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               retVal = -1;
-       }
-
-       free(pPVName);
-
-       if((status = ca_task_exit()) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-       }
-
-       return retVal;
-}
-
-int Param_storeString(const Param *my, const char *name, const char *idx, const char *value)
-{
-       int retVal = 0;
-       int status;
-       int found = 1;
-       chid chan;
-       char *pPVName;
-
-       if((status = ca_task_initialize()) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               retVal = -1;
-       }
-
-       pPVName = malloc((strlen("HAD:PS:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
-       Param_returnPVName(my, "PS", name, idx, pPVName);
-
-       if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
-               Param_strerror((Param *) my, ca_message(status));
-               found = 0;
-       } else if (status != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               retVal = -1;
-               found = -1;
-       }
-
-       if((status = ca_pend_io(TIMEOUT)) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               found = 0;
-               retVal = 0;
-       }
-       if(found == 1) {
-               status = ca_put(DBR_STRING, chan, value);
-               Param_strerror((Param *) my, ca_message(status));
-
-               if((status = ca_pend_event(TIMEOUT)) == ECA_TIMEOUT) {
-                       Param_strerror((Param *) my, ca_message(status));
-               } else if (status != ECA_NORMAL) {
-                       Param_strerror((Param *) my, ca_message(status));
-                       retVal = -1;
-               }
-       }
-
-       if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-               retVal = -1;
-       }
-
-       free(pPVName);
-
-       if((status = ca_task_exit()) != ECA_NORMAL) {
-               Param_strerror((Param *) my, ca_message(status));
-       }
-
-       return retVal;
-}
-
-const char *Param_getErrStr(const Param *my)
-{
-       return my->strerror;
-}
-
-static void Param_copyToAllocMem(struct event_handler_args args)
-{
-       int i;
-       ParamResult *result = args.usr;
-       dbr_string_t *buffer = (dbr_string_t *) args.dbr;
-       
-       *(result->rows) = (args.count > result->maxrows) ?
-               result->maxrows :
-               args.count;
-       if(args.type == DBR_STRING && args.status == ECA_NORMAL) {
-               for(i = 0 ; i < *(result->rows) ; i++) {
-                       strcpy((result->val)[i], buffer[i]);
-               }
-       } else {
-               Param_strerror((Param *) result->my, ca_message(args.status));
-               *(result->rows) = 0;
-               *(result->retVal) = -1;
-       }
-}
-
-static void Param_returnPVName(const Param *my, const char *get_store, const char *name, const char *idx, char *pPVName)
-{
-       int i;
-
-       if (my->setup == NULL) {
-               sprintf(pPVName ,"HAD:%s:%s:%s", get_store, name, idx);
-       } else {
-               sprintf(pPVName ,"HAD:%s:%s:%s:%s", get_store, my->setup, name, idx);
-       }
-       for (i = 0 ; i < strlen(pPVName) ; i++) {
-               pPVName[i] = toupper(pPVName[i]);
-       }
-}
-
-static void Param_strerror(Param *my, const char *strerror)
-{
-       my->strerror = realloc(my->strerror, strlen(strerror) + 1);
-       if(my->strerror != NULL) {
-               strcpy(my->strerror, strerror);
-       }
-}
-
diff --git a/allParam/ca/client/Makefile b/allParam/ca/client/Makefile
new file mode 100644 (file)
index 0000000..8b77380
--- /dev/null
@@ -0,0 +1,21 @@
+CFLAGS = -g -ansi -Wall -I$(EPICS_BASE)/include \
+  -I$(EPICS_BASE)/include/os/$(HOST_ARCH) -I../../include
+ARFLAGS = -rc
+
+libcaParam.a : caParam.o
+       $(AR) $(ARFLAGS) $@ $<
+
+caParam.o : caParam.c
+
+install : libcaParam.a
+       -mkdir -p $(LIBDIR)
+       cp $< $(LIBDIR)
+       -mkdir -p $(INCDIR)
+       cp ../../include/allParam.h $(INCDIR)
+
+clean :
+       rm -f *.o
+
+lib_clean :
+       rm -f *.o *.a
+
diff --git a/allParam/ca/client/caParam.c b/allParam/ca/client/caParam.c
new file mode 100644 (file)
index 0000000..3fc598f
--- /dev/null
@@ -0,0 +1,535 @@
+#define _POSIX_C_SOURCE 199509L
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <cadef.h>
+
+#include <allParam.h>
+
+#define TIMEOUT 0.2
+
+static void Param_copyStringsToAllocMem(struct event_handler_args args);
+static void Param_copyIntsToAllocMem(struct event_handler_args args);
+static void Param_copyBlobToAllocMem(struct event_handler_args args);
+static void Param_returnPVName(const Param *my, const char *, const char *, const char *, char *);
+static void Param_strerror(Param *, const char *);
+
+typedef struct ParamStringResultS {
+       char **val;
+       int *rows;
+       int maxrows;
+       const Param *my;
+       int *retVal;
+} ParamStringResult;
+
+typedef struct ParamIntResultS {
+       unsigned long int *val;
+       int *rows;
+       int maxrows;
+       const Param *my;
+       int *retVal;
+} ParamIntResult;
+
+typedef struct ParamBlobResultS {
+       FILE *val;
+       size_t *size;
+       size_t maxsize;
+       const Param *my;
+       int *retVal;
+} ParamBlobResult;
+
+int conSetupParam(Param *my, const char *setup)
+{
+       my->strerror = NULL;
+       if(setup != NULL) {
+               my->setup = malloc(strlen(setup) + 1);
+               strcpy(my->setup, setup);
+       } else {
+               my->setup = NULL;
+       }
+       return 0;
+}
+
+int conParam(Param *my)
+{
+       return conSetupParam(my, NULL);
+}
+
+void desParam(Param *my)
+{
+       if(my->setup != NULL) {
+               free(my->setup);
+       }
+}
+
+int Param_getInt(const Param *my, const char *name, const char *idx, int *row, unsigned long int *val)
+{
+       return Param_getIntArray(my, name, idx, 1, row, val);
+}
+
+int Param_getString(const Param *my, const char *name, const char *idx, int *row, char *val)
+{
+       return Param_getStringArray(my, name, idx, 1, row, &val);
+}
+
+int Param_getFilename(const Param *my, const char *name, const char *idx, int *row, char *val)
+{
+       return Param_getFilenameArray(my, name, idx, 1, row, &val);
+}
+
+int Param_getIntArray(const Param *my, const char *name, const char *idx, int maxrows, int *rows, unsigned long int *val)
+{
+       int retVal = 0;
+       int status;
+       int found = 1;
+       chid chan;
+       char *pPVName;
+
+       *rows = 0;
+       if((status = ca_task_initialize()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       pPVName = malloc((strlen("HAD:PI:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
+       Param_returnPVName(my, "PI", name, idx, pPVName);
+
+       if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+       } else if (status != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+               found = -1;
+       }
+
+       if((status = ca_pend_io(TIMEOUT)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+               retVal = 0;
+       }
+       if(found == 1) {
+               ParamIntResult resultS, *result = &resultS;
+               result->val = val;
+               result->rows = rows;
+               result->maxrows = maxrows;
+               result->my = my;
+               result->retVal = &retVal;
+
+               status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyIntsToAllocMem, result);
+               Param_strerror((Param *) my, ca_message(status));
+
+               if((status = ca_pend_event(TIMEOUT)) == ECA_TIMEOUT) {
+                       Param_strerror((Param *) my, ca_message(status));
+               } else if (status != ECA_NORMAL) {
+                       Param_strerror((Param *) my, ca_message(status));
+                       retVal = -1;
+               }
+       }
+
+       if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       free(pPVName);
+
+       if((status = ca_task_exit()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+       }
+
+       return retVal;
+}
+
+int Param_getStringArray(const Param *my, const char *name, const char *idx, int maxrows, int *rows, char **val)
+{
+       int retVal = 0;
+       int status;
+       int found = 1;
+       chid chan;
+       char *pPVName;
+
+       *rows = 0;
+       if((status = ca_task_initialize()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       pPVName = malloc((strlen("HAD:PS:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
+       Param_returnPVName(my, "PS", name, idx, pPVName);
+
+       if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+       } else if (status != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+               found = -1;
+       }
+
+       if((status = ca_pend_io(TIMEOUT)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+               retVal = 0;
+       }
+       if(found == 1) {
+               ParamStringResult resultS, *result = &resultS;
+               result->val = val;
+               result->rows = rows;
+               result->maxrows = maxrows;
+               result->my = my;
+               result->retVal = &retVal;
+
+               status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyStringsToAllocMem, result);
+               Param_strerror((Param *) my, ca_message(status));
+
+               if((status = ca_pend_event(TIMEOUT)) == ECA_TIMEOUT) {
+                       Param_strerror((Param *) my, ca_message(status));
+               } else if (status != ECA_NORMAL) {
+                       Param_strerror((Param *) my, ca_message(status));
+                       retVal = -1;
+               }
+       }
+
+       if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       free(pPVName);
+
+       if((status = ca_task_exit()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+       }
+
+       return retVal;
+}
+
+int Param_getFilenameArray(const Param *my, const char *name, const char *idx, int maxrows, int *rows, char **val)
+{
+       int retVal = 0;
+       int status;
+       int found = 1;
+       chid chan;
+       char *pPVName;
+
+       *rows = 0;
+       if((status = ca_task_initialize()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       pPVName = malloc((strlen("HAD:PF:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
+       Param_returnPVName(my, "PF", name, idx, pPVName);
+
+       if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+       } else if (status != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+               found = -1;
+       }
+
+       if((status = ca_pend_io(TIMEOUT)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+               retVal = 0;
+       }
+       if(found == 1) {
+               ParamStringResult resultS, *result = &resultS;
+               result->val = val;
+               result->rows = rows;
+               result->maxrows = maxrows;
+               result->my = my;
+               result->retVal = &retVal;
+
+               status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyStringsToAllocMem, result);
+               Param_strerror((Param *) my, ca_message(status));
+
+               if((status = ca_pend_event(TIMEOUT)) == ECA_TIMEOUT) {
+                       Param_strerror((Param *) my, ca_message(status));
+               } else if (status != ECA_NORMAL) {
+                       Param_strerror((Param *) my, ca_message(status));
+                       retVal = -1;
+               }
+       }
+
+       if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       free(pPVName);
+
+       if((status = ca_task_exit()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+       }
+
+       return retVal;
+}
+
+int Param_getBlob(const Param *my, const char *name, const char *idx, size_t maxsize, size_t *size, FILE *val)
+{
+       int retVal = 0;
+       int status;
+       int found = 1;
+       chid chan;
+       char *pPVName;
+
+       *size = 0;
+       if((status = ca_task_initialize()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       pPVName = malloc((strlen("HAD:PB:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
+       Param_returnPVName(my, "PB", name, idx, pPVName);
+
+       if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+       } else if (status != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+               found = -1;
+       }
+
+       if((status = ca_pend_io(TIMEOUT)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+               retVal = 0;
+       }
+       if(found == 1) {
+               ParamBlobResult resultS, *result = &resultS;
+               result->val = val;
+               result->size = size;
+               result->maxsize = maxsize;
+               result->my = my;
+               result->retVal = &retVal;
+
+               status = ca_array_get_callback(ca_field_type(chan), ca_element_count(chan), chan, Param_copyBlobToAllocMem, result);
+               Param_strerror((Param *) my, ca_message(status));
+
+               if((status = ca_pend_event(TIMEOUT)) == ECA_TIMEOUT) {
+                       Param_strerror((Param *) my, ca_message(status));
+               } else if (status != ECA_NORMAL) {
+                       Param_strerror((Param *) my, ca_message(status));
+                       retVal = -1;
+               }
+       }
+
+       if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       free(pPVName);
+
+       if((status = ca_task_exit()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+       }
+
+       return retVal;
+}
+
+int Param_storeInt(const Param *my, const char *name, const char *idx, unsigned long int value)
+{
+       int retVal = 0;
+       int status;
+       int found = 1;
+       chid chan;
+       char *pPVName;
+
+       if((status = ca_task_initialize()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       pPVName = malloc((strlen("HAD:PI:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
+       Param_returnPVName(my, "PI", name, idx, pPVName);
+
+       if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+       } else if (status != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+               found = -1;
+       }
+
+       if((status = ca_pend_io(TIMEOUT)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+               retVal = 0;
+       }
+       if(found == 1) {
+               status = ca_put(DBR_LONG, chan, &value);
+               Param_strerror((Param *) my, ca_message(status));
+
+               if((status = ca_pend_event(TIMEOUT)) == ECA_TIMEOUT) {
+                       Param_strerror((Param *) my, ca_message(status));
+               } else if (status != ECA_NORMAL) {
+                       Param_strerror((Param *) my, ca_message(status));
+                       retVal = -1;
+               }
+       }
+
+       if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       free(pPVName);
+
+       if((status = ca_task_exit()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+       }
+
+       return retVal;
+}
+
+int Param_storeString(const Param *my, const char *name, const char *idx, const char *value)
+{
+       int retVal = 0;
+       int status;
+       int found = 1;
+       chid chan;
+       char *pPVName;
+
+       if((status = ca_task_initialize()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       pPVName = malloc((strlen("HAD:PS:") + (my->setup == NULL ? 0 : strlen(my->setup) + 1) + strlen(name) + 1 + strlen(idx) + 1) * sizeof(char));
+       Param_returnPVName(my, "PS", name, idx, pPVName);
+
+       if((status = ca_search(pPVName, &chan)) == ECA_GETFAIL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+       } else if (status != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+               found = -1;
+       }
+
+       if((status = ca_pend_io(TIMEOUT)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               found = 0;
+               retVal = 0;
+       }
+       if(found == 1) {
+               status = ca_put(DBR_STRING, chan, value);
+               Param_strerror((Param *) my, ca_message(status));
+
+               if((status = ca_pend_event(TIMEOUT)) == ECA_TIMEOUT) {
+                       Param_strerror((Param *) my, ca_message(status));
+               } else if (status != ECA_NORMAL) {
+                       Param_strerror((Param *) my, ca_message(status));
+                       retVal = -1;
+               }
+       }
+
+       if((status = ca_clear_channel(chan)) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+               retVal = -1;
+       }
+
+       free(pPVName);
+
+       if((status = ca_task_exit()) != ECA_NORMAL) {
+               Param_strerror((Param *) my, ca_message(status));
+       }
+
+       return retVal;
+}
+
+const char *Param_getErrStr(const Param *my)
+{
+       return my->strerror;
+}
+
+static void Param_copyStringsToAllocMem(struct event_handler_args args)
+{
+       int i;
+       ParamStringResult *result = args.usr;
+       dbr_string_t *buffer = (dbr_string_t *) args.dbr;
+       
+       *(result->rows) = (args.count > result->maxrows) ?
+               result->maxrows :
+               args.count;
+       if(args.type == DBR_STRING && args.status == ECA_NORMAL) {
+               for(i = 0 ; i < *(result->rows) ; i++) {
+                       strcpy((result->val)[i], buffer[i]);
+               }
+       } else {
+               Param_strerror((Param *) result->my, ca_message(args.status));
+               *(result->rows) = 0;
+               *(result->retVal) = -1;
+       }
+}
+
+static void Param_copyIntsToAllocMem(struct event_handler_args args)
+{
+       int i;
+       ParamIntResult *result = args.usr;
+       dbr_long_t *buffer = (dbr_long_t *) args.dbr;
+       
+       *(result->rows) = (args.count > result->maxrows) ?
+               result->maxrows :
+               args.count;
+       if(args.type == DBR_LONG && args.status == ECA_NORMAL) {
+               for(i = 0 ; i < *(result->rows) ; i++) {
+                       (result->val)[i] = buffer[i];
+               }
+       } else {
+               Param_strerror((Param *) result->my, ca_message(args.status));
+               *(result->rows) = 0;
+               *(result->retVal) = -1;
+       }
+}
+
+static void Param_copyBlobToAllocMem(struct event_handler_args args)
+{
+       ParamBlobResult *result = args.usr;
+       dbr_long_t *buffer = (dbr_long_t *) args.dbr;
+       
+       *(result->size) = (args.count > result->maxsize) ?
+               result->maxsize :
+               args.count;
+       if(args.type == DBR_LONG && args.status == ECA_NORMAL) {
+               fwrite(buffer, sizeof(dbr_long_t), *(result->size), result->val);
+       } else {
+               Param_strerror((Param *) result->my, ca_message(args.status));
+               *(result->size) = 0;
+               *(result->retVal) = -1;
+       }
+}
+
+static void Param_returnPVName(const Param *my, const char *type, const char *name, const char *idx, char *pPVName)
+{
+       int i;
+
+       if (my->setup == NULL) {
+               sprintf(pPVName ,"HAD:%s:%s:%s", type, name, idx);
+       } else {
+               sprintf(pPVName ,"HAD:%s:%s:%s:%s", type, my->setup, name, idx);
+       }
+       for (i = 0 ; i < strlen(pPVName) ; i++) {
+               pPVName[i] = toupper(pPVName[i]);
+       }
+}
+
+static void Param_strerror(Param *my, const char *strerror)
+{
+       my->strerror = realloc(my->strerror, strlen(strerror) + 1);
+       if(my->strerror != NULL) {
+               strcpy(my->strerror, strerror);
+       }
+}
+
diff --git a/allParam/ca/server/Makefile b/allParam/ca/server/Makefile
new file mode 100644 (file)
index 0000000..2bb7f1d
--- /dev/null
@@ -0,0 +1,81 @@
+##########
+# Macros #
+##########
+
+MV = mv
+
+CXXFLAGS = -g -ansi -Wall -I$(EPICS_BASE)/include \
+  -I$(EPICS_BASE)/include/os/$(HOST_ARCH) -I../../include
+
+LOADLIBES = -L$(EPICS_BASE)/lib/$(HOST_ARCH) -lcas -lgdd -lca -lCom
+
+# Objects
+
+OBJS = record.o paramRecord.o paramGetRecord.o paramStoreRecord.o \
+  paramRecordSet.o paramServer.o
+
+###########
+# Targets #
+###########
+
+daq_file_param_cas : ../../file/libfileParam.a
+       $(MAKE) daq_param_cas "LOADLIBES=-L../../file -lfileParam $(LOADLIBES)"
+       $(MV) daq_param_cas $@
+
+daq_ora_param_cas : ../../ora/liboraParam.a
+       $(MAKE) daq_param_cas \
+         "LOADLIBES=-L../../ora -loraParam -L$(ORACLE_HOME)/lib \
+         -lsql -lclntsh -lcommon -lcore4 -lnlsrtl3 $(LOADLIBES)"
+       $(MV) daq_param_cas $@
+
+daq_psql_param_cas : ../../psql/libpsqlParam.a
+       $(MAKE) daq_param_cas \
+         "LOADLIBES=-L../../psql -lpsqlParam -lpq -lcrypt $(LOADLIBES)"
+       $(MV) daq_param_cas $@
+
+daq_tcl_param_cas : ../../tcl/libtclParam.a
+       $(MAKE) daq_param_cas \
+         "LOADLIBES=-L../../tcl -ltclParam -ltcl -lm -ldl $(LOADLIBES)"
+       $(MV) daq_param_cas $@
+
+daq_param_cas : $(OBJS)
+       $(CXX) $(LDFLAGS) $^ $(LOADLIBES) -o $@
+
+paramServer.o: paramServer.cc paramRecordSet.h \
+  paramRecord.h record.h
+
+paramRecordSet.o: paramRecordSet.cc paramRecordSet.h paramGetRecord.h \
+  paramStoreRecord.h paramRecord.h record.h
+
+record.o : record.cc record.h
+paramRecord.o: paramRecord.cc paramRecord.h record.h
+paramGetRecord.o: paramGetRecord.cc paramGetRecord.h paramRecord.h record.h
+paramStoreRecord.o: paramStoreRecord.cc paramStoreRecord.h paramRecord.h \
+  record.h
+
+# Libraries as sources for the server
+
+../../file/libfileParam.a :
+       cd ../../file ; $(MAKE)
+
+../../ora/liboraParam.a :
+       cd ../../ora ; $(MAKE)
+
+../../psql/libpsqlParam.a :
+       cd ../../psql ; $(MAKE)
+
+../../tcl/libtclParam.a :
+       cd ../../tcl ; $(MAKE)
+
+# Administrative
+
+install :
+       -mkdir -p $(BINDIR)
+       cp daq_*_param_cas $(BINDIR)
+
+clean :
+       rm -f *.o
+
+bin_clean :
+       rm -f *.o daq_*_param_cas
+
index 6d377edf385363bac90584a7c7eca4e2c86cec11..283351d42d8b69a352f11962c6c9a880dfbfb489 100644 (file)
@@ -1,4 +1,5 @@
 CFLAGS = -g -ansi -Wall -I../include
+ARFLAGS = -rc
 
 libfileParam.a : fileParam.o
        $(AR) $(ARFLAGS) $@ $<
@@ -7,9 +8,9 @@ fileParam.o : fileParam.c
 
 install : libfileParam.a
        -mkdir -p $(LIBDIR)
-       install -m 644 $< $(LIBDIR)
+       cp $< $(LIBDIR)
        -mkdir -p $(INCDIR)
-       install -m 644 ../include/allParam.h $(INCDIR)
+       cp ../include/allParam.h $(INCDIR)
 
 clean :
        rm -f *.o
index f691ac9d581647dc51538be9b1cd987cc40775fd..538962f81aaf9aca33d9e7bf7e61e438dfdb0f62 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef ALLPARAM_H
 #define ALLPARAM_H
 
+#ifdef __cplusplus
+extern "C" {
+#include <stdio.h>
+#endif
+#ifdef __cplusplus
+}
+#endif
+
 #define PARAM_MAX_ARRAY_LEN 128
 #define PARAM_MAX_VALUE_LEN 128
 #define PARAM_MAX_NAME_LEN 128
@@ -21,6 +29,7 @@ int Param_getIntArray(const Param *, const char *, const char *, int, int *, uns
 int Param_getStringArray(const Param *, const char *, const char *, int, int *, char **);
 int Param_getFilename(const Param *, const char *, const char *, int *, char *);
 int Param_getFilenameArray(const Param *, const char *, const char *, int, int *, char **);
+int Param_getBlob(const Param *my, const char *, const char *, size_t, size_t *, FILE *);
 
 int Param_storeInt(const Param *, const char *, const char *, unsigned long int);
 int Param_storeString(const Param *, const char *, const char *, const char *);
index 5509062a2c07fab7e5944c7ce67e1349b6e2c7c2..26e857482cb537e718e70ccf8648371badb6b56a 100644 (file)
@@ -1,4 +1,5 @@
 CFLAGS = -g -ansi -Wall -I../include -I$(ORACLE_HOME)/precomp/public/
+ARFLAGS = -rc
 
 ORA_USER = hades/hades@db-hades.gsi.de
 
@@ -24,9 +25,9 @@ oraParam.c : oraParam.pc
 
 install : liboraParam.a
        -mkdir -p $(LIBDIR)
-       install -m 644 $< $(LIBDIR)
+       cp $< $(LIBDIR)
        -mkdir -p $(INCDIR)
-       install -m 644 ../include/allParam.h $(INCDIR)
+       cp ../include/allParam.h $(INCDIR)
 
 clean :
        rm -f *.o oraParam.c oraParam.lis
index 48068df9644d65182b12a87a52f05dbba999f906..27dec61afabdf0f875a47c6a6d01deaf3af37592 100644 (file)
@@ -1,4 +1,5 @@
 CFLAGS = -g -ansi -Wall -I/usr/include/pgsql -I../include
+ARFLAGS = -rc
 
 libpsqlParam.a : psqlParam.o
        $(AR) $(ARFLAGS) $@ $<
@@ -7,9 +8,9 @@ psqlParam.o : psqlParam.c
 
 install : libpsqlParam.a
        -mkdir -p $(LIBDIR)
-       install -m 644 $< $(LIBDIR)
+       cp $< $(LIBDIR)
        -mkdir -p $(INCDIR)
-       install -m 644 ../include/allParam.h $(INCDIR)
+       cp ../include/allParam.h $(INCDIR)
 
 clean :
        rm -f *.o
index 6bb1ccd5be6914276004219bccbeec76499a8abc..fa922295415e6dfd9d908f3e5789815899bc8932 100644 (file)
@@ -1,4 +1,5 @@
 CFLAGS = -g -ansi -Wall -I../include
+ARFLAGS = -rc
 
 libtclParam.a : tclParam.o
        $(AR) $(ARFLAGS) $@ $<
@@ -7,9 +8,9 @@ tclParam.o : tclParam.c
 
 install : libtclParam.a
        -mkdir -p $(LIBDIR)
-       install -m 644 $< $(LIBDIR)
+       cp $< $(LIBDIR)
        -mkdir -p $(INCDIR)
-       install -m 644 ../include/allParam.h $(INCDIR)
+       cp ../include/allParam.h $(INCDIR)
 
 clean :
        rm -f *.o