summaryrefslogtreecommitdiff
path: root/src/include/gnunet_service_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_service_lib.h')
-rw-r--r--src/include/gnunet_service_lib.h92
1 files changed, 53 insertions, 39 deletions
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h
index 9cdf4d459..19a5fb89b 100644
--- a/src/include/gnunet_service_lib.h
+++ b/src/include/gnunet_service_lib.h
@@ -50,7 +50,8 @@ extern "C"
50/** 50/**
51 * Options for the service (bitmask). 51 * Options for the service (bitmask).
52 */ 52 */
53enum GNUNET_SERVICE_Options { 53enum GNUNET_SERVICE_Options
54{
54 /** 55 /**
55 * Use defaults. Terminates all client connections and the listen 56 * Use defaults. Terminates all client connections and the listen
56 * sockets immediately upon receiving the shutdown signal. 57 * sockets immediately upon receiving the shutdown signal.
@@ -68,7 +69,18 @@ enum GNUNET_SERVICE_Options {
68 * Trigger a SOFT server shutdown on signals, allowing active 69 * Trigger a SOFT server shutdown on signals, allowing active
69 * non-monitor clients to complete their transactions. 70 * non-monitor clients to complete their transactions.
70 */ 71 */
71 GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN = 2 72 GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN = 2,
73
74 /**
75 * Bitmask over the shutdown options.
76 */
77 GNUNET_SERVICE_OPTION_SHUTDOWN_BITMASK = 3,
78
79 /**
80 * Instead of listening on lsocks passed by the parent,
81 * close them *after* opening our own listen socket(s).
82 */
83 GNUNET_SERVICE_OPTION_CLOSE_LSOCKS = 4
72}; 84};
73 85
74 86
@@ -164,12 +176,12 @@ typedef void
164 * @return NULL on error 176 * @return NULL on error
165 */ 177 */
166struct GNUNET_SERVICE_Handle * 178struct GNUNET_SERVICE_Handle *
167GNUNET_SERVICE_start(const char *service_name, 179GNUNET_SERVICE_start (const char *service_name,
168 const struct GNUNET_CONFIGURATION_Handle *cfg, 180 const struct GNUNET_CONFIGURATION_Handle *cfg,
169 GNUNET_SERVICE_ConnectHandler connect_cb, 181 GNUNET_SERVICE_ConnectHandler connect_cb,
170 GNUNET_SERVICE_DisconnectHandler disconnect_cb, 182 GNUNET_SERVICE_DisconnectHandler disconnect_cb,
171 void *cls, 183 void *cls,
172 const struct GNUNET_MQ_MessageHandler *handlers); 184 const struct GNUNET_MQ_MessageHandler *handlers);
173 185
174 186
175/** 187/**
@@ -178,7 +190,7 @@ GNUNET_SERVICE_start(const char *service_name,
178 * @param srv service to stop 190 * @param srv service to stop
179 */ 191 */
180void 192void
181GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv); 193GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv);
182 194
183 195
184/** 196/**
@@ -223,15 +235,15 @@ GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv);
223 * @return 0 on success, non-zero on error 235 * @return 0 on success, non-zero on error
224 */ 236 */
225int 237int
226GNUNET_SERVICE_run_(int argc, 238GNUNET_SERVICE_run_ (int argc,
227 char *const *argv, 239 char *const *argv,
228 const char *service_name, 240 const char *service_name,
229 enum GNUNET_SERVICE_Options options, 241 enum GNUNET_SERVICE_Options options,
230 GNUNET_SERVICE_InitCallback service_init_cb, 242 GNUNET_SERVICE_InitCallback service_init_cb,
231 GNUNET_SERVICE_ConnectHandler connect_cb, 243 GNUNET_SERVICE_ConnectHandler connect_cb,
232 GNUNET_SERVICE_DisconnectHandler disconnect_cb, 244 GNUNET_SERVICE_DisconnectHandler disconnect_cb,
233 void *cls, 245 void *cls,
234 const struct GNUNET_MQ_MessageHandler *handlers); 246 const struct GNUNET_MQ_MessageHandler *handlers);
235 247
236 248
237/** 249/**
@@ -291,23 +303,24 @@ GNUNET_SERVICE_run_(int argc,
291 * GNUNET_MQ_handler_end ()); 303 * GNUNET_MQ_handler_end ());
292 * </code> 304 * </code>
293 */ 305 */
294#define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, disconnect_cb, cls, ...) \ 306#define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \
307 disconnect_cb, cls, ...) \
295 int \ 308 int \
296 main(int argc, \ 309 main (int argc, \
297 char *const *argv) \ 310 char *const *argv) \
298 { \ 311 { \
299 struct GNUNET_MQ_MessageHandler mh[] = { \ 312 struct GNUNET_MQ_MessageHandler mh[] = { \
300 __VA_ARGS__ \ 313 __VA_ARGS__ \
301 }; \ 314 }; \
302 return GNUNET_SERVICE_run_(argc, \ 315 return GNUNET_SERVICE_run_ (argc, \
303 argv, \ 316 argv, \
304 service_name, \ 317 service_name, \
305 service_options, \ 318 service_options, \
306 init_cb, \ 319 init_cb, \
307 connect_cb, \ 320 connect_cb, \
308 disconnect_cb, \ 321 disconnect_cb, \
309 cls, \ 322 cls, \
310 mh); \ 323 mh); \
311 } 324 }
312 325
313 326
@@ -318,7 +331,7 @@ GNUNET_SERVICE_run_(int argc,
318 * @param sh service to stop accepting connections. 331 * @param sh service to stop accepting connections.
319 */ 332 */
320void 333void
321GNUNET_SERVICE_suspend(struct GNUNET_SERVICE_Handle *sh); 334GNUNET_SERVICE_suspend (struct GNUNET_SERVICE_Handle *sh);
322 335
323 336
324/** 337/**
@@ -327,7 +340,7 @@ GNUNET_SERVICE_suspend(struct GNUNET_SERVICE_Handle *sh);
327 * @param sh service to resume accepting connections. 340 * @param sh service to resume accepting connections.
328 */ 341 */
329void 342void
330GNUNET_SERVICE_resume(struct GNUNET_SERVICE_Handle *sh); 343GNUNET_SERVICE_resume (struct GNUNET_SERVICE_Handle *sh);
331 344
332 345
333/** 346/**
@@ -337,7 +350,7 @@ GNUNET_SERVICE_resume(struct GNUNET_SERVICE_Handle *sh);
337 * @param c the client to continue receiving from 350 * @param c the client to continue receiving from
338 */ 351 */
339void 352void
340GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c); 353GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c);
341 354
342 355
343/** 356/**
@@ -347,7 +360,7 @@ GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c);
347 * @return the message queue of @a c 360 * @return the message queue of @a c
348 */ 361 */
349struct GNUNET_MQ_Handle * 362struct GNUNET_MQ_Handle *
350GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c); 363GNUNET_SERVICE_client_get_mq (struct GNUNET_SERVICE_Client *c);
351 364
352 365
353/** 366/**
@@ -359,7 +372,8 @@ GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c);
359 * @param c client for which to disable the warning 372 * @param c client for which to disable the warning
360 */ 373 */
361void 374void
362GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c); 375GNUNET_SERVICE_client_disable_continue_warning (struct
376 GNUNET_SERVICE_Client *c);
363 377
364 378
365/** 379/**
@@ -378,7 +392,7 @@ GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c);
378 * @param c client to disconnect now 392 * @param c client to disconnect now
379 */ 393 */
380void 394void
381GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c); 395GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c);
382 396
383 397
384/** 398/**
@@ -387,7 +401,7 @@ GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c);
387 * @param sh server to shutdown 401 * @param sh server to shutdown
388 */ 402 */
389void 403void
390GNUNET_SERVICE_shutdown(struct GNUNET_SERVICE_Handle *sh); 404GNUNET_SERVICE_shutdown (struct GNUNET_SERVICE_Handle *sh);
391 405
392 406
393/** 407/**
@@ -403,7 +417,7 @@ GNUNET_SERVICE_shutdown(struct GNUNET_SERVICE_Handle *sh);
403 * @param c client to mark as a monitor 417 * @param c client to mark as a monitor
404 */ 418 */
405void 419void
406GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c); 420GNUNET_SERVICE_client_mark_monitor (struct GNUNET_SERVICE_Client *c);
407 421
408 422
409/** 423/**
@@ -414,7 +428,7 @@ GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c);
414 * @param c client to persist the socket (never to be closed) 428 * @param c client to persist the socket (never to be closed)
415 */ 429 */
416void 430void
417GNUNET_SERVICE_client_persist(struct GNUNET_SERVICE_Client *c); 431GNUNET_SERVICE_client_persist (struct GNUNET_SERVICE_Client *c);
418 432
419 433
420#if 0 /* keep Emacsens' auto-indent happy */ 434#if 0 /* keep Emacsens' auto-indent happy */