1 |
rakinar2 |
44 |
#ifndef FREEHTTPD_H |
2 |
|
|
#define FREEHTTPD_H |
3 |
|
|
|
4 |
rakinar2 |
45 |
#include <magic.h> |
5 |
rakinar2 |
44 |
#include <stddef.h> |
6 |
|
|
|
7 |
|
|
typedef struct freehttpd_config |
8 |
|
|
{ |
9 |
|
|
unsigned int port; |
10 |
|
|
char *addr; |
11 |
|
|
unsigned int max_listen_queue; |
12 |
rakinar2 |
45 |
char *docroot; |
13 |
rakinar2 |
44 |
size_t max_method_len; |
14 |
|
|
size_t max_uri_len; |
15 |
|
|
size_t max_version_len; |
16 |
rakinar2 |
45 |
|
17 |
|
|
/* The following fields are for internal use only */ |
18 |
|
|
size_t _docroot_length; |
19 |
rakinar2 |
44 |
} freehttpd_config_t; |
20 |
|
|
|
21 |
|
|
typedef enum freehttpd_error_code |
22 |
|
|
{ |
23 |
|
|
E_OK, |
24 |
|
|
E_UNKNOWN, |
25 |
|
|
E_UNKNOWN_OPT, |
26 |
|
|
E_MALFORMED_REQUEST, |
27 |
|
|
E_SYSCALL_SOCKET, |
28 |
|
|
E_SYSCALL_BIND, |
29 |
|
|
E_SYSCALL_LISTEN, |
30 |
|
|
E_SYSCALL_ACCEPT, |
31 |
|
|
E_SYSCALL_RECV, |
32 |
|
|
E_SYSCALL_SETSOCKOPT, |
33 |
rakinar2 |
45 |
E_SYSCALL_READ, |
34 |
|
|
E_SYSCALL_WRITE, |
35 |
rakinar2 |
44 |
E_LIBC_FDOPEN, |
36 |
|
|
E_LIBC_MALLOC |
37 |
|
|
} ecode_t; |
38 |
|
|
|
39 |
|
|
typedef enum freehttpd_config_option |
40 |
|
|
{ |
41 |
|
|
FREEHTTPD_CONFIG_PORT, |
42 |
|
|
FREEHTTPD_CONFIG_ADDR, |
43 |
|
|
FREEHTTPD_CONFIG_MAX_LISTEN_QUEUE, |
44 |
|
|
FREEHTTPD_CONFIG_MAX_METHOD_LEN, |
45 |
|
|
FREEHTTPD_CONFIG_MAX_URI_LEN, |
46 |
|
|
FREEHTTPD_CONFIG_MAX_VERSION_LEN, |
47 |
rakinar2 |
45 |
FREEHTTPD_CONFIG_DOCROOT, |
48 |
rakinar2 |
44 |
} freehttpd_opt_t; |
49 |
|
|
|
50 |
|
|
typedef struct freehttpd freehttpd_t; |
51 |
|
|
|
52 |
rakinar2 |
45 |
freehttpd_t *freehttpd_init (magic_t magic); |
53 |
rakinar2 |
44 |
void freehttpd_free (freehttpd_t *freehttpd); |
54 |
|
|
ecode_t freehttpd_start (freehttpd_t *restrict freehttpd); |
55 |
|
|
ecode_t freehttpd_setopt (freehttpd_t *freehttpd, freehttpd_opt_t opt, |
56 |
|
|
void *value); |
57 |
|
|
|
58 |
|
|
const freehttpd_config_t *freehttpd_get_config (freehttpd_t *freehttpd); |
59 |
|
|
|
60 |
|
|
#endif |