-Functions of class **afb_req_t**
+Functions of class **afb_req**
============================
## General function
* @return 0 if not valid or 1 if valid.
*/
int afb_req_is_valid(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_get_api
* @return the api serving the request
*/
afb_api_t afb_req_get_api(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_get_vcbdata
* @return the callback data attached to the verb description
*/
void *afb_req_get_vcbdata(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_get_called_api
* @see afb_api_add_alias
*/
const char *afb_req_get_called_api(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_get_called_verb
* @return the name of the called verb
*/
const char *afb_req_get_called_verb(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_addref
*
* @return returns the request req
*/
-afb_req_t*afb_req_addref(
- afb_req_t*req);
+afb_req_t *afb_req_addref(
+ afb_req_t req);
```
### afb_req_unref
* @param req the request
*/
void afb_req_unref(
- afb_req_t*req);
+ afb_req_t req);
```
* @see syslog
*/
int afb_req_wants_log_level(
- afb_req_t*req,
+ afb_req_t req,
int level);
```
* @see afb_req_verbose
*/
void afb_req_vverbose(
- afb_req_t*req,
+ afb_req_t req,
int level, const char *file,
int line,
const char * func,
* @see printf
*/
void afb_req_verbose(
- afb_req_t*req,
+ afb_req_t req,
int level, const char *file,
int line,
const char * func,
* @see afb_req_path
*/
struct afb_arg afb_req_get(
- afb_req_t*req,
+ afb_req_t req,
const char *name);
```
* @see afb_req_path
*/
const char *afb_req_value(
- afb_req_t*req,
+ afb_req_t req,
const char *name);
```
* @see afb_req_value
*/
const char *afb_req_path(
- afb_req_t*req,
+ afb_req_t req,
const char *name);
```
* @see afb_req_path
*/
struct json_object *afb_req_json(
- afb_req_t*req);
+ afb_req_t req);
```
## Reply functions
* @see afb_req_reply_f
*/
void afb_req_reply(
- afb_req_t*req,
+ afb_req_t req,
struct json_object *obj,
const char *error,
const char *info);
* @see vprintf
*/
void afb_req_reply_v(
- afb_req_t*req,
+ afb_req_t req,
struct json_object *obj,
const char *error,
const char *info,
* @see printf
*/
void afb_req_reply_f(
- afb_req_t*req,
+ afb_req_t req,
struct json_object *obj,
const char *error,
const char *info,
* 4. 'info' a string handling some info (can be NULL)
* 5. 'req' the req
*
+ * NOTE: For convenience, *json_object_put* is called on 'object' after the
+ * callback returns. So, it is wrong to call *json_object_put* in the callback.
+ *
* @param req The request
* @param api The api name of the method to call
* @param verb The verb name of the method to call
* @see also 'afb_req_subcall_sync'
*/
void afb_req_subcall(
- afb_req_t*req,
+ afb_req_t req,
const char *api,
const char *verb,
struct json_object *args,
struct json_object *object,
const char *error,
const char * info,
- afb_req_t*req),
+ afb_req_t req),
void *closure);
```
* @return 0 in case of success or -1 in case of error
*/
int afb_req_subcall_sync(
- afb_req_t*req,
+ afb_req_t req,
const char *api,
const char *verb,
struct json_object *args,
* Establishes for the client link identified by 'req' a subscription
* to the 'event'.
*
+ * Establishing subscription MUST be called BEFORE replying to the request.
+ *
* @param req the request
* @param event the event to subscribe
*
* @return 0 in case of successful subscription or -1 in case of error.
*/
int afb_req_subscribe(
- afb_req_t*req,
+ afb_req_t req,
afb_event_t event);
```
* link identified by 'req'.
* Returns 0 in case of successful subscription or -1 in case of error.
*
+ * Revoking subscription MUST be called BEFORE replying to the request.
+ *
* @param req the request
* @param event the event to revoke
*
* @return 0 in case of successful subscription or -1 in case of error.
*/
int afb_req_unsubscribe(
- afb_req_t*req,
+ afb_req_t req,
afb_event_t event);
```
* @return the stored value
*/
void *afb_req_context(
- afb_req_t*req,
+ afb_req_t req,
int replace,
void *(*create_context)(void *closure),
void (*free_context)(void*),
* @return the previously stored value
*/
void *afb_req_context_get(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_context_set
* @param free_context the cleaning function for the stored context (can be NULL)
*/
void afb_req_context_set(
- afb_req_t*req,
+ afb_req_t req,
void *context,
void (*free_context)(void*));
```
* @param req the request
*/
void afb_req_context_clear(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_session_close
* @param req the request
*/
void afb_req_session_close(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_session_set_LOA
* @return 0 on success or -1 if failed.
*/
int afb_req_session_set_LOA(
- afb_req_t*req,
+ afb_req_t req,
unsigned level);
```
* @return 1 if the permission is granted or 0 otherwise.
*/
int afb_req_has_permission(
- afb_req_t*req,
+ afb_req_t req,
const char *permission);
```
* @return the string for the application id of the client MUST BE FREED
*/
char *afb_req_get_application_id(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_get_uid
*
*/
int afb_req_get_uid(
- afb_req_t*req);
+ afb_req_t req);
```
### afb_req_get_client_info
* @return a JSON object that must be freed using @ref json_object_put
*/
struct json_object *afb_req_get_client_info(
- afb_req_t*req);
+ afb_req_t req);
```
## Legacy functions
* @see afb_req_subcall_sync
*/
void afb_req_subcall_legacy(
- afb_req_t*req,
+ afb_req_t req,
const char *api,
const char *verb,
struct json_object *args,
void *closure,
int iserror,
struct json_object *result,
- afb_req_t*req),
+ afb_req_t req),
void *closure);
```
*
* Makes a call to the method of name 'api' / 'verb' with the object 'args'.
* This call is made in the context of the request 'req'.
- * This call is synchronous, it waits untill completion of the request.
+ * This call is synchronous, it waits until completion of the request.
* It returns 0 on success or a negative value on error answer.
* The object pointed by 'result' is filled and must be released by the caller
* after its use by calling 'json_object_put'.
* @see afb_req_subcall_sync
*/
int afb_req_subcall_sync_legacy(
- afb_req_t*req,
+ afb_req_t req,
const char *api,
const char *verb,
struct json_object *args,