+ afb_req_fail_f(req, "unknown-verb", "verb %.*s unknown within api %s", (int)lenverb, verb, desc->binding->v1.prefix);
+}
+
+static int service_start_cb(void *closure, int share_session, int onneed)
+{
+ int (*init)(struct afb_service service);
+ void (*onevent)(const char *event, struct json_object *object);
+
+ struct api_so_desc *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, 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;