libonion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Enumerations | Functions
Handler. Creates and manages the user handlers so that onion can call them when required.

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_handleronion_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.

Detailed Description

Typedef Documentation

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

Enumeration Type Documentation

The desired connection state of the connection.If <0 it means close connection. May mean also to show something to the client.

Enumerator:
OCS_NOT_PROCESSED 
OCS_NEED_MORE_DATA 
OCS_PROCESSED 
OCS_CLOSE_CONNECTION 
OCS_KEEP_ALIVE 
OCS_WEBSOCKET 
OCS_REQUEST_READY 

Internal. After parsing the request, it is ready to handle.

OCS_INTERNAL_ERROR 
OCS_NOT_IMPLEMENTED 
OCS_FORBIDDEN 
OCS_YIELD 

Do not remove the request/response from the pollers, I will manage it in another thread (for exmaple longpoll)

Function Documentation

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 
)
onion_handler * onion_handler_new ( onion_handler_handler  handler,
void *  priv_data,
onion_handler_private_data_free  priv_data_free 
)