X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=include%2Fafb%2Fafb-req-itf.h;h=5116b13311316e0c1706c2936810431f0fb0e914;hb=b6b049eac4035c2ef581205af8eccce93f5727b3;hp=af452faf0fb0d03ccd7d1eefa1fc5b1c46a5e021;hpb=7059e59cddc1c81321639875636e88895bc14309;p=src%2Fapp-framework-binder.git diff --git a/include/afb/afb-req-itf.h b/include/afb/afb-req-itf.h index af452faf..5116b133 100644 --- a/include/afb/afb-req-itf.h +++ b/include/afb/afb-req-itf.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 "IoT.bzh" + * Copyright (C) 2016, 2017 "IoT.bzh" * Author: José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,7 +46,7 @@ struct afb_arg { * It records the functions to be called for the request. * Don't use this structure directly. * Use the helper functions documented below. - */ + */ struct afb_req_itf { /* CAUTION: respect the order, add at the end */ @@ -82,6 +82,16 @@ struct afb_req { void *closure; /* the closure argument for functions of 'itf' */ }; +/* + * Checks wether the request 'req' is valid or not. + * + * Returns 0 if not valid or 1 if valid. + */ +static inline int afb_req_is_valid(struct afb_req req) +{ + return req.itf != NULL; +} + /* * Gets from the request 'req' the argument of 'name'. * Returns a PLAIN structure of type 'struct afb_arg'. @@ -138,7 +148,7 @@ static inline struct json_object *afb_req_json(struct afb_req req) * Its send the object 'obj' (can be NULL) with an * informationnal comment 'info (can also be NULL). * - * For conveniency, the function calls 'json_object_put' for 'obj'. + * For convenience, the function calls 'json_object_put' for 'obj'. * Thus, in the case where 'obj' should remain available after * the function returns, the function 'json_object_get' shall be used. */ @@ -151,7 +161,7 @@ static inline void afb_req_success(struct afb_req req, struct json_object *obj, * Same as 'afb_req_success' but the 'info' is a formatting * string followed by arguments. * - * For conveniency, the function calls 'json_object_put' for 'obj'. + * For convenience, the function calls 'json_object_put' for 'obj'. * Thus, in the case where 'obj' should remain available after * the function returns, the function 'json_object_get' shall be used. */ @@ -176,7 +186,7 @@ static inline void afb_req_success_f(struct afb_req req, struct json_object *obj * to call afb_req_success(NULL, info). Thus even if possible it * is strongly recommanded to NEVER use "success" for status. * - * For conveniency, the function calls 'json_object_put' for 'obj'. + * For convenience, the function calls 'json_object_put' for 'obj'. * Thus, in the case where 'obj' should remain available after * the function returns, the function 'json_object_get' shall be used. */ @@ -189,7 +199,7 @@ static inline void afb_req_fail(struct afb_req req, const char *status, const ch * Same as 'afb_req_fail' but the 'info' is a formatting * string followed by arguments. * - * For conveniency, the function calls 'json_object_put' for 'obj'. + * For convenience, the function calls 'json_object_put' for 'obj'. * Thus, in the case where 'obj' should remain available after * the function returns, the function 'json_object_get' shall be used. */ @@ -300,7 +310,7 @@ static inline int afb_req_session_set_LOA(struct afb_req req, unsigned level) */ static inline struct afb_req *afb_req_store(struct afb_req req) { - struct afb_req *result = malloc(sizeof *result); + struct afb_req *result = (struct afb_req*)malloc(sizeof *result); if (result != NULL) { *result = req; afb_req_addref(req);