improving script
[oweals/gnunet.git] / src / arm / gnunet-service-arm.c
index c9736982fee8627e6252e55b7f423ad6371bb1a1..4417a68a0630e29a4ce4bd503a316b5715f2f830 100644 (file)
@@ -257,9 +257,11 @@ static void
 start_process (struct ServiceList *sl)
 {
   char *loprefix;
+  char *options;
   char **argv;
   unsigned int argv_size;
   char *lopos;
+  char *optpos;
   const char *firstarg;
   int use_debug;
 
@@ -268,6 +270,10 @@ start_process (struct ServiceList *sl)
       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))
+    options = GNUNET_strdup ("");
   use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG");
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting service `%s'\n"), sl->name);
@@ -276,7 +282,7 @@ start_process (struct ServiceList *sl)
               "Starting service `%s' using binary `%s' and configuration `%s'\n",
               sl->name, sl->binary, sl->config);
 #endif
-  argv_size = 5;
+  argv_size = 6;
   if (use_debug)
     argv_size += 2;
   lopos = loprefix;
@@ -286,10 +292,18 @@ start_process (struct ServiceList *sl)
         argv_size++;
       lopos++;
     }
+  optpos = options;
+  while ('\0' != *optpos)
+    {
+      if (*optpos == ' ')
+        argv_size++;
+      optpos++;
+    }
   firstarg = NULL;
   argv = GNUNET_malloc (argv_size * sizeof (char *));
   argv_size = 0;
   lopos = loprefix;
+
   while ('\0' != *lopos)
     {
       while (*lopos == ' ')
@@ -316,10 +330,26 @@ start_process (struct ServiceList *sl)
       argv[argv_size++] = "-L";
       argv[argv_size++] = "DEBUG";
     }
+  optpos = options;
+  while ('\0' != *optpos)
+    {
+      while (*optpos == ' ')
+        optpos++;
+      if (*optpos == '\0')
+        continue;
+      argv[argv_size++] = optpos;
+      while (('\0' != *optpos) && (' ' != *optpos))
+        optpos++;
+      if ('\0' == *optpos)
+        continue;
+      *optpos = '\0';
+      optpos++;
+    }
   argv[argv_size++] = NULL;
   sl->pid = GNUNET_OS_start_process_v (firstarg, argv);
   GNUNET_free (argv);
   GNUNET_free (loprefix);
+  GNUNET_free (options);
 }
 
 
@@ -370,8 +400,6 @@ start_service (struct GNUNET_SERVER_Client *client, const char *servicename)
       GNUNET_free (config);
       return;
     }
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              _("Preparing to start `%s'\n"), servicename);
   sl = GNUNET_malloc (sizeof (struct ServiceList));
   sl->name = GNUNET_strdup (servicename);
   sl->next = running;