-static const char *getappid(struct json_object *obj)
-{
- return json_type_string == json_object_get_type(obj) ? json_object_get_string(obj) : NULL;
-}
-
-static void reply(struct jreq *jreq, struct json_object *resp, const char *errstr)
-{
- if (resp)
- jbus_reply_j(jreq, resp);
- else
- jbus_reply_error_s(jreq, errstr);
-}
-
-static void on_runnables(struct jreq *jreq, struct json_object *obj)
-{
- struct json_object *resp = afm_db_application_list(afdb);
- jbus_reply_j(jreq, resp);
- json_object_put(resp);
-}
-
-static void on_detail(struct jreq *jreq, struct json_object *obj)
-{
- const char *appid = getappid(obj);
- struct json_object *resp = afm_db_get_application_public(afdb, appid);
- reply(jreq, resp, error_not_found);
- json_object_put(resp);
-}
-
-static const char *j_get_string(struct json_object *obj, const char *key, const char *defval)
-{
- struct json_object *o;
- return json_object_object_get_ex(obj, key, &o) && json_object_get_type(o) == json_type_string ? json_object_get_string(o) : defval;
-}
-
-static int j_get_boolean(struct json_object *obj, const char *key, int defval)
-{
- struct json_object *o;
- return json_object_object_get_ex(obj, key, &o) && json_object_get_type(o) == json_type_boolean ? json_object_get_boolean(o) : defval;
-}
-
-static int json_add(struct json_object *obj, const char *key, struct json_object *val)
-{
- json_object_object_add(obj, key, val);
- return 0;
-}
-
-static int json_add_str(struct json_object *obj, const char *key, const char *val)
-{
- struct json_object *str = json_object_new_string (val ? val : "");
- return str ? json_add(obj, key, str) : (errno = ENOMEM, -1);
-}
-/*
-static int json_add_int(struct json_object *obj, const char *key, int val)
-{
- struct json_object *v = json_object_new_int (val);
- return v ? json_add(obj, key, v) : (errno = ENOMEM, -1);
-}
-*/
-static void on_install(struct jreq *jreq, struct json_object *req)