2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
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 2, or (at your
8 option) any later version.
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.
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_service_lib.h
23 * @brief functions related to starting services
24 * @author Christian Grothoff
27 #ifndef GNUNET_SERVICE_LIB_H
28 #define GNUNET_SERVICE_LIB_H
33 #if 0 /* keep Emacsens' auto-indent happy */
38 #include "gnunet_configuration_lib.h"
39 #include "gnunet_server_lib.h"
42 * Function called by the service's run
43 * method to run service-specific setup code.
46 * @param sched scheduler to use
47 * @param server the initialized server
48 * @param cfg configuration to use
50 typedef void (*GNUNET_SERVICE_Main) (void *cls,
51 struct GNUNET_SCHEDULER_Handle * sched,
52 struct GNUNET_SERVER_Handle * server,
53 const struct GNUNET_CONFIGURATION_Handle *
58 * Options for the service (bitmask).
60 enum GNUNET_SERVICE_Options
65 GNUNET_SERVICE_OPTION_NONE = 0,
68 * Do not trigger server shutdown on signals, allow for the user
69 * to terminate the server explicitly when needed.
71 GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN = 1
76 * Run a standard GNUnet service startup sequence (initialize loggers
77 * and configuration, parse options).
79 * @param argc number of command line arguments
80 * @param argv command line arguments
81 * @param serviceName our service name
82 * @param opt service options
83 * @param task main task of the service
84 * @param task_cls closure for task
85 * @return GNUNET_SYSERR on error, GNUNET_OK
86 * if we shutdown nicely
88 int GNUNET_SERVICE_run (int argc,
90 const char *serviceName,
91 enum GNUNET_SERVICE_Options opt,
92 GNUNET_SERVICE_Main task,
96 struct GNUNET_SERVICE_Context;
99 * Run a service startup sequence within an existing
100 * initialized system.
102 * @param serviceName our service name
103 * @param sched scheduler to use
104 * @param cfg configuration to use
105 * @return NULL on error, service handle
107 struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName,
109 GNUNET_SCHEDULER_Handle
112 GNUNET_CONFIGURATION_Handle
117 * Obtain the server used by a service. Note that the server must NOT
118 * be destroyed by the caller.
120 * @param ctx the service context returned from the start function
121 * @return handle to the server for this service, NULL if there is none
123 struct GNUNET_SERVER_Handle *GNUNET_SERVICE_get_server (struct
124 GNUNET_SERVICE_Context
129 * Stop a service that was started with "GNUNET_SERVICE_start".
131 * @param sctx the service context returned from the start function
133 void GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx);
136 #if 0 /* keep Emacsens' auto-indent happy */
143 /* ifndef GNUNET_SERVICE_LIB_H */
145 /* end of gnunet_service_lib.h */