]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
test
authorhadaq <hadaq>
Mon, 24 Aug 2009 17:15:00 +0000 (17:15 +0000)
committerhadaq <hadaq>
Mon, 24 Aug 2009 17:15:00 +0000 (17:15 +0000)
allParam/tcl/tclParam.c

index 9042d08affb304efa1a35369905cd65d6d66f0e2..a1b52c8cfede01a94c41efd46708975d3cdb11be 100644 (file)
@@ -1,4 +1,4 @@
-static const char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/tcl/tclParam.c,v 1.33 2005-04-06 14:37:56 hadaq Exp $";
+static const char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/allParam/tcl/tclParam.c,v 1.34 2009-08-24 17:15:00 hadaq Exp $";
 #define _POSIX_C_SOURCE 199509L
 
 #if HAVE_CONFIG_H
@@ -80,6 +80,80 @@ typedef struct TclParamS {
        FILE *store;
 } TclParam;
 
+int conSetupParamOnly(Param * my, const char *setup)
+{
+  /* Open only param file (_p.tcl) and not storage file (_s.tcl). S.Y. */
+
+       int retVal = 0;
+       char *paramFile;
+       int code;
+       int row = 0;
+       int i = 0;
+       struct utsname bufferS, *buffer = &bufferS;
+
+       my->strerror = NULL;
+       my->specParam = malloc(sizeof(TclParam));
+
+#ifdef PTHREADS
+       ((TclParam *) (my->specParam))->interpLock = malloc(sizeof(pthread_mutex_t));
+       pthread_mutex_init(((TclParam *) (my->specParam))->interpLock, NULL);
+#endif                                                 /* PTHREADS */
+
+       if (setup != NULL) {
+               my->setup = malloc(strlen(setup) + 1);
+               strcpy(my->setup, setup);
+       } else {
+               my->setup = NULL;
+       }
+       paramFile = malloc(((my->setup == NULL) ? strlen("default") : strlen(setup)) + strlen("_p.tcl") + 1);
+       sprintf(paramFile, "%s_p.tcl", (my->setup == NULL) ? "default" : setup);
+
+#ifdef PTHREADS
+       if (0 == pthread_mutex_lock(((TclParam *) (my->specParam))->interpLock)) {
+#endif                                                 /* PTHREADS */
+               ((TclParam *) (my->specParam))->interp = Tcl_CreateInterp();
+               code = Tcl_EvalFile(((TclParam *) (my->specParam))->interp, paramFile);
+               if (code != TCL_OK) {
+                       if (*((TclParam *) (my->specParam))->interp->result != 0) {
+                               Param_strerror(my, ((TclParam *) (my->specParam))->interp->result);
+                       } else {
+                               Param_strerror((Param *) my, "Tcl interpreter cannot read file correctly and does not deliver an error string.");
+                       }
+                       retVal = -1;
+               }
+#ifdef PTHREADS
+               pthread_mutex_unlock(((TclParam *) (my->specParam))->interpLock);
+       }
+#endif                                                 /* PTHREADS */
+
+       if (retVal == 0) {
+               my->basedir = malloc(PARAM_MAX_VALUE_LEN);
+               uname(buffer);
+               while (buffer->nodename[i]) {
+                       if (!isalnum(buffer->nodename[i])) {
+                               buffer->nodename[i] = '_';
+                       }
+                       i++;
+               }
+               if (Param_getString(my, buffer->nodename, "basedir", &row, my->basedir)
+                       || (row != 1)) {
+                       if (Param_getString(my, "glob", "basedir", &row, my->basedir)
+                               || (row != 1)) {
+                               strcpy(my->basedir, "");
+                       }
+               }
+               if ((NULL != my->basedir) && strlen(my->basedir)) {
+                       strcat(my->basedir, "/");
+               }
+       } else {
+               my->basedir = NULL;
+       }
+
+       free(paramFile);
+
+       return retVal;
+}
+
 int conSetupParam(Param * my, const char *setup)
 {
        int retVal = 0;