38 lines
763 B
C
38 lines
763 B
C
#ifndef HTTP_SERVER_H
|
|
#define HTTP_SERVER_H
|
|
|
|
#include <netinet/in.h>
|
|
#include <sys/socket.h>
|
|
|
|
#ifndef DEFAULT_HTML
|
|
#define DEFAULT_HTML "index.html"
|
|
#endif
|
|
|
|
typedef enum {
|
|
HTTP_SRS_RUNNING = 0,
|
|
HTTP_SRS_SETUP,
|
|
HTTP_SRS_STOPPED,
|
|
HTTP_SRS_SOCKET_FAILED,
|
|
HTTP_SRS_SETSOCKOPT_FAILED,
|
|
HTTP_SRS_BIND_FAILED,
|
|
HTTP_SRS_LISTEN_FAILED,
|
|
HTTP_SRS_ACCEPT_FAILED,
|
|
HTTP_SRS_READ_FAILED,
|
|
HTTP_SRS_HANDLE_REQUEST_FAILED,
|
|
HTTP_SRS_FORK_FAILED,
|
|
HTTP_SRS_WONT_HANDLE,
|
|
} HttpServerRunStatus;
|
|
|
|
typedef struct {
|
|
int port;
|
|
int server_fd;
|
|
unsigned int workers;
|
|
struct sockaddr_in *address;
|
|
} HttpServer;
|
|
|
|
HttpServerRunStatus http_server_setup(HttpServer *s);
|
|
HttpServerRunStatus http_server_run(HttpServer *s);
|
|
HttpServerRunStatus http_server_stop(HttpServer *s);
|
|
|
|
#endif
|