aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_program_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_program_lib.h')
-rw-r--r--src/include/gnunet_program_lib.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/include/gnunet_program_lib.h b/src/include/gnunet_program_lib.h
index 4167060c0..f06d95422 100644
--- a/src/include/gnunet_program_lib.h
+++ b/src/include/gnunet_program_lib.h
@@ -18,7 +18,15 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
26 * @addtogroup libgnunetutil
27 * Multi-function utilities library for GNUnet programs
28 * @{
29 *
22 * @author Christian Grothoff 30 * @author Christian Grothoff
23 * 31 *
24 * @file 32 * @file
@@ -40,6 +48,7 @@ extern "C"
40#endif 48#endif
41#endif 49#endif
42 50
51
43#include "gnunet_configuration_lib.h" 52#include "gnunet_configuration_lib.h"
44#include "gnunet_getopt_lib.h" 53#include "gnunet_getopt_lib.h"
45#include "gnunet_scheduler_lib.h" 54#include "gnunet_scheduler_lib.h"
@@ -113,6 +122,45 @@ GNUNET_PROGRAM_run (int argc,
113 GNUNET_PROGRAM_Main task, 122 GNUNET_PROGRAM_Main task,
114 void *task_cls); 123 void *task_cls);
115 124
125enum GNUNET_GenericReturnValue
126GNUNET_DAEMON_register (const char *daemon_name,
127 const char *daemon_desc,
128 GNUNET_PROGRAM_Main task);
129
130#ifndef HAVE_GNUNET_MONOLITH
131#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \
132 int \
133 main (int argc, \
134 char *const *argv) \
135 { \
136 int ret; \
137 struct GNUNET_GETOPT_CommandLineOption options[] = { \
138 GNUNET_GETOPT_OPTION_END \
139 }; \
140 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, \
141 &argv)) \
142 return 2; \
143 ret = GNUNET_PROGRAM_run (argc, \
144 argv, \
145 daemon_name, \
146 daemon_help, \
147 options, \
148 init_cb, \
149 NULL); \
150 GNUNET_free_nz ((void*) argv); \
151 return ret; \
152 }
153#else
154#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \
155 static int __attribute__ ((constructor)) \
156 init (void) \
157 { \
158 return GNUNET_DAEMON_register (daemon_name, \
159 daemon_help, \
160 init_cb); \
161 }
162#endif
163
116 164
117#if 0 /* keep Emacsens' auto-indent happy */ 165#if 0 /* keep Emacsens' auto-indent happy */
118{ 166{
@@ -126,4 +174,6 @@ GNUNET_PROGRAM_run (int argc,
126 174
127/** @} */ /* end of group program */ 175/** @} */ /* end of group program */
128 176
177/** @} */ /* end of group addition */
178
129/* end of gnunet_program_lib.h */ 179/* end of gnunet_program_lib.h */