X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=include%2Fafb-req-itf.h;h=357ffd7b3a72db6de0ecd2f5d5547c1e836d2262;hb=3d28e7d00cd8641bf600d47ed0e3e7e57cb5b439;hp=9ced7630d129d2593f49daf66242152137d56d58;hpb=fc19b7d7974f9c64dffc40e180464d595a9805cd;p=src%2Fapp-framework-binder.git diff --git a/include/afb-req-itf.h b/include/afb-req-itf.h index 9ced7630..357ffd7b 100644 --- a/include/afb-req-itf.h +++ b/include/afb-req-itf.h @@ -15,20 +15,23 @@ * limitations under the License. */ +#pragma once + struct json_object; struct afb_arg { const char *name; const char *value; const char *path; - size_t size; }; struct afb_req_itf { + struct json_object *(*json)(void *data); struct afb_arg (*get)(void *data, const char *name); - void (*iterate)(void *data, int (*iterator)(void *closure, struct afb_arg arg), void *closure); - void (*fail)(void *data, const char *status, const char *info); void (*success)(void *data, struct json_object *obj, const char *info); + void (*fail)(void *data, const char *status, const char *info); + const char *(*raw)(void *data, size_t *size); + void (*send)(void *data, char *buffer, size_t size); int (*session_create)(void *data); int (*session_check)(void *data, int refresh); void (*session_close)(void *data); @@ -45,7 +48,7 @@ static inline struct afb_arg afb_req_get(struct afb_req req, const char *name) return req.itf->get(req.data, name); } -static inline const char *afb_req_argument(struct afb_req req, const char *name) +static inline const char *afb_req_value(struct afb_req req, const char *name) { return afb_req_get(req, name).value; } @@ -55,9 +58,14 @@ static inline const char *afb_req_path(struct afb_req req, const char *name) return afb_req_get(req, name).path; } -static inline void afb_req_iterate(struct afb_req req, int (*iterator)(void *closure, struct afb_arg arg), void *closure) +static inline struct json_object *afb_req_json(struct afb_req req) { - req.itf->iterate(req.data, iterator, closure); + return req.itf->json(req.data); +} + +static inline void afb_req_success(struct afb_req req, struct json_object *obj, const char *info) +{ + req.itf->success(req.data, obj, info); } static inline void afb_req_fail(struct afb_req req, const char *status, const char *info) @@ -65,9 +73,14 @@ static inline void afb_req_fail(struct afb_req req, const char *status, const ch req.itf->fail(req.data, status, info); } -static inline void afb_req_success(struct afb_req req, struct json_object *obj, const char *info) +static inline const char *afb_req_raw(struct afb_req req, size_t *size) { - req.itf->success(req.data, obj, info); + return req.itf->raw(req.data, size); +} + +static inline void afb_req_send(struct afb_req req, char *buffer, size_t size) +{ + req.itf->send(req.data, buffer, size); } static inline int afb_req_session_create(struct afb_req req)