Files
cweb/http/http_server.h
2024-11-15 10:56:07 +01:00

36 lines
717 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,
} 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