|
Monero
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#include <sys/socket.h>#include <sys/wait.h>#include <arpa/inet.h>#include <netinet/in.h>#include <signal.h>#include <time.h>#include <errno.h>
Macros | |
| #define | INADDR_LOOPBACK 0x7f000001 |
| #define | CRAP_LENGTH (2048) |
| #define | FAVICON_LENGTH (6 + 16 + 40 + 8 + 32 * 4) |
Enumerations | |
| enum | modes { MODE_INVALID , MODE_CHUNKED , MODE_ADDCRAP , MODE_NORMAL , MODE_FAVICON , MODE_MALFORMED } |
Functions | |
| static int | server (unsigned short port, const char *expected_file_name, int ipv6) |
| void | handle_signal_chld (int sig) |
| void | handle_signal_int (int sig) |
| void | build_content (char *p, size_t n) |
| void | build_crap (char *p, size_t n) |
| char * | build_chunked_response (size_t content_length, size_t *response_len) |
| void | build_favicon_content (unsigned char *p, size_t n) |
| void | send_response (int c, const char *buffer, size_t len) |
| void | handle_http_connection (int c) |
| int | main (int argc, char **argv) |
Variables | |
| volatile sig_atomic_t | quit = 0 |
| volatile sig_atomic_t | child_to_wait_for = 0 |
| struct { | |
| enum modes mode | |
| const char * text | |
| } | modes_array [] |
| #define CRAP_LENGTH (2048) |
| #define FAVICON_LENGTH (6 + 16 + 40 + 8 + 32 * 4) |
| #define INADDR_LOOPBACK 0x7f000001 |
| enum modes |
| char * build_chunked_response | ( | size_t | content_length, |
| size_t * | response_len ) |
build chunked response. return a malloc'ed buffer
| void build_content | ( | char * | p, |
| size_t | n ) |
build a text/plain content of the specified length
| void build_crap | ( | char * | p, |
| size_t | n ) |
build crappy content
| void build_favicon_content | ( | unsigned char * | p, |
| size_t | n ) |
| void handle_http_connection | ( | int | c | ) |
handle the HTTP connection
| void handle_signal_chld | ( | int | sig | ) |
signal handler for SIGCHLD (child status has changed)
| void handle_signal_int | ( | int | sig | ) |
signal handler for SIGINT (CRTL C)
| int main | ( | int | argc, |
| char ** | argv ) |
| void send_response | ( | int | c, |
| const char * | buffer, | ||
| size_t | len ) |
write the response with random behaviour !
|
static |
| volatile sig_atomic_t child_to_wait_for = 0 |
| enum modes mode |
| const struct { ... } modes_array[] |
| volatile sig_atomic_t quit = 0 |
| const char* text |