X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_service_lib.h;h=fca2ff329bdc3cde07e9ed1a2d25406c93cd10cb;hb=502af2167f7c218366666ca4944bd7cc54b5b19a;hp=dbfb2588bd629d51e4af8e87bb1bcab56c57cbe5;hpb=0a217a8df1657b4334b55b0e4a6c7837a8dbcfd9;p=oweals%2Fgnunet.git diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index dbfb2588b..fca2ff329 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h @@ -38,32 +38,64 @@ 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 serviceName 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 *serviceName, + 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, - struct GNUNET_CONFIGURATION_Handle * + const struct GNUNET_CONFIGURATION_Handle * cfg); /** - * Function called when the service shuts - * down to run service-specific teardown code. - * - * @param cls closure - * @param cfg configuration to use + * Options for the service (bitmask). */ -typedef void (*GNUNET_SERVICE_Term) (void *cls, - struct GNUNET_CONFIGURATION_Handle * - cfg); +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 +}; /** @@ -73,19 +105,18 @@ typedef void (*GNUNET_SERVICE_Term) (void *cls, * @param argc number of command line arguments * @param argv command line arguments * @param serviceName our service name + * @param opt service options * @param task main task of the service * @param task_cls closure for task - * @param term termination task of the service - * @param term_cls closure for term * @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, - GNUNET_SERVICE_Term term, void *term_cls); +int +GNUNET_SERVICE_run (int argc, + char *const *argv, + const char *serviceName, + enum GNUNET_SERVICE_Options opt, + GNUNET_SERVICE_Main task, void *task_cls); struct GNUNET_SERVICE_Context; @@ -95,15 +126,11 @@ struct GNUNET_SERVICE_Context; * initialized system. * * @param serviceName our service name - * @param sched scheduler to use * @param cfg configuration to use * @return NULL on error, service handle */ struct GNUNET_SERVICE_Context *GNUNET_SERVICE_start (const char *serviceName, - struct - GNUNET_SCHEDULER_Handle - *sched, - struct + const struct GNUNET_CONFIGURATION_Handle *cfg); @@ -123,9 +150,9 @@ struct GNUNET_SERVER_Handle *GNUNET_SERVICE_get_server (struct /** * Stop a service that was started with "GNUNET_SERVICE_start". * - * @param ctx the service context returned from the start function + * @param sctx the service context returned from the start function */ -void GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *ctx); +void GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx); #if 0 /* keep Emacsens' auto-indent happy */