Fix compiler errors

This commit is contained in:
2025-07-20 23:53:23 +02:00
parent 3b196546da
commit c3bfb86707
18 changed files with 895 additions and 145 deletions
+42 -10
View File
@@ -10,13 +10,15 @@
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
//////////////////////////////////////////////////////////////////////
// src/basic.h
//////////////////////////////////////////////////////////////////////
#ifndef CHTTP_BASIC_INCLUDED
#define CHTTP_BASIC_INCLUDED
#include <stdbool.h>
// String type used throughout cHTTP.
typedef struct {
char *ptr;
@@ -89,10 +91,14 @@ HTTP_String http_trim(HTTP_String s);
#define HTTP_ASSERT(X) {if (!(X)) { __builtin_trap(); }}
#endif
//////////////////////////////////////////////////////////////////////
#endif // CHTTP_BASIC_INCLUDED//////////////////////////////////////////////////////////////////////
// src/parse.h
//////////////////////////////////////////////////////////////////////
#ifndef PARSE_INCLUDED
#define PARSE_INCLUDED
#include "basic.h"
#define HTTP_MAX_HEADERS 32
typedef struct {
@@ -181,10 +187,14 @@ HTTP_String http_getqueryparam (HTTP_Request *req, HTTP_String name);
HTTP_String http_getbodyparam (HTTP_Request *req, HTTP_String name);
HTTP_String http_getcookie (HTTP_Request *req, HTTP_String name);
//////////////////////////////////////////////////////////////////////
#endif // PARSE_INCLUDED//////////////////////////////////////////////////////////////////////
// src/engine.h
//////////////////////////////////////////////////////////////////////
#ifndef HTTP_ENGINE_INCLUDED
#define HTTP_ENGINE_INCLUDED
#include "parse.h"
typedef enum {
HTTP_MEMFUNC_MALLOC,
HTTP_MEMFUNC_FREE,
@@ -299,10 +309,16 @@ void http_engine_bodyack (HTTP_Engine *eng, int num);
void http_engine_done (HTTP_Engine *eng);
void http_engine_undo (HTTP_Engine *eng);
//////////////////////////////////////////////////////////////////////
#endif // HTTP_ENGINE_INCLUDED//////////////////////////////////////////////////////////////////////
// src/client.h
//////////////////////////////////////////////////////////////////////
#ifndef CLIENT_INCLUDED
#define CLIENT_INCLUDED
#include <stdbool.h>
#include "parse.h"
// Initialize the global state of cHTTP.
//
// cHTTP tries to avoid global state. What this function
@@ -399,10 +415,16 @@ HTTP_Response *http_post(HTTP_String url,
HTTP_String *headers, int num_headers,
HTTP_String body, HTTP_RequestHandle *phandle);
//////////////////////////////////////////////////////////////////////
#endif // CLIENT_INCLUDED//////////////////////////////////////////////////////////////////////
// src/server.h
//////////////////////////////////////////////////////////////////////
#ifndef HTTP_SERVER_INCLUDED
#define HTTP_SERVER_INCLUDED
#include <stdint.h>
#include "parse.h"
typedef struct {
void *data0;
int data1;
@@ -428,10 +450,15 @@ void http_response_bodyack (HTTP_ResponseHandle res, int num);
void http_response_undo (HTTP_ResponseHandle res);
void http_response_done (HTTP_ResponseHandle res);
//////////////////////////////////////////////////////////////////////
#endif // HTTP_SERVER_INCLUDED//////////////////////////////////////////////////////////////////////
// src/cert.h
//////////////////////////////////////////////////////////////////////
#ifndef CERT_INCLUDED
#define CERT_INCLUDED
#include "basic.h"
// This is an utility to create self-signed certificates
// useful when testing HTTPS servers locally. This is only
// meant to be used by people starting out with a library
@@ -449,10 +476,15 @@ void http_response_done (HTTP_ResponseHandle res);
int http_create_test_certificate(HTTP_String C, HTTP_String O, HTTP_String CN,
HTTP_String cert_file, HTTP_String key_file);
//////////////////////////////////////////////////////////////////////
#endif // CERT_INCLUDED//////////////////////////////////////////////////////////////////////
// src/router.h
//////////////////////////////////////////////////////////////////////
#ifndef HTTP_ROUTER_INCLUDED
#define HTTP_ROUTER_INCLUDED
#include "server.h"
typedef struct HTTP_Router HTTP_Router;
typedef void (*HTTP_RouterFunc)(HTTP_Request*, HTTP_ResponseHandle, void*);;
@@ -463,7 +495,7 @@ void http_router_dir (HTTP_Router *router, HTTP_String endpoint, HTT
void http_router_func (HTTP_Router *router, HTTP_Method method, HTTP_String endpoint, HTTP_RouterFunc func, void*);
int http_serve (char *addr, int port, HTTP_Router *router);
#endif // HTTP_ROUTER_INCLUDED
#ifdef __cplusplus
}
#endif