static const char rcsId[] =
- "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/rpc/rpcParam.c,v 1.2 2004-04-07 08:43:55 muench Exp $";
+ "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/rpc/rpcParam.c,v 1.3 2004-04-07 12:58:28 muench Exp $";
#define _POSIX_C_SOURCE 199509L
#if HAVE_CONFIG_H
{
RpcParam *rpcParam = my->specParam;
- Args args;
- Res res;
+ GetScalarArgs args;
+ GetIntRes res;
args.param = rpcParam->remParam;
args.name = name;
int Param_getString(const Param *my, const char *name, const char *idx,
int *row, char *val)
{
-#if 0
- return Param_getStringArray(my, name, idx, 1, row, &val);
-#endif
+ RpcParam *rpcParam = my->specParam;
+
+ GetScalarArgs args;
+ GetStringRes res;
+
+ args.param = rpcParam->remParam;
+ args.name = name;
+ args.idx = idx;
+ res = *getstring_1(&args, rpcParam->cl);
+ *row = res.rows;
+ strcpy(val, res.value);
+
+ xdr_free(xdr_GetStringRes, &res);
+
+ return res.ret;
}
int Param_getFilename(const Param *my, const char *name, const char *idx,
int *row, char *val)
{
- int retVal = 0;
-#if 0
- int rows = 0;
- char value[PARAM_MAX_VALUE_LEN];
-
- if (((retVal = Param_getString(my, name, idx, &rows, value)) == 0)
- && (rows == 1)) {
- if (value[0] == '/') {
- strcpy(val, value);
- } else {
- strcpy(val, my->basedir);
- strcat(val, value);
- }
- *row = 1;
- } else {
- *row = 0;
- }
-#endif
- return retVal;
+ RpcParam *rpcParam = my->specParam;
+
+ GetScalarArgs args;
+ GetStringRes res;
+
+ args.param = rpcParam->remParam;
+ args.name = name;
+ args.idx = idx;
+ res = *getfilename_1(&args, rpcParam->cl);
+ *row = res.rows;
+ strcpy(val, res.value);
+
+ xdr_free(xdr_GetStringRes, &res);
+
+ return res.ret;
}
int Param_getIntArray(const Param *my, const char *name, const char *idx,
int maxrows, int *rows, unsigned long int *val)
{
- int retVal = 0;
-#if 0
+ RpcParam *rpcParam = my->specParam;
+
+ GetArrayArgs args;
+ GetIntArrayRes res;
+
int i;
- char *endptr;
- char *strval[PARAM_MAX_ARRAY_LEN];
- for (i = 0; i < maxrows; i++) {
- strval[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
- }
- *rows = 0;
- if ((retVal |=
- Param_getStringArray(my, name, idx, maxrows, rows, strval)) == 0) {
- for (i = 0; i < *rows; i++) {
- val[i] = strtoul(strval[i], &endptr, 0);
- if (*endptr != '\0') {
- *rows = 0;
- retVal = -1;
- Param_strerror((Param *) my,
- "Value seems to be no integer.");
- }
- }
- }
- for (i = 0; i < maxrows; i++) {
- free(strval[i]);
+ args.param = rpcParam->remParam;
+ args.name = name;
+ args.idx = idx;
+ args.maxrows = maxrows;
+ res = *getintarray_1(&args, rpcParam->cl);
+ *rows = res.value.value_len;
+
+ for (i = 0; i < res.value.value_len; i++) {
+ val[i] = res.value.value_val[i];
}
-#endif
- return retVal;
+
+ xdr_free(xdr_GetStringRes, &res);
+
+ return res.ret;
}
int Param_getStringArray(const Param *my, const char *name, const char *idx,
int maxrows, int *rows, char **val)
{
- int retVal = 0;
-#if 0
+ RpcParam *rpcParam = my->specParam;
+
+ GetArrayArgs args;
+ GetStringArrayRes res;
+
int i;
- char lname[PARAM_MAX_NAME_LEN];
- char lidx[PARAM_MAX_NAME_LEN];
- for (i = 0; i <= strlen(name); i++) {
- lname[i] = tolower(name[i]);
- }
- for (i = 0; i <= strlen(idx); i++) {
- lidx[i] = tolower(idx[i]);
- }
+ args.param = rpcParam->remParam;
+ args.name = name;
+ args.idx = idx;
+ args.maxrows = maxrows;
+ res = *getstringarray_1(&args, rpcParam->cl);
+ *rows = res.value.value_len;
- *rows = 0;
-#ifdef PTHREADS
- if (0 == pthread_mutex_lock(((TclParam *) (my->specParam))->interpLock)) {
-#endif /* PTHREADS */
- if (Tcl_GetVar2
- (((TclParam *) (my->specParam))->interp, lname, lidx, 0) != 0) {
- strcpy(val[0],
- Tcl_GetVar2(((TclParam *) (my->specParam))->interp,
- lname, lidx, 0));
- *rows = 1;
- } else {
- char index[PARAM_MAX_NAME_LEN];
- for (i = 0; i < maxrows; i++) {
- sprintf(index, "%s%d", lidx, i);
- if (Tcl_GetVar2
- (((TclParam *) (my->specParam))->interp, lname, index,
- 0) != 0) {
- strcpy(val[i],
- Tcl_GetVar2(((TclParam *) (my->specParam))->
- interp, lname, index, 0));
- (*rows)++;
- } else {
- i = maxrows;
- }
- }
- }
-#ifdef PTHREADS
- pthread_mutex_unlock(((TclParam *) (my->specParam))->interpLock);
+ for (i = 0; i < res.value.value_len; i++) {
+ strcpy(val[i], res.value.value_val[i]);
}
-#endif /* PTHREADS */
-#endif
- return retVal;
+
+ xdr_free(xdr_GetStringRes, &res);
+
+ return res.ret;
}
int Param_getFilenameArray(const Param *my, const char *name,
const char *idx, int maxrows, int *rows,
char **val)
{
- int retVal = 0;
-#if 0
+ RpcParam *rpcParam = my->specParam;
+
+ GetArrayArgs args;
+ GetStringArrayRes res;
+
int i;
- char *value[PARAM_MAX_ARRAY_LEN];
- for (i = 0; i < maxrows; i++) {
- value[i] = malloc(PARAM_MAX_VALUE_LEN);
- }
+ args.param = rpcParam->remParam;
+ args.name = name;
+ args.idx = idx;
+ args.maxrows = maxrows;
+ res = *getfilenamearray_1(&args, rpcParam->cl);
+ *rows = res.value.value_len;
- if (((retVal =
- Param_getStringArray(my, name, idx, maxrows, rows, value)) == 0)
- && (*rows > 0)) {
- for (i = 0; i < *rows; i++) {
- if (value[i][0] != '/') {
- strcpy(val[i], my->basedir);
- strcat(val[i], value[i]);
- } else {
- strcpy(val[i], value[i]);
- }
- }
- } else {
- *rows = 0;
+ for (i = 0; i < res.value.value_len; i++) {
+ strcpy(val[i], res.value.value_val[i]);
}
- for (i = 0; i < maxrows; i++) {
- free(value[i]);
- }
+ xdr_free(xdr_GetStringRes, &res);
-#endif
- return retVal;
+ return res.ret;
}
int Param_getBlob(const Param *my, const char *name, const char *idx,
int Param_storeInt(const Param *my, const char *name, const char *idx,
unsigned long int value)
{
-#if 0
- char buf[7 + 2 * PARAM_MAX_NAME_LEN + PARAM_MAX_VALUE_LEN];
- sprintf(buf, "set %s(%s)\t%lu\n", name, idx, value);
- fprintf(((TclParam *) (my->specParam))->store, buf);
- fflush(((TclParam *) (my->specParam))->store);
-#ifdef PTHREADS
- if (0 == pthread_mutex_lock(((TclParam *) (my->specParam))->interpLock)) {
-#endif /* PTHREADS */
- Tcl_Eval(((TclParam *) (my->specParam))->interp, buf);
-#ifdef PTHREADS
- pthread_mutex_unlock(((TclParam *) (my->specParam))->interpLock);
- }
-#endif /* PTHREADS */
-#endif
- return 0;
+ RpcParam *rpcParam = my->specParam;
+
+ StoreIntArgs args;
+ int res;
+
+ args.param = rpcParam->remParam;
+ args.name = name;
+ args.idx = idx;
+ args.value = value;
+ res = *storeint_1(&args, rpcParam->cl);
+
+ return res;
}
int Param_storeString(const Param *my, const char *name, const char *idx,
const char *value)
{
-#if 0
- char buf[7 + 2 * PARAM_MAX_NAME_LEN + PARAM_MAX_VALUE_LEN];
- sprintf(buf, "set %s(%s)\t\"%s\"\n", name, idx, value);
- fprintf(((TclParam *) (my->specParam))->store, buf);
- fflush(((TclParam *) (my->specParam))->store);
-#ifdef PTHREADS
- if (0 == pthread_mutex_lock(((TclParam *) (my->specParam))->interpLock)) {
-#endif /* PTHREADS */
- Tcl_Eval(((TclParam *) (my->specParam))->interp, buf);
-#ifdef PTHREADS
- pthread_mutex_unlock(((TclParam *) (my->specParam))->interpLock);
- }
-#endif /* PTHREADS */
-#endif
- return 0;
+ RpcParam *rpcParam = my->specParam;
+
+ StoreStringArgs args;
+ int res;
+
+ args.param = rpcParam->remParam;
+ args.name = name;
+ args.idx = idx;
+ args.value = value;
+ res = *storestring_1(&args, rpcParam->cl);
+
+ return res;
}
void Param_clearCache(const Param *my)
return arg;
}
-Res *getint_1_svc(Args *args, struct svc_req *svcReq) {
- static Res resS, *res = &resS;
+GetIntRes *getint_1_svc(GetScalarArgs *args, struct svc_req *svcReq) {
+ static GetIntRes res;
Param *p = (Param *)args->param;
- res->ret = Param_getInt(p, args->name, args->idx, &res->rows, &res->value);
+ res.ret = Param_getInt(p, args->name, args->idx, &res.rows, &res.value);
- return res;
+ return &res;
+}
+
+GetStringRes *getstring_1_svc(GetScalarArgs *args, struct svc_req *svcReq) {
+ static GetStringRes res;
+ Param *p = (Param *)args->param;
+
+ xdr_free(xdr_GetStringRes, &res);
+
+ res.value = malloc(PARAM_MAX_VALUE_LEN);
+ res.ret = Param_getString(p, args->name, args->idx, &res.rows, res.value);
+
+ return &res;
+}
+
+GetStringRes *getfilename_1_svc(GetScalarArgs *args, struct svc_req *svcReq) {
+ static GetStringRes res;
+ Param *p = (Param *)args->param;
+
+ xdr_free(xdr_GetStringRes, &res);
+
+ res.value = malloc(PARAM_MAX_VALUE_LEN);
+ res.ret = Param_getFilename(p, args->name, args->idx, &res.rows, res.value);
+
+ return &res;
+}
+
+GetIntArrayRes *getintarray_1_svc(GetArrayArgs *args, struct svc_req *svcReq) {
+ static GetIntArrayRes res;
+ Param *p = (Param *)args->param;
+
+ xdr_free(xdr_GetIntArrayRes, &res);
+
+ res.value.value_val = malloc(args->maxrows * sizeof(unsigned long));
+ res.ret = Param_getIntArray(p, args->name, args->idx, args->maxrows, &res.value.value_len, res.value.value_val);
+
+ return &res;
+}
+
+GetStringArrayRes *getstringarray_1_svc(GetArrayArgs *args, struct svc_req *svcReq) {
+ static GetStringArrayRes res;
+ Param *p = (Param *)args->param;
+
+ int i;
+
+ xdr_free(xdr_GetStringArrayRes, &res);
+
+ res.value.value_val = malloc(args->maxrows * sizeof(char *));
+ for (i = 0; i < args->maxrows; i++) {
+ res.value.value_val[i] = malloc(PARAM_MAX_VALUE_LEN);
+ }
+ res.ret = Param_getStringArray(p, args->name, args->idx, args->maxrows, &res.value.value_len, res.value.value_val);
+
+ return &res;
+}
+
+GetStringArrayRes *getfilenamearray_1_svc(GetArrayArgs *args, struct svc_req *svcReq) {
+ static GetStringArrayRes res;
+ Param *p = (Param *)args->param;
+
+ int i;
+
+ xdr_free(xdr_GetStringArrayRes, &res);
+
+ res.value.value_val = malloc(args->maxrows * sizeof(char *));
+ for (i = 0; i < args->maxrows; i++) {
+ res.value.value_val[i] = malloc(PARAM_MAX_VALUE_LEN);
+ }
+ res.ret = Param_getFilenameArray(p, args->name, args->idx, args->maxrows, &res.value.value_len, res.value.value_val);
+
+ return &res;
+}
+
+int *storeint_1_svc(StoreIntArgs *args, struct svc_req *svcReq) {
+ static int res;
+ Param *p = (Param *)args->param;
+
+ res = Param_storeInt(p, args->name, args->idx, args->value);
+
+ return &res;
+}
+
+int *storestring_1_svc(StoreStringArgs *args, struct svc_req *svcReq) {
+ static int res;
+ Param *p = (Param *)args->param;
+
+ res = Param_storeString(p, args->name, args->idx, args->value);
+
+ return &res;
}