Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / arm / gnunet-arm.c
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009, 2012, 2013 GNUnet e.V.
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file arm/gnunet-arm.c
23  * @brief arm for writing a tool
24  * @author Christian Grothoff
25  */
26 #include "platform.h"
27 #include "gnunet_arm_service.h"
28 #include "gnunet_constants.h"
29 #include "gnunet_util_lib.h"
30
31 /**
32  * Set if we are to shutdown all services (including ARM).
33  */
34 static int end;
35
36 /**
37  * Set if we are to start default services (including ARM).
38  */
39 static int start;
40
41 /**
42  * Set if we are to stop/start default services (including ARM).
43  */
44 static int restart;
45
46 /**
47  * Set if we should delete configuration and temp directory on exit.
48  */
49 static int delete;
50
51 /**
52  * Set if we should not print status messages.
53  */
54 static int quiet;
55
56 /**
57  * Monitor ARM activity.
58  */
59 static int monitor;
60
61 /**
62  * Set if we should print a list of currently running services.
63  */
64 static int list;
65
66 /**
67  * Set to the name of a service to start.
68  */
69 static char *init;
70
71 /**
72  * Set to the name of a service to kill.
73  */
74 static char *term;
75
76 /**
77  * Set to the name of the config file used.
78  */
79 static const char *config_file;
80
81 /**
82  * Set to the directory where runtime files are stored.
83  */
84 static char *dir;
85
86 /**
87  * Final status code.
88  */
89 static int ret;
90
91 /**
92  * Connection with ARM.
93  */
94 static struct GNUNET_ARM_Handle *h;
95
96 /**
97  * Monitor connection with ARM.
98  */
99 static struct GNUNET_ARM_MonitorHandle *m;
100
101 /**
102  * Our configuration.
103  */
104 static struct GNUNET_CONFIGURATION_Handle *cfg;
105
106 /**
107  * Processing stage that we are in.  Simple counter.
108  */
109 static unsigned int phase;
110
111 /**
112  * User defined timestamp for completing operations.
113  */
114 static struct GNUNET_TIME_Relative timeout;
115
116 /**
117  * Task to be run on timeout.
118  */
119 static struct GNUNET_SCHEDULER_Task *timeout_task;
120
121 /**
122  * Do we want to give our stdout to gnunet-service-arm?
123  */
124 static int no_stdout;
125
126 /**
127  * Do we want to give our stderr to gnunet-service-arm?
128  */
129 static int no_stderr;
130
131 /**
132  * Handle for the task running the #action_loop().
133  */
134 static struct GNUNET_SCHEDULER_Task *al_task;
135
136 /**
137  * Current operation.
138  */
139 static struct GNUNET_ARM_Operation *op;
140
141 /**
142  * Attempts to delete configuration file and GNUNET_HOME
143  * on ARM shutdown provided the end and delete options
144  * were specified when gnunet-arm was run.
145  */
146 static void
147 delete_files ()
148 {
149   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
150               "Will attempt to remove configuration file %s and service directory %s\n",
151               config_file, dir);
152
153   if (0 != UNLINK (config_file))
154   {
155     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
156                 _("Failed to remove configuration file %s\n"),
157                 config_file);
158   }
159   if (GNUNET_OK != GNUNET_DISK_directory_remove (dir))
160   {
161     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
162                 _("Failed to remove servicehome directory %s\n"),
163                 dir);
164
165   }
166 }
167
168
169 /**
170  * Main continuation-passing-style loop.  Runs the various
171  * jobs that we've been asked to do in order.
172  *
173  * @param cls closure, unused
174  */
175 static void
176 shutdown_task (void *cls)
177 {
178   if (NULL != al_task)
179   {
180     GNUNET_SCHEDULER_cancel (al_task);
181     al_task = NULL;
182   }
183   if (NULL != op)
184   {
185     GNUNET_ARM_operation_cancel (op);
186     op = NULL;
187   }
188   if (NULL != h)
189   {
190     GNUNET_ARM_disconnect (h);
191     h = NULL;
192   }
193   if (NULL != m)
194   {
195     GNUNET_ARM_monitor_stop (m);
196     m = NULL;
197   }
198   if (NULL != timeout_task)
199   {
200     GNUNET_SCHEDULER_cancel (timeout_task);
201     timeout_task = NULL;
202   }
203   if ((GNUNET_YES == end) && (GNUNET_YES == delete))
204     delete_files ();
205   GNUNET_CONFIGURATION_destroy (cfg);
206   cfg = NULL;
207 }
208
209
210 /**
211  * Returns a string interpretation of 'rs'
212  *
213  * @param rs the request status from ARM
214  * @return a string interpretation of the request status
215  */
216 static const char *
217 req_string (enum GNUNET_ARM_RequestStatus rs)
218 {
219   switch (rs)
220   {
221   case GNUNET_ARM_REQUEST_SENT_OK:
222     return _("Message was sent successfully");
223   case GNUNET_ARM_REQUEST_DISCONNECTED:
224     return _("We disconnected from ARM before we could send a request");
225   }
226   return _("Unknown request status");
227 }
228
229
230 /**
231  * Returns a string interpretation of the 'result'
232  *
233  * @param result the arm result
234  * @return a string interpretation
235  */
236 static const char *
237 ret_string (enum GNUNET_ARM_Result result)
238 {
239   switch (result)
240   {
241   case GNUNET_ARM_RESULT_STOPPED:
242     return _("is stopped");
243   case GNUNET_ARM_RESULT_STARTING:
244     return _("is starting");
245   case GNUNET_ARM_RESULT_STOPPING:
246     return _("is stopping");
247   case GNUNET_ARM_RESULT_IS_STARTING_ALREADY:
248     return _("is starting already");
249   case GNUNET_ARM_RESULT_IS_STOPPING_ALREADY:
250     return _("is stopping already");
251   case GNUNET_ARM_RESULT_IS_STARTED_ALREADY:
252     return _("is started already");
253   case GNUNET_ARM_RESULT_IS_STOPPED_ALREADY:
254     return _("is stopped already");
255   case GNUNET_ARM_RESULT_IS_NOT_KNOWN:
256     return _("service is not known to ARM");
257   case GNUNET_ARM_RESULT_START_FAILED:
258     return _("service failed to start");
259   case GNUNET_ARM_RESULT_IN_SHUTDOWN:
260     return _("service cannot be manipulated because ARM is shutting down");
261   }
262   return _("Unknown result code.");
263 }
264
265
266 /**
267  * Main task that runs our various operations in order.
268  *
269  * @param cls closure
270  */
271 static void
272 action_loop (void *cls);
273
274
275 /**
276  * Function called whenever we connect to or disconnect from ARM.
277  * Termiantes the process if we fail to connect to the service on
278  * our first attempt.
279  *
280  * @param cls closure
281  * @param connected #GNUNET_YES if connected, #GNUNET_NO if disconnected,
282  *                  #GNUNET_SYSERR on error.
283  */
284 static void
285 conn_status (void *cls,
286              int connected)
287 {
288   static int once;
289
290   if ( (GNUNET_SYSERR == connected) &&
291        (0 == once) )
292   {
293     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
294                 _("Fatal error initializing ARM API.\n"));
295     GNUNET_SCHEDULER_shutdown ();
296     return;
297   }
298   once = 1;
299 }
300
301
302 /**
303  * We have requested ARM to be started, this function
304  * is called with the result of the operation.  Informs the
305  * use of the result; on success, we continue with the event
306  * loop, on failure we terminate the process.
307  *
308  * @param cls closure unused
309  * @param rs what happened to our request
310  * @param result if the request was processed, this is the result
311  *               according to ARM
312  */
313 static void
314 start_callback (void *cls,
315                 enum GNUNET_ARM_RequestStatus rs,
316                 enum GNUNET_ARM_Result result)
317 {
318   op = NULL;
319   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
320   {
321     FPRINTF (stdout,
322              _("Failed to start the ARM service: %s\n"),
323              req_string (rs));
324     GNUNET_SCHEDULER_shutdown ();
325     return;
326   }
327   if ( (GNUNET_ARM_RESULT_STARTING != result) &&
328        (GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result) )
329   {
330     FPRINTF (stdout,
331              _("Failed to start the ARM service: %s\n"),
332              ret_string (result));
333     GNUNET_SCHEDULER_shutdown ();
334     return;
335   }
336   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
337               "ARM service [re]start successful\n");
338   start = 0;
339   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
340 }
341
342
343 /**
344  * We have requested ARM to be stopped, this function
345  * is called with the result of the operation.  Informs the
346  * use of the result; on success, we continue with the event
347  * loop, on failure we terminate the process.
348  *
349  * @param cls closure unused
350  * @param rs what happened to our request
351  * @param result if the request was processed, this is the result
352  *               according to ARM
353  */
354 static void
355 stop_callback (void *cls,
356                enum GNUNET_ARM_RequestStatus rs,
357                enum GNUNET_ARM_Result result)
358 {
359   char *msg;
360
361   op = NULL;
362   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
363   {
364     GNUNET_asprintf (&msg, "%s",
365                      _("Failed to send a stop request to the ARM service: %s\n"));
366     FPRINTF (stdout, msg, req_string (rs));
367     GNUNET_free (msg);
368     GNUNET_SCHEDULER_shutdown ();
369     return;
370   }
371   if ((GNUNET_ARM_RESULT_STOPPING != result) &&
372       (GNUNET_ARM_RESULT_STOPPED != result) &&
373       (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
374   {
375     FPRINTF (stdout,
376              _("Failed to stop the ARM service: %s\n"),
377              ret_string (result));
378     GNUNET_SCHEDULER_shutdown ();
379     return;
380   }
381   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
382               "ARM service shutdown successful\n");
383   end = 0;
384   if (restart)
385   {
386     restart = 0;
387     start = 1;
388     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
389                 "Initiating an ARM restart\n");
390   }
391   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
392 }
393
394
395 /**
396  * We have requested a service to be started, this function
397  * is called with the result of the operation.  Informs the
398  * use of the result; on success, we continue with the event
399  * loop, on failure we terminate the process.
400  *
401  * @param cls closure unused
402  * @param rs what happened to our request
403  * @param result if the request was processed, this is the result
404  *               according to ARM
405  */
406 static void
407 init_callback (void *cls,
408                enum GNUNET_ARM_RequestStatus rs,
409                enum GNUNET_ARM_Result result)
410 {
411   op = NULL;
412   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
413   {
414     FPRINTF (stdout,
415              _("Failed to send a request to start the `%s' service: %s\n"),
416              init,
417              req_string (rs));
418     GNUNET_SCHEDULER_shutdown ();
419     return;
420   }
421   if ((GNUNET_ARM_RESULT_STARTING != result) &&
422       (GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result))
423   {
424     FPRINTF (stdout,
425              _("Failed to start the `%s' service: %s\n"),
426              init,
427              ret_string (result));
428     GNUNET_SCHEDULER_shutdown ();
429     return;
430   }
431   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
432               "Service %s [re]started successfully\n",
433               init);
434   GNUNET_free (init);
435   init = NULL;
436   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
437 }
438
439
440 /**
441  * We have requested a service to be stopped, this function
442  * is called with the result of the operation.  Informs the
443  * use of the result; on success, we continue with the event
444  * loop, on failure we terminate the process.
445  *
446  * @param cls closure unused
447  * @param rs what happened to our request
448  * @param result if the request was processed, this is the result
449  *               according to ARM
450  */
451 static void
452 term_callback (void *cls,
453                enum GNUNET_ARM_RequestStatus rs,
454                enum GNUNET_ARM_Result result)
455 {
456   char *msg;
457
458   op = NULL;
459   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
460   {
461     GNUNET_asprintf (&msg,
462                      _("Failed to send a request to kill the `%s' service: %%s\n"),
463                      term);
464     FPRINTF (stdout, msg, req_string (rs));
465     GNUNET_free (msg);
466     GNUNET_SCHEDULER_shutdown ();
467     return;
468   }
469   if ((GNUNET_ARM_RESULT_STOPPED != result) &&
470       (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
471   {
472     FPRINTF (stdout,
473              _("Failed to kill the `%s' service: %s\n"),
474              term,
475              ret_string (result));
476     GNUNET_SCHEDULER_shutdown ();
477     return;
478   }
479
480   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
481               "Service %s stopped successfully\n",
482               term);
483   GNUNET_free (term);
484   term = NULL;
485   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
486 }
487
488
489 /**
490  * Function called with the list of running services. Prints
491  * the list to stdout, then starts the event loop again.
492  * Prints an error message and terminates the process on errors.
493  *
494  * @param cls closure (unused)
495  * @param rs request status (success, failure, etc.)
496  * @param count number of services in the list
497  * @param list list of services that are running
498  */
499 static void
500 list_callback (void *cls,
501                enum GNUNET_ARM_RequestStatus rs,
502                unsigned int count,
503                const char *const*list)
504 {
505   unsigned int i;
506
507   op = NULL;
508   if (GNUNET_ARM_REQUEST_SENT_OK != rs)
509   {
510     char *msg;
511
512     GNUNET_asprintf (&msg, "%s",
513                      _("Failed to request a list of services: %s\n"));
514     FPRINTF (stdout, msg, req_string (rs));
515     GNUNET_free (msg);
516     ret = 3;
517     GNUNET_SCHEDULER_shutdown ();
518   }
519   if (NULL == list)
520   {
521     FPRINTF (stderr, "%s",
522              _("Error communicating with ARM. ARM not running?\n"));
523     GNUNET_SCHEDULER_shutdown ();
524     ret = 3;
525     return;
526   }
527   if (! quiet)
528     FPRINTF (stdout, "%s", _("Running services:\n"));
529   for (i = 0; i < count; i++)
530     FPRINTF (stdout, "%s\n", list[i]);
531   al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
532 }
533
534
535 /**
536  * Main action loop.  Runs the various jobs that we've been asked to
537  * do, in order.
538  *
539  * @param cls closure, unused
540  */
541 static void
542 action_loop (void *cls)
543 {
544   al_task = NULL;
545   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
546               "Running requested actions\n");
547   while (1)
548   {
549     switch (phase++)
550     {
551     case 0:
552       if (NULL != term)
553       {
554         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
555                     "Termination action\n");
556         op = GNUNET_ARM_request_service_stop (h,
557                                               term,
558                                               &term_callback,
559                                               NULL);
560         return;
561       }
562       break;
563     case 1:
564       if (end || restart)
565       {
566         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
567                     "End action\n");
568         op = GNUNET_ARM_request_service_stop (h,
569                                               "arm",
570                                               &stop_callback,
571                                               NULL);
572         return;
573       }
574       break;
575     case 2:
576       if (start)
577       {
578         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
579                     "Start action\n");
580         op = GNUNET_ARM_request_service_start (h, "arm",
581                                                (no_stdout ? 0 : GNUNET_OS_INHERIT_STD_OUT) |
582                                                (no_stderr ? 0 : GNUNET_OS_INHERIT_STD_ERR),
583                                                &start_callback,
584                                                NULL);
585         return;
586       }
587       break;
588     case 3:
589       if (NULL != init)
590       {
591         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
592                     "Initialization action\n");
593         op = GNUNET_ARM_request_service_start (h, init,
594                                                GNUNET_OS_INHERIT_STD_NONE,
595                                                &init_callback,
596                                                NULL);
597         return;
598       }
599       break;
600     case 4:
601       if (list)
602       {
603         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
604                     "Going to list all running services controlled by ARM.\n");
605         op = GNUNET_ARM_request_service_list (h,
606                                               &list_callback,
607                                               &list);
608         return;
609       }
610       break;
611     case 5:
612       if (monitor)
613         {
614           if (! quiet)
615             fprintf (stderr,
616                      _("Now only monitoring, press CTRL-C to stop.\n"));
617           quiet = 0; /* does not make sense to stay quiet in monitor mode at this time */
618           return; /* done with tasks, just monitor */
619         }
620       break;
621     default:            /* last phase */
622       GNUNET_SCHEDULER_shutdown ();
623       return;
624     }
625   }
626 }
627
628
629 /**
630  * Function called when a service starts or stops.
631  *
632  * @param cls closure
633  * @param service service name
634  * @param status status of the service
635  */
636 static void
637 srv_status (void *cls,
638             const char *service,
639             enum GNUNET_ARM_ServiceStatus status)
640 {
641   const char *msg;
642
643   switch (status)
644   {
645   case GNUNET_ARM_SERVICE_MONITORING_STARTED:
646     return; /* this should be done silently */
647   case GNUNET_ARM_SERVICE_STOPPED:
648     msg = _("Stopped %s.\n");
649     break;
650   case GNUNET_ARM_SERVICE_STARTING:
651     msg = _("Starting %s...\n");
652     break;
653   case GNUNET_ARM_SERVICE_STOPPING:
654     msg = _("Stopping %s...\n");
655     break;
656   default:
657     msg = NULL;
658     break;
659   }
660   if (! quiet)
661   {
662     if (NULL != msg)
663       FPRINTF (stderr,
664                msg,
665                service);
666     else
667       FPRINTF (stderr,
668                _("Unknown status %u for service %s.\n"),
669                status,
670                service);
671   }
672   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
673               "Got service %s status %d\n",
674               service, (int)
675               status);
676 }
677
678
679 /**
680  * Task run on timeout (if -T is given).
681  */
682 static void
683 timeout_task_cb (void *cls)
684 {
685   timeout_task = NULL;
686   ret = 2;
687   GNUNET_SCHEDULER_shutdown ();
688 }
689
690
691 /**
692  * Main function that will be run by the scheduler.
693  *
694  * @param cls closure
695  * @param args remaining command-line arguments
696  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
697  * @param c configuration
698  */
699 static void
700 run (void *cls,
701      char *const *args,
702      const char *cfgfile,
703      const struct GNUNET_CONFIGURATION_Handle *c)
704 {
705   char *armconfig;
706
707   cfg = GNUNET_CONFIGURATION_dup (c);
708   config_file = cfgfile;
709   if (GNUNET_OK !=
710       GNUNET_CONFIGURATION_get_value_string (cfg,
711                                              "PATHS",
712                                              "GNUNET_HOME",
713                                              &dir))
714   {
715     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
716                                "PATHS",
717                                "GNUNET_HOME");
718     return;
719   }
720   if (NULL != cfgfile)
721   {
722     if (GNUNET_OK !=
723         GNUNET_CONFIGURATION_get_value_filename (cfg,
724                                                  "arm",
725                                                  "CONFIG",
726                                                  &armconfig))
727     {
728       GNUNET_CONFIGURATION_set_value_string (cfg,
729                                              "arm",
730                                              "CONFIG",
731                                              cfgfile);
732     }
733     else
734       GNUNET_free (armconfig);
735   }
736   if (NULL == (h = GNUNET_ARM_connect (cfg,
737                                        &conn_status,
738                                        NULL)))
739     return;
740   if (monitor)
741     m = GNUNET_ARM_monitor_start (cfg,
742                             &srv_status,
743                             NULL);
744   al_task = GNUNET_SCHEDULER_add_now (&action_loop,
745                                       NULL);
746   GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
747                                  NULL);
748   if (0 != timeout.rel_value_us)
749     timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
750                                                  &timeout_task_cb,
751                                                  NULL);
752 }
753
754
755 /**
756  * The main function to obtain arm from gnunetd.
757  *
758  * @param argc number of arguments from the command line
759  * @param argv command line arguments
760  * @return 0 ok, 1 on error, 2 on timeout
761  */
762 int
763 main (int argc, char *const *argv)
764 {
765   struct GNUNET_GETOPT_CommandLineOption options[] = {
766
767     GNUNET_GETOPT_OPTION_SET_ONE ('e',
768                                   "end",
769                                   gettext_noop ("stop all GNUnet services"),
770                                   &end),
771
772     GNUNET_GETOPT_OPTION_STRING ('i',
773                                  "init",
774                                  "SERVICE",
775                                  gettext_noop ("start a particular service"),
776                                  &init),
777
778     GNUNET_GETOPT_OPTION_STRING ('k',
779                                  "kill",
780                                  "SERVICE",
781                                  gettext_noop ("stop a particular service"),
782                                  &term),
783
784     GNUNET_GETOPT_OPTION_SET_ONE ('s',
785                                   "start",
786                                   gettext_noop ("start all GNUnet default services"),
787                                   &start),
788
789     GNUNET_GETOPT_OPTION_SET_ONE ('r',
790                                   "restart",
791                                   gettext_noop ("stop and start all GNUnet default services"),
792                                   &restart),
793     GNUNET_GETOPT_OPTION_SET_ONE ('d',
794                                   "delete",
795                                   gettext_noop ("delete config file and directory on exit"),
796                                   &delete),
797
798     GNUNET_GETOPT_OPTION_SET_ONE ('m',
799                                   "monitor",
800                                   gettext_noop ("monitor ARM activities"),
801                                   &monitor),
802
803     GNUNET_GETOPT_OPTION_SET_ONE ('q',
804                                   "quiet",
805                                   gettext_noop ("don't print status messages"),
806                                   &quiet),
807
808     GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('T',
809                                             "timeout",
810                                             "DELAY",
811                                             gettext_noop ("exit with error status if operation does not finish after DELAY"),
812                                             &timeout),
813
814     GNUNET_GETOPT_OPTION_SET_ONE ('I',
815                                   "info",
816                                   gettext_noop ("list currently running services"),
817                                   &list), 
818
819     GNUNET_GETOPT_OPTION_SET_ONE ('O',
820                                   "no-stdout",
821                                   gettext_noop ("don't let gnunet-service-arm inherit standard output"),
822                                   &no_stdout),
823
824     GNUNET_GETOPT_OPTION_SET_ONE ('E',
825                                   "no-stderr",
826                                   gettext_noop ("don't let gnunet-service-arm inherit standard error"),
827                                   &no_stderr),
828
829     GNUNET_GETOPT_OPTION_END
830   };
831
832   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv,
833                                                  &argc, &argv))
834     return 2;
835
836   if (GNUNET_OK ==
837       GNUNET_PROGRAM_run (argc, argv, "gnunet-arm",
838                           gettext_noop
839                           ("Control services and the Automated Restart Manager (ARM)"),
840                           options, &run, NULL))
841   {
842     GNUNET_free ((void *) argv);
843     return ret;
844   }
845   GNUNET_free ((void*) argv);
846   return 1;
847 }
848
849 /* end of gnunet-arm.c */