internal shared structures More...
#include "platform.h"
#include "microhttpd.h"
Go to the source code of this file.
Data Structures | |
struct | MHD_Pollfd |
struct | MHD_NonceNc |
struct | MHD_HTTP_Header |
struct | MHD_Response |
struct | MHD_Connection |
struct | MHD_Daemon |
Defines | |
#define | EXTRA_CHECKS MHD_NO |
#define | MHD_MAX(a, b) ((a)<(b)) ? (b) : (a) |
#define | MHD_MIN(a, b) ((a)<(b)) ? (a) : (b) |
#define | MHD_BUF_INC_SIZE 2048 |
#define | MHD_PANIC(msg) mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL) |
#define | MAX_NONCE_LENGTH 129 |
#define | DEBUG_STATES MHD_NO |
#define | EXTRA_CHECK(a) |
#define | DLL_insert(head, tail, element) |
#define | DLL_remove(head, tail, element) |
Typedefs | |
typedef ssize_t(* | ReceiveCallback )(struct MHD_Connection *conn, void *write_to, size_t max_bytes) |
typedef ssize_t(* | TransmitCallback )(struct MHD_Connection *conn, const void *write_to, size_t max_bytes) |
typedef void *(* | LogCallback )(void *cls, const char *uri) |
typedef size_t(* | UnescapeCallback )(void *cls, struct MHD_Connection *conn, char *uri) |
Enumerations | |
enum | MHD_PollActions { MHD_POLL_ACTION_NOTHING = 0, MHD_POLL_ACTION_IN = 1, MHD_POLL_ACTION_OUT = 2 } |
enum | MHD_CONNECTION_STATE { MHD_CONNECTION_INIT = 0, MHD_CONNECTION_URL_RECEIVED = MHD_CONNECTION_INIT + 1, MHD_CONNECTION_HEADER_PART_RECEIVED = MHD_CONNECTION_URL_RECEIVED + 1, MHD_CONNECTION_HEADERS_RECEIVED = MHD_CONNECTION_HEADER_PART_RECEIVED + 1, MHD_CONNECTION_HEADERS_PROCESSED = MHD_CONNECTION_HEADERS_RECEIVED + 1, MHD_CONNECTION_CONTINUE_SENDING = MHD_CONNECTION_HEADERS_PROCESSED + 1, MHD_CONNECTION_CONTINUE_SENT = MHD_CONNECTION_CONTINUE_SENDING + 1, MHD_CONNECTION_BODY_RECEIVED = MHD_CONNECTION_CONTINUE_SENT + 1, MHD_CONNECTION_FOOTER_PART_RECEIVED = MHD_CONNECTION_BODY_RECEIVED + 1, MHD_CONNECTION_FOOTERS_RECEIVED = MHD_CONNECTION_FOOTER_PART_RECEIVED + 1, MHD_CONNECTION_HEADERS_SENDING = MHD_CONNECTION_FOOTERS_RECEIVED + 1, MHD_CONNECTION_HEADERS_SENT = MHD_CONNECTION_HEADERS_SENDING + 1, MHD_CONNECTION_NORMAL_BODY_READY = MHD_CONNECTION_HEADERS_SENT + 1, MHD_CONNECTION_NORMAL_BODY_UNREADY = MHD_CONNECTION_NORMAL_BODY_READY + 1, MHD_CONNECTION_CHUNKED_BODY_READY = MHD_CONNECTION_NORMAL_BODY_UNREADY + 1, MHD_CONNECTION_CHUNKED_BODY_UNREADY = MHD_CONNECTION_CHUNKED_BODY_READY + 1, MHD_CONNECTION_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_UNREADY + 1, MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_BODY_SENT + 1, MHD_CONNECTION_FOOTERS_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1, MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1, MHD_CONNECTION_IN_CLEANUP = MHD_CONNECTION_CLOSED + 1, MHD_TLS_CONNECTION_INIT = MHD_CONNECTION_CLOSED + 1 } |
Functions | |
size_t | MHD_http_unescape (void *cls, struct MHD_Connection *connection, char *val) |
time_t | MHD_monotonic_time (void) |
Variables | |
MHD_PanicCallback | mhd_panic |
void * | mhd_panic_cls |
internal shared structures
Definition in file internal.h.
#define DEBUG_STATES MHD_NO |
Should all state transitions be printed to stderr?
Definition at line 426 of file internal.h.
#define DLL_insert | ( | head, | |||
tail, | |||||
element | ) |
do { \ (element)->next = (head); \ (element)->prev = NULL; \ if ((tail) == NULL) \ (tail) = element; \ else \ (head)->prev = element; \ (head) = (element); } while (0)
Insert an element at the head of a DLL. Assumes that head, tail and element are structs with prev and next fields.
head | pointer to the head of the DLL | |
tail | pointer to the tail of the DLL | |
element | element to insert |
Definition at line 1050 of file internal.h.
Referenced by close_all_connections(), MHD_add_connection(), and MHD_connection_handle_idle().
#define DLL_remove | ( | head, | |||
tail, | |||||
element | ) |
do { \ if ((element)->prev == NULL) \ (head) = (element)->next; \ else \ (element)->prev->next = (element)->next; \ if ((element)->next == NULL) \ (tail) = (element)->prev; \ else \ (element)->next->prev = (element)->prev; \ (element)->next = NULL; \ (element)->prev = NULL; } while (0)
Remove an element from a DLL. Assumes that head, tail and element are structs with prev and next fields.
head | pointer to the head of the DLL | |
tail | pointer to the tail of the DLL | |
element | element to remove |
Definition at line 1069 of file internal.h.
Referenced by close_all_connections(), MHD_add_connection(), MHD_cleanup_connections(), and MHD_connection_handle_idle().
#define EXTRA_CHECK | ( | a | ) |
Definition at line 1038 of file internal.h.
Referenced by build_header_response(), MHD_connection_get_pollfd(), MHD_connection_handle_idle(), MHD_connection_handle_write(), parse_connection_headers(), process_broken_line(), transmit_error_response(), and try_ready_chunked_body().
#define EXTRA_CHECKS MHD_NO |
Should we perform additional sanity checks at runtime (on our internal invariants)? This may lead to aborts, but can be useful for debugging.
Definition at line 40 of file internal.h.
#define MAX_NONCE_LENGTH 129 |
Maximum length of a nonce in digest authentication. 32(MD5 Hex) + 8(Timestamp Hex) + 1(NULL); hence 41 should suffice, but Opera (already) takes more (see Mantis #1633), so we've increased the value to support something longer...
Definition at line 125 of file internal.h.
Referenced by MHD_digest_auth_check().
#define MHD_BUF_INC_SIZE 2048 |
Size by which MHD usually tries to increment read/write buffers. TODO: we should probably get rid of this magic constant and put in code to automatically determine a good value.
Definition at line 51 of file internal.h.
Referenced by get_next_header_line(), MHD_connection_handle_read(), and try_grow_read_buffer().
#define MHD_MAX | ( | a, | |||
b | ) | ((a)<(b)) ? (b) : (a) |
Definition at line 42 of file internal.h.
#define MHD_MIN | ( | a, | |||
b | ) | ((a)<(b)) ? (a) : (b) |
Definition at line 43 of file internal.h.
Referenced by try_ready_normal_body().
#define MHD_PANIC | ( | msg | ) | mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL) |
Trigger 'panic' action based on fatal errors.
error | message (const char *) |
Definition at line 76 of file internal.h.
Referenced by close_all_connections(), MHD_add_connection(), MHD_cleanup_connections(), MHD_connection_handle_idle(), MHD_ip_count_lock(), MHD_ip_count_unlock(), MHD_ip_limit_del(), and MHD_stop_daemon().
typedef void*(* LogCallback)(void *cls, const char *uri) |
Signature of function called to log URI accesses.
cls | closure | |
uri | uri being accessed |
Definition at line 763 of file internal.h.
typedef ssize_t(* ReceiveCallback)(struct MHD_Connection *conn, void *write_to, size_t max_bytes) |
Function to receive plaintext data.
conn | the connection struct | |
write_to | where to write received data | |
max_bytes | maximum number of bytes to receive |
Definition at line 444 of file internal.h.
typedef ssize_t(* TransmitCallback)(struct MHD_Connection *conn, const void *write_to, size_t max_bytes) |
Function to transmit plaintext data.
conn | the connection struct | |
read_from | where to read data to transmit | |
max_bytes | maximum number of bytes to transmit |
Definition at line 456 of file internal.h.
typedef size_t(* UnescapeCallback)(void *cls, struct MHD_Connection *conn, char *uri) |
Signature of function called to unescape URIs. See also MHD_http_unescape.
cls | closure | |
conn | connection handle | |
uri | 0-terminated string to unescape (should be updated) |
Definition at line 774 of file internal.h.
enum MHD_CONNECTION_STATE |
States in a state machine for a connection.
Transitions are any-state to CLOSED, any state to state+1, FOOTERS_SENT to INIT. CLOSED is the terminal state and INIT the initial state.
Note that transitions for *reading* happen only after the input has been processed; transitions for *writing* happen after the respective data has been put into the write buffer (the write does not have to be completed yet). A transition to CLOSED or INIT requires the write to be complete.
Definition at line 298 of file internal.h.
enum MHD_PollActions |
Events we care about with respect to poll/select for file descriptors.
MHD_POLL_ACTION_NOTHING |
No event interests us. |
MHD_POLL_ACTION_IN |
We would like to read. |
MHD_POLL_ACTION_OUT |
We would like to write. |
Definition at line 83 of file internal.h.
size_t MHD_http_unescape | ( | void * | cls, | |
struct MHD_Connection * | connection, | |||
char * | val | |||
) |
Process escape sequences ('+'=space, HH) Updates val in place; the result should be UTF-8 encoded and cannot be larger than the input. The result must also still be 0-terminated.
cls | closure (use NULL) | |
connection | handle to connection, not used |
Definition at line 118 of file internal.c.
Referenced by MHD_start_daemon_va(), and post_process_urlencoded().
time_t MHD_monotonic_time | ( | void | ) |
Equivalent to time(NULL) but tries to use some sort of monotonic clock that isn't affected by someone setting the system real time clock.
Definition at line 160 of file internal.c.
References NULL.
Referenced by MHD_add_connection(), MHD_connection_handle_idle(), MHD_connection_handle_read(), MHD_connection_handle_write(), MHD_digest_auth_check(), MHD_get_timeout(), MHD_handle_connection(), MHD_queue_auth_fail_response(), MHD_tls_connection_handle_idle(), and run_tls_handshake().
Handler for fatal errors.
Definition at line 111 of file daemon.c.
Referenced by build_header_response(), MHD_create_post_processor(), MHD_init(), MHD_set_panic_func(), post_process_multipart(), post_process_urlencoded(), process_request_body(), and try_ready_normal_body().
void* mhd_panic_cls |
Closure argument for "mhd_panic".
Definition at line 116 of file daemon.c.
Referenced by build_header_response(), MHD_create_post_processor(), MHD_init(), MHD_set_panic_func(), post_process_multipart(), post_process_urlencoded(), process_request_body(), and try_ready_normal_body().