KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
httpd.c File Reference
#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_tst_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>"
 

Macro Definition Documentation

◆ BUFSIZE

#define BUFSIZE   (256*1024)

Referenced by client_thread().

◆ st_foreach

#define st_foreach ( var)
Value:
TAILQ_FOREACH(var, &states, list)
http_state_list_t states
Definition httpd.c:36
static pvr_list_t list
Definition shadow.c:25

Referenced by httpd(), and st_add_fds().

Function Documentation

◆ client_thread()

◆ do_dirlist()

int do_dirlist ( const char * name,
http_state_t * hs,
file_t f )

◆ httpd()

◆ read_headers()

int read_headers ( http_state_t * hs,
char * buffer,
int bufsize )

References buffer, NULL, readline(), and http_state_t::socket.

Referenced by client_thread().

◆ readline()

int readline ( int sock,
char * buf,
int bufsize )

References r.

Referenced by read_headers().

◆ send_error()

int send_error ( http_state_t * hs,
int errcode,
const char * str )

◆ send_ok()

int send_ok ( http_state_t * hs,
const char * ct )

References buffer, and http_state_t::socket.

Referenced by client_thread(), and do_dirlist().

◆ st_add_fds()

int st_add_fds ( fd_set * fds,
int maxfd )

◆ st_create()

http_state_t * st_create ( void )

References calloc(), list, list_mutex, mutex_lock(), mutex_unlock(), and states.

Referenced by httpd().

◆ st_destroy()

void st_destroy ( http_state_t * st)

References free(), list, list_mutex, mutex_lock(), mutex_unlock(), and states.

Referenced by client_thread(), and httpd().

◆ st_init()

int st_init ( void )

References states.

Referenced by httpd().

◆ TAILQ_HEAD()

typedef TAILQ_HEAD ( http_state_list ,
http_state  )

References list, socket(), and thd().

Variable Documentation

◆ errmsg1

const char* errmsg1 = "<html><head><title>"
static

Referenced by send_error().

◆ errmsg2

const char* errmsg2 = "</title></head><body bgcolor=\"white\"><h4>"
static

Referenced by send_error().

◆ errmsg3

const char* errmsg3 = "</h4>\n<hr>\nKOSHttp/1.0 server\n</body></html>"
static

Referenced by send_error().

◆ http_state_t

http_state_t

◆ list_mutex

mutex_t list_mutex = MUTEX_INITIALIZER

Referenced by st_add_fds(), st_create(), and st_destroy().

◆ states

http_state_list_t states

Referenced by st_create(), st_destroy(), and st_init().