diff options
Diffstat (limited to 'src/include/gnunet_service_lib.h')
-rw-r--r-- | src/include/gnunet_service_lib.h | 92 |
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 | */ |
53 | enum GNUNET_SERVICE_Options { | 53 | enum 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 | */ |
166 | struct GNUNET_SERVICE_Handle * | 178 | struct GNUNET_SERVICE_Handle * |
167 | GNUNET_SERVICE_start(const char *service_name, | 179 | GNUNET_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 | */ |
180 | void | 192 | void |
181 | GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv); | 193 | GNUNET_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 | */ |
225 | int | 237 | int |
226 | GNUNET_SERVICE_run_(int argc, | 238 | GNUNET_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 | */ |
320 | void | 333 | void |
321 | GNUNET_SERVICE_suspend(struct GNUNET_SERVICE_Handle *sh); | 334 | GNUNET_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 | */ |
329 | void | 342 | void |
330 | GNUNET_SERVICE_resume(struct GNUNET_SERVICE_Handle *sh); | 343 | GNUNET_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 | */ |
339 | void | 352 | void |
340 | GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c); | 353 | GNUNET_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 | */ |
349 | struct GNUNET_MQ_Handle * | 362 | struct GNUNET_MQ_Handle * |
350 | GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c); | 363 | GNUNET_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 | */ |
361 | void | 374 | void |
362 | GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c); | 375 | GNUNET_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 | */ |
380 | void | 394 | void |
381 | GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c); | 395 | GNUNET_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 | */ |
389 | void | 403 | void |
390 | GNUNET_SERVICE_shutdown(struct GNUNET_SERVICE_Handle *sh); | 404 | GNUNET_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 | */ |
405 | void | 419 | void |
406 | GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c); | 420 | GNUNET_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 | */ |
416 | void | 430 | void |
417 | GNUNET_SERVICE_client_persist(struct GNUNET_SERVICE_Client *c); | 431 | GNUNET_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 */ |