GNUnet 0.22.1
gnunet_program_lib.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2001-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
21#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
40#ifndef GNUNET_PROGRAM_LIB_H
41#define GNUNET_PROGRAM_LIB_H
42
43#ifdef __cplusplus
44extern "C"
45{
46#if 0 /* keep Emacsens' auto-indent happy */
47}
48#endif
49#endif
50
51
53#include "gnunet_getopt_lib.h"
55
64typedef void
65(*GNUNET_PROGRAM_Main) (void *cls,
66 char *const *args,
67 const char *cfgfile,
68 const struct GNUNET_CONFIGURATION_Handle *cfg);
69
70
90GNUNET_PROGRAM_run2 (int argc,
91 char *const *argv,
92 const char *binaryName,
93 const char *binaryHelp,
96 void *task_cls,
97 int run_without_scheduler);
98
99
117GNUNET_PROGRAM_run (int argc,
118 char *const *argv,
119 const char *binaryName,
120 const char *binaryHelp,
123 void *task_cls);
124
126GNUNET_DAEMON_register (const char *daemon_name,
127 const char *daemon_desc,
129
133void
135 char *const *argv,
137
138#ifndef HAVE_GNUNET_MONOLITH
139#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \
140 int \
141 main (int argc, \
142 char *const *argv) \
143 { \
144 int ret; \
145 struct GNUNET_GETOPT_CommandLineOption options[] = { \
146 GNUNET_GETOPT_OPTION_END \
147 }; \
148 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, \
149 &argv)) \
150 return 2; \
151 ret = GNUNET_PROGRAM_run (argc, \
152 argv, \
153 daemon_name, \
154 daemon_help, \
155 options, \
156 init_cb, \
157 NULL); \
158 GNUNET_free_nz ((void*) argv); \
159 return ret; \
160 }
161#else
162#define GNUNET_DAEMON_MAIN(daemon_name, daemon_help, init_cb) \
163 int init (void); \
164 int __attribute__ ((constructor)) \
165 init (void) \
166 { \
167 return GNUNET_DAEMON_register (daemon_name, \
168 daemon_help, \
169 init_cb); \
170 }
171#endif
172
173
179 char *const *argv,
181
182
187void
188GNUNET_DAEMON_main (int argc,
189 char *const *argv,
191 enum GNUNET_GenericReturnValue with_scheduler);
192
193
194#if 0 /* keep Emacsens' auto-indent happy */
195{
196#endif
197#ifdef __cplusplus
198}
199#endif
200
201/* ifndef GNUNET_PROGRAM_LIB_H */
202#endif
203 /* end of group program */
205 /* end of group addition */
207
208/* end of gnunet_program_lib.h */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
Configuration API.
Command line parsing and –help formatting.
API to schedule computations using continuation passing style.
GNUNET_GenericReturnValue
Named constants for return values.
enum GNUNET_GenericReturnValue GNUNET_DAEMON_register(const char *daemon_name, const char *daemon_desc, GNUNET_PROGRAM_Main task)
Definition: program.c:655
void GNUNET_DAEMON_main(int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_GenericReturnValue with_scheduler)
Run the mainloop in a monolithic libgnunet.
Definition: program.c:633
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run2(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls, int run_without_scheduler)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:132
void(* GNUNET_PROGRAM_Main)(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
void GNUNET_PROGRAM_monolith_main(int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg)
Start all services and daemons in a single process.
Definition: program.c:564
enum GNUNET_GenericReturnValue 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)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:400
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_conf_and_options(int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg)
Create configuration handle from options and configuration file.
Definition: program.c:420
Definition of a command line option.