|
KallistiOS git master
Independent SDK for the Sega Dreamcast
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/queue.h>#include <sys/stat.h>#include <sys/socket.h>#include <sys/select.h>#include <netinet/in.h>#include <kos/fs.h>#include <kos/thread.h>#include <kos/mutex.h>Macros | |
| #define | st_foreach(var) |
| #define | BUFSIZE (256*1024) |
Functions | |
| typedef | TAILQ_HEAD (http_state_list, http_state) |
| int | st_init (void) |
| http_state_t * | st_create (void) |
| void | st_destroy (http_state_t *st) |
| int | st_add_fds (fd_set *fds, int maxfd) |
| int | readline (int sock, char *buf, int bufsize) |
| int | read_headers (http_state_t *hs, char *buffer, int bufsize) |
| int | send_error (http_state_t *hs, int errcode, const char *str) |
| int | send_ok (http_state_t *hs, const char *ct) |
| int | do_dirlist (const char *name, http_state_t *hs, file_t f) |
| void * | client_thread (void *p) |
| void | httpd (void) |
Variables | |
| http_state_t | |
| http_state_list_t | states |
| mutex_t | list_mutex = MUTEX_INITIALIZER |
| static const char * | errmsg1 = "<html><head><title>" |
| static const char * | errmsg2 = "</title></head><body bgcolor=\"white\"><h4>" |
| static const char * | errmsg3 = "</h4>\n<hr>\nKOSHttp/1.0 server\n</body></html>" |
| #define BUFSIZE (256*1024) |
Referenced by client_thread().
| #define st_foreach | ( | var | ) |
| void * client_thread | ( | void * | p | ) |
References BUFSIZE, do_dirlist(), free(), fs_close(), fs_open(), fs_read(), malloc(), NULL, O_DIR, printf, r, read_headers(), send_error(), send_ok(), http_state_t::socket, and st_destroy().
Referenced by httpd().
| int do_dirlist | ( | const char * | name, |
| http_state_t * | hs, | ||
| file_t | f ) |
References free(), fs_readdir(), malloc(), dirent_t::name, NULL, r, send_ok(), dirent_t::size, and http_state_t::socket.
Referenced by client_thread().
| void httpd | ( | void | ) |
References accept(), AF_INET, bind(), http_state_t::client, client_thread(), FD_ISSET, FD_SET, FD_ZERO, htonl(), htons(), INADDR_ANY, listen(), printf, in_addr::s_addr, select(), sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_STREAM, http_state_t::socket, socket(), st_create(), st_destroy(), st_foreach, st_init(), and thd_create().
Referenced by do_httpd().
| int read_headers | ( | http_state_t * | hs, |
| char * | buffer, | ||
| int | bufsize ) |
References buffer, NULL, readline(), and http_state_t::socket.
Referenced by client_thread().
| int readline | ( | int | sock, |
| char * | buf, | ||
| int | bufsize ) |
References r.
Referenced by read_headers().
| int send_error | ( | http_state_t * | hs, |
| int | errcode, | ||
| const char * | str ) |
References buffer, errmsg1, errmsg2, errmsg3, free(), malloc(), NULL, and http_state_t::socket.
Referenced by client_thread().
| int send_ok | ( | http_state_t * | hs, |
| const char * | ct ) |
References buffer, and http_state_t::socket.
Referenced by client_thread(), and do_dirlist().
| int st_add_fds | ( | fd_set * | fds, |
| int | maxfd ) |
References FD_SET, list_mutex, mutex_lock(), mutex_unlock(), http_state_t::socket, and st_foreach.
| http_state_t * st_create | ( | void | ) |
References calloc(), list, list_mutex, mutex_lock(), mutex_unlock(), and states.
Referenced by httpd().
| void st_destroy | ( | http_state_t * | st | ) |
References free(), list, list_mutex, mutex_lock(), mutex_unlock(), and states.
Referenced by client_thread(), and httpd().
|
static |
Referenced by send_error().
|
static |
Referenced by send_error().
|
static |
Referenced by send_error().
| http_state_t |
| mutex_t list_mutex = MUTEX_INITIALIZER |
Referenced by st_add_fds(), st_create(), and st_destroy().
| http_state_list_t states |
Referenced by st_create(), st_destroy(), and st_init().