view seobeo/seobeo_internal.h @ 55:0dcfbf5ba997

Remvoing unneeded bzl rules.
author June Park <parkjune1995@gmail.com>
date Fri, 19 Dec 2025 13:59:11 -0800
parents 84672efec192
children ea9ef388ab97
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);
extern void           Seobeo_Web_Edge_2(Seobeo_PHandle p_server_handle, Dowa_PHashMap p_html_cache);

#endif