view seobeo/seobeo_internal.h @ 22:947b81010aba

[Dowa & Seobeo] Updated so that Dowa hashmaps can use arena and not be broken. Split up web so taht it can handle different paths. Also fixes issues with hash collisions which was pain in the ass.
author June Park <parkjune1995@gmail.com>
date Tue, 07 Oct 2025 07:11:02 -0700
parents 875bb6e10db7
children 84672efec192
line wrap: on
line source

#ifndef SEOBEO_SERVER_INTERNAL_H
#define SEOBEO_SERVER_INTERNAL_H

// SSL
#include <openssl/ssl.h> 
#include <openssl/err.h>

#include "dowa/dowa.h"

typedef enum {
  SEOBEO_STREAM_TYPE_SERVER,
  SEOBEO_STREAM_TYPE_CLIENT,
} Seobeo_SocketType;

typedef struct {
  int32       socket; 
  Seobeo_SocketType  type;
  boolean     connected; 

  char        *host;
  char        *port;
 
  SSL_CTX     *ssl_ctx;
  SSL         *ssl;

  uint8       *read_buffer;
  uint32      read_buffer_capacity;
  uint32      read_buffer_len; // current size
  uint32      read_buffer_used; // TODO: Implement this for client 

  uint8       *write_buffer;
  uint32      write_buffer_capacity;
  uint32      write_buffer_len; // current size

  void        *file;
  void        *text_copy;
  char        *file_name;

  atomic_bool destroyed;
} Sebeo_Handle, *Seobeo_PHandle;

typedef struct {
  Seobeo_PHandle  srv;
  Dowa_PHashMap   cache;
  int             evfd;    // epoll‐fd or kqueue‐fd
} WorkerArgs;

typedef enum {
  SEOBEO_MODE_FORK,
  SEOBEO_MODE_EDGE,
} Seobeo_ServerMode;




// --- Parse Header into Dowa Map ---//
extern int            Seobeo_Web_Header_Parse(Seobeo_PHandle p_handle, Dowa_PHashMap map);

// --- Handle Request --- //
extern void           Seobeo_Web_HandleClientRequest(Seobeo_PHandle cli, Dowa_PHashMap p_html_cache);

// --- SSL --- //
extern void           Seobeo_Web_SSL_Init();
extern void           Seobeo_Web_SSL_Cleanup(); // Not used

// --- Serving using Edge --- //
extern void          *Seobeo_Web_Edge_Worker(void *vargs); 
extern void           Seobeo_Web_Edge(Seobeo_PHandle p_server_handle, int thread_count, Dowa_PHashMap p_html_cache);

#endif