Definition in file tcp_utils.c.
Go to the source code of this file.
Defines | |
#define | _GNU_SOURCE |
Functions | |
int | tcp_read (SOCKET sockfd, char *buffer, int maxlen) |
TBD. | |
int | tcp_write (SOCKET sockfd, const char *buff, int buff_len) |
TBD. | |
void | decode_keys_values (mihl_cnx_t *cnx, char *_request, int *nb_options, char *options_names[], char *options_values[], int maxnb_options, int *nb_variables, char *vars_names[], char *vars_values[], int maxnb_values) |
TBD. | |
int | mihl_add (mihl_cnx_t *cnx, char const *fmt,...) |
Build HTML page for a given HTTP URL. | |
int | mihl_send (mihl_cnx_t *cnx, char const *answer, char const *fmt_header,...) |
TBD. | |
static int | filelength (int fd) |
TBD. | |
int | read_file (char const *fname, char **file, int *length) |
Read en entire file in memory. |
#define _GNU_SOURCE |
Definition at line 11 of file tcp_utils.c.
int tcp_read | ( | SOCKET | sockfd, | |
char * | buffer, | |||
int | maxlen | |||
) |
TBD.
sockfd | TBD | |
buffer | TBD | |
maxlen | TBD |
Definition at line 47 of file tcp_utils.c.
Referenced by got_data_for_active_connexion().
int tcp_write | ( | SOCKET | sockfd, | |
const char * | buff, | |||
int | buff_len | |||
) |
TBD.
sockfd | TBD | |
buff | TBD | |
buff_len | TBD |
Definition at line 104 of file tcp_utils.c.
Referenced by mihl_send(), and send_file().
void decode_keys_values | ( | mihl_cnx_t * | cnx, | |
char * | _request, | |||
int * | nb_options, | |||
char * | options_names[], | |||
char * | options_values[], | |||
int | maxnb_options, | |||
int * | nb_variables, | |||
char * | vars_names[], | |||
char * | vars_values[], | |||
int | maxnb_values | |||
) |
TBD.
Called by: got_data_for_active_connexion
cnx | opaque context structure as returned by mihl_init() | |
_request | TBD | |
[out] | nb_options | TBD |
[out] | options_names | TBD |
[out] | options_values | TBD |
maxnb_options | TBD | |
[out] | nb_variables | TBD |
[out] | vars_names | TBD |
[out] | vars_values | TBD |
maxnb_values | TBD |
Definition at line 156 of file tcp_utils.c.
References mihl_cnx::authorization, mihl_cnxinfo_t::host, mihl_cnx::info, mihl_cnx::is_keep_alive, mihl_cnx::keep_alive, and mihl_cnxinfo_t::user_agent.
Referenced by got_data_for_active_connexion().
int mihl_add | ( | mihl_cnx_t * | cnx, | |
char const * | fmt, | |||
... | ||||
) |
Build HTML page for a given HTTP URL.
Used within a C handler function (such as one provide to mihl_handle_get or mihl_handle_post), to build a page content. Once the page will is finished, a call to mihl_add should be done.
cnx | Opaque pointer, as provided to the C handler function (GET). | |
fmt | printf like format and optional arguments to describe the data to add into the page (typically HTML content). | |
... | Optional printf like format arguments |
Definition at line 261 of file tcp_utils.c.
References mihl_cnx::html_buffer, mihl_cnx::html_buffer_len, and mihl_cnx::html_buffer_sz.
Referenced by http_data(), http_root(), and page_not_found().
int mihl_send | ( | mihl_cnx_t * | cnx, | |
char const * | answer, | |||
char const * | fmt_header, | |||
... | ||||
) |
TBD.
cnx | opaque context structure as returned by mihl_init() | |
[in] | answer | HTTP answer to send, If NULL, will send "HTTP/1.1 200 OK\r\n" |
fmt_header | TBD | |
... | TBD |
Definition at line 289 of file tcp_utils.c.
References ERRNO, mihl_cnx::html_buffer, mihl_cnx::html_buffer_len, mihl_cnx::sockfd, and tcp_write().
Referenced by http_data(), http_root(), and page_not_found().
static int filelength | ( | int | fd | ) | [static] |
TBD.
fd | TBD |
Definition at line 333 of file tcp_utils.c.
Referenced by read_file().
int read_file | ( | char const * | fname, | |
char ** | file, | |||
int * | length | |||
) |
Read en entire file in memory.
The buffer is dynamically allocated (malloc).
fname | TBD | |
file | TBD | |
length | TBD |
Definition at line 350 of file tcp_utils.c.
References filelength(), and O_BINARY.
Referenced by send_file().