gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] 01/02: reindenting with clang


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 01/02: reindenting with clang
Date: Thu, 02 May 2019 08:44:55 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit 0c2263e8cd3aec2a92809fa838b08ef0ef4a1388
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu May 2 08:42:33 2019 +0200

    reindenting with clang
---
 src/arm/gnunet-arm.c | 402 +++++++++++++++++++++++++--------------------------
 src/util/program.c   | 201 ++++++++++----------------
 2 files changed, 272 insertions(+), 331 deletions(-)

diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index 80b5ca3e2..5a4acb31a 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
@@ -146,20 +146,21 @@ static struct GNUNET_ARM_Operation *op;
 static void
 delete_files ()
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Will attempt to remove configuration file %s and service 
directory %s\n",
-             config_file,
-             dir);
+  GNUNET_log (
+    GNUNET_ERROR_TYPE_DEBUG,
+    "Will attempt to remove configuration file %s and service directory %s\n",
+    config_file,
+    dir);
   if (0 != UNLINK (config_file))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("Failed to remove configuration file %s\n"),
+                _ ("Failed to remove configuration file %s\n"),
                 config_file);
   }
   if (GNUNET_OK != GNUNET_DISK_directory_remove (dir))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               _("Failed to remove servicehome directory %s\n"),
+                _ ("Failed to remove servicehome directory %s\n"),
                 dir);
   }
 }
@@ -208,7 +209,7 @@ shutdown_task (void *cls)
 
 
 /**
- * Returns a string interpretation of 'rs'
+ * Returns a string interpretation of @a rs
  *
  * @param rs the request status from ARM
  * @return a string interpretation of the request status
@@ -219,16 +220,16 @@ req_string (enum GNUNET_ARM_RequestStatus rs)
   switch (rs)
   {
   case GNUNET_ARM_REQUEST_SENT_OK:
-    return _("Message was sent successfully");
+    return _ ("Message was sent successfully");
   case GNUNET_ARM_REQUEST_DISCONNECTED:
-    return _("We disconnected from ARM before we could send a request");
+    return _ ("We disconnected from ARM before we could send a request");
   }
-  return _("Unknown request status");
+  return _ ("Unknown request status");
 }
 
 
 /**
- * Returns a string interpretation of the 'result'
+ * Returns a string interpretation of the @a result
  *
  * @param result the arm result
  * @return a string interpretation
@@ -239,27 +240,27 @@ ret_string (enum GNUNET_ARM_Result result)
   switch (result)
   {
   case GNUNET_ARM_RESULT_STOPPED:
-    return _("is stopped");
+    return _ ("is stopped");
   case GNUNET_ARM_RESULT_STARTING:
-    return _("is starting");
+    return _ ("is starting");
   case GNUNET_ARM_RESULT_STOPPING:
-    return _("is stopping");
+    return _ ("is stopping");
   case GNUNET_ARM_RESULT_IS_STARTING_ALREADY:
-    return _("is starting already");
+    return _ ("is starting already");
   case GNUNET_ARM_RESULT_IS_STOPPING_ALREADY:
-    return _("is stopping already");
+    return _ ("is stopping already");
   case GNUNET_ARM_RESULT_IS_STARTED_ALREADY:
-    return _("is started already");
+    return _ ("is started already");
   case GNUNET_ARM_RESULT_IS_STOPPED_ALREADY:
-    return _("is stopped already");
+    return _ ("is stopped already");
   case GNUNET_ARM_RESULT_IS_NOT_KNOWN:
-    return _("service is not known to ARM");
+    return _ ("service is not known to ARM");
   case GNUNET_ARM_RESULT_START_FAILED:
-    return _("service failed to start");
+    return _ ("service failed to start");
   case GNUNET_ARM_RESULT_IN_SHUTDOWN:
-    return _("service cannot be manipulated because ARM is shutting down");
+    return _ ("service cannot be manipulated because ARM is shutting down");
   }
-  return _("Unknown result code.");
+  return _ ("Unknown result code.");
 }
 
 
@@ -282,17 +283,15 @@ action_loop (void *cls);
  *                  #GNUNET_SYSERR on error.
  */
 static void
-conn_status (void *cls,
-            int connected)
+conn_status (void *cls, int connected)
 {
   static int once;
 
   (void) cls;
-  if ( (GNUNET_SYSERR == connected) &&
-       (0 == once) )
+  if ((GNUNET_SYSERR == connected) && (0 == once))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("Fatal error initializing ARM API.\n"));
+                _ ("Fatal error initializing ARM API.\n"));
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
@@ -313,30 +312,29 @@ conn_status (void *cls,
  */
 static void
 start_callback (void *cls,
-               enum GNUNET_ARM_RequestStatus rs,
-               enum GNUNET_ARM_Result result)
+                enum GNUNET_ARM_RequestStatus rs,
+                enum GNUNET_ARM_Result result)
 {
   (void) cls;
   op = NULL;
   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
   {
     FPRINTF (stdout,
-             _("Failed to start the ARM service: %s\n"),
+             _ ("Failed to start the ARM service: %s\n"),
              req_string (rs));
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  if ( (GNUNET_ARM_RESULT_STARTING != result) &&
-       (GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result) )
+  if ((GNUNET_ARM_RESULT_STARTING != result) &&
+      (GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result))
   {
     FPRINTF (stdout,
-             _("Failed to start the ARM service: %s\n"),
+             _ ("Failed to start the ARM service: %s\n"),
              ret_string (result));
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "ARM service [re]start successful\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM service [re]start successful\n");
   start = 0;
   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
 }
@@ -355,8 +353,8 @@ start_callback (void *cls,
  */
 static void
 stop_callback (void *cls,
-              enum GNUNET_ARM_RequestStatus rs,
-              enum GNUNET_ARM_Result result)
+               enum GNUNET_ARM_RequestStatus rs,
+               enum GNUNET_ARM_Result result)
 {
   char *msg;
 
@@ -364,8 +362,10 @@ stop_callback (void *cls,
   op = NULL;
   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
   {
-    GNUNET_asprintf (&msg, "%s",
-                    _("Failed to send a stop request to the ARM service: 
%s\n"));
+    GNUNET_asprintf (&msg,
+                     "%s",
+                     _ (
+                       "Failed to send a stop request to the ARM service: 
%s\n"));
     FPRINTF (stdout, msg, req_string (rs));
     GNUNET_free (msg);
     GNUNET_SCHEDULER_shutdown ();
@@ -376,20 +376,18 @@ stop_callback (void *cls,
       (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
   {
     FPRINTF (stdout,
-             _("Failed to stop the ARM service: %s\n"),
+             _ ("Failed to stop the ARM service: %s\n"),
              ret_string (result));
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "ARM service shutdown successful\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM service shutdown successful\n");
   end = 0;
   if (restart)
   {
     restart = 0;
     start = 1;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Initiating an ARM restart\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initiating an ARM restart\n");
   }
   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
 }
@@ -408,15 +406,15 @@ stop_callback (void *cls,
  */
 static void
 init_callback (void *cls,
-              enum GNUNET_ARM_RequestStatus rs,
-              enum GNUNET_ARM_Result result)
+               enum GNUNET_ARM_RequestStatus rs,
+               enum GNUNET_ARM_Result result)
 {
   (void) cls;
   op = NULL;
   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
   {
     FPRINTF (stdout,
-             _("Failed to send a request to start the `%s' service: %s\n"),
+             _ ("Failed to send a request to start the `%s' service: %s\n"),
              init,
              req_string (rs));
     GNUNET_SCHEDULER_shutdown ();
@@ -426,15 +424,15 @@ init_callback (void *cls,
       (GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result))
   {
     FPRINTF (stdout,
-             _("Failed to start the `%s' service: %s\n"),
+             _ ("Failed to start the `%s' service: %s\n"),
              init,
              ret_string (result));
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Service %s [re]started successfully\n",
-             init);
+              "Service %s [re]started successfully\n",
+              init);
   GNUNET_free (init);
   init = NULL;
   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
@@ -454,8 +452,8 @@ init_callback (void *cls,
  */
 static void
 term_callback (void *cls,
-              enum GNUNET_ARM_RequestStatus rs,
-              enum GNUNET_ARM_Result result)
+               enum GNUNET_ARM_RequestStatus rs,
+               enum GNUNET_ARM_Result result)
 {
   char *msg;
 
@@ -464,7 +462,8 @@ term_callback (void *cls,
   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
   {
     GNUNET_asprintf (&msg,
-                     _("Failed to send a request to kill the `%s' service: 
%%s\n"),
+                     _ (
+                       "Failed to send a request to kill the `%s' service: 
%%s\n"),
                      term);
     FPRINTF (stdout, msg, req_string (rs));
     GNUNET_free (msg);
@@ -475,7 +474,7 @@ term_callback (void *cls,
       (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
   {
     FPRINTF (stdout,
-             _("Failed to kill the `%s' service: %s\n"),
+             _ ("Failed to kill the `%s' service: %s\n"),
              term,
              ret_string (result));
     GNUNET_SCHEDULER_shutdown ();
@@ -483,7 +482,7 @@ term_callback (void *cls,
   }
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Service %s stopped successfully\n",
+              "Service %s stopped successfully\n",
               term);
   GNUNET_free (term);
   term = NULL;
@@ -503,20 +502,19 @@ term_callback (void *cls,
  */
 static void
 list_callback (void *cls,
-              enum GNUNET_ARM_RequestStatus rs,
-              unsigned int count,
-              const char *const*list)
+               enum GNUNET_ARM_RequestStatus rs,
+               unsigned int count,
+               const char *const *list)
 {
-  unsigned int i;
-
   (void) cls;
   op = NULL;
   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
   {
     char *msg;
 
-    GNUNET_asprintf (&msg, "%s",
-                    _("Failed to request a list of services: %s\n"));
+    GNUNET_asprintf (&msg,
+                     "%s",
+                     _ ("Failed to request a list of services: %s\n"));
     FPRINTF (stdout, msg, req_string (rs));
     GNUNET_free (msg);
     ret = 3;
@@ -524,15 +522,16 @@ list_callback (void *cls,
   }
   if (NULL == list)
   {
-    FPRINTF (stderr, "%s",
-            _("Error communicating with ARM. ARM not running?\n"));
+    FPRINTF (stderr,
+             "%s",
+             _ ("Error communicating with ARM. ARM not running?\n"));
     GNUNET_SCHEDULER_shutdown ();
     ret = 3;
     return;
   }
   if (! quiet)
-    FPRINTF (stdout, "%s", _("Running services:\n"));
-  for (i = 0; i < count; i++)
+    FPRINTF (stdout, "%s", _ ("Running services:\n"));
+  for (unsigned int i = 0; i < count; i++)
     FPRINTF (stdout, "%s\n", list[i]);
   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
 }
@@ -549,8 +548,7 @@ action_loop (void *cls)
 {
   (void) cls;
   al_task = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Running requested actions\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running requested actions\n");
   while (1)
   {
     switch (phase++)
@@ -558,46 +556,43 @@ action_loop (void *cls)
     case 0:
       if (NULL != term)
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                   "Termination action\n");
-        op = GNUNET_ARM_request_service_stop (h,
-                                              term,
-                                              &term_callback,
-                                              NULL);
-       return;
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Termination action\n");
+        op = GNUNET_ARM_request_service_stop (h, term, &term_callback, NULL);
+        return;
       }
       break;
     case 1:
       if (end || restart)
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                   "End action\n");
-        op = GNUNET_ARM_request_service_stop (h,
-                                              "arm",
-                                              &stop_callback,
-                                              NULL);
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "End action\n");
+        op = GNUNET_ARM_request_service_stop (h, "arm", &stop_callback, NULL);
         return;
       }
       break;
     case 2:
       if (start)
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                   "Start action\n");
-        op = GNUNET_ARM_request_service_start (h, "arm",
-                                               (no_stdout ? 0 : 
GNUNET_OS_INHERIT_STD_OUT) |
-                                               (no_stderr ? 0 : 
GNUNET_OS_INHERIT_STD_ERR),
-                                               &start_callback,
-                                               NULL);
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start action\n");
+        op =
+          GNUNET_ARM_request_service_start (h,
+                                            "arm",
+                                            (no_stdout
+                                               ? 0
+                                               : GNUNET_OS_INHERIT_STD_OUT) |
+                                              (no_stderr
+                                                 ? 0
+                                                 : GNUNET_OS_INHERIT_STD_ERR),
+                                            &start_callback,
+                                            NULL);
         return;
       }
       break;
     case 3:
       if (NULL != init)
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                   "Initialization action\n");
-        op = GNUNET_ARM_request_service_start (h, init,
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initialization action\n");
+        op = GNUNET_ARM_request_service_start (h,
+                                               init,
                                                GNUNET_OS_INHERIT_STD_NONE,
                                                &init_callback,
                                                NULL);
@@ -607,25 +602,23 @@ action_loop (void *cls)
     case 4:
       if (list)
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                   "Going to list all running services controlled by ARM.\n");
-        op = GNUNET_ARM_request_service_list (h,
-                                              &list_callback,
-                                              &list);
-       return;
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "Going to list all running services controlled by ARM.\n");
+        op = GNUNET_ARM_request_service_list (h, &list_callback, &list);
+        return;
       }
       break;
     case 5:
       if (monitor)
-       {
-         if (! quiet)
-           fprintf (stderr,
-                    _("Now only monitoring, press CTRL-C to stop.\n"));
-         quiet = 0; /* does not make sense to stay quiet in monitor mode at 
this time */
-         return; /* done with tasks, just monitor */
-       }
+      {
+        if (! quiet)
+          fprintf (stderr, _ ("Now only monitoring, press CTRL-C to stop.\n"));
+        quiet =
+          0; /* does not make sense to stay quiet in monitor mode at this time 
*/
+        return; /* done with tasks, just monitor */
+      }
       break;
-    default:           /* last phase */
+    default: /* last phase */
       GNUNET_SCHEDULER_shutdown ();
       return;
     }
@@ -642,8 +635,8 @@ action_loop (void *cls)
  */
 static void
 srv_status (void *cls,
-           const char *service,
-           enum GNUNET_ARM_ServiceStatus status)
+            const char *service,
+            enum GNUNET_ARM_ServiceStatus status)
 {
   const char *msg;
 
@@ -653,13 +646,13 @@ srv_status (void *cls,
   case GNUNET_ARM_SERVICE_MONITORING_STARTED:
     return; /* this should be done silently */
   case GNUNET_ARM_SERVICE_STOPPED:
-    msg = _("Stopped %s.\n");
+    msg = _ ("Stopped %s.\n");
     break;
   case GNUNET_ARM_SERVICE_STARTING:
-    msg = _("Starting %s...\n");
+    msg = _ ("Starting %s...\n");
     break;
   case GNUNET_ARM_SERVICE_STOPPING:
-    msg = _("Stopping %s...\n");
+    msg = _ ("Stopping %s...\n");
     break;
   default:
     msg = NULL;
@@ -668,19 +661,17 @@ srv_status (void *cls,
   if (! quiet)
   {
     if (NULL != msg)
-      FPRINTF (stderr,
-               msg,
-               service);
+      FPRINTF (stderr, msg, service);
     else
       FPRINTF (stderr,
-               _("Unknown status %u for service %s.\n"),
+               _ ("Unknown status %u for service %s.\n"),
                status,
                service);
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Got service %s status %d\n",
-              service, (int)
-              status);
+              service,
+              (int) status);
 }
 
 
@@ -716,36 +707,24 @@ run (void *cls,
   (void) cfgfile;
   cfg = GNUNET_CONFIGURATION_dup (c);
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                             "PATHS",
-                                             "GNUNET_HOME",
-                                             &dir))
+      GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "GNUNET_HOME", 
&dir))
   {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                              "PATHS",
-                               "GNUNET_HOME");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "PATHS", 
"GNUNET_HOME");
     return;
   }
   (void) GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                                 "arm",
-                                                 "CONFIG",
-                                                 &config_file);
-  if (NULL == (h = GNUNET_ARM_connect (cfg,
-                                       &conn_status,
-                                       NULL)))
+                                                  "arm",
+                                                  "CONFIG",
+                                                  &config_file);
+  if (NULL == (h = GNUNET_ARM_connect (cfg, &conn_status, NULL)))
     return;
   if (monitor)
-    m = GNUNET_ARM_monitor_start (cfg,
-                                 &srv_status,
-                                 NULL);
-  al_task = GNUNET_SCHEDULER_add_now (&action_loop,
-                                      NULL);
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                 NULL);
+    m = GNUNET_ARM_monitor_start (cfg, &srv_status, NULL);
+  al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
   if (0 != timeout.rel_value_us)
-    timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
-                                                 &timeout_task_cb,
-                                                 NULL);
+    timeout_task =
+      GNUNET_SCHEDULER_add_delayed (timeout, &timeout_task_cb, NULL);
 }
 
 
@@ -757,82 +736,87 @@ run (void *cls,
  * @return 0 ok, 1 on error, 2 on timeout
  */
 int
-main (int argc,
-      char *const *argv)
+main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_flag ('e',
-                              "end",
-                              gettext_noop ("stop all GNUnet services"),
-                              &end),
-    GNUNET_GETOPT_option_string ('i',
-                                 "init",
-                                 "SERVICE",
-                                 gettext_noop ("start a particular service"),
-                                 &init),
-    GNUNET_GETOPT_option_string ('k',
-                                 "kill",
-                                 "SERVICE",
-                                 gettext_noop ("stop a particular service"),
-                                 &term),
-    GNUNET_GETOPT_option_flag ('s',
-                              "start",
-                              gettext_noop ("start all GNUnet default 
services"),
-                              &start),
-    GNUNET_GETOPT_option_flag ('r',
-                              "restart",
-                              gettext_noop ("stop and start all GNUnet default 
services"),
-                              &restart),
-    GNUNET_GETOPT_option_flag ('d',
-                              "delete",
-                              gettext_noop ("delete config file and directory 
on exit"),
-                              &delete),
-    GNUNET_GETOPT_option_flag ('m',
-                              "monitor",
-                              gettext_noop ("monitor ARM activities"),
-                              &monitor),
-    GNUNET_GETOPT_option_flag ('q',
-                              "quiet",
-                              gettext_noop ("don't print status messages"),
-                              &quiet),
-    GNUNET_GETOPT_option_relative_time ('T',
-                                       "timeout",
-                                       "DELAY",
-                                       gettext_noop ("exit with error status 
if operation does not finish after DELAY"),
-                                       &timeout),
-    GNUNET_GETOPT_option_flag ('I',
-                              "info",
-                              gettext_noop ("list currently running services"),
-                              &list), 
-    GNUNET_GETOPT_option_flag ('O',
-                              "no-stdout",
-                              gettext_noop ("don't let gnunet-service-arm 
inherit standard output"),
-                              &no_stdout),
-    GNUNET_GETOPT_option_flag ('E',
-                              "no-stderr",
-                              gettext_noop ("don't let gnunet-service-arm 
inherit standard error"),
-                              &no_stderr),
-    GNUNET_GETOPT_OPTION_END
-  };
-
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_get_utf8_args (argc, argv,
-                                   &argc, &argv))
+  struct GNUNET_GETOPT_CommandLineOption options[] =
+    {GNUNET_GETOPT_option_flag ('e',
+                                "end",
+                                gettext_noop ("stop all GNUnet services"),
+                                &end),
+     GNUNET_GETOPT_option_string ('i',
+                                  "init",
+                                  "SERVICE",
+                                  gettext_noop ("start a particular service"),
+                                  &init),
+     GNUNET_GETOPT_option_string ('k',
+                                  "kill",
+                                  "SERVICE",
+                                  gettext_noop ("stop a particular service"),
+                                  &term),
+     GNUNET_GETOPT_option_flag ('s',
+                                "start",
+                                gettext_noop (
+                                  "start all GNUnet default services"),
+                                &start),
+     GNUNET_GETOPT_option_flag ('r',
+                                "restart",
+                                gettext_noop (
+                                  "stop and start all GNUnet default 
services"),
+                                &restart),
+     GNUNET_GETOPT_option_flag ('d',
+                                "delete",
+                                gettext_noop (
+                                  "delete config file and directory on exit"),
+                                &delete),
+     GNUNET_GETOPT_option_flag ('m',
+                                "monitor",
+                                gettext_noop ("monitor ARM activities"),
+                                &monitor),
+     GNUNET_GETOPT_option_flag ('q',
+                                "quiet",
+                                gettext_noop ("don't print status messages"),
+                                &quiet),
+     GNUNET_GETOPT_option_relative_time (
+       'T',
+       "timeout",
+       "DELAY",
+       gettext_noop (
+         "exit with error status if operation does not finish after DELAY"),
+       &timeout),
+     GNUNET_GETOPT_option_flag ('I',
+                                "info",
+                                gettext_noop (
+                                  "list currently running services"),
+                                &list),
+     GNUNET_GETOPT_option_flag (
+       'O',
+       "no-stdout",
+       gettext_noop ("don't let gnunet-service-arm inherit standard output"),
+       &no_stdout),
+     GNUNET_GETOPT_option_flag (
+       'E',
+       "no-stderr",
+       gettext_noop ("don't let gnunet-service-arm inherit standard error"),
+       &no_stderr),
+     GNUNET_GETOPT_OPTION_END};
+
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
-
   if (GNUNET_OK ==
-      GNUNET_PROGRAM_run (argc,
-                         argv,
-                         "gnunet-arm",
-                         gettext_noop
-                         ("Control services and the Automated Restart Manager 
(ARM)"),
-                         options,
-                         &run, NULL))
+      GNUNET_PROGRAM_run (
+        argc,
+        argv,
+        "gnunet-arm",
+        gettext_noop (
+          "Control services and the Automated Restart Manager (ARM)"),
+        options,
+        &run,
+        NULL))
   {
     GNUNET_free ((void *) argv);
     return ret;
   }
-  GNUNET_free ((void*) argv);
+  GNUNET_free ((void *) argv);
   return 1;
 }
 
diff --git a/src/util/program.c b/src/util/program.c
index f22dcddbf..8a5b1c414 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -31,9 +31,10 @@
 #include "speedup.h"
 #include <gcrypt.h>
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util-program", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "util-program", __VA_ARGS__)
 
-#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file 
(kind, "util-program", syscall, filename)
+#define LOG_STRERROR_FILE(kind, syscall, filename) \
+  GNUNET_log_from_strerror_file (kind, "util-program", syscall, filename)
 
 /**
  * Context for the command.
@@ -64,7 +65,6 @@ struct CommandContext
    * Configuration to use.
    */
   const struct GNUNET_CONFIGURATION_Handle *cfg;
-
 };
 
 
@@ -88,14 +88,10 @@ program_main (void *cls)
 {
   struct CommandContext *cc = cls;
 
-  GNUNET_SPEEDUP_start_(cc->cfg);
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
-                                NULL);
+  GNUNET_SPEEDUP_start_ (cc->cfg);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
   GNUNET_RESOLVER_connect (cc->cfg);
-  cc->task (cc->task_cls,
-           cc->args,
-           cc->cfgfile,
-           cc->cfg);
+  cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg);
 }
 
 
@@ -107,8 +103,7 @@ program_main (void *cls)
  * @param a2 second command line option
  */
 static int
-cmd_sorter (const void *a1,
-           const void *a2)
+cmd_sorter (const void *a1, const void *a2)
 {
   const struct GNUNET_GETOPT_CommandLineOption *c1 = a1;
   const struct GNUNET_GETOPT_CommandLineOption *c2 = a2;
@@ -144,12 +139,12 @@ cmd_sorter (const void *a1,
  */
 int
 GNUNET_PROGRAM_run2 (int argc,
-                    char *const *argv,
-                    const char *binaryName,
+                     char *const *argv,
+                     const char *binaryName,
                      const char *binaryHelp,
                      const struct GNUNET_GETOPT_CommandLineOption *options,
                      GNUNET_PROGRAM_Main task,
-                    void *task_cls,
+                     void *task_cls,
                      int run_without_scheduler)
 {
   struct CommandContext cc;
@@ -166,13 +161,12 @@ GNUNET_PROGRAM_run2 (int argc,
   unsigned long long skew_variance;
   long long clock_offset;
   struct GNUNET_CONFIGURATION_Handle *cfg;
-  struct GNUNET_GETOPT_CommandLineOption defoptions[] = {
-    GNUNET_GETOPT_option_cfgfile (&cc.cfgfile),
-    GNUNET_GETOPT_option_help (binaryHelp),
-    GNUNET_GETOPT_option_loglevel (&loglev),
-    GNUNET_GETOPT_option_logfile (&logfile),
-    GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION)
-  };
+  struct GNUNET_GETOPT_CommandLineOption defoptions[] =
+    {GNUNET_GETOPT_option_cfgfile (&cc.cfgfile),
+     GNUNET_GETOPT_option_help (binaryHelp),
+     GNUNET_GETOPT_option_loglevel (&loglev),
+     GNUNET_GETOPT_option_logfile (&logfile),
+     GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION)};
   struct GNUNET_GETOPT_CommandLineOption *allopts;
   const char *gargs;
   char *lpfx;
@@ -189,26 +183,16 @@ GNUNET_PROGRAM_run2 (int argc,
     gargv = NULL;
     gargc = 0;
     for (int i = 0; i < argc; i++)
-      GNUNET_array_append (gargv,
-                          gargc,
-                          GNUNET_strdup (argv[i]));
+      GNUNET_array_append (gargv, gargc, GNUNET_strdup (argv[i]));
     cargs = GNUNET_strdup (gargs);
-    for (char *tok = strtok (cargs, " ");
-        NULL != tok;
-        tok = strtok (NULL, " "))
-      GNUNET_array_append (gargv,
-                          gargc,
-                          GNUNET_strdup (tok));
+    for (char *tok = strtok (cargs, " "); NULL != tok; tok = strtok (NULL, " 
"))
+      GNUNET_array_append (gargv, gargc, GNUNET_strdup (tok));
     GNUNET_free (cargs);
-    GNUNET_array_append (gargv,
-                        gargc,
-                        NULL);
+    GNUNET_array_append (gargv, gargc, NULL);
     argv = (char *const *) gargv;
     argc = gargc - 1;
   }
-  memset (&cc,
-         0,
-         sizeof (cc));
+  memset (&cc, 0, sizeof (cc));
   loglev = NULL;
   cc.task = task;
   cc.task_cls = task_cls;
@@ -219,8 +203,7 @@ GNUNET_PROGRAM_run2 (int argc,
   path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR);
   if (NULL != path)
   {
-    BINDTEXTDOMAIN ("GNUnet",
-                   path);
+    BINDTEXTDOMAIN ("GNUnet", path);
     GNUNET_free (path);
   }
   textdomain ("GNUnet");
@@ -229,20 +212,17 @@ GNUNET_PROGRAM_run2 (int argc,
   while (NULL != options[cnt].name)
     cnt++;
   allopts =
-      GNUNET_malloc ((cnt +
-                      1) * sizeof (struct GNUNET_GETOPT_CommandLineOption) +
-                     sizeof (defoptions));
-  GNUNET_memcpy (allopts,
-                defoptions,
-                sizeof (defoptions));
-  GNUNET_memcpy (&allopts
-                [sizeof (defoptions) /
-                 sizeof (struct GNUNET_GETOPT_CommandLineOption)], options,
-                (cnt + 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption));
+    GNUNET_malloc ((cnt + 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption) 
+
+                   sizeof (defoptions));
+  GNUNET_memcpy (allopts, defoptions, sizeof (defoptions));
+  GNUNET_memcpy (&allopts[sizeof (defoptions) /
+                          sizeof (struct GNUNET_GETOPT_CommandLineOption)],
+                 options,
+                 (cnt + 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption));
   cnt += sizeof (defoptions) / sizeof (struct GNUNET_GETOPT_CommandLineOption);
   qsort (allopts,
-        cnt,
-        sizeof (struct GNUNET_GETOPT_CommandLineOption),
+         cnt,
+         sizeof (struct GNUNET_GETOPT_CommandLineOption),
          &cmd_sorter);
   loglev = NULL;
   xdg = getenv ("XDG_CONFIG_HOME");
@@ -257,15 +237,9 @@ GNUNET_PROGRAM_run2 (int argc,
   lpfx = GNUNET_strdup (binaryName);
   if (NULL != (spc = strstr (lpfx, " ")))
     *spc = '\0';
-  ret = GNUNET_GETOPT_run (binaryName,
-                          allopts,
-                          (unsigned int) argc,
-                          argv);
+  ret = GNUNET_GETOPT_run (binaryName, allopts, (unsigned int) argc, argv);
   if ((GNUNET_OK > ret) ||
-      (GNUNET_OK !=
-       GNUNET_log_setup (lpfx,
-                        loglev,
-                        logfile)))
+      (GNUNET_OK != GNUNET_log_setup (lpfx, loglev, logfile)))
   {
     GNUNET_free (allopts);
     GNUNET_free (lpfx);
@@ -273,15 +247,13 @@ GNUNET_PROGRAM_run2 (int argc,
   }
   if (NULL != cc.cfgfile)
   {
-    if ( (GNUNET_YES !=
-         GNUNET_DISK_file_test (cc.cfgfile)) ||
-        (GNUNET_SYSERR ==
-         GNUNET_CONFIGURATION_load (cfg,
-                                    cc.cfgfile)) ) 
+    if ((GNUNET_YES != GNUNET_DISK_file_test (cc.cfgfile)) ||
+        (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cc.cfgfile)))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 _("Unreadable or malformed configuration file `%s', exit 
...\n"),
-                 cc.cfgfile);
+                  _ (
+                    "Unreadable or malformed configuration file `%s', exit 
...\n"),
+                  cc.cfgfile);
       ret = GNUNET_SYSERR;
       GNUNET_free (allopts);
       GNUNET_free (lpfx);
@@ -290,51 +262,46 @@ GNUNET_PROGRAM_run2 (int argc,
   }
   else
   {
-    if (GNUNET_YES ==
-       GNUNET_DISK_file_test (cfg_fn))
+    if (GNUNET_YES == GNUNET_DISK_file_test (cfg_fn))
     {
-      if (GNUNET_SYSERR ==
-         GNUNET_CONFIGURATION_load (cfg,
-                                    cfg_fn))
+      if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfg_fn))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Unreadable or malformed default configuration file `%s', 
exit ...\n"),
-                   cfg_fn);
-       ret = GNUNET_SYSERR;
-       GNUNET_free (allopts);
-       GNUNET_free (lpfx);
-       goto cleanup;
+        GNUNET_log (
+          GNUNET_ERROR_TYPE_ERROR,
+          _ (
+            "Unreadable or malformed default configuration file `%s', exit 
...\n"),
+          cfg_fn);
+        ret = GNUNET_SYSERR;
+        GNUNET_free (allopts);
+        GNUNET_free (lpfx);
+        goto cleanup;
       }
     }
     else
     {
       GNUNET_free (cfg_fn);
       cfg_fn = NULL;
-      if (GNUNET_OK !=
-         GNUNET_CONFIGURATION_load (cfg,
-                                    NULL))
+      if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, NULL))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Unreadable or malformed configuration, exit ...\n"));
-       ret = GNUNET_SYSERR;
-       GNUNET_free (allopts);
-       GNUNET_free (lpfx);
-       goto cleanup;
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    _ ("Unreadable or malformed configuration, exit ...\n"));
+        ret = GNUNET_SYSERR;
+        GNUNET_free (allopts);
+        GNUNET_free (lpfx);
+        goto cleanup;
       }
     }
   }
   GNUNET_free (allopts);
   GNUNET_free (lpfx);
-  if (GNUNET_OK ==
-      GNUNET_CONFIGURATION_get_value_number (cc.cfg,
-                                            "testing",
-                                            "skew_offset",
-                                             &skew_offset) &&
-      (GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_number (cc.cfg,
-                                             "testing",
-                                              "skew_variance",
-                                             &skew_variance)))
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cc.cfg,
+                                                          "testing",
+                                                          "skew_offset",
+                                                          &skew_offset) &&
+      (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cc.cfg,
+                                                           "testing",
+                                                           "skew_variance",
+                                                           &skew_variance)))
   {
     clock_offset = skew_offset - skew_variance;
     GNUNET_TIME_set_offset (clock_offset);
@@ -345,43 +312,29 @@ GNUNET_PROGRAM_run2 (int argc,
      in "cfg".  This is typically really only having an effect if we
      are running code in src/arm/, as obviously the rest of the code
      has little business with ARM-specific options. */
-  if (GNUNET_YES !=
-      GNUNET_CONFIGURATION_have_value (cfg,
-                                      "arm",
-                                      "CONFIG"))
+  if (GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, "arm", "CONFIG"))
   {
     if (NULL != cc.cfgfile)
-      GNUNET_CONFIGURATION_set_value_string (cfg,
-                                            "arm",
-                                            "CONFIG",
-                                            cc.cfgfile);
+      GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", cc.cfgfile);
     else if (NULL != cfg_fn)
-      GNUNET_CONFIGURATION_set_value_string (cfg,
-                                            "arm",
-                                            "CONFIG",
-                                            cfg_fn);
+      GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", cfg_fn);
   }
 
   /* run */
   cc.args = &argv[ret];
-  if ( (NULL == cc.cfgfile) &&
-       (NULL != cfg_fn) )
+  if ((NULL == cc.cfgfile) && (NULL != cfg_fn))
     cc.cfgfile = GNUNET_strdup (cfg_fn);
   if (GNUNET_NO == run_without_scheduler)
   {
-    GNUNET_SCHEDULER_run (&program_main,
-                         &cc);
+    GNUNET_SCHEDULER_run (&program_main, &cc);
   }
   else
   {
     GNUNET_RESOLVER_connect (cc.cfg);
-    cc.task (cc.task_cls,
-            cc.args,
-            cc.cfgfile,
-            cc.cfg);
+    cc.task (cc.task_cls, cc.args, cc.cfgfile, cc.cfg);
   }
   ret = GNUNET_OK;
- cleanup:
+cleanup:
   GNUNET_CONFIGURATION_destroy (cfg);
   GNUNET_free_non_null (cc.cfgfile);
   GNUNET_free_non_null (cfg_fn);
@@ -405,17 +358,21 @@ GNUNET_PROGRAM_run2 (int argc,
  * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
  */
 int
-GNUNET_PROGRAM_run (int argc, char *const *argv,
+GNUNET_PROGRAM_run (int argc,
+                    char *const *argv,
                     const char *binaryName,
                     const char *binaryHelp,
                     const struct GNUNET_GETOPT_CommandLineOption *options,
                     GNUNET_PROGRAM_Main task,
                     void *task_cls)
 {
-  return GNUNET_PROGRAM_run2 (argc, argv,
-                              binaryName, binaryHelp,
+  return GNUNET_PROGRAM_run2 (argc,
+                              argv,
+                              binaryName,
+                              binaryHelp,
                               options,
-                              task, task_cls,
+                              task,
+                              task_cls,
                               GNUNET_NO);
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]