Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
lxrc.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Application Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: lxrc.h 5978 2026-09-11 16:13:48Z wini $
15 *
16 * COPYRIGHT: Real Time Logic, 2023 - 2026
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 */
30#ifndef __lxrc_h
31#define __lxrc_h
32
33#ifndef NO_SHARKSSL
34#include <SharkSSL.h>
35#endif
36#include <balua.h>
37#include <SoDispCon.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
56void balua_forkpty(lua_State* L);
57
61void balua_http(lua_State* L);
62
66void balua_luaio(lua_State *L);
67
71void balua_sharkssl(lua_State *L);
72
76void balua_socket(lua_State* L);
77
84void balua_relsocket(lua_State* L);
85
89void balua_crypto(lua_State *L);
90
91struct ThreadJob;
92struct LThreadMgr;
93
99void balua_tracelogger(lua_State *L, struct LThreadMgr* tmgr);
100
118typedef void (*ThreadJob_Run)(struct ThreadJob* tj, struct LThreadMgr* mgr);
119
130typedef void (*ThreadJob_LRun)(
131 struct ThreadJob* tj, int msgh, struct LThreadMgr* mgr);
132
137typedef struct LThreadMgr
138{
139 HttpCmdThreadPoolIntf super; /* Inherits from HttpCmdThreadPoolIntf */
140 DoubleList idleThreadList;
141 DoubleList runningThreadList;
142 DoubleList pendingJobList; /* ThreadJob */
144 lua_State* Lg;
148 ThreadPriority priority;
149 int stackSize;
152
153
156typedef struct ThreadJob
157{
158 DoubleLink super; /* Inherits from DoubleLink */
159 ThreadJob_Run run;
160 ThreadJob_LRun lrun;
161 lua_State* Lt;
163
170#define LThreadMgr_canRun(o) ! DoubleList_isEmpty(&(o)->idleThreadList)
171
179#define LThreadMgr_enableHttpPool(o, server) \
180 HttpServer_setThreadPoolIntf(server, (HttpCmdThreadPoolIntf*)o)
181
189
204 ThreadPriority priority, int stackSize,
205 int threads, lua_State* L, int allowCreate);
206
216BA_API ThreadJob* ThreadJob_create(size_t size, ThreadJob_Run run);
217
227BA_API ThreadJob* ThreadJob_lcreate(size_t size, ThreadJob_LRun lrun);
228
239 /* end of ThreadMgr */
241 /* end of AuxLSP */
243
244#ifdef __cplusplus
245}
246#endif
247
248/************************ Private functions ***************************/
249
250int lGetStdSockOptions(lua_State* L, int tabIx, const char** intf,
251 BaBool* ipv6, BaBool* secure);
252#ifndef NO_SHARKSSL
253void lsharkssl_unlock(lua_State *L,SharkSsl* super);
254SharkSsl* lsharkssl_lock(
255 lua_State *L,int tabIx,SharkSsl_Role role,SharkSsl* lockedShark);
256#endif
257int pushCertificate(lua_State *L, SoDispCon* con);
258int pushCiphers(lua_State *L, SoDispCon* con);
259int calcTabSize(lua_State* L, int ix, BaBool query); /* lhttp.c */
260struct HttpClientKeyVal;
261char* extractTab(const char* tab, lua_State* L, int ix,
262 char* ud, struct HttpClientKeyVal** pkv); /* lhttp.c */
263
264#define HTTPCLIENT "HTTPCLIENT"
265struct HttpClient;
266#define toHttpClient(L,ix) (struct HttpClient*)luaL_checkudata(L,ix,HTTPCLIENT)
267
268#define BACERTSTORE "BACERTSTORE"
269/* tocs: To SharkSslCertStore -- Certificate Authority
270 */
271#define toCertStore(L,ix) (SharkSslCertStore*)luaL_checkudata(L,ix,BACERTSTORE)
272
273
274
275#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)
Notify registered coroutine sockets that the server is shutting down.
ThreadPriority
Portable priority choices, mapped to the target operating system.
Definition: ThreadLib.h:61
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:118
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 and install ba.thread.
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 stop 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 lua_pcall.
Definition: lxrc.h:130
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:118
A container for key/value pairs used when setting custom HTTP headers or URL encoded HTTP parameters.
Definition: HttpClient.h:90
Blocking HTTP/1.1 client with optional SharkSSL HTTPS support.
Definition: HttpClient.h:187
Worker-pool dispatch interface borrowed by HttpServer.
Definition: HttpCmdThreadPoolIntf.h:63
The Web Server.
Definition: HttpServer.h:3393
The global instance created by C code or a dynamic instance created by ba.thread.create
Definition: lxrc.h:138
lua_State * Lg
Global state.
Definition: lxrc.h:144
int runningThreads
Threads currently running.
Definition: lxrc.h:145
int pendingJobs
Jobs queued.
Definition: lxrc.h:146
HttpServer * server
The server object.
Definition: lxrc.h:143
int isDynamic
if created via ba.thread.create()
Definition: lxrc.h:147
int threads
number of threads
Definition: lxrc.h:150
Contains information about the physical socket connection.
Definition: SoDispCon.h:120
A thread job created by ThreadJob_create or ThreadJob_lcreate.
Definition: lxrc.h:157
lua_State * Lt
Borrowed Lua thread, valid only during the job callback.
Definition: lxrc.h:161