enable $ expansion for GLOBAL_POSTFIX
authorChristian Grothoff <christian@grothoff.org>
Wed, 10 Mar 2010 16:16:27 +0000 (16:16 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 10 Mar 2010 16:16:27 +0000 (16:16 +0000)
src/arm/gnunet-service-arm.c

index e5f97498b4fc603d13959e3d9d4ae0d81e7de2a7..9eb7e75341ea7f2a298e9b8e1e8192facf08245d 100644 (file)
@@ -357,7 +357,11 @@ start_process (struct ServiceList *sl)
   char *loprefix;
   char *options;
   char *optpos;
+  char *optend;
+  const char *next;
   int use_debug;
+  char b;
+  char *val;
 
   /* start service */
   if (GNUNET_OK !=
@@ -369,9 +373,9 @@ start_process (struct ServiceList *sl)
                                             sl->name, "OPTIONS", &options))
     {      
       options = GNUNET_strdup (final_option);
-      /* replace '{}' with service name */
       if (NULL == strstr (options, "%"))
        {
+         /* replace '{}' with service name */
          while (NULL != (optpos = strstr (options, "{}")))
            {
              optpos[0] = '%';
@@ -382,6 +386,33 @@ start_process (struct ServiceList *sl)
              GNUNET_free (options);
              options = optpos;
            }
+         /* replace '$PATH' with value associated with "PATH" */
+         while (NULL != (optpos = strstr (options, "$")))
+           {
+             optend = optpos + 1;
+             while (isupper (*optend)) optend++;             
+             b = *optend;
+             if ('\0' == b)
+               next = "";
+             else
+               next = optend+1;
+             *optend = '\0';
+             if (GNUNET_OK !=
+                 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS",
+                                                        optpos+1,
+                                                        &val))
+               val = GNUNET_strdup ("");
+             *optpos = '\0';
+             GNUNET_asprintf (&optpos,
+                              "%s%s%c%s",
+                              options,
+                              val,
+                              b,
+                              next);
+             GNUNET_free (options);
+             GNUNET_free (val);
+             options = optpos;
+           }
        }
     }
   use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG");