annotate seobeo/seobeo_internal.h @ 120:cbbf78b17cfa

[Seobeo][Websocket] Created Web socket client logic.
author June Park <parkjune1995@gmail.com>
date Thu, 08 Jan 2026 03:19:59 -0800
parents c39582f937e5
children 7b1719fa918c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
1 #ifndef SEOBEO_SERVER_INTERNAL_H
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
2 #define SEOBEO_SERVER_INTERNAL_H
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
3
67
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
4 #ifndef SEOBEO_NO_SSL
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
5 #include <openssl/ssl.h>
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
6 #include <openssl/err.h>
67
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
7 #define SSL_CTX_TYPE SSL_CTX
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
8 #define SSL_TYPE SSL
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
9 #else
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
10 #define SSL_CTX_TYPE void
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
11 #define SSL_TYPE void
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
12 #endif
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
13
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
14 #include "dowa/dowa.h"
96
70401cf61e97 [Seobeo] Added logging.
June Park <parkjune1995@gmail.com>
parents: 72
diff changeset
15 #include <stdatomic.h>
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
16
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
17 typedef enum {
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
18 SEOBEO_STREAM_TYPE_SERVER,
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
19 SEOBEO_STREAM_TYPE_CLIENT,
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
20 } Seobeo_SocketType;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
21
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
22 typedef struct {
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
23 int32 socket;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
24 Seobeo_SocketType type;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
25 boolean connected;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
26
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
27 char *host;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
28 char *port;
67
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
29
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
30 SSL_CTX_TYPE *ssl_ctx;
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
31 SSL_TYPE *ssl;
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
32
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
33 uint8 *read_buffer;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
34 uint32 read_buffer_capacity;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
35 uint32 read_buffer_len; // current size
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
36 uint32 read_buffer_used; // TODO: Implement this for client
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
37
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
38 uint8 *write_buffer;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
39 uint32 write_buffer_capacity;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
40 uint32 write_buffer_len; // current size
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
41
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
42 void *file;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
43 void *text_copy;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
44 char *file_name;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
45
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
46 atomic_bool destroyed;
66
a0f0ad5e42eb [Misc] taking out capital P stuff.
June Park <parkjune1995@gmail.com>
parents: 65
diff changeset
47 } Seobeo_Handle;
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
48
71
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
49 // HTML cache type: maps file paths (char*) to file contents (char*)
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
50 typedef Dowa_KV(char*, char*) Seobeo_Cache_Entry;
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
51
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
52 typedef struct {
71
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
53 Seobeo_Handle *srv;
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
54 Seobeo_Cache_Entry *cache;
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
55 } WorkerArgs;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
56
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
57 typedef enum {
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
58 SEOBEO_MODE_FORK,
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
59 SEOBEO_MODE_EDGE,
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
60 } Seobeo_ServerMode;
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
61
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
62
71
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
63 // HTTP request map type: maps header names to header values
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
64 typedef Dowa_KV(char*, char*) Seobeo_Request_Entry;
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
65
72
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
66 // --- Router Types --- //
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
67 // Forward declaration
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
68 typedef struct Seobeo_Route_Struct Seobeo_Route;
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
69
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
70 // Route handler function type
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
71 typedef Seobeo_Request_Entry* (*Seobeo_Route_Handler)(
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
72 Seobeo_Request_Entry *p_request_map,
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
73 Dowa_Arena *p_arena
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
74 );
4532ce6d9eb8 [Seobeo] Added router to the server logic. Few dowa string manipulation logics.
June Park <parkjune1995@gmail.com>
parents: 71
diff changeset
75
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
76 // --- Parse Header into Dowa Map ---//
71
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
77 extern int Seobeo_Web_Header_Parse(Seobeo_Handle *p_handle, Seobeo_Request_Entry **pp_map, Dowa_Arena *p_arena);
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
78
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
79 // --- Handle Request --- //
71
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
80 extern void Seobeo_Web_HandleClientRequest(Seobeo_Handle *cli, Seobeo_Cache_Entry *p_html_cache);
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
81
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
82 // --- SSL --- //
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
83 extern void Seobeo_Web_SSL_Init();
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
84 extern void Seobeo_Web_SSL_Cleanup(); // Not used
67
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
85 extern int Seobeo_SSL_Setup_Client(Seobeo_Handle *p_handle, const char *host, int socket_fd);
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
86 extern void Seobeo_SSL_Cleanup(Seobeo_Handle *p_handle);
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
87 extern int32 Seobeo_SSL_Write(Seobeo_Handle *p_handle, const uint8 *data, uint32 length);
6626ec933933 [Seobeo] Separated out Client Server logic. Created test tools.
June Park <parkjune1995@gmail.com>
parents: 66
diff changeset
88 extern int32 Seobeo_SSL_Read(Seobeo_Handle *p_handle, uint8 *buffer, uint32 length);
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
89
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
90 // --- Serving using Edge --- //
71
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
91 extern void *Seobeo_Web_Edge_Worker(void *vargs);
75de5903355c Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
June Park <parkjune1995@gmail.com>
parents: 67
diff changeset
92 extern void Seobeo_Web_Edge(Seobeo_Handle *p_server_handle, int thread_count, Seobeo_Cache_Entry *p_html_cache);
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
93
119
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
94 // --- HTTP Client Types --- //
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
95 typedef struct {
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
96 char *method;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
97 char *url;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
98 char *host;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
99 char *port;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
100 char *path;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
101 boolean use_tls;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
102
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
103 // Headers can be either HashMap or Array
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
104 Seobeo_Request_Entry *headers_map;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
105 char **headers_array;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
106
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
107 char *body;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
108 size_t body_length;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
109
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
110 boolean follow_redirects;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
111 int32 max_redirects;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
112
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
113 char *download_path;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
114
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
115 Dowa_Arena *p_arena;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
116 } Seobeo_Client_Request;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
117
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
118 typedef struct {
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
119 int32 status_code;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
120 char *status_text;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
121
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
122 Seobeo_Request_Entry *headers;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
123
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
124 char *body;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
125 size_t body_length;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
126
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
127 char *redirect_url;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
128
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
129 Dowa_Arena *p_arena;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
130 } Seobeo_Client_Response;
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
131
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
132 // --- HTTP Client Functions --- //
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
133 extern Seobeo_Client_Request *Seobeo_Client_Request_Create(const char *url);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
134 extern void Seobeo_Client_Request_Set_Method(Seobeo_Client_Request *p_req, const char *method);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
135 extern void Seobeo_Client_Request_Add_Header_Map(Seobeo_Client_Request *p_req, const char *key, const char *value);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
136 extern void Seobeo_Client_Request_Add_Header_Array(Seobeo_Client_Request *p_req, const char *header);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
137 extern void Seobeo_Client_Request_Set_Body(Seobeo_Client_Request *p_req, const char *body, size_t length);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
138 extern void Seobeo_Client_Request_Set_Follow_Redirects(Seobeo_Client_Request *p_req, boolean follow, int32 max_redirects);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
139 extern void Seobeo_Client_Request_Set_Download_Path(Seobeo_Client_Request *p_req, const char *path);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
140 extern Seobeo_Client_Response *Seobeo_Client_Request_Execute(Seobeo_Client_Request *p_req);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
141 extern void Seobeo_Client_Request_Destroy(Seobeo_Client_Request *p_req);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
142 extern void Seobeo_Client_Response_Destroy(Seobeo_Client_Response *p_resp);
c39582f937e5 [Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents: 96
diff changeset
143
120
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
144 // --- WebSocket Types --- //
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
145 typedef enum {
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
146 SEOBEO_WS_OPCODE_CONTINUATION = 0x0,
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
147 SEOBEO_WS_OPCODE_TEXT = 0x1,
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
148 SEOBEO_WS_OPCODE_BINARY = 0x2,
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
149 SEOBEO_WS_OPCODE_CLOSE = 0x8,
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
150 SEOBEO_WS_OPCODE_PING = 0x9,
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
151 SEOBEO_WS_OPCODE_PONG = 0xA
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
152 } Seobeo_WebSocket_Opcode;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
153
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
154 typedef enum {
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
155 SEOBEO_WS_STATE_CONNECTING = 0,
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
156 SEOBEO_WS_STATE_OPEN,
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
157 SEOBEO_WS_STATE_CLOSING,
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
158 SEOBEO_WS_STATE_CLOSED
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
159 } Seobeo_WebSocket_State;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
160
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
161 typedef struct {
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
162 Seobeo_WebSocket_Opcode opcode;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
163 uint8 *data;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
164 size_t length;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
165 boolean is_final;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
166 } Seobeo_WebSocket_Message;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
167
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
168 typedef struct {
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
169 Seobeo_Handle *p_handle;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
170 char *url;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
171 char *host;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
172 char *port;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
173 char *path;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
174 boolean use_tls;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
175
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
176 Seobeo_WebSocket_State state;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
177
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
178 uint8 *fragment_buffer;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
179 size_t fragment_length;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
180 size_t fragment_capacity;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
181 Seobeo_WebSocket_Opcode fragment_opcode;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
182
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
183 Dowa_Arena *p_arena;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
184 } Seobeo_WebSocket;
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
185
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
186 // --- WebSocket Functions --- //
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
187 extern Seobeo_WebSocket *Seobeo_WebSocket_Connect(const char *url);
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
188 extern int32 Seobeo_WebSocket_Send_Text(Seobeo_WebSocket *p_ws, const char *text);
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
189 extern int32 Seobeo_WebSocket_Send_Binary(Seobeo_WebSocket *p_ws, const uint8 *data, size_t length);
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
190 extern int32 Seobeo_WebSocket_Send_Ping(Seobeo_WebSocket *p_ws, const char *payload);
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
191 extern int32 Seobeo_WebSocket_Send_Pong(Seobeo_WebSocket *p_ws, const char *payload);
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
192 extern Seobeo_WebSocket_Message *Seobeo_WebSocket_Receive(Seobeo_WebSocket *p_ws);
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
193 extern void Seobeo_WebSocket_Message_Destroy(Seobeo_WebSocket_Message *p_msg);
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
194 extern int32 Seobeo_WebSocket_Close(Seobeo_WebSocket *p_ws, uint16 code, const char *reason);
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
195 extern void Seobeo_WebSocket_Destroy(Seobeo_WebSocket *p_ws);
cbbf78b17cfa [Seobeo][Websocket] Created Web socket client logic.
June Park <parkjune1995@gmail.com>
parents: 119
diff changeset
196
19
875bb6e10db7 [Seobeo] Chaning Function naming to be easily readable.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
197 #endif