If file non existant crashing resolved

This commit is contained in:
cdricms
2024-11-15 10:56:07 +01:00
parent 9ccde76edc
commit ce2edb6293
8 changed files with 209 additions and 74 deletions

35
http/http_server.h Normal file
View File

@@ -0,0 +1,35 @@
#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