diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-04-25 23:32:22 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-04-25 23:32:22 +0000 |
commit | 6d3a556d04de01db5098a068c76e66983acc777c (patch) | |
tree | 83a5be22b5c959d399238d417c42ffb7f2a0c21c /src/arm/gnunet-service-arm.c | |
parent | 28bc390f3aab1f475d1f44f9e0476acd32e923f8 (diff) | |
download | gnunet-6d3a556d04de01db5098a068c76e66983acc777c.tar.gz gnunet-6d3a556d04de01db5098a068c76e66983acc777c.zip |
Use dollar expansion helper instead of custom code
Diffstat (limited to 'src/arm/gnunet-service-arm.c')
-rw-r--r-- | src/arm/gnunet-service-arm.c | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index 189e1872c..4aec7b4e6 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c | |||
@@ -415,13 +415,8 @@ start_process (struct ServiceList *sl, | |||
415 | { | 415 | { |
416 | char *loprefix; | 416 | char *loprefix; |
417 | char *options; | 417 | char *options; |
418 | char *optpos; | ||
419 | char *optend; | ||
420 | const char *next; | ||
421 | int use_debug; | 418 | int use_debug; |
422 | int is_simple_service; | 419 | int is_simple_service; |
423 | char b; | ||
424 | char *val; | ||
425 | struct ServiceListeningInfo *sli; | 420 | struct ServiceListeningInfo *sli; |
426 | SOCKTYPE *lsocks; | 421 | SOCKTYPE *lsocks; |
427 | unsigned int ls; | 422 | unsigned int ls; |
@@ -456,42 +451,21 @@ start_process (struct ServiceList *sl, | |||
456 | GNUNET_CONFIGURATION_get_value_string (cfg, sl->name, "OPTIONS", | 451 | GNUNET_CONFIGURATION_get_value_string (cfg, sl->name, "OPTIONS", |
457 | &options)) | 452 | &options)) |
458 | { | 453 | { |
454 | char *new_options; | ||
455 | char *optpos; | ||
459 | options = GNUNET_strdup (final_option); | 456 | options = GNUNET_strdup (final_option); |
460 | if (NULL == strstr (options, "%")) | 457 | /* replace '{}' with service name */ |
461 | { | 458 | while (NULL != (optpos = strstr (options, "{}"))) |
462 | /* replace '{}' with service name */ | 459 | { |
463 | while (NULL != (optpos = strstr (options, "{}"))) | 460 | /* terminate string at opening parenthesis */ |
464 | { | 461 | *optpos = 0; |
465 | char *new_options; | 462 | GNUNET_asprintf (&new_options, "%s%s%s", options, sl->name, optpos + 2); |
466 | /* terminate string at opening parenthesis */ | 463 | GNUNET_free (options); |
467 | *optpos = 0; | 464 | options = new_options; |
468 | GNUNET_asprintf (&new_options, "%s%s%s", options, sl->name, optpos + 2); | 465 | } |
469 | GNUNET_free (options); | 466 | new_options = GNUNET_CONFIGURATION_expand_dollar (cfg, options); |
470 | options = new_options; | 467 | GNUNET_free (options); |
471 | } | 468 | options = new_options; |
472 | /* replace '$PATH' with value associated with "PATH" */ | ||
473 | while (NULL != (optpos = strstr (options, "$"))) | ||
474 | { | ||
475 | optend = optpos + 1; | ||
476 | while (isupper ((unsigned char) *optend)) | ||
477 | optend++; | ||
478 | b = *optend; | ||
479 | if ('\0' == b) | ||
480 | next = ""; | ||
481 | else | ||
482 | next = optend + 1; | ||
483 | *optend = '\0'; | ||
484 | if (GNUNET_OK != | ||
485 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", | ||
486 | optpos + 1, &val)) | ||
487 | val = GNUNET_strdup (""); | ||
488 | *optpos = '\0'; | ||
489 | GNUNET_asprintf (&optpos, "%s%s%c%s", options, val, b, next); | ||
490 | GNUNET_free (options); | ||
491 | GNUNET_free (val); | ||
492 | options = optpos; | ||
493 | } | ||
494 | } | ||
495 | } | 469 | } |
496 | use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG"); | 470 | use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG"); |
497 | 471 | ||