Ulfius
HTTP Framework for REST Applications in C
Functions
struct _u_request, struct _u_response and struct _u_cookie

Functions

int ulfius_init_request (struct _u_request *request)
 
int ulfius_clean_request (struct _u_request *request)
 
int ulfius_clean_request_full (struct _u_request *request)
 
int ulfius_copy_request (struct _u_request *dest, const struct _u_request *source)
 
int ulfius_set_request_properties (struct _u_request *request,...)
 
int ulfius_init_response (struct _u_response *response)
 
int ulfius_clean_response (struct _u_response *response)
 
int ulfius_clean_response_full (struct _u_response *response)
 
int ulfius_copy_response (struct _u_response *dest, const struct _u_response *source)
 
int ulfius_clean_cookie (struct _u_cookie *cookie)
 
int ulfius_copy_cookie (struct _u_cookie *dest, const struct _u_cookie *source)
 
struct _u_requestulfius_duplicate_request (const struct _u_request *request)
 
struct _u_responseulfius_duplicate_response (const struct _u_response *response)
 
int ulfius_set_response_properties (struct _u_response *response,...)
 
json_t * ulfius_get_json_body_request (const struct _u_request *request, json_error_t *json_error)
 
int ulfius_set_json_body_request (struct _u_request *request, json_t *j_body)
 
json_t * ulfius_get_json_body_response (struct _u_response *response, json_error_t *json_error)
 
int ulfius_set_json_body_response (struct _u_response *response, const unsigned int status, const json_t *j_body)
 

Detailed Description

struct _u_request, struct _u_response and struct _u_cookie management functions

Function Documentation

◆ ulfius_init_request()

int ulfius_init_request ( struct _u_request request)

ulfius_init_request Initialize a request structure by allocating inner elements

Parameters
requestthe request to initialize
Returns
U_OK on success

ulfius_init_request Initialize a request structure by allocating inner elements return U_OK on success

◆ ulfius_clean_request()

int ulfius_clean_request ( struct _u_request request)

ulfius_clean_request clean the specified request's inner elements user must free the parent pointer if needed after clean or use ulfius_clean_request_full

Parameters
requestthe request to cleanup
Returns
U_OK on success

ulfius_clean_request clean the specified request's inner elements user must free the parent pointer if needed after clean or use ulfius_clean_request_full return U_OK on success

◆ ulfius_clean_request_full()

int ulfius_clean_request_full ( struct _u_request request)

ulfius_clean_request_full clean the specified request and all its elements

Parameters
requestthe request to cleanup
Returns
U_OK on success

ulfius_clean_request_full clean the specified request and all its elements return U_OK on success

◆ ulfius_copy_request()

int ulfius_copy_request ( struct _u_request dest,
const struct _u_request source 
)

ulfius_copy_request Copy the source request elements into the dest request

Parameters
destthe request to receive the copied data
sourcethe source request to copy
Returns
U_OK on success

ulfius_copy_request Copy the source request elements into the dest request return U_OK on success

◆ ulfius_set_request_properties()

int ulfius_set_request_properties ( struct _u_request request,
  ... 
)

ulfius_set_request_properties Set a list of properties to a request return U_OK on success

◆ ulfius_init_response()

int ulfius_init_response ( struct _u_response response)

ulfius_init_response Initialize a response structure by allocating inner elements

Parameters
responsethe response to initialize
Returns
U_OK on success

◆ ulfius_clean_response()

int ulfius_clean_response ( struct _u_response response)

ulfius_clean_response clean the specified response's inner elements user must free the parent pointer if needed after clean or use ulfius_clean_response_full

Parameters
responsethe response to cleanup
Returns
U_OK on success

◆ ulfius_clean_response_full()

int ulfius_clean_response_full ( struct _u_response response)

ulfius_clean_response_full clean the specified response and all its elements

Parameters
responsethe response to cleanup
Returns
U_OK on success

◆ ulfius_copy_response()

int ulfius_copy_response ( struct _u_response dest,
const struct _u_response source 
)

ulfius_copy_response Copy the source response elements into the dest response

Parameters
destthe response to receive the copied data
sourcethe source response to copy
Returns
U_OK on success

◆ ulfius_clean_cookie()

int ulfius_clean_cookie ( struct _u_cookie cookie)

ulfius_clean_cookie clean the cookie's elements

Parameters
cookiethe cookie structure to cleanup
Returns
U_OK on success

◆ ulfius_copy_cookie()

int ulfius_copy_cookie ( struct _u_cookie dest,
const struct _u_cookie source 
)

Copy the cookie source elements into dest elements

Parameters
destthe cookie to receive the copied data
sourcethe cookie response to copy
Returns
U_OK on success

◆ ulfius_duplicate_request()

struct _u_request* ulfius_duplicate_request ( const struct _u_request request)

create a new request based on the source elements returned value must be cleaned after use

Parameters
requestthe request to duplicate
Returns
a heap-allocated request

create a new request based on the source elements returned value must be free'd after use

◆ ulfius_duplicate_response()

struct _u_response* ulfius_duplicate_response ( const struct _u_response response)

create a new response based on the source elements return value must be cleaned after use

Parameters
responsethe response to duplicate
Returns
a heap-allocated response

◆ ulfius_set_response_properties()

int ulfius_set_response_properties ( struct _u_response response,
  ... 
)

ulfius_set_response_properties Set a list of properties to a response return U_OK on success

◆ ulfius_get_json_body_request()

json_t* ulfius_get_json_body_request ( const struct _u_request request,
json_error_t *  json_error 
)

ulfius_get_json_body_request Get JSON structure from the request body if the request is valid In case of an error in getting or parsing JSON data in the request, the structure json_error_t * json_error will be filled with an error message if json_error is not NULL

Parameters
requestthe request to retrieve the JSON data
json_errora json_error_t reference that will contain decoding errors if any, may be NULL
Returns
a json_t * containing the JSON decoded, NULL on error

ulfius_get_json_body_request Get JSON structure from the request body if the request is valid request: struct _u_request used json_error: structure to store json_error_t if specified

◆ ulfius_set_json_body_request()

int ulfius_set_json_body_request ( struct _u_request request,
json_t *  j_body 
)

ulfius_set_json_body_request Add a json_t j_body to a request

Parameters
requestthe request to retrieve the JSON data
j_bodya json_t to stringify in the body
Returns
U_OK on success

ulfius_set_json_body_request Add a json_t j_body to a response return U_OK on success

◆ ulfius_get_json_body_response()

json_t* ulfius_get_json_body_response ( struct _u_response response,
json_error_t *  json_error 
)

ulfius_get_json_body_response Get JSON structure from the response body if the response is valid In case of an error in getting or parsing JSON data in the response, the structure json_error_t * json_error will be filled with an error message if json_error is not NULL

Parameters
responsethe response to retrieve the JSON data
json_errora json_error_t reference that will contain decoding errors if any, may be NULL
Returns
a json_t * containing the JSON decoded, NULL on error

ulfius_get_json_body_response Get JSON structure from the request body if the request is valid request: struct _u_request used json_error: structure to store json_error_t if specified

◆ ulfius_set_json_body_response()

int ulfius_set_json_body_response ( struct _u_response response,
const unsigned int  status,
const json_t *  j_body 
)

ulfius_set_json_body_response Add a json_t j_body to a response

Parameters
responsethe response to retrieve the JSON data
statusthe HTTP status for the response
j_bodya json_t to stringify in the body
Returns
U_OK on success

ulfius_set_json_body_response Add a json_t j_body to a response return U_OK on success