From f80a715b51f29c406885b63e92620deacf427c84 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 10 Mar 2010 16:16:27 +0000 Subject: [PATCH] enable $ expansion for GLOBAL_POSTFIX --- src/arm/gnunet-service-arm.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index e5f97498b..9eb7e7534 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -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"); -- 2.25.1