+Sending a reply to a request must be done at most one time.
+
+Two kinds of replies can be made: successful replies and
+failure replies.
+
+The functions to send replies are defined as below:
+
+ /*
+ * 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);
+ }
+
+
+