Barracuda Application Server C/C++ Reference
NO
lxrc.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Application Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: lxrc.h 5568 2024-09-14 14:51:10Z wini $
15 *
16 * COPYRIGHT: Real Time Logic, 2023 - 2024
17 * https://realtimelogic.com
18 *
19 * The copyright to the program herein is the property of
20 * Real Time Logic. The program may be used or copied only
21 * with the written permission from Real Time Logic or
22 * in accordance with the terms and conditions stipulated in
23 * the agreement under which the program has been supplied.
24 ****************************************************************************
25 *
26 *
27 */
28#ifndef __lxrc_h
29#define __lxrc_h
30
31#ifndef NO_SHARKSSL
32#include <SharkSSL.h>
33#endif
34#include <balua.h>
35#include <SoDispCon.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
50void balua_forkpty(lua_State* L);
51
54void balua_http(lua_State* L);
55
58void balua_luaio(lua_State *L);
59
62void balua_sharkssl(lua_State *L);
63
66void balua_socket(lua_State* L);
67
72void balua_relsocket(lua_State* L);
73
76void balua_crypto(lua_State *L);
77
78struct ThreadJob;
79struct LThreadMgr;
80
85void balua_tracelogger(lua_State *L, struct LThreadMgr* tmgr);
86
101typedef void (*ThreadJob_Run)(struct ThreadJob* tj, struct LThreadMgr* mgr);
102
110typedef void (*ThreadJob_LRun)(
111 struct ThreadJob* tj, int msgh, struct LThreadMgr* mgr);
112
117typedef struct LThreadMgr
118{
119 HttpCmdThreadPoolIntf super; /* Inherits from HttpCmdThreadPoolIntf */
120 DoubleList idleThreadList;
121 DoubleList runningThreadList;
122 DoubleList pendingJobList; /* ThreadJob */
124 lua_State* Lg;
128 ThreadPriority priority;
129 int stackSize;
132
133
136typedef struct ThreadJob
137{
138 DoubleLink super; /* Inherits from DoubleLink */
139 ThreadJob_Run run;
140 ThreadJob_LRun lrun;
141 lua_State* Lt;
143
149#define LThreadMgr_canRun(o) ! DoubleList_isEmpty(&(o)->idleThreadList)
150
158#define LThreadMgr_enableHttpPool(o, server) \
159 HttpServer_setThreadPoolIntf(server, (HttpCmdThreadPoolIntf*)o)
160
165
177 ThreadPriority priority, int stackSize,
178 int threads, lua_State* L, int allowCreate);
179
185BA_API ThreadJob* ThreadJob_create(size_t size, ThreadJob_Run run);
186
192BA_API ThreadJob* ThreadJob_lcreate(size_t size, ThreadJob_LRun lrun);
193
200 /* end of ThreadMgr */
202 /* end of AuxLSP */
204
205#ifdef __cplusplus
206}
207#endif
208
209/************************ Private functions ***************************/
210
211int lGetStdSockOptions(lua_State* L, int tabIx, const char** intf,
212 BaBool* ipv6, BaBool* secure);
213#ifndef NO_SHARKSSL
214void lsharkssl_unlock(lua_State *L,SharkSsl* super);
215SharkSsl* lsharkssl_lock(
216 lua_State *L,int tabIx,SharkSsl_Role role,SharkSsl* lockedShark);
217#endif
218int pushCertificate(lua_State *L, SoDispCon* con);
219int pushCiphers(lua_State *L, SoDispCon* con);
220int calcTabSize(lua_State* L, int ix); /* lhttp.c */
221struct HttpClientKeyVal;
222char* extractTab(const char* tab, lua_State* L, int ix,
223 char* ud, struct HttpClientKeyVal** pkv); /* lhttp.c */
224
225#define HTTPCLIENT "HTTPCLIENT"
226struct HttpClient;
227#define toHttpClient(L,ix) (struct HttpClient*)luaL_checkudata(L,ix,HTTPCLIENT)
228
229#define BACERTSTORE "BACERTSTORE"
230/* tocs: To SharkSslCertStore -- Certificate Authority
231 */
232#define toCertStore(L,ix) (SharkSslCertStore*)luaL_checkudata(L,ix,BACERTSTORE)
233
234
235
236#endif
void balua_http(lua_State *L)
Install the httpc Lua bindings.
void balua_crypto(lua_State *L)
Install the crypto Lua bindings.
void balua_sharkssl(lua_State *L)
Install the SharkSSL Lua bindings.
void balua_luaio(lua_State *L)
Install the LuaIo Lua bindings.
void balua_tracelogger(lua_State *L, struct LThreadMgr *tmgr)
Install the TraceLogger Lua bindings.
void balua_socket(lua_State *L)
Install the socket Lua bindings.
void balua_forkpty(lua_State *L)
Install the forkpty Lua bindings.
void balua_relsocket(lua_State *L)
When the socket Lua bindings are installed and the server application implements a gracefully system ...
ThreadPriority
Thread priority list.
Definition: ThreadLib.h:58
BA_API ThreadJob * ThreadJob_lcreate(size_t size, ThreadJob_LRun lrun)
Create a thread job designed to execute Lua code.
void(* ThreadJob_Run)(struct ThreadJob *tj, struct LThreadMgr *mgr)
Generic ThreadJob callback.
Definition: lxrc.h:101
struct ThreadJob ThreadJob
A thread job created by ThreadJob_create or ThreadJob_lcreate.
BA_API void LThreadMgr_constructor(LThreadMgr *o, HttpServer *server, ThreadPriority priority, int stackSize, int threads, lua_State *L, int allowCreate)
Initialize the Thread Pool.
BA_API int LThreadMgr_run(LThreadMgr *o, ThreadJob *tj)
This function sends a thread job to an available idle thread, or queues the job if no threads are cur...
struct LThreadMgr LThreadMgr
The global instance created by C code or a dynamic instance created by ba.thread.create
BA_API void LThreadMgr_destructor(LThreadMgr *o)
This function terminates the Thread Pool and waits for all threads to become idle before returning.
BA_API ThreadJob * ThreadJob_create(size_t size, ThreadJob_Run run)
Create a generic thread job.
void(* ThreadJob_LRun)(struct ThreadJob *tj, int msgh, struct LThreadMgr *mgr)
ThreadJob callback designed for calling Lua code using pcall.
Definition: lxrc.h:110
A container for key/value pairs that is used when setting custom HTTP headers and/or when setting URL...
Definition: HttpClient.h:88
The HTTP(S) "C" client library implementation conforms to the HTTP/1.1 standard, RFC 2616.
Definition: HttpClient.h:190
The Web Server.
Definition: HttpServer.h:2864
The global instance created by C code or a dynamic instance created by ba.thread.create
Definition: lxrc.h:118
lua_State * Lg
Global state.
Definition: lxrc.h:124
int runningThreads
Threads currently running.
Definition: lxrc.h:125
int pendingJobs
Jobs queued.
Definition: lxrc.h:126
HttpServer * server
The server object.
Definition: lxrc.h:123
int isDynamic
if created via ba.thread.create()
Definition: lxrc.h:127
int threads
number of threads
Definition: lxrc.h:130
Contains information about the physical socket connection.
Definition: SoDispCon.h:112
A thread job created by ThreadJob_create or ThreadJob_lcreate.
Definition: lxrc.h:137
lua_State * Lt
Thread state.
Definition: lxrc.h:141