+/**
+ * Declare that the api of 'name' requires the api of name 'required'.
+ * The api is searched in the apiset 'set' and if 'rec' isn't null also in its subset.
+ * Returns 0 if the declaration successed or -1 in case of failure
+ * (ENOMEM: allocation failure, ENOENT: api name not found)
+ */
+int afb_apiset_require(struct afb_apiset *set, const char *name, const char *required)
+{
+ struct api_desc *a;
+ struct api_depend *d;
+ int rc = -1;
+
+ a = searchrec(set, name);
+ if (!a)
+ errno = ENOENT;
+ else {
+ d = malloc(strlen(required) + sizeof *d);
+ if (!d)
+ errno = ENOMEM;
+ else {
+ d->set = set;
+ strcpy(d->name, required);
+ rc = api_array_add(&a->require.apis, d);
+ }
+ }
+ return rc;
+}
+
+/**
+ * Declare that the api of name 'apiname' requires the class of name 'classname'.
+ * Returns 0 if the declaration successed or -1 in case of failure
+ * (ENOMEM: allocation failure, ENOENT: api name not found)
+ */
+int afb_apiset_require_class(struct afb_apiset *set, const char *apiname, const char *classname)
+{
+ struct api_desc *a = searchrec(set, apiname);
+ struct api_class *c = class_search(classname, 1);
+ return a && c ? api_array_add(&a->require.classes, c) : (errno = ENOENT, -1);
+}
+
+/**
+ * Declare that the api of name 'apiname' provides the class of name 'classname'
+ * Returns 0 if the declaration successed or -1 in case of failure
+ * (ENOMEM: allocation failure, ENOENT: api name not found)
+ */
+int afb_apiset_provide_class(struct afb_apiset *set, const char *apiname, const char *classname)
+{
+ struct api_desc *a = searchrec(set, apiname);
+ struct api_class *c = class_search(classname, 1);
+ return a && c ? api_array_add(&c->providers, a) : (errno = ENOENT, -1);
+}
+
+/**
+ * Start any API that provides the class of name 'classname'
+ */
+int afb_apiset_class_start(const char *classname)
+{
+ struct api_class *cla = class_search(classname, 0);
+ return cla ? start_class(cla) : (errno = ENOENT, -1);
+}
+