X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=include%2Fafb-req-itf.h;h=061c1f0de326b417b6eed3f2692a77c5b8feca73;hb=0a06ae40543bb9043e80be8d2aa480ecf995800c;hp=f03ce868e0709661f67a3ead772df54c7d18334a;hpb=46d9538587a3521caa1e3b20bf337a53ed400777;p=src%2Fapp-framework-binder.git diff --git a/include/afb-req-itf.h b/include/afb-req-itf.h index f03ce868..061c1f0d 100644 --- a/include/afb-req-itf.h +++ b/include/afb-req-itf.h @@ -31,9 +31,9 @@ struct afb_req_itf { void (*success)(void *req_closure, struct json_object *obj, const char *info); void (*fail)(void *req_closure, const char *status, const char *info); const char *(*raw)(void *req_closure, size_t *size); - void (*send)(void *req_closure, char *buffer, size_t size); + void (*send)(void *req_closure, const char *buffer, size_t size); void *(*context_get)(void *ctx_closure); - void (*context_set)(void *ctx_closure, void *context, void (*free_context)(void*)); + void (*context_set)(void *ctx_closure, void *value, void (*free_value)(void*)); int (*session_create)(void *req_closure); int (*session_check)(void *req_closure, int refresh); void (*session_close)(void *req_closure); @@ -44,6 +44,7 @@ struct afb_req { void *req_closure; void *ctx_closure; }; + static inline struct afb_arg afb_req_get(struct afb_req req, const char *name) { return req.itf->get(req.req_closure, name); @@ -79,7 +80,7 @@ static inline const char *afb_req_raw(struct afb_req req, size_t *size) return req.itf->raw(req.req_closure, size); } -static inline void afb_req_send(struct afb_req req, char *buffer, size_t size) +static inline void afb_req_send(struct afb_req req, const char *buffer, size_t size) { req.itf->send(req.req_closure, buffer, size); } @@ -89,9 +90,9 @@ static inline void *afb_req_context_get(struct afb_req req) return req.itf->context_get(req.ctx_closure); } -static inline void afb_req_context_set(struct afb_req req, void *context, void (*free_context)(void*)) +static inline void afb_req_context_set(struct afb_req req, void *value, void (*free_value)(void*)) { - return req.itf->context_set(req.ctx_closure, context, free_context); + return req.itf->context_set(req.ctx_closure, value, free_value); } static inline void afb_req_context_clear(struct afb_req req) @@ -120,12 +121,28 @@ static inline void afb_req_session_close(struct afb_req req) req.itf->session_close(req.req_closure); } +#include + +static inline struct afb_req *afb_req_store(struct afb_req req) +{ + struct afb_req *result = malloc(sizeof *result); + if (result != NULL) + *result = req; + return result; +} + +static inline struct afb_req afb_req_unstore(struct afb_req *req) +{ + struct afb_req result = *req; + free(req); + return result; +} + #if !defined(_GNU_SOURCE) # error "_GNU_SOURCE must be defined for using vasprintf" #endif #include -#include #include static inline void afb_req_fail_v(struct afb_req req, const char *status, const char *info, va_list args)