- return afb_req_get(req, name).value;
-}
-
-/*
- * Gets from the request 'req' the path for file attached to the argument of 'name'.
- * Returns NULL if when there is no argument of 'name' or when there is no file.
- * Returns the path of the argument of 'name' otherwise.
- *
- * Shortcut for: afb_req_get(req, name).path
- */
-static inline const char *afb_req_path(struct afb_req req, const char *name)
-{
- return afb_req_get(req, name).path;
-}
-
-/*
- * Gets from the request 'req' the json object hashing the arguments.
- * The returned object must not be released using 'json_object_put'.
- */
-static inline struct json_object *afb_req_json(struct afb_req req)
-{
- return req.itf->json(req.closure);
-}
-
-/*
- * Sends a reply of kind success to the request 'req'.
- * The status of the reply is automatically set to "success".
- * Its send the object 'obj' (can be NULL) with an
- * informationnal comment 'info (can also be NULL).
- */
-static inline void afb_req_success(struct afb_req req, struct json_object *obj, const char *info)
-{
- req.itf->success(req.closure, obj, info);
-}
-
-/*
- * Same as 'afb_req_success' but the 'info' is a formatting
- * string followed by arguments.
- */
-static inline void afb_req_success_f(struct afb_req req, struct json_object *obj, const char *info, ...)
-{
- char *message;
- va_list args;
- va_start(args, info);
- if (info == NULL || vasprintf(&message, info, args) < 0)
- message = NULL;
- va_end(args);
- afb_req_success(req, obj, message);
- free(message);
-}
-
-/*
- * Sends a reply of kind failure to the request 'req'.
- * The status of the reply is set to 'status' and an
- * informationnal comment 'info' (can also be NULL) can be added.
- *
- * Note that calling afb_req_fail("success", info) is equivalent
- * to call afb_req_success(NULL, info). Thus even if possible it
- * is strongly recommanded to NEVER use "success" for status.
- */
-static inline void afb_req_fail(struct afb_req req, const char *status, const char *info)
-{
- req.itf->fail(req.closure, status, info);
-}
-
-/*
- * Same as 'afb_req_fail' but the 'info' is a formatting
- * string followed by arguments.
- */
-static inline void afb_req_fail_f(struct afb_req req, const char *status, const char *info, ...)
-{
- char *message;
- va_list args;
- va_start(args, info);
- if (info == NULL || vasprintf(&message, info, args) < 0)
- message = NULL;
- va_end(args);
- afb_req_fail(req, status, message);
- free(message);
-}
-
-/*
- * Gets the pointer stored by the plugin for the session of 'req'.
- * When the plugin has not yet recorded a pointer, NULL is returned.
- */
-static inline void *afb_req_context_get(struct afb_req req)
-{
- return req.itf->context_get(req.closure);
-}
-
-/*
- * Stores for the plugin the pointer 'context' to the session of 'req'.
- * The function 'free_context' will be called when the session is closed
- * or if plugin stores an other pointer.
- */
-static inline void afb_req_context_set(struct afb_req req, void *context, void (*free_context)(void*))
-{
- req.itf->context_set(req.closure, context, free_context);
-}
-
-/*
- * Gets the pointer stored by the plugin for the session of 'req'.
- * If the stored pointer is NULL, indicating that no pointer was
- * already stored, afb_req_context creates a new context by calling
- * the function 'create_context' and stores it with the freeing function
- * 'free_context'.
- */
-static inline void *afb_req_context(struct afb_req req, void *(*create_context)(), void (*free_context)(void*))
-{
- void *result = afb_req_context_get(req);
- if (result == NULL) {
- result = create_context();
- afb_req_context_set(req, result, free_context);
- }
- return result;
-}
-
-/*
- * Frees the pointer stored by the plugin for the session of 'req'
- * and sets it to NULL.
- *
- * Shortcut for: afb_req_context_set(req, NULL, NULL)
- */
-static inline void afb_req_context_clear(struct afb_req req)
-{
- afb_req_context_set(req, NULL, NULL);
-}
-
-/*
- * Adds one to the count of references of 'req'.
- * This function MUST be called by asynchronous implementations
- * of verbs if no reply was sent before returning.
- */
-static inline void afb_req_addref(struct afb_req req)
-{
- req.itf->addref(req.closure);
-}
-
-/*
- * Substracts one to the count of references of 'req'.
- * This function MUST be called by asynchronous implementations
- * of verbs after sending the asynchronous reply.
- */
-static inline void afb_req_unref(struct afb_req req)
-{
- req.itf->unref(req.closure);
-}
-
-/*
- * Closes the session associated with 'req'
- * and delete all associated contexts.
- */
-static inline void afb_req_session_close(struct afb_req req)
-{
- req.itf->session_close(req.closure);
-}
-
-/*
- * Sets the level of assurance of the session of 'req'
- * to 'level'. The effect of this function is subject of
- * security policies.
- * Returns 1 on success or 0 if failed.
- */
-static inline int afb_req_session_set_LOA(struct afb_req req, unsigned level)
-{
- return req.itf->session_set_LOA(req.closure, level);
-}
-
-/*
- * Stores 'req' on heap for asynchrnous use.
- * Returns a pointer to the stored 'req' or NULL on memory depletion.
- * The count of reference to 'req' is incremented on success
- * (see afb_req_addref).
- */
-static inline struct afb_req *afb_req_store(struct afb_req req)
-{
- struct afb_req *result = malloc(sizeof *result);
- if (result != NULL) {
- *result = req;
- afb_req_addref(req);
- }
- return result;
-}
-
-/*
- * Retrieves the afb_req stored at 'req' and frees the memory.
- * Returns the stored request.
- * The count of reference is UNCHANGED, thus, normally, the
- * function 'afb_req_unref' should be called on the result
- * after that the asynchronous reply if sent.
- */
-static inline struct afb_req afb_req_unstore(struct afb_req *req)
-{
- struct afb_req result = *req;
- free(req);
- return result;
-}
-
-/* internal use */
-static inline const char *afb_req_raw(struct afb_req req, size_t *size)
-{
- return req.itf->raw(req.closure, size);
-}
-
-/* internal use */
-static inline void afb_req_send(struct afb_req req, const char *buffer, size_t size)
-{
- req.itf->send(req.closure, buffer, size);
-}