+static struct afb_req unstore_req_cb(void *closure, struct afb_stored_req *sreq)
+{
+ return afb_xreq_unstore(sreq);
+}
+
+static int require_api_cb(void *closure, const char *name, int initialized)
+{
+ struct afb_ditf *ditf = closure;
+ if (ditf->state != Daemon_Init) {
+ ERROR("[API %s] Bad call to 'afb_daemon_require(%s, %d)', must be in Init", ditf->api, name, initialized);
+ errno = EINVAL;
+ return -1;
+ }
+ return -!(initialized ? afb_apiset_lookup_started : afb_apiset_lookup)(main_apiset, name, 1);
+}
+
+static int rename_api_cb(void *closure, const char *name)
+{
+ struct afb_ditf *ditf = closure;
+ if (ditf->state != Daemon_Pre_Init) {
+ ERROR("[API %s] Bad call to 'afb_daemon_rename(%s)', must be in PreInit", ditf->api, name);
+ errno = EINVAL;
+ return -1;
+ }
+ if (!afb_api_is_valid_name(name)) {
+ ERROR("[API %s] Can't rename to %s: bad API name", ditf->api, name);
+ errno = EINVAL;
+ return -1;
+ }
+ NOTICE("[API %s] renamed to [API %s]", ditf->api, name);
+ afb_ditf_rename(ditf, name);
+ return 0;
+}
+