libfileParam_p_a_SOURCES = file/fileParam.c
liboraParam_a_SOURCES = oraParam.c
liboraParam_p_a_SOURCES = oraParam.c
-librpcParam_a_SOURCES = $(srcdir)/rpc/rpcParam.c $(srcdir)/rpc/rpcParam_clnt.c $(srcdir)/rpc/rpcParam_xdr.c
+librpcParam_a_SOURCES = $(srcdir)/rpc/rpcParam.c $(srcdir)/rpc/pcache.c $(srcdir)/rpc/rpcParam_clnt.c $(srcdir)/rpc/rpcParam_xdr.c
librpcParam_p_a_SOURCES = $(srcdir)/rpc/rpcParam.c $(srcdir)/rpc/rpcParam_clnt.c $(srcdir)/rpc/rpcParam_xdr.c
libtclParam_a_SOURCES = tcl/tclParam.c
libtclParam_p_a_SOURCES = tcl/tclParam.c
libfileParam_p_a_SOURCES = file/fileParam.c
liboraParam_a_SOURCES = oraParam.c
liboraParam_p_a_SOURCES = oraParam.c
-librpcParam_a_SOURCES = $(srcdir)/rpc/rpcParam.c $(srcdir)/rpc/rpcParam_clnt.c $(srcdir)/rpc/rpcParam_xdr.c
+librpcParam_a_SOURCES = $(srcdir)/rpc/rpcParam.c $(srcdir)/rpc/pcache.c $(srcdir)/rpc/rpcParam_clnt.c $(srcdir)/rpc/rpcParam_xdr.c
librpcParam_p_a_SOURCES = $(srcdir)/rpc/rpcParam.c $(srcdir)/rpc/rpcParam_clnt.c $(srcdir)/rpc/rpcParam_xdr.c
libtclParam_a_SOURCES = tcl/tclParam.c
libtclParam_p_a_SOURCES = tcl/tclParam.c
librpcParam_a_AR = $(AR) cru
librpcParam_a_LIBADD =
am_librpcParam_a_OBJECTS = librpcParam_a-rpcParam.$(OBJEXT) \
+ librpcParam_a-pcache.$(OBJEXT) \
librpcParam_a-rpcParam_clnt.$(OBJEXT) \
librpcParam_a-rpcParam_xdr.$(OBJEXT)
librpcParam_a_OBJECTS = $(am_librpcParam_a_OBJECTS)
@AMDEP_TRUE@ ./$(DEPDIR)/libfileParam_p_a-fileParam.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/liboraParam_a-oraParam.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/liboraParam_p_a-oraParam.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/librpcParam_a-pcache.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/librpcParam_a-rpcParam.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/librpcParam_a-rpcParam_clnt.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/librpcParam_a-rpcParam_xdr.Po \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfileParam_p_a-fileParam.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liboraParam_a-oraParam.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liboraParam_p_a-oraParam.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librpcParam_a-pcache.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librpcParam_a-rpcParam.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librpcParam_a-rpcParam_clnt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librpcParam_a-rpcParam_xdr.Po@am__quote@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librpcParam_a_CFLAGS) $(CFLAGS) -c -o librpcParam_a-rpcParam.obj `if test -f '$(srcdir)/rpc/rpcParam.c'; then $(CYGPATH_W) '$(srcdir)/rpc/rpcParam.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/rpc/rpcParam.c'; fi`
+librpcParam_a-pcache.o: $(srcdir)/rpc/pcache.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librpcParam_a_CFLAGS) $(CFLAGS) -MT librpcParam_a-pcache.o -MD -MP -MF "$(DEPDIR)/librpcParam_a-pcache.Tpo" \
+@am__fastdepCC_TRUE@ -c -o librpcParam_a-pcache.o `test -f '$(srcdir)/rpc/pcache.c' || echo '$(srcdir)/'`$(srcdir)/rpc/pcache.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/librpcParam_a-pcache.Tpo" "$(DEPDIR)/librpcParam_a-pcache.Po"; \
+@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/librpcParam_a-pcache.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/rpc/pcache.c' object='librpcParam_a-pcache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/librpcParam_a-pcache.Po' tmpdepfile='$(DEPDIR)/librpcParam_a-pcache.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librpcParam_a_CFLAGS) $(CFLAGS) -c -o librpcParam_a-pcache.o `test -f '$(srcdir)/rpc/pcache.c' || echo '$(srcdir)/'`$(srcdir)/rpc/pcache.c
+
+librpcParam_a-pcache.obj: $(srcdir)/rpc/pcache.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librpcParam_a_CFLAGS) $(CFLAGS) -MT librpcParam_a-pcache.obj -MD -MP -MF "$(DEPDIR)/librpcParam_a-pcache.Tpo" \
+@am__fastdepCC_TRUE@ -c -o librpcParam_a-pcache.obj `if test -f '$(srcdir)/rpc/pcache.c'; then $(CYGPATH_W) '$(srcdir)/rpc/pcache.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/rpc/pcache.c'; fi`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/librpcParam_a-pcache.Tpo" "$(DEPDIR)/librpcParam_a-pcache.Po"; \
+@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/librpcParam_a-pcache.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/rpc/pcache.c' object='librpcParam_a-pcache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/librpcParam_a-pcache.Po' tmpdepfile='$(DEPDIR)/librpcParam_a-pcache.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librpcParam_a_CFLAGS) $(CFLAGS) -c -o librpcParam_a-pcache.obj `if test -f '$(srcdir)/rpc/pcache.c'; then $(CYGPATH_W) '$(srcdir)/rpc/pcache.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/rpc/pcache.c'; fi`
+
librpcParam_a-rpcParam_clnt.o: $(srcdir)/rpc/rpcParam_clnt.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librpcParam_a_CFLAGS) $(CFLAGS) -MT librpcParam_a-rpcParam_clnt.o -MD -MP -MF "$(DEPDIR)/librpcParam_a-rpcParam_clnt.Tpo" \
@am__fastdepCC_TRUE@ -c -o librpcParam_a-rpcParam_clnt.o `test -f '$(srcdir)/rpc/rpcParam_clnt.c' || echo '$(srcdir)/'`$(srcdir)/rpc/rpcParam_clnt.c; \
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+
+#include "pcache.h"
+
+PData *newPInt(const char *name, const char *idx, unsigned long int value) {
+ PData *my = malloc(sizeof(PData));
+
+ my->name = malloc(strlen(name));
+ strcpy(my->name, name);
+
+ my->idx = malloc(strlen(idx));
+ strcpy(my->idx, idx);
+
+ my->type = PInt;
+ my->value.PInt = value;
+
+ return my;
+}
+
+void delPData(PData *my) {
+ if (my != NULL) {
+ switch (my->type) {
+ case PInt:
+ break;
+ }
+ free(my->idx);
+ free(my->name);
+ free(my);
+ }
+}
+
+static int keyCompare(const PData *my, const PData *data) {
+ int retVal;
+
+ retVal = strcmp(my->name, data->name);
+ if (retVal == 0) {
+ retVal = strcmp(my->idx, data->idx);
+ }
+
+ return retVal;
+}
+
+PCache *insert(PCache *my, PData *data) {
+ if (my == NULL) {
+ my = malloc(sizeof(PCache));
+ my->r = NULL;
+ my->l = NULL;
+ my->data = data;
+ } else {
+ switch (keyCompare(my->data, data)) {
+ case 0:
+ delPData(my->data);
+ my->data = data;
+ break;
+ case -1:
+ my->l = insert(my->l, data);
+ break;
+ case 1:
+ my->r = insert(my->r, data);
+ break;
+ }
+ }
+ return my;
+}
+
+PData *find(const PCache *my, const PData *data) {
+ PData *retVal;
+
+ if (my == NULL) {
+ retVal = NULL;
+ } else {
+ switch (keyCompare(my->data, data)) {
+ case 0:
+ retVal = my->data;
+ break;
+ case -1:
+ retVal = find(my->l, data);
+ break;
+ case 1:
+ retVal = find(my->r, data);
+ break;
+ }
+ }
+ return retVal;
+}
+
+int PCache_storeInt(PCache **my, const char *name, const char *idx, unsigned long int value) {
+ *my = insert(*my, newPInt(name, idx, value));
+}
+
+int PCache_getInt(const PCache *my, const char *name, const char *idx, unsigned long int *value) {
+ int retVal;
+ const PData *data;
+
+ data = find(my, newPInt(name, idx, 0));
+ if (data == NULL) {
+ *value = 0;
+ retVal = -1;
+ } else {
+ *value = data->value.PInt;
+ retVal = 0;
+ }
+ return retVal;
+}
--- /dev/null
+#ifndef PCHE_H
+#define PCHE_H
+
+enum PType { PInt, PString, PIntArray, PStringArray };
+struct PDataS {
+ char *name;
+ char *idx;
+ enum PType type;
+ union {
+ unsigned long int PInt;
+ char *PString;
+ unsigned long int *PIntArray;
+ char **PStringArray;
+ } value;
+};
+typedef struct PDataS PData;
+
+struct PCacheS {
+ struct PCacheS *r;
+ struct PCacheS *l;
+ PData *data;
+};
+typedef struct PCacheS PCache;
+
+int PCache_storeInt(PCache **my, const char *name, const char *idx, unsigned long int value);
+int PCache_getInt(const PCache *my, const char *name, const char *idx, unsigned long int *value);
+
+#endif
-static const char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/rpc/rpcParam.c,v 1.6 2004-04-19 12:58:54 muench Exp $";
+static const char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/rpc/rpcParam.c,v 1.7 2004-05-07 11:55:29 muench Exp $";
#define _POSIX_C_SOURCE 199509L
#if HAVE_CONFIG_H
#include "../include/allParam.h"
+#include "pcache.h"
#include "rpcParam.h"
static void Param_strerror(Param *, const char *);
typedef struct RpcParamS {
CLIENT *cl;
unsigned long remParam;
+ PCache *cache;
} RpcParam;
int conSetupParam(Param * my, const char *setup)
}
}
+ rpcParam->cache = NULL;
+
my->specParam = rpcParam;
return retVal;
int Param_getInt(const Param * my, const char *name, const char *idx, int *row, unsigned long int *val)
{
+ int retVal;
RpcParam *rpcParam = my->specParam;
- GetScalarArgs args;
- GetIntRes res;
+ retVal = PCache_getInt(rpcParam->cache, name, idx, val);
+ if (retVal != 0) {
+ GetScalarArgs args;
+ GetIntRes res;
- args.param = rpcParam->remParam;
- args.name = name;
- args.idx = idx;
+ args.param = rpcParam->remParam;
+ args.name = name;
+ args.idx = idx;
- res = *getint_1(&args, rpcParam->cl);
+ res = *getint_1(&args, rpcParam->cl);
- *row = res.rows;
- *val = res.value;
+ *row = res.rows;
+ *val = res.value;
- return res.ret;
+ retVal = res.ret;
+ PCache_storeInt(&rpcParam->cache, name, idx, *val);
+ puts("no cache");
+ } else {
+ puts("cache");
+ }
+ return retVal;
}
int Param_getString(const Param * my, const char *name, const char *idx, int *row, char *val)
param = malloc(sizeof(Param));
conParam(param);
+ retVal = Param_getInt(param, name, idx, &rows, &result);
+ retVal = Param_getInt(param, name, idx, &rows, &result);
retVal = Param_getInt(param, name, idx, &rows, &result);
if ((rows == 1) && (result == 100) && (retVal == 0)) {
myRetVal = 0;