+ /* 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, binding_service_init_function_v1);
+ if (init == 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 */
+ onevent = dlsym(desc->handle, binding_service_event_function_v1);
+ desc->service = afb_svc_create(share_session, init, onevent);
+ if (desc->service == NULL) {
+ /* starting error */
+ ERROR("Starting service %s failed", desc->binding->v1.prefix);
+ return -1;
+ }
+
+ return 0;
+}
+
+void afb_api_so_set_timeout(int to)
+{
+ api_timeout = to;
+}
+
+int afb_api_so_add_binding(const char *path)
+{
+ int rc;
+ void *handle;
+ struct api_so_desc *desc;
+ struct afb_binding *(*register_function) (const struct afb_binding_interface *interface);
+ struct afb_verb_desc_v1 fake_verb;
+ struct afb_binding fake_binding;
+
+ // This is a loadable library let's check if it's a binding
+ rc = 0;
+ handle = dlopen(path, RTLD_NOW | RTLD_LOCAL);
+ if (handle == NULL) {
+ ERROR("binding [%s] not loadable", path);