libonion
|
Data Structures | |
struct | onion_handler_t |
Information about a handler for onion. A tree structure of handlers is what really serves the data. More... |
Typedefs | |
typedef onion_connection_status(* | onion_handler_handler )(void *privdata, onion_request *req, onion_response *res) |
typedef void(* | onion_handler_private_data_free )(void *privdata) |
Enumerations | |
enum | onion_connection_status_e { OCS_NOT_PROCESSED = 0, OCS_NEED_MORE_DATA = 1, OCS_PROCESSED = 2, OCS_CLOSE_CONNECTION = -2, OCS_KEEP_ALIVE = 3, OCS_WEBSOCKET = 4, OCS_REQUEST_READY = 5, OCS_INTERNAL_ERROR = -500, OCS_NOT_IMPLEMENTED = -501, OCS_FORBIDDEN = -502, OCS_YIELD = -3 } |
The desired connection state of the connection.If <0 it means close connection. May mean also to show something to the client. More... |
Functions | |
onion_connection_status | onion_handler_t::onion_handler_handle (onion_handler *handler, onion_request *request, onion_response *response) |
Tryes to handle the petition with that handler. | |
onion_handler * | onion_handler_t::onion_handler_new (onion_handler_handler handler, void *priv_data, onion_handler_private_data_free priv_data_free) |
Creates an onion handler with that private datas. | |
int | onion_handler_t::onion_handler_free (onion_handler *handler) |
Frees the memory used by this handler. | |
void | onion_handler_t::onion_handler_add (onion_handler *base, onion_handler *new_handler) |
Adds a handler to the list of handlers of this level. | |
void * | onion_handler_t::onion_handler_get_private_data (onion_handler *handler) |
Returns the private data part of a handler. |
typedef onion_connection_status(* onion_handler_handler)(void *privdata, onion_request *req, onion_response *res) |
Signature of request handlers.
typedef void(* onion_handler_private_data_free)(void *privdata) |
Signature of free function of private data of request handlers
The desired connection state of the connection.If <0 it means close connection. May mean also to show something to the client.
void onion_handler_add | ( | onion_handler * | base, |
onion_handler * | new_handler | ||
) |
Adds a handler to the list of handlers of this level.
Adds a handler at the end of the list of handlers of this level. Each handler is called in order, until one of them succeds. So each handler is in charge of cheching if its itself who is being called.
References onion_handler_t::next.
int onion_handler_free | ( | onion_handler * | handler | ) |
Frees the memory used by this handler.
It calls the private data handler free if available, and free the 'next' handler too.
It should be called when this handler is not going to be used anymore. Most of the cases you call it over the root handler, and from there it removes all the handlers.
Returns the number of handlers freed on this level.
References onion_handler_t::next, onion_low_free(), onion_handler_t::priv_data, and onion_handler_t::priv_data_free.
Referenced by onion_free(), onion_handler_auth_pam_delete(), onion_handler_path_delete(), onion_url_free(), and onion_url_free_data().
void * onion_handler_get_private_data | ( | onion_handler * | handler | ) |
Returns the private data part of a handler.
This is useful to allow external users of a given handler to modify the behaviour. For example on the directory handler this helps to change the default header and footers.
References onion_handler_t::priv_data.
Referenced by onion_handler_export_local_set_footer(), onion_handler_export_local_set_header(), and onion_url_add_handler().
onion_connection_status onion_handler_handle | ( | onion_handler * | handler, |
onion_request * | request, | ||
onion_response * | response | ||
) |
Tryes to handle the petition with that handler.
It needs the handler to handle, the request and the response.
It checks this parser, and siblings.
References onion_response_t::buffer, onion_response_t::buffer_pos, onion_response_t::flags, onion_handler_t::handler, onion_handler_t::next, OCS_INTERNAL_ERROR, OCS_NOT_PROCESSED, OCS_WEBSOCKET, ONION_DEBUG0, ONION_ERROR, onion_low_free(), onion_response_flush(), onion_response_t::onion_response_set_length(), onion_websocket_t::onion_websocket_call(), OR_HEADER_SENT, onion_handler_t::priv_data, onion_png_data_t::res, and onion_request_t::websocket.
Referenced by onion_handler_auth_pam_handler(), onion_handler_path_handler(), onion_request_process(), onion_shortcut_internal_redirect(), and onion_url_handler().
onion_handler * onion_handler_new | ( | onion_handler_handler | handler, |
void * | priv_data, | ||
onion_handler_private_data_free | priv_data_free | ||
) |
Creates an onion handler with that private datas.
References onion_handler_t::handler, onion_low_calloc(), onion_handler_t::priv_data, and onion_handler_t::priv_data_free.
Referenced by onion_handler_auth_pam(), onion_handler_export_local_new(), onion_handler_opack(), onion_handler_path(), onion_handler_static(), onion_handler_webdav(), onion_internal_status(), onion_new(), onion_url_add(), onion_url_add_with_data(), and onion_url_new().