All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
onion.h File Reference
#include "request.h"
#include "response.h"
#include "handler.h"
#include "types.h"
#include "url.h"


oniononion_new (int flags)
 Creates the onion structure to fill with the server data, and later do the onion_listen()Creates an onion structure that can be used to set the server, port, SSL and similar parameters. It works over the onion structure, which is the main structure to control the listening of new connections throught TCP/IP.
void onion_set_client_data (onion *server, void *data, onion_client_data_free_sig *data_free)
 set a client data in the onion, freeing the previous one if it exists. Thread-safe.
void * onion_client_data (onion *server)
 Retrieve the client data in the onion server. Thread-safe.
int onion_listen (onion *o)
 Performs the listening with the given modeThis is the main loop for the onion server.
void onion_listen_stop (onion *server)
 Stops the listening.
void onion_free (onion *onion)
 Removes the allocated data.
void onion_set_root_handler (onion *onion, onion_handler *handler)
 Sets the root handler.
onion_handleronion_get_root_handler (onion *server)
 Returns current root handler.For example when changing root handler, the old one is not deleted (as oposed that when deleting the onion* object it is). So user may use onion_handler_free(onion_get_root_handler(o));.
void onion_set_internal_error_handler (onion *server, onion_handler *handler)
 Sets the internal error handler.
void onion_set_port (onion *server, const char *port)
 Sets the port to listen.
void onion_set_hostname (onion *server, const char *hostname)
 Sets the hostname on which to listen.
int onion_set_certificate (onion *onion, onion_ssl_certificate_type type, const char *filename,...)
 Set a certificate for use in the connection.
int onion_set_certificate_va (onion *onion, onion_ssl_certificate_type type, const char *filename, va_list va)
 Set a certificate for use in the connection. va_list version.
int onion_add_listen_point (onion *server, const char *hostname, const char *port, onion_listen_point *protocol)
 Sets the port to listen to.Default listen point is HTTP at localhost:8080.
onion_listen_pointonion_get_listen_point (onion *server, int nlisten_point)
 Gets a single listen point, or NULL if not that many.
int onion_flags (onion *onion)
 Returns the current flags.
void onion_set_timeout (onion *onion, int timeout)
 Sets the timeout, in millisecondsThe default timeout is 5000 milliseconds.
void onion_set_max_threads (onion *onion, int max_threads)
 Sets the maximum number of threads to use for requests. default 16.Can only be tweaked before listen.
void onion_set_user (onion *server, const char *username)
 User to which drop priviledges when listeningDrops the priviledges of current program as soon as it starts listening.
onion_urlonion_root_url (onion *server)
 If no root handler is set, creates an url handler and returns it.It can also check if the current root handler is a url handler, and if it is, returns it. Else returns NULL.
onion_polleronion_get_poller (onion *server)
 If on poller mode, returns the poller, if not, returns NULL.
void onion_set_max_post_size (onion *server, size_t max_size)
 Set the maximum post size.
void onion_set_max_file_size (onion *server, size_t max_size)
 Set the maximum post FILE size.
void onion_set_session_backend (onion *server, onion_sessions *sessions_backend)
 Set a new session backend.