-static int service_start_cb(void *closure, int share_session, int onneed, struct afb_apiset *apiset)
-{
- int rc;
- int (*init)(struct afb_service service);
- void (*onevent)(const char *event, struct json_object *object);
-
- struct api_so_v1 *desc = closure;
-
- /* check state */
- if (desc->service != NULL) {
- /* not an error when onneed */
- if (onneed != 0)
- return 0;
-
- /* already started: it is an error */
- ERROR("Service %s already started", desc->binding->v1.prefix);
- return -1;
- }
-
- /* get the initialisation */
- init = dlsym(desc->handle, afb_api_so_v1_service_init);
- onevent = dlsym(desc->handle, afb_api_so_v1_service_event);
- if (init == NULL && onevent == NULL) {
- /* not an error when onneed */
- if (onneed != 0)
- return 0;
-
- /* no initialisation method */
- ERROR("Binding %s is not a service", desc->binding->v1.prefix);
- return -1;
- }
-
- /* get the event handler if any */
- desc->service = afb_svc_create(desc->binding->v1.prefix, apiset, share_session, onevent, NULL);
- if (desc->service == NULL) {
- ERROR("Creation of service %s failed", desc->binding->v1.prefix);
- return -1;
- }
-
- /* Starts the service */
- rc = afb_svc_start_v1(desc->service, init);
- if (rc < 0) {
- /* initialisation error */
- ERROR("Initialisation of service %s failed (%d): %m", desc->binding->v1.prefix, rc);
- afb_svc_destroy(desc->service, NULL);
- desc->service = NULL;
- return rc;
- }
-
- return 0;
-}
-
-static void update_hooks_cb(void *closure)
-{
- struct api_so_v1 *desc = closure;
- afb_ditf_update_hook(&desc->ditf);
- if (desc->service)
- afb_svc_update_hook(desc->service);
-}
-
-static int get_verbosity_cb(void *closure)
-{
- struct api_so_v1 *desc = closure;
- return desc->interface.verbosity;
-}
-
-static void set_verbosity_cb(void *closure, int level)
-{
- struct api_so_v1 *desc = closure;
- desc->interface.verbosity = level;
-}
-