-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 (afb_export_is_started(desc->export)) {
- /* not an error when onneed */
- if (onneed != 0)
- goto done;
-
- /* already started: it is an error */
- ERROR("Service %s already started", afb_export_apiname(desc->export));
- 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);
-
- /* unshare the session if asked */
- if (!share_session) {
- rc = afb_export_unshare_session(desc->export);
- if (rc < 0) {
- ERROR("Can't unshare the session for %s", afb_export_apiname(desc->export));
- return -1;
- }
- }
-
- /* set event handling */
- rc = afb_export_handle_events(desc->export, onevent);
- if (rc < 0) {
- ERROR("Can't set event handler for %s", afb_export_apiname(desc->export));
- return -1;
- }
-
- /* Starts the service */
- rc = afb_export_start_v1(desc->export, init);
- if (rc < 0) {
- /* initialisation error */
- ERROR("Initialisation of service %s failed (%d): %m", afb_export_apiname(desc->export), rc);
- return rc;
- }
-
-done:
- return 0;
-}
-
-static void update_hooks_cb(void *closure)
-{
- struct api_so_v1 *desc = closure;
- afb_export_update_hook(desc->export);
-}
-
-static int get_verbosity_cb(void *closure)
-{
- struct api_so_v1 *desc = closure;
- return afb_export_verbosity_get(desc->export);
-}
-
-static void set_verbosity_cb(void *closure, int level)
-{
- struct api_so_v1 *desc = closure;
- afb_export_verbosity_set(desc->export, level);
-}
-
-static struct json_object *addperm(struct json_object *o, struct json_object *x)
-{
- struct json_object *a;
-
- if (!o)
- return x;
-
- if (!json_object_object_get_ex(o, "allOf", &a)) {
- a = json_object_new_array();
- json_object_array_add(a, o);
- o = json_object_new_object();
- json_object_object_add(o, "allOf", a);
- }
- json_object_array_add(a, x);
- return o;
-}
-
-static struct json_object *addperm_key_val(struct json_object *o, const char *key, struct json_object *val)
-{
- struct json_object *x = json_object_new_object();
- json_object_object_add(x, key, val);
- return addperm(o, x);
-}
-
-static struct json_object *addperm_key_valstr(struct json_object *o, const char *key, const char *val)
-{
- return addperm_key_val(o, key, json_object_new_string(val));
-}
-
-static struct json_object *addperm_key_valint(struct json_object *o, const char *key, int val)
-{
- return addperm_key_val(o, key, json_object_new_int(val));
-}
-
-static struct json_object *make_description_openAPIv3(struct api_so_v1 *desc)