+static struct afb_xreq_query_itf startup_xreq_itf =
+{
+ .reply = startup_call_reply,
+ .unref = startup_call_unref
+};
+
+static void startup_call_current(struct startup_req *sreq)
+{
+ char *api, *verb, *json;
+
+ api = sreq->current->value;
+ verb = strchr(api, '/');
+ if (verb) {
+ json = strchr(verb, ':');
+ if (json) {
+ afb_xreq_init(&sreq->xreq, &startup_xreq_itf);
+ afb_context_init(&sreq->xreq.context, sreq->session, NULL);
+ sreq->xreq.context.validated = 1;
+ sreq->api = strndup(api, verb - api);
+ sreq->verb = strndup(verb + 1, json - verb - 1);
+ sreq->xreq.api = sreq->api;
+ sreq->xreq.verb = sreq->verb;
+ sreq->xreq.json = json_tokener_parse(json + 1);
+ if (sreq->api && sreq->verb && sreq->xreq.json) {
+ afb_xreq_process(&sreq->xreq, main_apiset);
+ return;
+ }
+ }
+ }
+ ERROR("Bad call specification %s", sreq->current->value);
+ exit(1);
+}
+
+static void run_startup_calls()
+{
+ struct afb_config_list *list;
+ struct startup_req *sreq;
+
+ list = config->calls;
+ if (list) {
+ sreq = calloc(1, sizeof *sreq);
+ sreq->session = afb_session_create("startup", 3600);
+ sreq->current = list;
+ startup_call_current(sreq);
+ }
+}
+
+/*---------------------------------------------------------
+ | job for starting the daemon
+ +--------------------------------------------------------- */
+
+static void start()
+{
+ struct afb_hsrv *hsrv;