view seobeo/seobeo_internal.h @ 70:4bc56e88e1f3

Remove unnecessary files.
author June Park <parkjune1995@gmail.com>
date Thu, 25 Dec 2025 20:10:46 -0800
parents 6626ec933933
children 75de5903355c
line wrap: on
line source

#ifndef SEOBEO_SERVER_INTERNAL_H
#define SEOBEO_SERVER_INTERNAL_H

// SSL - conditionally included
#ifndef SEOBEO_NO_SSL
#include <openssl/ssl.h>
#include <openssl/err.h>
#define SSL_CTX_TYPE SSL_CTX
#define SSL_TYPE SSL
#else
#define SSL_CTX_TYPE void
#define SSL_TYPE void
#endif

#ifndef DIRECTORY
#define DIRECTORY
#endif
#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_TYPE     *ssl_ctx;
  SSL_TYPE         *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;
} Seobeo_Handle;

typedef struct {
  Seobeo_Handle  *srv;
  Dowa_HashMap   *cache;
} WorkerArgs;

typedef enum {
  SEOBEO_MODE_FORK,
  SEOBEO_MODE_EDGE,
} Seobeo_ServerMode;




// --- Parse Header into Dowa Map ---//
extern int            Seobeo_Web_Header_Parse(Seobeo_Handle *p_handle, Dowa_HashMap *map);

// --- Handle Request --- //
extern void           Seobeo_Web_HandleClientRequest(Seobeo_Handle *cli, Dowa_HashMap *p_html_cache);

// --- SSL --- //
extern void           Seobeo_Web_SSL_Init();
extern void           Seobeo_Web_SSL_Cleanup(); // Not used
extern int            Seobeo_SSL_Setup_Client(Seobeo_Handle *p_handle, const char *host, int socket_fd);
extern void           Seobeo_SSL_Cleanup(Seobeo_Handle *p_handle);
extern int32          Seobeo_SSL_Write(Seobeo_Handle *p_handle, const uint8 *data, uint32 length);
extern int32          Seobeo_SSL_Read(Seobeo_Handle *p_handle, uint8 *buffer, uint32 length);

// --- Serving using Edge --- //
extern void          *Seobeo_Web_Edge_Worker(void *vargs); 
extern void           Seobeo_Web_Edge(Seobeo_Handle *p_server_handle, int thread_count, Dowa_HashMap *p_html_cache);
extern void           Seobeo_Web_Edge_2(Seobeo_Handle *p_server_handle, Dowa_HashMap *p_html_cache);

#endif