30 #ifndef MAX_CONNECTIONS 31 #define MAX_CONNECTIONS 1 65 #define IO_MAX 512 // buffered IO MEMSPACE void web_init(int port)
Setup WEB server and accept connections.
MEMSPACE void rwbuf_winit(rwbuf_t *p)
Initialize socket send status and write index.
MEMSPACE char * nextbreak(char *ptr)
Find next space or ? character.
MEMSPACE rwbuf_t * rwbuf_create(void)
Create socket read/write buffer for a connection.
MEMSPACE int write_buffer(rwbuf_t *p)
Socket write buffer for this connection We wait for previous send to complete - then send any new dat...
MEMSPACE int find_cgitoken_start(char *str)
Find start of CGI token in a string CGI tokens have the following syntax @ They start with "@_" and e...
MEMSPACE char * memgets(mem_t *p)
Memory gets function We ASSUME we can replace any with a \0.
MEMSPACE int delete_connection(rwbuf_t *p)
Delete our main connection structure and connection buffers.
MEMSPACE void write_len(rwbuf_t *p, char *str, int len)
Write data using buffered write_byte function.
MEMSPACE char * http_value(hinfo_t *hi, char *str)
Lookup and argument name and return its value.
MEMSPACE int wait_send(rwbuf_t *p)
Wait for buffer to send for this connection If write_buffer sending flag is set then wait for it to c...
MEMSPACE void web_task(void)
Process ALL incoming HTTP requests.
MEMSPACE char * meminit(mem_t *p, char *ptr, int size)
in memory memory gets function
MEMSPACE void init_hinfo(hinfo_t *hi)
MEMSPACE int write_flush(rwbuf_t *p)
Write all outstanding data and wait for it to send.
MEMSPACE void web_sep(void)
printer seperator
MEMSPACE void led_on(int led)
MEMSPACE void led_off(int led)
Turn off virtual LED.
MEMSPACE char * arg_value(hinfo_t *hi)
Return the argument value for current argument.
MEMSPACE int sock_printf(rwbuf_t *p, const char *fmt,...)
sock_printf function
MEMSPACE int rewrite_cgi_token(rwbuf_t *p, char *src)
Replace CGI token with CGI result CGI tokens have the following syntax @ They start with "@_" and end...
MEMSPACE void web_init_connections(void)
MEMSPACE char * process_args(hinfo_t *hi, char *ptr)
Process GET argments or POST message name/value data. HTML encoding is done in place often reducting ...
MEMSPACE rwbuf_t * find_connection(espconn_t *conn, int *index, char *msg)
Find a read/write socket buffer for an espconn connection.
MEMSPACE int write_byte(rwbuf_t *p, int c)
Write a byte (buffered) using the rwbuf_t socket buffers for this connection If the buffers are full ...
MEMSPACE void html_head(rwbuf_t *p, int status, char type, int len)
Write HTTP Contenet-Type/Content-Length header.
MEMSPACE char * next_arg(hinfo_t *hi)
Find next POST/GET argument We have to skip a name and a value.
MEMSPACE char * first_arg(hinfo_t *hi)
Find first POST/GET argument.
MEMSPACE int parse_http_request(rwbuf_t *p, hinfo_t *hi)
Get arguments for a GET or POST request.
MEMSPACE char * html_status(int status)
Convert html status into string using http_status table.
MEMSPACE rwbuf_t * create_connection(espconn_t *conn)
Allocate read/write socket buffers and add it to the working pool.
MEMSPACE char * mime_type(int type)
return strung pointer for mime type index
MEMSPACE int file_type(char *name)
Determin mimetype using file name extension.
MEMSPACE int is_cgitoken_char(int c)
test to see if a character is a valid member of the CGI token character set CGI tokens have the follo...
MEMSPACE int is_cgitoken(char *str)
Does the string have a CGI TOKEN at the beginning ? CGI tokens have the following syntax @ They start...
MEMSPACE void display_ipv4(char *msg, uint8_t *ip, int port)
Display IPV4 address.
MEMSPACE int is_header(char *str, char **p)
Does the string look like a header token with a ':' ?
MEMSPACE int match_headers(char *str, char **p)
Match GET/POST message headers.
MEMSPACE int vsock_printf(rwbuf_t *p, const char *fmt, va_list va)
vsock_printf function
MEMSPACE void u5toa(char *ptr, uint16_t num)
Print a decimal number into a string without an EOS.
MEMSPACE void write_str(rwbuf_t *p, char *str)
Write string using buffered write_byte function.
MEMSPACE void rwbuf_delete(rwbuf_t *p)
Delete socket read/write buffers.
MEMSPACE void rwbuf_rinit(rwbuf_t *p)
Initialize socket read status and read index.
MEMSPACE char * arg_name(hinfo_t *hi)
Return the argument name for current argument.
MEMSPACE int html_msg(rwbuf_t *p, int status, char type, char *fmt,...)
Send an HTML status message to socket.