+ NOTICE("API %s starting...", api->name);
+ if (api->api.itf->service_start) {
+ api->status = EBUSY;
+ rc = api->api.itf->service_start(api->api.closure, share_session, onneed, set);
+ if (rc < 0) {
+ api->status = errno ?: ECANCELED;
+ ERROR("The api %s failed to start (%d)", api->name, rc);
+ return -1;
+ }
+ } else if (!onneed) {
+ /* already started: it is an error */
+ ERROR("The api %s is not a startable service", api->name);
+ api->status = EINVAL;
+ return -1;
+ }
+ NOTICE("API %s started", api->name);
+ api->status = 0;
+ return 0;
+}
+
+/**
+ * Get from the 'set' the API of 'name' in 'api' with fallback to subset or default api
+ * @param set the set of API
+ * @param name the name of the API to get
+ * @param api the structure where to store data about the API of name
+ * @return 0 in case of success or -1 in case of error
+ */
+int afb_apiset_get_started(struct afb_apiset *set, const char *name, struct afb_api *api)
+{
+ struct api_desc *i;
+
+ i = get_api(set, name);
+ if (!i) {
+ errno = ENOENT;
+ return -1;
+ }
+ *api = i->api;
+ return i->status ? start_api(set, i, 1, 1) : 0;