use c99
[oweals/gnunet.git] / src / arm / gnunet-service-arm.c
index 152a358fc3550a032ef9786186181bfc52d772e7..0ccffa27ba03cde8a254929c1b64ec64c3513acd 100644 (file)
@@ -444,39 +444,69 @@ start_process (struct ServiceList *sl,
 
   /* obtain configuration */
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg, sl->name, "PREFIX",
-                                            &loprefix))
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             sl->name,
+                                             "PREFIX",
+                                             &loprefix))
     loprefix = GNUNET_strdup (prefix_command);
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg, sl->name, "OPTIONS",
-                                            &options))
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             sl->name,
+                                             "OPTIONS",
+                                             &options))
+    options = NULL;
+
+  {
+    char *new_options;
+    char *optpos;
+    char *fin_options;
+
+    fin_options = GNUNET_strdup (final_option);
+    /* replace '{}' with service name */
+    while (NULL != (optpos = strstr (fin_options, "{}")))
+      {
+        /* terminate string at opening parenthesis */
+        *optpos = 0;
+        GNUNET_asprintf (&new_options,
+                         "%s%s%s",
+                         fin_options,
+                         sl->name,
+                         optpos + 2);
+        GNUNET_free (fin_options);
+        fin_options = new_options;
+      }
+    if (NULL != options)
     {
-      char *new_options;
-      char *optpos;
-      options = GNUNET_strdup (final_option);
-      /* replace '{}' with service name */
-      while (NULL != (optpos = strstr (options, "{}")))
-        {
-          /* terminate string at opening parenthesis */
-          *optpos = 0;
-          GNUNET_asprintf (&new_options, "%s%s%s", options, sl->name, optpos + 2);
-          GNUNET_free (options);
-          options = new_options;
-        }
-      options = GNUNET_CONFIGURATION_expand_dollar (cfg, options);
+      /* combine "fin_options" with "options" */
+      optpos = options;
+      GNUNET_asprintf (&options,
+                       "%s %s",
+                       fin_options,
+                       optpos);
+      GNUNET_free (optpos);
     }
-  use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG");
-
+    else
+    {
+      /* only have "fin_options", use that */
+      options = fin_options;
+    }
+  }
+  options = GNUNET_CONFIGURATION_expand_dollar (cfg,
+                                                options);
+  use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                    sl->name,
+                                                    "DEBUG");
   {
     const char *service_type = NULL;
     const char *choices[] = { "GNUNET", "SIMPLE", NULL };
+
     is_simple_service = GNUNET_NO;
     if ( (GNUNET_OK ==
-            GNUNET_CONFIGURATION_get_value_choice (cfg,
-                                                   sl->name,
-                                                   "TYPE",
-                                                   choices,
-                                                   &service_type)) &&
+          GNUNET_CONFIGURATION_get_value_choice (cfg,
+                                                 sl->name,
+                                                 "TYPE",
+                                                 choices,
+                                                 &service_type)) &&
          (0 == strcasecmp (service_type, "SIMPLE")) )
       is_simple_service = GNUNET_YES;
   }
@@ -501,8 +531,11 @@ start_process (struct ServiceList *sl,
     sl->proc =
       GNUNET_OS_start_process_s (sl->pipe_control,
                                  GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                 lsocks, loprefix, quotedbinary,
-                                 options, NULL);
+                                 lsocks,
+                                 loprefix,
+                                 quotedbinary,
+                                 options,
+                                 NULL);
   }
   else
   {
@@ -521,15 +554,23 @@ start_process (struct ServiceList *sl,
         sl->proc =
           GNUNET_OS_start_process_s (sl->pipe_control,
                                      GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                     lsocks, loprefix, quotedbinary, "-L",
-                                     "DEBUG", options, NULL);
+                                     lsocks,
+                                     loprefix,
+                                     quotedbinary,
+                                     "-L", "DEBUG",
+                                     options,
+                                     NULL);
       else
         sl->proc =
             GNUNET_OS_start_process_s (sl->pipe_control,
                                        GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                       lsocks, loprefix, quotedbinary, "-c",
-                                       sl->config, "-L",
-                                       "DEBUG", options, NULL);
+                                       lsocks,
+                                       loprefix,
+                                       quotedbinary,
+                                       "-c", sl->config,
+                                       "-L", "DEBUG",
+                                       options,
+                                       NULL);
     }
     else
     {
@@ -537,14 +578,21 @@ start_process (struct ServiceList *sl,
         sl->proc =
             GNUNET_OS_start_process_s (sl->pipe_control,
                                        GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                       lsocks, loprefix, quotedbinary,
-                                       options, NULL);
+                                       lsocks,
+                                       loprefix,
+                                       quotedbinary,
+                                       options,
+                                       NULL);
       else
         sl->proc =
             GNUNET_OS_start_process_s (sl->pipe_control,
                                        GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
-                                       lsocks, loprefix, quotedbinary, "-c",
-                                       sl->config, options, NULL);
+                                       lsocks,
+                                       loprefix,
+                                       quotedbinary,
+                                       "-c", sl->config,
+                                       options,
+                                       NULL);
     }
   }
   GNUNET_free (binary);
@@ -1469,7 +1517,7 @@ setup_service (void *cls,
   if (( (GNUNET_OK !=
         GNUNET_CONFIGURATION_get_value_filename (cfg, section,
                                                   "CONFIG",
-                                                 &config)) &&
+                                                  &config)) &&
        (GNUNET_OK !=
         GNUNET_CONFIGURATION_get_value_filename (cfg,
                                                   "PATHS",
@@ -1495,8 +1543,12 @@ setup_service (void *cls,
 #if WINDOWS
   sl->pipe_control = GNUNET_YES;
 #else
-  if (GNUNET_CONFIGURATION_have_value (cfg, section, "PIPECONTROL"))
-    sl->pipe_control = GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "PIPECONTROL");
+  if (GNUNET_CONFIGURATION_have_value (cfg,
+                                       section,
+                                       "PIPECONTROL"))
+    sl->pipe_control = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                             section,
+                                                             "PIPECONTROL");
 #endif
   GNUNET_CONTAINER_DLL_insert (running_head,
                                running_tail,
@@ -1626,21 +1678,29 @@ run (void *cls, struct GNUNET_SERVER_Handle *serv,
   }
 #endif
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg, "ARM", "GLOBAL_PREFIX",
-                                            &prefix_command))
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "ARM",
+                                             "GLOBAL_PREFIX",
+                                             &prefix_command))
     prefix_command = GNUNET_strdup ("");
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg, "ARM", "GLOBAL_POSTFIX",
-                                            &final_option))
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "ARM",
+                                             "GLOBAL_POSTFIX",
+                                             &final_option))
     final_option = GNUNET_strdup ("");
   if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (cfg, "ARM", "USER_ONLY"))
+      GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                            "ARM",
+                                            "USER_ONLY"))
   {
     GNUNET_break (GNUNET_YES == start_user);
     start_system = GNUNET_NO;
   }
   if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (cfg, "ARM", "SYSTEM_ONLY"))
+      GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                            "ARM",
+                                            "SYSTEM_ONLY"))
   {
     GNUNET_break (GNUNET_YES == start_system);
     start_user = GNUNET_NO;