X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_service_lib.h;h=39e6a805098d53f2e90e3a608cf94db3e253619f;hb=0c4acf951c74b9a9479cc3cbf3cf45abcdd49451;hp=82089954edb497c78a6055d0edfcc93f6d1dfeee;hpb=cf45b8dff29c366d51aa2e6ea6a64b99b514b9c9;p=oweals%2Fgnunet.git diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index 82089954e..39e6a8050 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h @@ -38,59 +38,109 @@ extern "C" #include "gnunet_configuration_lib.h" #include "gnunet_server_lib.h" + +/** + * Get the list of addresses that a server for the given service + * should bind to. + * + * @param service_name name of the service + * @param cfg configuration (which specifies the addresses) + * @param addrs set (call by reference) to an array of pointers to the + * addresses the server should bind to and listen on; the + * array will be NULL-terminated (on success) + * @param addr_lens set (call by reference) to an array of the lengths + * of the respective 'struct sockaddr' struct in the 'addrs' + * array (on success) + * @return number of addresses found on success, + * GNUNET_SYSERR if the configuration + * did not specify reasonable finding information or + * if it specified a hostname that could not be resolved; + * GNUNET_NO if the number of addresses configured is + * zero (in this case, '*addrs' and '*addr_lens' will be + * set to NULL). + */ +int +GNUNET_SERVICE_get_server_addresses (const char *service_name, + const struct GNUNET_CONFIGURATION_Handle + *cfg, struct sockaddr ***addrs, + socklen_t ** addr_lens); + + /** * Function called by the service's run * method to run service-specific setup code. * * @param cls closure - * @param sched scheduler to use * @param server the initialized server * @param cfg configuration to use */ typedef void (*GNUNET_SERVICE_Main) (void *cls, - struct GNUNET_SCHEDULER_Handle * sched, struct GNUNET_SERVER_Handle * server, const struct GNUNET_CONFIGURATION_Handle * cfg); +/** + * Options for the service (bitmask). + */ +enum GNUNET_SERVICE_Options +{ + /** + * Use defaults. + */ + GNUNET_SERVICE_OPTION_NONE = 0, + + /** + * Do not trigger server shutdown on signals, allow for the user + * to terminate the server explicitly when needed. + */ + GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN = 1, + + /** + * Trigger a SOFT server shutdown on signals, allowing active + * non-monitor clients to complete their transactions. + */ + GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN = 2 +}; + + /** * Run a standard GNUnet service startup sequence (initialize loggers * and configuration, parse options). * * @param argc number of command line arguments * @param argv command line arguments - * @param serviceName our service name + * @param service_name our service name + * @param options service options * @param task main task of the service * @param task_cls closure for task * @return GNUNET_SYSERR on error, GNUNET_OK * if we shutdown nicely */ -int GNUNET_SERVICE_run (int argc, - char *const *argv, - const char *serviceName, - GNUNET_SERVICE_Main task, - void *task_cls); +int +GNUNET_SERVICE_run (int argc, char *const *argv, const char *service_name, + enum GNUNET_SERVICE_Options options, GNUNET_SERVICE_Main task, + void *task_cls); +/** + * Opaque handle for a service. + */ struct GNUNET_SERVICE_Context; /** * Run a service startup sequence within an existing * initialized system. * - * @param serviceName our service name - * @param sched scheduler to use + * @param service_name our service name * @param cfg configuration to use + * @param options service options * @return NULL on error, service handle */ -struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName, - struct - GNUNET_SCHEDULER_Handle - *sched, - const struct - GNUNET_CONFIGURATION_Handle - *cfg); +struct GNUNET_SERVICE_Context * +GNUNET_SERVICE_start (const char *service_name, + const struct GNUNET_CONFIGURATION_Handle *cfg, + enum GNUNET_SERVICE_Options options); /** @@ -100,9 +150,8 @@ struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName, * @param ctx the service context returned from the start function * @return handle to the server for this service, NULL if there is none */ -struct GNUNET_SERVER_Handle *GNUNET_SERVICE_get_server (struct - GNUNET_SERVICE_Context - *ctx); +struct GNUNET_SERVER_Handle * +GNUNET_SERVICE_get_server (struct GNUNET_SERVICE_Context *ctx); /** @@ -110,7 +159,8 @@ struct GNUNET_SERVER_Handle *GNUNET_SERVICE_get_server (struct * * @param sctx the service context returned from the start function */ -void GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx); +void +GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx); #if 0 /* keep Emacsens' auto-indent happy */