-#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
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) $@
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 :
--- /dev/null
++------------------------------------------------------------------------------+
+| 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. |
++------------------------------------------------------------------------------+
-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
+++ /dev/null
-#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);
- }
-}
-
--- /dev/null
+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
+
--- /dev/null
+#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);
+ }
+}
+
--- /dev/null
+##########
+# 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
+
CFLAGS = -g -ansi -Wall -I../include
+ARFLAGS = -rc
libfileParam.a : fileParam.o
$(AR) $(ARFLAGS) $@ $<
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
#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
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 *);
CFLAGS = -g -ansi -Wall -I../include -I$(ORACLE_HOME)/precomp/public/
+ARFLAGS = -rc
ORA_USER = hades/hades@db-hades.gsi.de
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
CFLAGS = -g -ansi -Wall -I/usr/include/pgsql -I../include
+ARFLAGS = -rc
libpsqlParam.a : psqlParam.o
$(AR) $(ARFLAGS) $@ $<
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
CFLAGS = -g -ansi -Wall -I../include
+ARFLAGS = -rc
libtclParam.a : tclParam.o
$(AR) $(ARFLAGS) $@ $<
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