GNUnet 0.22.2
gnunet-arm.c
Go to the documentation of this file.
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 it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
26#include "platform.h"
27#include "gnunet_arm_service.h"
28#include "gnunet_util_lib.h"
29
33static int end;
34
38static int start;
39
43static int restart;
44
48static int delete;
49
53static int quiet;
54
58static int show_all;
59
63static int monitor;
64
68static int list;
69
73static char *init;
74
78static char *term;
79
83static char *config_file;
84
88static char *dir;
89
93static int ret;
94
98static struct GNUNET_ARM_Handle *h;
99
104
109
113static unsigned int phase;
114
119
124
128static int no_stdout;
129
133static int no_stderr;
134
139
144
150static void
152{
153 GNUNET_log (
155 "Will attempt to remove configuration file %s and service directory %s\n",
157 dir);
158 if (0 != unlink (config_file))
159 {
161 _ ("Failed to remove configuration file %s\n"),
163 }
165 {
167 _ ("Failed to remove servicehome directory %s\n"),
168 dir);
169 }
170}
171
172
179static void
180shutdown_task (void *cls)
181{
182 (void) cls;
183 if (NULL != al_task)
184 {
186 al_task = NULL;
187 }
188 if (NULL != op)
189 {
191 op = NULL;
192 }
193 if (NULL != h)
194 {
196 h = NULL;
197 }
198 if (NULL != m)
199 {
201 m = NULL;
202 }
203 if (NULL != timeout_task)
204 {
206 timeout_task = NULL;
207 }
208 if ( (GNUNET_YES == end) &&
209 (GNUNET_YES == delete) )
210 delete_files ();
212 cfg = NULL;
213}
214
215
222static const char *
224{
225 switch (rs)
226 {
228 return _ ("Message was sent successfully");
229
231 return _ ("We disconnected from ARM before we could send a request");
232 }
233 return _ ("Unknown request status");
234}
235
236
243static const char *
245{
246 switch (result)
247 {
249 return _ ("is stopped");
250
252 return _ ("is starting");
253
255 return _ ("is stopping");
256
258 return _ ("is starting already");
259
261 return _ ("is stopping already");
262
264 return _ ("is started already");
265
267 return _ ("is stopped already");
268
270 return _ ("service is not known to ARM");
271
273 return _ ("service failed to start");
274
276 return _ ("service cannot be manipulated because ARM is shutting down");
277 }
278 return _ ("Unknown result code.");
279}
280
281
287static void
288action_loop (void *cls);
289
290
300static void
301conn_status (void *cls,
302 int connected)
303{
304 static int once;
305
306 (void) cls;
307 if ( (GNUNET_SYSERR == connected) &&
308 (0 == once) )
309 {
311 _ ("Fatal error initializing ARM API.\n"));
313 return;
314 }
315 once = 1;
316}
317
318
330static void
331start_callback (void *cls,
334{
335 (void) cls;
336 op = NULL;
338 {
339 fprintf (stdout,
340 _ ("Failed to start the ARM service: %s\n"),
341 req_string (rs));
343 return;
344 }
347 {
348 fprintf (stdout,
349 _ ("Failed to start the ARM service: %s\n"),
352 return;
353 }
355 "ARM service [re]start successful\n");
356 start = 0;
358 NULL);
359}
360
361
373static void
374stop_callback (void *cls,
377{
378 char *msg;
379
380 (void) cls;
381 op = NULL;
383 {
385 "%s",
386 _ (
387 "Failed to send a stop request to the ARM service: %s\n")
388 );
389 fprintf (stdout, msg, req_string (rs));
392 return;
393 }
397 {
398 fprintf (stdout,
399 _ ("Failed to stop the ARM service: %s\n"),
402 return;
403 }
405 "ARM service shutdown successful\n");
406 end = 0;
407 if (restart)
408 {
409 restart = 0;
410 start = 1;
412 "Initiating an ARM restart\n");
413 }
415 NULL);
416}
417
418
430static void
431init_callback (void *cls,
434{
435 (void) cls;
436 op = NULL;
438 {
439 fprintf (stdout,
440 _ ("Failed to send a request to start the `%s' service: %s\n"),
441 init,
442 req_string (rs));
444 return;
445 }
448 {
449 fprintf (stdout,
450 _ ("Failed to start the `%s' service: %s\n"),
451 init,
454 return;
455 }
457 "Service %s [re]started successfully\n",
458 init);
460 init = NULL;
462 NULL);
463}
464
465
477static void
478term_callback (void *cls,
481{
482 char *msg;
483
484 (void) cls;
485 op = NULL;
487 {
489 _ (
490 "Failed to send a request to kill the `%s' service: %%s\n"),
491 term);
492 fprintf (stdout,
493 msg,
494 req_string (rs));
497 return;
498 }
501 {
502 fprintf (stdout,
503 _ ("Failed to kill the `%s' service: %s\n"),
504 term,
507 return;
508 }
509
511 "Service %s stopped successfully\n",
512 term);
514 term = NULL;
516 NULL);
517}
518
519
530static void
531list_callback (void *cls,
533 unsigned int count,
534 const struct GNUNET_ARM_ServiceInfo *service_info)
535{
536 unsigned int num_stopped = 0;
537 unsigned int num_started = 0;
538 unsigned int num_stopping = 0;
539 unsigned int num_failed = 0;
540 unsigned int num_finished = 0;
541 (void) cls;
542 op = NULL;
544 {
545 char *msg;
546
548 "%s",
549 _ ("Failed to request a list of services: %s\n"));
550 fprintf (stdout,
551 msg,
552 req_string (rs));
554 ret = 3;
556 }
557 if (NULL == service_info)
558 {
559 fprintf (stderr,
560 "%s",
561 _ ("Error communicating with ARM. ARM not running?\n"));
563 ret = 3;
564 return;
565 }
566 for (unsigned int i = 0; i < count; i++)
567 {
568 switch (service_info[i].status)
569 {
571 num_stopped++;
572 break;
574 num_failed++;
575 break;
577 num_finished++;
578 break;
580 num_started++;
581 break;
583 num_stopping++;
584 fprintf (stdout,
585 "%s (binary='%s', status=stopping)\n",
586 service_info[i].name,
587 service_info[i].binary);
588 break;
589 default:
590 GNUNET_break_op (0);
591 fprintf (stdout,
592 "%s (binary='%s', status=unknown)\n",
593 service_info[i].name,
594 service_info[i].binary);
595 break;
596 }
597 }
598 if (! quiet)
599 {
600 if (show_all)
601 fprintf (stdout,
602 "%s",
603 _ ("All services:\n"));
604 else
605 fprintf (stdout,
606 "%s",
607 _ ("Services (excluding stopped services):\n"));
608 if (num_stopped || num_failed || num_finished || num_stopping ||
609 num_started)
610 {
611 int sep = 0;
612 fprintf (stdout, "(");
613 if (0 != num_started)
614 {
615 if (sep)
616 fprintf (stdout, " / ");
617 fprintf (stdout,
618 "started: %u",
619 num_started);
620 sep = 1;
621 }
622 if (0 != num_failed)
623 {
624 if (sep)
625 fprintf (stdout, " / ");
626 fprintf (stdout,
627 "failed: %u",
628 num_failed);
629 sep = 1;
630 }
631 if (0 != num_stopping)
632 {
633 if (sep)
634 fprintf (stdout, " / ");
635 fprintf (stdout,
636 "stopping: %u",
637 num_stopping);
638 sep = 1;
639 }
640 if (0 != num_stopped)
641 {
642 if (sep)
643 fprintf (stdout, " / ");
644 fprintf (stdout,
645 "stopped: %u",
646 num_stopped);
647 sep = 1;
648 }
649 if (0 != num_finished)
650 {
651 if (sep)
652 fprintf (stdout, " / ");
653 fprintf (stdout,
654 "finished: %u",
655 num_finished);
656 sep = 1;
657 }
658 fprintf (stdout, ")\n");
659 }
660 else
661 {
662 fprintf (stdout,
663 "%s",
664 _ ("(No services configured.)\n"));
665 }
666 }
667 for (unsigned int i = 0; i < count; i++)
668 {
669 struct GNUNET_TIME_Relative restart_in;
670 switch (service_info[i].status)
671 {
673 if (show_all)
674 fprintf (stdout,
675 "%s (binary='%s', status=stopped)\n",
676 service_info[i].name,
677 service_info[i].binary);
678 break;
680 restart_in = GNUNET_TIME_absolute_get_remaining (service_info[i].
681 restart_at);
682 fprintf (stdout,
683 "%s (binary='%s', status=failed, exit_status=%d, restart_delay='%s')\n",
684 service_info[i].name,
685 service_info[i].binary,
686 service_info[i].last_exit_status,
688 GNUNET_YES));
689 break;
691 fprintf (stdout,
692 "%s (binary='%s', status=finished)\n",
693 service_info[i].name,
694 service_info[i].binary);
695 break;
697 fprintf (stdout,
698 "%s (binary='%s', status=started)\n",
699 service_info[i].name,
700 service_info[i].binary);
701 break;
703 fprintf (stdout,
704 "%s (binary='%s', status=stopping)\n",
705 service_info[i].name,
706 service_info[i].binary);
707 break;
708 default:
709 GNUNET_break_op (0);
710 fprintf (stdout,
711 "%s (binary='%s', status=unknown)\n",
712 service_info[i].name,
713 service_info[i].binary);
714 break;
715 }
716 }
718 NULL);
719}
720
721
728static void
729action_loop (void *cls)
730{
731 (void) cls;
732 al_task = NULL;
734 "Running requested actions\n");
735 while (1)
736 {
737 switch (phase++)
738 {
739 case 0:
740 if (NULL != term)
741 {
743 "Termination action\n");
745 term,
747 NULL);
748 return;
749 }
750 break;
751
752 case 1:
753 if (end || restart)
754 {
755 if (GNUNET_YES !=
757 "arm"))
758 {
760 "GNUnet not running, cannot stop the peer\n");
761 }
762 else
763 {
765 "End action\n");
767 "arm",
769 NULL);
770 return;
771 }
772 }
773 break;
774
775 case 2:
776 if (start)
777 {
779 "Start action\n");
780 op =
782 "arm",
783 (no_stdout
784 ? 0
786 | (no_stderr
787 ? 0
790 NULL);
791 return;
792 }
793 break;
794
795 case 3:
796 if (NULL != init)
797 {
799 "Initialization action\n");
801 init,
804 NULL);
805 return;
806 }
807 break;
808
809 case 4:
810 if (list)
811 {
813 "Going to list all running services controlled by ARM.\n");
816 &list);
817 return;
818 }
819 break;
820
821 case 5:
822 if (monitor)
823 {
824 if (! quiet)
825 fprintf (stderr,
826 _ ("Now only monitoring, press CTRL-C to stop.\n"));
827 quiet =
828 0; /* does not make sense to stay quiet in monitor mode at this time */
829 return; /* done with tasks, just monitor */
830 }
831 break;
832
833 default: /* last phase */
835 return;
836 }
837 }
838}
839
840
848static void
849srv_status (void *cls,
850 const char *service,
852{
853 const char *msg;
854
855 (void) cls;
856 switch (status)
857 {
859 return; /* this should be done silently */
860
862 msg = _ ("Stopped %s.\n");
863 break;
864
866 msg = _ ("Starting %s...\n");
867 break;
868
870 msg = _ ("Stopping %s...\n");
871 break;
872
873 default:
874 msg = NULL;
875 break;
876 }
877 if (! quiet)
878 {
879 if (NULL != msg)
880 fprintf (stderr,
881 msg,
882 service);
883 else
884 fprintf (stderr,
885 _ ("Unknown status %u for service %s.\n"),
886 status,
887 service);
888 }
890 "Got service %s status %d\n",
891 service,
892 (int) status);
893}
894
895
899static void
901{
902 (void) cls;
903 timeout_task = NULL;
904 ret = 2;
906}
907
908
917static void
918run (void *cls,
919 char *const *args,
920 const char *cfgfile,
921 const struct GNUNET_CONFIGURATION_Handle *c)
922{
923 (void) cls;
924 (void) args;
925 (void) cfgfile;
927 if (GNUNET_OK !=
929 "PATHS",
930 "GNUNET_HOME",
931 &dir))
932 {
934 "PATHS",
935 "GNUNET_HOME");
936 return;
937 }
939 "arm",
940 "CONFIG",
941 &config_file);
942 if (NULL == (h = GNUNET_ARM_connect (cfg,
944 NULL)))
945 return;
946 if (monitor)
948 &srv_status,
949 NULL);
951 NULL);
953 NULL);
954 if (0 != timeout.rel_value_us)
958 NULL);
959}
960
961
969int
970main (int argc, char *const *argv)
971{
974 "end",
975 gettext_noop ("stop all GNUnet services"),
976 &end),
978 "init",
979 "SERVICE",
980 gettext_noop ("start a particular service"),
981 &init),
983 "kill",
984 "SERVICE",
985 gettext_noop ("stop a particular service"),
986 &term),
988 "all",
990 "also show stopped services (used with -I)"),
991 &show_all),
993 "start",
995 "start all GNUnet default services"),
996 &start),
998 "restart",
1000 "stop and start all GNUnet default services"),
1001 &restart),
1003 "delete",
1004 gettext_noop (
1005 "delete config file and directory on exit"),
1006 &delete),
1008 "monitor",
1009 gettext_noop ("monitor ARM activities"),
1010 &monitor),
1012 "quiet",
1013 gettext_noop ("don't print status messages"),
1014 &quiet),
1016 'T',
1017 "timeout",
1018 "DELAY",
1019 gettext_noop (
1020 "exit with error status if operation does not finish after DELAY"),
1021 &timeout),
1023 "info",
1024 gettext_noop (
1025 "list currently running services"),
1026 &list),
1028 'O',
1029 "no-stdout",
1030 gettext_noop ("don't let gnunet-service-arm inherit standard output"),
1031 &no_stdout),
1033 'E',
1034 "no-stderr",
1035 gettext_noop ("don't let gnunet-service-arm inherit standard error"),
1036 &no_stderr),
1038 };
1039 int lret;
1040
1041 if (GNUNET_OK ==
1042 (lret = GNUNET_PROGRAM_run (
1044 argc,
1045 argv,
1046 "gnunet-arm",
1047 gettext_noop (
1048 "Control services and the Automated Restart Manager (ARM)"),
1049 options,
1050 &run,
1051 NULL)))
1052 {
1053 return ret;
1054 }
1055 return lret;
1056}
1057
1058
1059/* end of gnunet-arm.c */
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define gettext_noop(String)
Definition: gettext.h:74
static int once
Global to mark if we've run the initialization.
Definition: gnsrecord.c:65
static int no_stdout
Do we want to give our stdout to gnunet-service-arm?
Definition: gnunet-arm.c:128
static void timeout_task_cb(void *cls)
Task run on timeout (if -T is given).
Definition: gnunet-arm.c:900
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:143
static const char * req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
Definition: gnunet-arm.c:223
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:103
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
static void term_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested a service to be stopped, this function is called with the result of the operation.
Definition: gnunet-arm.c:478
static void delete_files()
Attempts to delete configuration file and GNUNET_HOME on ARM shutdown provided the end and delete opt...
Definition: gnunet-arm.c:151
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:38
static int monitor
Monitor ARM activity.
Definition: gnunet-arm.c:63
static int show_all
Set if we should print all services, including stopped ones.
Definition: gnunet-arm.c:58
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:68
static int quiet
Set if we should not print status messages.
Definition: gnunet-arm.c:53
static void stop_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested ARM to be stopped, this function is called with the result of the operation.
Definition: gnunet-arm.c:374
static void shutdown_task(void *cls)
Main continuation-passing-style loop.
Definition: gnunet-arm.c:180
static int ret
Final status code.
Definition: gnunet-arm.c:93
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:88
static char * term
Set to the name of a service to kill.
Definition: gnunet-arm.c:78
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:73
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
Definition: gnunet-arm.c:918
static void action_loop(void *cls)
Main task that runs our various operations in order.
Definition: gnunet-arm.c:729
static int restart
Set if we are to stop/start default services (including ARM).
Definition: gnunet-arm.c:43
static const char * ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
Definition: gnunet-arm.c:244
static void conn_status(void *cls, int connected)
Function called whenever we connect to or disconnect from ARM.
Definition: gnunet-arm.c:301
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:118
static void list_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, unsigned int count, const struct GNUNET_ARM_ServiceInfo *service_info)
Function called with the list of running services.
Definition: gnunet-arm.c:531
static unsigned int phase
Processing stage that we are in.
Definition: gnunet-arm.c:113
static struct GNUNET_SCHEDULER_Task * al_task
Handle for the task running the action_loop().
Definition: gnunet-arm.c:138
static void srv_status(void *cls, const char *service, enum GNUNET_ARM_ServiceMonitorStatus status)
Function called when a service starts or stops.
Definition: gnunet-arm.c:849
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:33
static char * config_file
Set to the name of the config file used.
Definition: gnunet-arm.c:83
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
Definition: gnunet-arm.c:123
int main(int argc, char *const *argv)
The main function to obtain arm from gnunetd.
Definition: gnunet-arm.c:970
static int no_stderr
Do we want to give our stderr to gnunet-service-arm?
Definition: gnunet-arm.c:133
static void init_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested a service to be started, this function is called with the result of the operation.
Definition: gnunet-arm.c:431
static void start_callback(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
We have requested ARM to be started, this function is called with the result of the operation.
Definition: gnunet-arm.c:331
static char * name
Name (label) of the records to list.
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:39
static int result
Global testing status.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
GNUNET_ARM_ServiceMonitorStatus
Statuses of services.
struct GNUNET_ARM_Handle * GNUNET_ARM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ConnectionStatusCallback conn_status, void *conn_status_cls)
Set up a context for communicating with ARM, then start connecting to the ARM service using that cont...
Definition: arm_api.c:577
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_start(struct GNUNET_ARM_Handle *h, const char *service_name, enum GNUNET_OS_InheritStdioFlags std_inheritance, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request for a service to be started.
Definition: arm_api.c:936
struct GNUNET_ARM_MonitorHandle * GNUNET_ARM_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ServiceMonitorCallback cont, void *cont_cls)
Setup a context for monitoring ARM, then start connecting to the ARM service for monitoring using tha...
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_list(struct GNUNET_ARM_Handle *h, GNUNET_ARM_ServiceListCallback cont, void *cont_cls)
Request a list of running services.
Definition: arm_api.c:1086
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_stop(struct GNUNET_ARM_Handle *h, const char *service_name, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request a service to be stopped.
Definition: arm_api.c:1050
void GNUNET_ARM_monitor_stop(struct GNUNET_ARM_MonitorHandle *h)
Disconnect from the ARM service and destroy the handle.
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service and destroy the handle.
Definition: arm_api.c:603
GNUNET_ARM_Result
Replies to ARM requests.
GNUNET_ARM_RequestStatus
Statuses of the requests that client can send to ARM.
void GNUNET_ARM_operation_cancel(struct GNUNET_ARM_Operation *op)
Abort an operation.
Definition: arm_api.c:795
@ GNUNET_ARM_SERVICE_STATUS_FINISHED
The service was started, but then exited normally.
@ GNUNET_ARM_SERVICE_STATUS_FAILED
The service has previously failed, and will be restarted.
@ GNUNET_ARM_SERVICE_STATUS_STOPPED
Service is stopped.
@ GNUNET_ARM_SERVICE_STATUS_STOPPING
The service was started, and we're currently waiting for it to be stopped.
@ GNUNET_ARM_SERVICE_STATUS_STARTED
Service has been started and is currently running.
@ GNUNET_ARM_SERVICE_STOPPING
Service stopping was initiated.
@ GNUNET_ARM_SERVICE_STOPPED
Service was stopped.
@ GNUNET_ARM_SERVICE_STARTING
Service starting was initiated.
@ GNUNET_ARM_SERVICE_MONITORING_STARTED
Dummy message.
@ GNUNET_ARM_RESULT_IS_NOT_KNOWN
Asked to start or stop a service, but it's not known.
@ GNUNET_ARM_RESULT_IS_STARTING_ALREADY
Asked to start it, but it's already starting.
@ GNUNET_ARM_RESULT_IS_STOPPED_ALREADY
Asked to stop it, but it's already stopped.
@ GNUNET_ARM_RESULT_STARTING
Service starting was initiated.
@ GNUNET_ARM_RESULT_IS_STARTED_ALREADY
Asked to start it, but it's already started.
@ GNUNET_ARM_RESULT_STOPPING
ARM stopping was initiated (there's no "stopped" for ARM itself).
@ GNUNET_ARM_RESULT_IS_STOPPING_ALREADY
Asked to stop it, but it's already stopping.
@ GNUNET_ARM_RESULT_STOPPED
Service was stopped (never sent for ARM itself).
@ GNUNET_ARM_RESULT_START_FAILED
Tried to start a service, but that failed for some reason.
@ GNUNET_ARM_RESULT_IN_SHUTDOWN
Asked to start something, but ARM is shutting down and can't comply.
@ GNUNET_ARM_REQUEST_DISCONNECTED
We disconnected from ARM, and request was not sent.
@ GNUNET_ARM_REQUEST_SENT_OK
Message was sent successfully.
enum GNUNET_GenericReturnValue GNUNET_CLIENT_test(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name)
Test if the port or UNIXPATH of the given service_name is in use and thus (most likely) the respectiv...
Definition: client.c:903
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:1065
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
@ GNUNET_OS_INHERIT_STD_OUT
When this flag is set, the child process will inherit stdout of the parent.
Definition: gnunet_os_lib.h:89
@ GNUNET_OS_INHERIT_STD_ERR
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:95
@ GNUNET_OS_INHERIT_STD_NONE
No standard streams should be inherited.
Definition: gnunet_os_lib.h:77
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:407
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1339
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1304
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1277
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:406
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:579
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
Handle for interacting with ARM.
Definition: arm_api.c:103
Handle for interacting with ARM.
Entry in a doubly-linked list of operations awaiting for replies (in-order) from the ARM service.
Definition: arm_api.c:41
Information about a service managed by ARM.
Definition of a command line option.
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.