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