├── doc └── youtube.jpg ├── inc ├── SoDispCon.h ├── opcua_module.h ├── dlmalloc.h ├── arch │ ├── INtime │ │ └── luaconf.h │ ├── Windows │ │ ├── luaconf.h │ │ └── ThreadLibArch.h │ ├── Posix │ │ └── luaconf.h │ ├── Zephyr │ │ ├── luaconf.h │ │ └── ThreadLibArch.h │ ├── FreeRTOS │ │ └── luaconf.h │ ├── uCOS-III │ │ └── luaconf.h │ ├── SMX │ │ └── luaconf.h │ ├── Nucleus │ │ ├── luaconf.h │ │ └── ThreadLibArch.h │ ├── ThreadX │ │ ├── luaconf.h │ │ └── ThreadLibArch.h │ ├── embOS │ │ ├── luaconf.h │ │ └── ThreadLibArch.h │ ├── Digi │ │ ├── luaconf.h │ │ └── ThreadLibArch.h │ ├── MQX │ │ ├── luaconf.h │ │ └── ThreadLibArch.h │ ├── INTEGRITY │ │ ├── luaconf.h │ │ └── ThreadLibArch.h │ ├── Quadros │ │ └── luaconf.h │ ├── VxWorks │ │ └── luaconf.h │ └── NET │ │ ├── INtime │ │ └── HttpCfg.h │ │ ├── CE │ │ └── HttpCfg.h │ │ ├── epoll │ │ └── HttpCfg.h │ │ └── embOSIP │ │ └── HttpCfg.h ├── LeakDetect.h ├── luasql.h ├── mime.h ├── lualib.h ├── FileCspReader.h ├── BaMimeTypes.h ├── CspCompileCommon.h ├── CspCompileTypes.h ├── barracuda.h ├── HttpCmdThreadPoolIntf.h ├── IoBufPrint.h ├── gBsdDspO.h ├── NetConv.h ├── RecIoIter.h ├── BaAtoi.h ├── SharkSSL_opts.h ├── FileZipReader.h ├── VirDir.h ├── DeadProp.h ├── BaSharkSslOpt.h ├── IoIntfCspReader.h ├── BaFile.h ├── FixedSizeAllocator.h ├── JConstrCont.h ├── JUserCont.h └── IoIntfZipReader.h ├── examples ├── MakoServer │ ├── src │ │ ├── MakoExt1.ch │ │ ├── MakoExtM1.ch │ │ ├── MakoExtM2.ch │ │ ├── MakoExtM3.ch │ │ ├── MakoExtM4.ch │ │ ├── MakoVer.h │ │ ├── MakoWBC.ch │ │ ├── EncryptionKey.h │ │ ├── Windows │ │ │ └── servutil.h │ │ └── mako.h │ ├── VcMake │ │ └── mako.sln │ └── GenNewEncryptionKey.py ├── C-WebSockets │ ├── README.md │ ├── HostBuild.gif │ ├── BuildZip.bat │ ├── BuildZip.sh │ ├── Makefile │ ├── VcMake │ │ └── example.sln │ └── html │ │ ├── style.css │ │ └── index.html ├── xedge │ ├── src │ │ ├── XedgeInitDiskIo.c │ │ ├── ZipBinPwd.h │ │ ├── ZipPublicKey.h │ │ ├── XedgeWBC.h │ │ ├── xedge.h │ │ └── EncryptionKey.h │ └── Lua-Examples │ │ ├── smq.lsp │ │ ├── blinkled.xlua │ │ └── httpclient.lsp ├── C-RESTful-Service │ ├── Makefile │ ├── TestApi.py │ ├── src │ │ ├── RestJsonUtils.h │ │ └── RestJsonUtils.c │ ├── README.md │ └── RestService.vcxproj └── HostInit │ └── Main.c ├── src ├── luasql.c └── arch │ ├── SMX │ └── ThreadLib.c │ ├── embOS │ └── ThreadLib.c │ ├── uCOS-III │ └── ThreadLib.c │ ├── Quadros │ ├── ThreadLib.c │ └── readme.txt │ ├── ce │ └── ThreadLib.c │ ├── INtime │ └── ThreadLib.c │ └── Windows │ └── ThreadLib.c ├── RaspberryPiBuild.sh ├── QNXBuild.sh └── LinuxBuild.sh /doc/youtube.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealTimeLogic/BAS/HEAD/doc/youtube.jpg -------------------------------------------------------------------------------- /inc/SoDispCon.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealTimeLogic/BAS/HEAD/inc/SoDispCon.h -------------------------------------------------------------------------------- /examples/MakoServer/src/MakoExt1.ch: -------------------------------------------------------------------------------- 1 | /* Inject optional code into MakoMain.c just before MakoExt2.ch */ 2 | -------------------------------------------------------------------------------- /examples/MakoServer/src/MakoExtM1.ch: -------------------------------------------------------------------------------- 1 | /* Inject optional code into MakoMain.c -> function runMako() */ 2 | -------------------------------------------------------------------------------- /examples/MakoServer/src/MakoExtM2.ch: -------------------------------------------------------------------------------- 1 | /* Inject optional code into MakoMain.c -> function runMako() */ 2 | -------------------------------------------------------------------------------- /examples/MakoServer/src/MakoExtM3.ch: -------------------------------------------------------------------------------- 1 | /* Inject optional code into MakoMain.c -> function runMako() */ 2 | -------------------------------------------------------------------------------- /examples/MakoServer/src/MakoExtM4.ch: -------------------------------------------------------------------------------- 1 | /* Inject optional code into MakoMain.c -> function runMako() */ 2 | -------------------------------------------------------------------------------- /examples/C-WebSockets/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealTimeLogic/BAS/HEAD/examples/C-WebSockets/README.md -------------------------------------------------------------------------------- /examples/C-WebSockets/HostBuild.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealTimeLogic/BAS/HEAD/examples/C-WebSockets/HostBuild.gif -------------------------------------------------------------------------------- /examples/xedge/src/XedgeInitDiskIo.c: -------------------------------------------------------------------------------- 1 | 2 | /* Example code showing how to set the mount point, if required 3 | */ 4 | 5 | #include "xedge.h" 6 | 7 | int xedgeInitDiskIo(DiskIo* dio) 8 | { 9 | DiskIo_setRootDir(dio,"/your/mount/point"); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /examples/MakoServer/src/MakoVer.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define MAKO_VER "4.3" 4 | 5 | #define MA_STR_HELPER(x) #x 6 | #define MA_STR(x) MA_STR_HELPER(x) 7 | 8 | #ifdef BASLIB_VER_NO 9 | #define MAKO_DATE "BAS lib " MA_STR(BASLIB_VER_NO) ". Build date: " __DATE__ 10 | #else 11 | #define MAKO_DATE "Build date: " __DATE__ 12 | #endif 13 | -------------------------------------------------------------------------------- /examples/C-WebSockets/BuildZip.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Zips together the data in the html directory and produces html.zip.c for 'release build'. Make sure to compile BAS\tools\bin2c.c prior to running this batch file. bin2c.exe and zip.exe must be in your path env. var. 3 | 4 | cd html || pause 5 | zip -D -u -r -9 ..\obj\release\html.zip * || pause 6 | cd ..\obj\release 7 | bin2c -z getZipReader html.zip html.zip.c || pause 8 | 9 | echo done 10 | pause 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /inc/opcua_module.h: -------------------------------------------------------------------------------- 1 | #ifndef OPCUA_MODULE_H 2 | #define OPCUA_MODULE_H 3 | 4 | #include 5 | #include 6 | 7 | /* 8 | an entry point for lua dynamically linked module 9 | */ 10 | LUALIB_API int luaopen_opcua_ns0(lua_State* l); 11 | 12 | /* 13 | an entry point for statically linked module 14 | calls luaL_requiref to register opcuac module 15 | */ 16 | void luaopen_opcua_ns0_static(lua_State* l); 17 | 18 | #endif // OPCUA_MODULE_H 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/xedge/src/ZipBinPwd.h: -------------------------------------------------------------------------------- 1 | /* When macro USE_ZIPBINPWD is defined 2 | 3 | Globally apply a password to all loaded ZIP files. This approach 4 | allows embedding an obfuscated password that will be automatically 5 | applied to all ZIP files. Use binpwd2str to generate the zipBinPwd 6 | array content below. 7 | 8 | Ref: https://realtimelogic.com/ba/examples/xedge/readme.html#security 9 | */ 10 | 11 | #error insert data here e.g. static const U8 zipBinPwd[] ={data}; 12 | -------------------------------------------------------------------------------- /inc/dlmalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef __dlmalloc_h 2 | #define __dlmalloc_h 3 | #include 4 | void dlmalloc_setExhaustedCB(void (*cb)(void)); 5 | void init_dlmalloc(char* heapstart, char* heapend); 6 | void* dlmalloc(size_t bytes); 7 | void* dlrealloc(void* oldmem, size_t bytes); 8 | void dlfree(void* mem); 9 | 10 | 11 | #ifdef USE_DLMALLOC 12 | #define baMalloc(size) dlmalloc(size) 13 | #define baRealloc(ptr, size) dlrealloc(ptr, size) 14 | #define baFree(ptr) dlfree(ptr) 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /inc/arch/INtime/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | #define BA_HAS_ANSI_IO 5 | 6 | #undef snprintf 7 | #undef sprintf 8 | #define snprintf nonosnprintf 9 | #define sprintf nonosprintf 10 | #include 11 | #undef snprintf 12 | #undef sprintf 13 | #define snprintf basnprintf 14 | #define sprintf basprintf 15 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 16 | extern int basprintf(char* buf, const char* fmt, ...); 17 | 18 | #ifdef NO_LOCALDECPOINT 19 | #define lua_getlocaledecpoint() '.' 20 | #endif 21 | 22 | #include 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /inc/arch/Windows/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | #ifdef _WIN32_WCE 5 | 6 | #define NO_TIMEFUNCS 7 | #define NO_LOG2 /* No log2() in Win-CE */ 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define abort() baFatalE(FE_EXIT,__LINE__) 12 | #define lua_getlocaledecpoint() '.' 13 | #define getenv(x) 0 14 | #define time(x) baGetUnixTime() 15 | #define strcoll strcmp 16 | #define BA_MINIOSLIB 17 | 18 | 19 | #else 20 | 21 | 22 | #define BA_HAS_ANSI_IO 23 | 24 | #endif 25 | 26 | #include 27 | #endif 28 | -------------------------------------------------------------------------------- /inc/LeakDetect.h: -------------------------------------------------------------------------------- 1 | 2 | /* See examples/misc/LeakDetector.cpp */ 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | #include 7 | void* baLeakDetectMalloc(size_t n, const char* file, int line); 8 | void* baLeakDetectRealloc(void* p, size_t n, const char* file, int line); 9 | void baLeakDetectFree(void* p, const char* file, int line); 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | #define baMalloc(n) baLeakDetectMalloc(n, __FILE__, __LINE__) 14 | #define baRealloc(p,n) baLeakDetectRealloc(p, n, __FILE__, __LINE__) 15 | #define baFree(p) baLeakDetectFree(p, __FILE__, __LINE__) 16 | -------------------------------------------------------------------------------- /examples/xedge/src/ZipPublicKey.h: -------------------------------------------------------------------------------- 1 | /* When macro USE_ZIPSIGNATURE is defined. 2 | 3 | Enable signed ZIP file enforcement. Create 'zipPubKey; below using 4 | SharkSSLParseKey.exe public_key.pem 5 | 6 | Details: 7 | https://realtimelogic.com/ba/examples/xedge/readme.html#security 8 | https://realtimelogic.com/ba/doc/en/C/reference/html/SignEncZip.html 9 | */ 10 | 11 | /* Create the embedded key as follows: SharkSSLParseKey public_key.pem 12 | Keep the name 'zipPubKey', but insert produced data below. 13 | */ 14 | static const U8 zipPubKey[] = 15 | { 16 | INSERT DATA HERE 17 | }; 18 | -------------------------------------------------------------------------------- /examples/C-WebSockets/BuildZip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Zips together the data in the html directory and produces html.zip.c 4 | # for 'release build'. Make sure to compile BAS/tools/bin2c.c prior to 5 | # running this batch file. bin2c and zip must be in your path 6 | # env. var. 7 | 8 | function failed() { 9 | echo "$1 failed" 10 | sleep 5 11 | exit 1 12 | } 13 | 14 | cd "$(dirname "$0")" 15 | rm -f obj/release/html.zip 16 | cd html || failed "cd" 17 | zip -D -r -9 ../obj/release/html.zip * || failed "zip" 18 | cd ../obj/release 19 | bin2c -z getZipReader html.zip html.zip.c || failed "bin2c" 20 | 21 | echo done 22 | -------------------------------------------------------------------------------- /examples/xedge/Lua-Examples/smq.lsp: -------------------------------------------------------------------------------- 1 | 22 | 23 | See README.md for how to connect SMQ clients. 24 | 25 | -------------------------------------------------------------------------------- /inc/arch/Posix/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | #define BA_HAS_ANSI_IO 5 | 6 | /* Redirect sprintf functions to the more stack friendly BA versions */ 7 | #ifndef NO_BA_SERVER 8 | #ifdef sprintf 9 | #undef snprintf 10 | #undef sprintf 11 | #define snprintf nonosnprintf 12 | #define sprintf nonosprintf 13 | #endif 14 | #include 15 | #undef snprintf 16 | #undef sprintf 17 | #define snprintf basnprintf 18 | #define sprintf basprintf 19 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 20 | extern int basprintf(char* buf, const char* fmt, ...); 21 | #endif 22 | 23 | #ifdef NO_LOCALDECPOINT 24 | #define lua_getlocaledecpoint() '.' 25 | #endif 26 | 27 | #include 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /examples/xedge/Lua-Examples/blinkled.xlua: -------------------------------------------------------------------------------- 1 | --[[ 2 | This example creates a timer coroutine that controls the LED via the 3 | Lua bindings in led.c. The timer object is free-floating since we are 4 | not referencing (anchoring) the object. The created timer(s) will 5 | eventually be collected by the Lua garbage collector. You can speed 6 | up the collecting by calling the Lua function: collectgarbage() 7 | 8 | Timer documentation: 9 | https://realtimelogic.com/ba/doc/?url=lua.html#ba_timer 10 | --]] 11 | 12 | local function blink() 13 | while true do 14 | trace"blink" 15 | LED.setLed(true) 16 | coroutine.yield(true) -- Sleep 17 | LED.setLed(false) 18 | coroutine.yield(true) -- Sleep 19 | end 20 | end 21 | 22 | timer=ba.timer(blink) 23 | timer:set(1000) 24 | 25 | -------------------------------------------------------------------------------- /inc/arch/Zephyr/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Default: Use integers, not 'double' for Lua numbers */ 5 | #if !defined(LUA_NUMBER_INTEGER) 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | #define lua_getlocaledecpoint() '.' 15 | 16 | /* Redirect sprintf functions to the more stack friendly BA versions */ 17 | #undef snprintf 18 | #undef sprintf 19 | #define snprintf nonosnprintf 20 | #define sprintf nonosprintf 21 | #include 22 | #undef snprintf 23 | #undef sprintf 24 | #define snprintf basnprintf 25 | #define sprintf basprintf 26 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 27 | extern int basprintf(char* buf, const char* fmt, ...); 28 | 29 | #include 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /inc/arch/FreeRTOS/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Default: Use integers, not 'double' for Lua numbers */ 5 | #if !defined(LUA_NUMBER_INTEGER) 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | #define lua_getlocaledecpoint() '.' 15 | 16 | /* Redirect sprintf functions to the more stack friendly BA versions */ 17 | #undef snprintf 18 | #undef sprintf 19 | #define snprintf nonosnprintf 20 | #define sprintf nonosprintf 21 | #include 22 | #undef snprintf 23 | #undef sprintf 24 | #define snprintf basnprintf 25 | #define sprintf basprintf 26 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 27 | extern int basprintf(char* buf, const char* fmt, ...); 28 | 29 | #include 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /inc/arch/uCOS-III/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Default: Use integers, not 'double' for Lua numbers */ 5 | #if !defined(LUA_NUMBER_INTEGER) 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | #define lua_getlocaledecpoint() '.' 15 | 16 | /* Redirect sprintf functions to the more stack friendly BA versions */ 17 | #undef snprintf 18 | #undef sprintf 19 | #define snprintf nonosnprintf 20 | #define sprintf nonosprintf 21 | #include 22 | #undef snprintf 23 | #undef sprintf 24 | #define snprintf basnprintf 25 | #define sprintf basprintf 26 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 27 | extern int basprintf(char* buf, const char* fmt, ...); 28 | 29 | #include "../gluaconf.h" 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /inc/arch/SMX/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Use integers, not 'double' for Lua numbers */ 5 | #ifndef LUA_NUMBER_INTEGER 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | #ifndef lua_getlocaledecpoint 15 | #define lua_getlocaledecpoint() '.' 16 | #endif 17 | 18 | /* Redirect sprintf functions to the more stack friendly BA versions */ 19 | #undef snprintf 20 | #undef sprintf 21 | #define snprintf nonosnprintf 22 | #define sprintf nonosprintf 23 | #include 24 | #undef snprintf 25 | #undef sprintf 26 | #define snprintf basnprintf 27 | #define sprintf basprintf 28 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 29 | extern int basprintf(char* buf, const char* fmt, ...); 30 | 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /examples/C-RESTful-Service/Makefile: -------------------------------------------------------------------------------- 1 | # Compiler and flags 2 | CC := gcc 3 | CFLAGS := -Wall -MMD -MP \ 4 | -I../../inc/ \ 5 | -I../../inc/arch/Posix/ \ 6 | -I../../inc/arch/NET/Posix/ 7 | 8 | # Source files 9 | SRCS := \ 10 | src/RestService.c \ 11 | src/RestJsonUtils.c \ 12 | ../../src/arch/Posix/ThreadLib.c \ 13 | ../../src/arch/NET/generic/SoDisp.c \ 14 | ../../src/BWS.c \ 15 | ../HostInit/Main.c \ 16 | ../HostInit/HostInit.c 17 | 18 | # Object files 19 | OBJS := $(SRCS:.c=.o) 20 | 21 | # Dependency files 22 | DEPS := $(OBJS:.o=.d) 23 | 24 | # Target executable 25 | TARGET := restservice 26 | 27 | # Default rule 28 | all: $(TARGET) 29 | 30 | # Link 31 | $(TARGET): $(OBJS) 32 | $(CC) -o $@ $^ 33 | 34 | # Include dependencies 35 | -include $(DEPS) 36 | 37 | # Clean rule 38 | clean: 39 | rm -f $(TARGET) $(OBJS) $(DEPS) 40 | 41 | .PHONY: all clean 42 | -------------------------------------------------------------------------------- /inc/arch/Nucleus/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Use integers, not 'double' for Lua numbers */ 5 | #ifndef LUA_NUMBER_INTEGER 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | #ifndef lua_getlocaledecpoint 15 | #define lua_getlocaledecpoint() '.' 16 | #endif 17 | 18 | /* Redirect sprintf functions to the more stack friendly BA versions */ 19 | #undef snprintf 20 | #undef sprintf 21 | #define snprintf nonosnprintf 22 | #define sprintf nonosprintf 23 | #include 24 | #undef snprintf 25 | #undef sprintf 26 | #define snprintf basnprintf 27 | #define sprintf basprintf 28 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 29 | extern int basprintf(char* buf, const char* fmt, ...); 30 | 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /inc/arch/ThreadX/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Use integers, not 'double' for Lua numbers */ 5 | #ifndef LUA_NUMBER_INTEGER 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | #ifndef lua_getlocaledecpoint 15 | #define lua_getlocaledecpoint() '.' 16 | #endif 17 | 18 | /* Redirect sprintf functions to the more stack friendly BA versions */ 19 | #undef snprintf 20 | #undef sprintf 21 | #define snprintf nonosnprintf 22 | #define sprintf nonosprintf 23 | #include 24 | #undef snprintf 25 | #undef sprintf 26 | #define snprintf basnprintf 27 | #define sprintf basprintf 28 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 29 | extern int basprintf(char* buf, const char* fmt, ...); 30 | 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /inc/arch/embOS/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Use integers, not 'double' for Lua numbers */ 5 | #ifndef LUA_NUMBER_INTEGER 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | #ifndef lua_getlocaledecpoint 15 | #define lua_getlocaledecpoint() '.' 16 | #endif 17 | 18 | /* Redirect sprintf functions to the more stack friendly BA versions */ 19 | #undef snprintf 20 | #undef sprintf 21 | #define snprintf nonosnprintf 22 | #define sprintf nonosprintf 23 | #include 24 | #undef snprintf 25 | #undef sprintf 26 | #define snprintf basnprintf 27 | #define sprintf basprintf 28 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 29 | extern int basprintf(char* buf, const char* fmt, ...); 30 | 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /inc/arch/Digi/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Use integers, not 'double' for Lua numbers */ 5 | #ifndef LUA_NUMBER_INTEGER 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | #ifndef lua_getlocaledecpoint 15 | #define lua_getlocaledecpoint() '.' 16 | #endif 17 | 18 | 19 | /* Redirect sprintf functions to the more stack friendly BA versions */ 20 | #undef snprintf 21 | #undef sprintf 22 | #define snprintf nonosnprintf 23 | #define sprintf nonosprintf 24 | #include 25 | #undef snprintf 26 | #undef sprintf 27 | #define snprintf basnprintf 28 | #define sprintf basprintf 29 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 30 | extern int basprintf(char* buf, const char* fmt, ...); 31 | 32 | #include 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /inc/arch/MQX/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Use integers, not 'double' for Lua numbers */ 5 | #ifndef LUA_NUMBER_INTEGER 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | 15 | #define NO_TIMEFUNCS 16 | #define lua_getlocaledecpoint() '.' 17 | typedef unsigned int time_t; 18 | 19 | /* Redirect sprintf functions to the more stack friendly BA versions */ 20 | #undef snprintf 21 | #undef sprintf 22 | #define snprintf nonosnprintf 23 | #define sprintf nonosprintf 24 | #include 25 | #undef snprintf 26 | #undef sprintf 27 | #define snprintf basnprintf 28 | #define sprintf basprintf 29 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 30 | extern int basprintf(char* buf, const char* fmt, ...); 31 | 32 | #define errno 0 33 | 34 | #include 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /inc/arch/INTEGRITY/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Use integers, not 'double' for Lua numbers */ 5 | #ifndef LUA_NUMBER_INTEGER 6 | #define LUA_NUMBER_INTEGER 0 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #ifdef USE_SYSTEM_POSIX 11 | #define BA_HAS_ANSI_IO 12 | #else 13 | #define BA_MINIOSLIB 14 | #endif 15 | 16 | #define LUA_PATH_DEFAULT "" 17 | #define LUA_CPATH_DEFAULT "" 18 | #ifndef lua_getlocaledecpoint 19 | #define lua_getlocaledecpoint() '.' 20 | #endif 21 | 22 | /* Redirect sprintf functions to the more stack friendly BA versions */ 23 | #undef snprintf 24 | #undef sprintf 25 | #define snprintf nonosnprintf 26 | #define sprintf nonosprintf 27 | #include 28 | #undef snprintf 29 | #undef sprintf 30 | #define snprintf basnprintf 31 | #define sprintf basprintf 32 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 33 | extern int basprintf(char* buf, const char* fmt, ...); 34 | 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /inc/arch/Quadros/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | /* Use integers, not 'double' for Lua numbers */ 5 | #ifndef LUA_NUMBER_INTEGER 6 | #define LUA_NUMBER_INTEGER 1 7 | #endif 8 | 9 | /* Only a subset of the os lib is available for embedded systems */ 10 | #define BA_MINIOSLIB 11 | #define LUA_NOIOLIB 12 | #define LUA_PATH_DEFAULT "" 13 | #define LUA_CPATH_DEFAULT "" 14 | 15 | #ifdef __CODEWARRIOR__ 16 | #define lua_getlocaledecpoint() '.' 17 | #define NO_TIMEFUNCS 18 | #ifndef BUFSIZ 19 | #define BUFSIZ 512 20 | #endif 21 | #endif 22 | 23 | /* Redirect sprintf functions to the more stack friendly BA versions */ 24 | #undef snprintf 25 | #undef sprintf 26 | #define snprintf nonosnprintf 27 | #define sprintf nonosprintf 28 | #include 29 | #undef snprintf 30 | #undef sprintf 31 | #define snprintf basnprintf 32 | #define sprintf basprintf 33 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 34 | extern int basprintf(char* buf, const char* fmt, ...); 35 | 36 | #include 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /inc/luasql.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: luasql.h 4914 2021-12-01 18:24:30Z wini $ 3 | ** See Copyright Notice in license.html 4 | */ 5 | 6 | #ifndef _LUASQL_ 7 | #define _LUASQL_ 8 | 9 | #ifndef LUASQL_API 10 | #define LUASQL_API 11 | #endif 12 | 13 | #define LUASQL_PREFIX "LuaSQL: " 14 | #define LUASQL_TABLENAME "luasql" 15 | #define LUASQL_ENVIRONMENT "Each driver must have an environment metatable" 16 | #define LUASQL_CONNECTION "Each driver must have a connection metatable" 17 | #define LUASQL_CURSOR "Each driver must have a cursor metatable" 18 | 19 | /* Barracuda BA_ENV_IX is on upvalue position 1 */ 20 | #define SQL_ENV_IX lua_upvalueindex(2) 21 | 22 | 23 | 24 | typedef struct { 25 | short closed; 26 | } pseudo_data; 27 | 28 | LUASQL_API int luasql_faildirect (lua_State *L, const char *err); 29 | LUASQL_API int luasql_createmeta (lua_State *L, const char *name, const luaL_Reg *methods); 30 | LUASQL_API void luasql_setmeta (lua_State *L, const char *name); 31 | LUASQL_API void luasql_set_info (lua_State *L); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /examples/C-WebSockets/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Basic makefile for Linux 3 | 4 | VPATH+=src:../HostInit:../../src:../../src/arch/Posix:../../src/arch/NET/generic:../../src/DiskIo/posix 5 | 6 | CFLAGS += -c -g -Wall 7 | CFLAGS += -DBA_FILESIZE64 -DLUA_USE_LINUX 8 | CFLAGS += -DBAIO_DISK 9 | CFLAGS += -I../../inc -I../../inc/arch/Posix -I../../inc/arch/NET/Posix 10 | 11 | ifndef ODIR 12 | ODIR = obj 13 | endif 14 | 15 | CPPSRC=ChatServer.cpp 16 | CSRC=Main.c HostInit.c BWS.c ThreadLib.c SoDisp.c BaFile.c 17 | 18 | # Implicit rules for making .o files from .c files 19 | $(ODIR)/%.o : %.c 20 | gcc $(CFLAGS) -o $@ $< 21 | # Implicit rules for making .o files from .cpp files 22 | $(ODIR)/%.o : %.cpp 23 | g++ $(CFLAGS) -o $@ $< 24 | 25 | OBJS = $(CSRC:%.c=$(ODIR)/%.o) $(CPPSRC:%.cpp=$(ODIR)/%.o) 26 | 27 | .PHONY : all clean 28 | 29 | all: $(ODIR) ChatServer 30 | 31 | ChatServer: $(OBJS) 32 | g++ -o $@ $^ -lpthread -lm -ldl 33 | echo "Build complete; start server: ./ChatServer" 34 | 35 | $(ODIR): 36 | mkdir $(ODIR) 37 | 38 | clean: 39 | rm -rf $(ODIR) ChatServer 40 | 41 | 42 | -------------------------------------------------------------------------------- /inc/arch/VxWorks/luaconf.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef lconfig_h 3 | 4 | #if 0 5 | /* Use integers, not 'double' for Lua numbers */ 6 | #ifndef LUA_NUMBER_INTEGER 7 | #define LUA_NUMBER_INTEGER 1 8 | #endif 9 | #endif 10 | 11 | /* when LUA_NUMBER_INTEGER == 0 (using float). No log2 in VxWorks */ 12 | #define NO_LOG2 13 | 14 | /* Use the standard Lua I/O and loadfile. The C libraries required 15 | * for this may be available in your VxWorks version. 16 | */ 17 | /* #define BA_HAS_ANSI_IO */ 18 | 19 | #ifndef BA_HAS_ANSI_IO 20 | #define BA_MINIOSLIB 21 | #endif 22 | 23 | #define LUA_PATH_DEFAULT "" 24 | #define LUA_CPATH_DEFAULT "" 25 | 26 | /* Redirect sprintf functions to the more stack friendly BA versions */ 27 | #undef snprintf 28 | #undef sprintf 29 | #define snprintf nonosnprintf 30 | #define sprintf nonosprintf 31 | #include 32 | #undef snprintf 33 | #undef sprintf 34 | #define snprintf basnprintf 35 | #define sprintf basprintf 36 | extern int basnprintf(char* buf, int len, const char* fmt, ...); 37 | extern int basprintf(char* buf, const char* fmt, ...); 38 | 39 | #include 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /examples/MakoServer/src/MakoWBC.ch: -------------------------------------------------------------------------------- 1 | /* 2 | Push the primary secret key material as a Lua string. 3 | 4 | We utilize White-box Cryptography (WBC) to obfuscate the secret 5 | key material. The Lua TPM (Trusted Platform Module) 6 | implementation doesn't require a specific fixed secret key; the 7 | only requirement is that a pre-selected, randomly chosen number 8 | remains consistent across reboots. This ensures persistence 9 | without exposing the actual key. 10 | 11 | The transformation applied below uses an S-box substitution 12 | technique to obscure the key's value, adding an extra layer of 13 | protection. 14 | */ 15 | baAssert(sizeof(ENCRYPTIONKEY) > 255); /* ENCRYPTIONKEY too short */ 16 | luaL_Buffer b; 17 | size_t i; 18 | U8* transformedKey = (U8*)luaL_buffinitsize(L,&b,sizeof(ENCRYPTIONKEY)); 19 | for (i = 0; i < sizeof(ENCRYPTIONKEY); i++) { 20 | /* Apply S-box substitution; This would crash if ENCRYPTIONKEY < 256 */ 21 | transformedKey[i] = ENCRYPTIONKEY[ENCRYPTIONKEY[i]] ^ ENCRYPTIONKEY[i]; 22 | } 23 | luaL_addsize(&b, sizeof(ENCRYPTIONKEY)); 24 | luaL_pushresult(&b); 25 | -------------------------------------------------------------------------------- /examples/xedge/src/XedgeWBC.h: -------------------------------------------------------------------------------- 1 | /* 2 | Push the primary secret key material as a Lua string. 3 | 4 | We utilize White-box Cryptography (WBC) to obfuscate the secret 5 | key material. The Lua TPM (Trusted Platform Module) 6 | implementation doesn't require a specific fixed secret key; the 7 | only requirement is that a pre-selected, randomly chosen number 8 | remains consistent across reboots. This ensures persistence 9 | without exposing the actual key. 10 | 11 | The transformation applied below uses an S-box substitution 12 | technique to obscure the key's value, adding an extra layer of 13 | protection. 14 | */ 15 | 16 | baAssert(sizeof(ENCRYPTIONKEY) > 255); /* ENCRYPTIONKEY too short */ 17 | luaL_Buffer b; 18 | size_t i; 19 | U8* transformedKey = (U8*)luaL_buffinitsize(L,&b,sizeof(ENCRYPTIONKEY)); 20 | for (i = 0; i < sizeof(ENCRYPTIONKEY); i++) { 21 | /* Apply S-box substitution; This would crash if ENCRYPTIONKEY < 256 */ 22 | transformedKey[i] = ENCRYPTIONKEY[ENCRYPTIONKEY[i]]; 23 | transformedKey[i] = transformedKey[i] ^ ENCRYPTIONKEY[i]; 24 | } 25 | luaL_addsize(&b, sizeof(ENCRYPTIONKEY)); 26 | luaL_pushresult(&b); 27 | -------------------------------------------------------------------------------- /inc/mime.h: -------------------------------------------------------------------------------- 1 | #ifndef MIME_H 2 | #define MIME_H 3 | /*=========================================================================*\ 4 | * Core MIME support 5 | * LuaSocket toolkit 6 | * 7 | * This module provides functions to implement transfer content encodings 8 | * and formatting conforming to RFC 2045. It is used by mime.lua, which 9 | * provide a higher level interface to this functionality. 10 | * 11 | * RCS ID: $Id: mime.h,v 1.15 2007/06/11 23:44:54 diego Exp $ 12 | \*=========================================================================*/ 13 | #include "lua.h" 14 | 15 | /*-------------------------------------------------------------------------*\ 16 | * Current MIME library version 17 | \*-------------------------------------------------------------------------*/ 18 | #define MIME_VERSION "MIME 1.0.2" 19 | #define MIME_COPYRIGHT "Copyright (C) 2004-2007 Diego Nehab" 20 | #define MIME_AUTHORS "Diego Nehab" 21 | 22 | /*-------------------------------------------------------------------------*\ 23 | * This macro prefixes all exported API functions 24 | \*-------------------------------------------------------------------------*/ 25 | #ifndef MIME_API 26 | #define MIME_API extern 27 | #endif 28 | 29 | MIME_API int luaopen_mime_core(lua_State *L); 30 | 31 | #endif /* MIME_H */ 32 | -------------------------------------------------------------------------------- /inc/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /examples/MakoServer/VcMake/mako.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mako", "mako.vcxproj", "{81E7B3A4-546F-C133-39D8-3D34E32C1A1C}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | release_noodbc|Win32 = release_noodbc|Win32 10 | release_nosql|Win32 = release_nosql|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {81E7B3A4-546F-C133-39D8-3D34E32C1A1C}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {81E7B3A4-546F-C133-39D8-3D34E32C1A1C}.Debug|Win32.Build.0 = Debug|Win32 16 | {81E7B3A4-546F-C133-39D8-3D34E32C1A1C}.release_noodbc|Win32.ActiveCfg = Release|Win32 17 | {81E7B3A4-546F-C133-39D8-3D34E32C1A1C}.release_noodbc|Win32.Build.0 = Release|Win32 18 | {81E7B3A4-546F-C133-39D8-3D34E32C1A1C}.release_nosql|Win32.ActiveCfg = Release|Win32 19 | {81E7B3A4-546F-C133-39D8-3D34E32C1A1C}.release_nosql|Win32.Build.0 = Release|Win32 20 | {81E7B3A4-546F-C133-39D8-3D34E32C1A1C}.Release|Win32.ActiveCfg = Release|Win32 21 | {81E7B3A4-546F-C133-39D8-3D34E32C1A1C}.Release|Win32.Build.0 = Release|Win32 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/xedge/Lua-Examples/httpclient.lsp: -------------------------------------------------------------------------------- 1 | 47 | -------------------------------------------------------------------------------- /src/luasql.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: luasql.c 4914 2021-12-01 18:24:30Z wini $ 3 | ** See Copyright Notice in license.html 4 | */ 5 | 6 | #include 7 | 8 | #ifndef BA_LIB 9 | #define BA_LIB 10 | #endif 11 | #ifndef LUA_LIB 12 | #define LUA_LIB 13 | #endif 14 | 15 | #include "balua.h" 16 | 17 | #include "luasql.h" 18 | 19 | /* this header cross depoendency is needed for the one 20 | basnprintf() call */ 21 | #include "BufPrint.h" 22 | 23 | /* 24 | ** Typical database error situation 25 | */ 26 | LUASQL_API int luasql_faildirect(lua_State *L, const char *err) { 27 | lua_pushnil(L); 28 | lua_pushstring(L, err); 29 | return 2; 30 | } 31 | 32 | 33 | /* 34 | ** Create a metatable and leave it on top of the stack. 35 | */ 36 | LUASQL_API int luasql_createmeta ( 37 | lua_State *L, const char *name, const luaL_Reg *methods) { 38 | if (!luaL_newmetatable (L, name)) 39 | return 0; 40 | 41 | lua_pushvalue(L,BA_ENV_IX); 42 | lua_pushvalue(L,SQL_ENV_IX); 43 | luaL_setfuncs(L, methods, 2); 44 | 45 | lua_pushliteral (L, "__index"); 46 | lua_pushvalue (L, -2); 47 | lua_settable (L, -3); 48 | 49 | lua_pushliteral (L, "__metatable"); 50 | lua_pushliteral (L,LUASQL_PREFIX" private"); 51 | lua_settable (L, -3); 52 | 53 | return 1; 54 | } 55 | 56 | 57 | /* 58 | ** Define the metatable for the object on top of the stack 59 | */ 60 | LUASQL_API void luasql_setmeta (lua_State *L, const char *name) { 61 | luaL_getmetatable (L, name); 62 | baAssert( ! lua_isnil(L, -1) ); 63 | lua_setmetatable (L, -2); 64 | } 65 | -------------------------------------------------------------------------------- /examples/MakoServer/GenNewEncryptionKey.py: -------------------------------------------------------------------------------- 1 | # This script generates a secret key for the TPM. 2 | # Refer to the documentation for detailed usage and security considerations. 3 | # https://realtimelogic.com/ba/examples/MakoServer/readme.html#TPM 4 | # 5 | # The generated key is stored in src/NewEncryptionKey.h. 6 | # 7 | # To use the generated key in your project, compile with the flag: 8 | # -DNewEncryptionKey 9 | 10 | import os 11 | import random 12 | 13 | # Determine the script's directory and the target path in 'src' 14 | scriptDir = os.path.dirname(os.path.abspath(__file__)) 15 | outputDir = os.path.join(scriptDir, "src") 16 | headerFile = os.path.join(outputDir, "NewEncryptionKey.h") 17 | 18 | keyLength = 512 # 512-byte encryption key 19 | 20 | def generateRandomKey(length): 21 | return [random.randint(0, 255) for _ in range(length)] 22 | 23 | def formatKeyArray(key): 24 | formatted = ",\n ".join(", ".join(f"0x{byte:02x}" for byte in key[i:i+10]) for i in range(0, len(key), 10)) 25 | return f"static const U8 ENCRYPTIONKEY[] = {{\n {formatted}\n}};" 26 | 27 | def generateHeaderFile(): 28 | key = generateRandomKey(keyLength) 29 | content = f"""/* TPM main secret key embedded in the binary. 30 | Change before compiling. The key can be any length, 31 | but must be > 255. 32 | */ 33 | 34 | {formatKeyArray(key)} 35 | """ 36 | with open(headerFile, "w") as f: 37 | f.write(content) 38 | print(f"{headerFile} generated successfully.") 39 | 40 | if __name__ == "__main__": 41 | generateHeaderFile() 42 | -------------------------------------------------------------------------------- /examples/C-WebSockets/VcMake/example.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.32510.428 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{9F306073-1553-A423-05EF-07C3ED230904}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | release_noodbc|Win32 = release_noodbc|Win32 12 | release_nosql|Win32 = release_nosql|Win32 13 | Release|Win32 = Release|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {9F306073-1553-A423-05EF-07C3ED230904}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {9F306073-1553-A423-05EF-07C3ED230904}.Debug|Win32.Build.0 = Debug|Win32 18 | {9F306073-1553-A423-05EF-07C3ED230904}.release_noodbc|Win32.ActiveCfg = Release|Win32 19 | {9F306073-1553-A423-05EF-07C3ED230904}.release_noodbc|Win32.Build.0 = Release|Win32 20 | {9F306073-1553-A423-05EF-07C3ED230904}.release_nosql|Win32.ActiveCfg = Release|Win32 21 | {9F306073-1553-A423-05EF-07C3ED230904}.release_nosql|Win32.Build.0 = Release|Win32 22 | {9F306073-1553-A423-05EF-07C3ED230904}.Release|Win32.ActiveCfg = Release|Win32 23 | {9F306073-1553-A423-05EF-07C3ED230904}.Release|Win32.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {C46E05A1-06DC-4366-89B8-2BB4BF6A22A8} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /examples/C-RESTful-Service/TestApi.py: -------------------------------------------------------------------------------- 1 | 2 | # Program to test the REST API 3 | # Generated by chatGPT 4 | 5 | BASE_URL = "http://localhost/api/users" 6 | 7 | import requests 8 | 9 | def print_response(r): 10 | print(f"Status: {r.status_code}") 11 | print("Response:", r.text) 12 | print("-" * 40) 13 | 14 | def post_user(name, email): 15 | return requests.post(BASE_URL, json={"name": name, "email": email}) 16 | 17 | print("Creating 5 users:") 18 | for i in range(5): 19 | r = post_user(f"User{i+1}", f"user{i+1}@example.com") 20 | print_response(r) 21 | 22 | print("Fetching all users:") 23 | r = requests.get(BASE_URL) 24 | print_response(r) 25 | 26 | print("Fetching user with id=1:") 27 | print_response(requests.get(f"{BASE_URL}/1")) 28 | 29 | print("Fetching non-existent user with id=99:") 30 | print_response(requests.get(f"{BASE_URL}/99")) 31 | 32 | print("Testing POST with missing 'email':") 33 | bad_user = {"name": "BadUser"} 34 | print_response(requests.post(BASE_URL, json=bad_user)) 35 | 36 | print("Creating 6 more users to test DB full condition:") 37 | for i in range(6): 38 | r = post_user(f"ExtraUser{i+1}", f"extrauser{i+1}@example.com") 39 | print_response(r) 40 | 41 | # Delete every second user: 1, 3, 5, 7, 9 42 | print("Deleting every second user (1, 3, 5, 7, 9):") 43 | for i in range(1, 11, 2): 44 | r = requests.delete(f"{BASE_URL}/{i}") 45 | print(f"DELETE /users/{i}") 46 | print_response(r) 47 | 48 | # Try adding 5 new users again 49 | print("Adding 5 new users after deletions:") 50 | for i in range(5): 51 | r = post_user(f"NewUser{i+1}", f"newuser{i+1}@example.com") 52 | print_response(r) 53 | -------------------------------------------------------------------------------- /examples/MakoServer/src/EncryptionKey.h: -------------------------------------------------------------------------------- 1 | 2 | /* TPM main secret key embedded in the binary. 3 | Change before compiling. The key can be any length, 4 | but must be > 255. 5 | */ 6 | 7 | static const U8 ENCRYPTIONKEY[] = { 8 | 0xb8,0xa4,0xe7,0x2d,0xd8,0x79,0xbd,0x93,0x5e,0x4d, 9 | 0x5d,0x5c,0xa5,0x21,0xdb,0x60,0xd6,0xe5,0xbb,0x3d, 10 | 0xef,0xd4,0x5f,0x82,0x60,0x82,0x16,0x3c,0x74,0x01, 11 | 0x53,0xae,0x1a,0x86,0x90,0x95,0x20,0x63,0xe7,0x46, 12 | 0x94,0xbb,0x7d,0xfd,0xb0,0x4d,0x56,0x17,0x86,0x45, 13 | 0xe5,0xb9,0x21,0x1f,0x13,0x17,0xb5,0x25,0xe0,0x29, 14 | 0x2b,0xf9,0x09,0x4b,0xf2,0x48,0xf7,0xc2,0xa7,0x44, 15 | 0x65,0xee,0x2b,0x21,0xfd,0xc9,0x32,0xd8,0x72,0xda, 16 | 0x04,0x3f,0x74,0x5e,0x19,0x7a,0x73,0x27,0x08,0x96, 17 | 0x6c,0x03,0x26,0x2d,0x22,0xed,0x15,0x81,0xd3,0xf3, 18 | 0xf1,0xba,0xb6,0x9d,0xe1,0x12,0xe0,0x91,0xa8,0xdc, 19 | 0xbf,0xdd,0xb7,0x7c,0xae,0x8c,0x24,0x53,0x22,0x1a, 20 | 0x13,0xc3,0x42,0x13,0x39,0xee,0xbe,0x12,0xe2,0xc3, 21 | 0x2f,0xde,0xfd,0x34,0xd7,0x7f,0xac,0xc5,0x9f,0x9a, 22 | 0x22,0x25,0xac,0xc6,0x79,0x99,0x3e,0x02,0xd9,0xbc, 23 | 0x4c,0x98,0x76,0xc8,0x10,0xc5,0x00,0x52,0x24,0xed, 24 | 0xf1,0x7f,0x79,0xdf,0xcc,0x8b,0x6a,0x8f,0xd1,0xdb, 25 | 0xee,0x0c,0xad,0x81,0x13,0x1f,0x10,0x74,0xbe,0x54, 26 | 0xa5,0x40,0x38,0x1a,0x52,0x03,0xcd,0x02,0x22,0x40, 27 | 0x97,0x3e,0xb5,0xc0,0xfe,0xb1,0x29,0x17,0x90,0xa9, 28 | 0xe3,0xef,0x58,0x4c,0xc5,0x72,0xed,0x19,0xfe,0xb7, 29 | 0xbf,0xac,0x5f,0x83,0xe7,0x91,0xc6,0xba,0xa9,0x64, 30 | 0x4d,0xe4,0x36,0xd0,0x93,0xd2,0x4d,0x9b,0x46,0x4f, 31 | 0xf7,0x5c,0xcb,0x66,0x60,0xe4,0xc7,0x46,0x65,0xfe, 32 | 0x7e,0xa1,0x62,0xe1,0x89,0xe8,0xa5,0xca,0x08,0xb7, 33 | 0x9f,0x8c,0x2c,0x24,0xf6,0x54 34 | }; 35 | -------------------------------------------------------------------------------- /inc/FileCspReader.h: -------------------------------------------------------------------------------- 1 | #ifndef __FileCspReader_h 2 | #define __FileCspReader_h 3 | 4 | #include 5 | #include 6 | 7 | /*! \page FileCspReaderIntro CspReader example code. 8 | The FileCspReader, which inherits from CspReader, 9 | shows you how to write CspReader driver object class. 10 | */ 11 | 12 | /** Example code that shows you how to write a CspReader driver object. 13 | @ingroup CSP 14 | The Web-Server uses the CspReader driver object when requesting data from 15 | the "dat" file generated by 16 | CspLink. 17 | 18 | This example code uses the file system for reading the "dat" file. 19 | The constructor opens the "dat" file and method "diskRead" uses the 20 | Posix function fseek for setting the file pointer to the requested offset 21 | position and function fread for reading the actual data. 22 | */ 23 | typedef struct FileCspReader 24 | #ifdef __cplusplus 25 | : public CspReader 26 | { 27 | /** The FileCspReader constructor opens the "dat" file for reading. 28 | You must call CspReader::isValid, which informs you if the constructor 29 | successfully opened the "data" file for reading. 30 | \param pathName is the path and name to the "data" file. 31 | */ 32 | FileCspReader(const char* pathName); 33 | #else 34 | { 35 | CspReader data; 36 | #endif 37 | U32 currentOffset; 38 | ResIntfPtr fp; 39 | } FileCspReader; 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | void 46 | FileCspReader_constructor(FileCspReader* o, const char* pathName); 47 | #ifdef __cplusplus 48 | } 49 | 50 | inline FileCspReader::FileCspReader(const char* pathName) { 51 | FileCspReader_constructor(this, pathName); } 52 | #endif 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /examples/xedge/src/xedge.h: -------------------------------------------------------------------------------- 1 | /* 2 | Declarations for xedgeInitDiskIo and xedgeOpenAUX. See details below. 3 | In addition: 4 | API designed to simplify the two following options as detailed in 5 | the example file led.c: 6 | 2. Utilize the custom Xedge configuration file API for 7 | reading/writing the Xedge configuration file 8 | 3. Add additional secrets for TPM key generation 9 | These optional configuration options must be set in the xedgeOpenAUX function. 10 | */ 11 | #include 12 | 13 | struct XedgeOpenAUX; 14 | 15 | /* Function pointer to addSecret() in xedge.c */ 16 | typedef void (*AddSecret)( 17 | struct XedgeOpenAUX* aux, BaBool unique, const U8* secret, size_t slen); 18 | 19 | /* Set this in xedgeOpenAUX() to enable (2) 20 | */ 21 | typedef int (*XedgeCfgFile)(lua_State* L); 22 | 23 | typedef struct XedgeOpenAUX { 24 | lua_State* L; /* The main Lua state */ 25 | IoIntfPtr dio; /* The DiskIo instance unless compiled with NO_BAIO_DISK */ 26 | AddSecret addSecret; /* Callback to addSecret() in xedge.c */ 27 | int initXedgeFuncRef; /* Reference to the init function in Xedge's .config */ 28 | XedgeCfgFile xedgeCfgFile; /* Set this in xedgeOpenAUX() to enable (2) */ 29 | } XedgeOpenAUX; 30 | 31 | /* External code can call this function for graceful shutdown 32 | */ 33 | void setDispExit(void); 34 | 35 | #ifndef NO_BAIO_DISK 36 | /* You must create this function unless compiled with NO_BAIO_DISK. 37 | Some embedded operating systems require the IO to be configured, 38 | such as setting the root directory (base path). 39 | */ 40 | int xedgeInitDiskIo(DiskIo* dio); 41 | #endif 42 | 43 | /* You must create this function and add your custom Lua bindings in 44 | * this function. 45 | */ 46 | int xedgeOpenAUX(XedgeOpenAUX* aux); 47 | -------------------------------------------------------------------------------- /examples/C-RESTful-Service/src/RestJsonUtils.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | /** 10 | * Parses the HTTP request body if it contains JSON data. 11 | * 12 | * This function checks if the incoming HTTP request has a payload and a 13 | * `Content-Type` of `application/json`. If so, it reads the payload in chunks 14 | * and uses the JParser to construct a JParserValFact (JSON value factory). 15 | * 16 | * @param req Pointer to the HttpRequest. 17 | * @param status Pointer to an integer that will be set to: 18 | * - 0 on success 19 | * - -1 on error (invalid or non-JSON data) 20 | * - If no payload is present, status is set to 0 and NULL is returned. 21 | * 22 | * @return Pointer to a dynamically allocated JParserValFact on success, 23 | * or NULL on error or if no JSON payload is present. 24 | * 25 | * Note: The function terminates the connection if a parsing error occurs. 26 | * Caller must free the returned JParserValFact using JParserValFact_destructor 27 | * and baFree(). 28 | */ 29 | JParserValFact* parseJSON(HttpRequest* req, int* status); 30 | 31 | 32 | /** 33 | * Initializes a JEncoder for the given HTTP response. 34 | * 35 | * This function sets up the JSON encoder that can be used to write structured 36 | * JSON responses to the HTTP output buffer. 37 | * 38 | * @param resp Pointer to the HttpResponse object. 39 | * @param enc Pointer to an uninitialized JEncoder object. 40 | * @param err Pointer to an uninitialized JErr object to track JSON encoding errors. 41 | */ 42 | void initializeJEncoder(HttpResponse* resp, JEncoder* encoder, JErr* err); 43 | 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /examples/xedge/src/EncryptionKey.h: -------------------------------------------------------------------------------- 1 | 2 | /* TPM main secret key embedded in the binary. 3 | Change before compiling. The key can be any length, 4 | but must be > 255. 5 | 6 | ref: https://realtimelogic.com/ba/examples/xedge/readme.html#TPM 7 | 8 | */ 9 | 10 | static const U8 ENCRYPTIONKEY[] = { 11 | 0xb8,0xa4,0xe7,0x2d,0xd8,0x79,0xbd,0x93,0x5e,0x4d, 12 | 0x5d,0x5c,0xa5,0x21,0xdb,0x60,0xd6,0xe5,0xbb,0x3d, 13 | 0xef,0xd4,0x5f,0x82,0x60,0x82,0x16,0x3c,0x74,0x01, 14 | 0x53,0xae,0x1a,0x86,0x90,0x95,0x20,0x63,0xe7,0x46, 15 | 0x94,0xbb,0x7d,0xfd,0xb0,0x4d,0x56,0x17,0x86,0x45, 16 | 0xe5,0xb9,0x21,0x1f,0x13,0x17,0xb5,0x25,0xe0,0x29, 17 | 0x2b,0xf9,0x09,0x4b,0xf2,0x48,0xf7,0xc2,0xa7,0x44, 18 | 0x65,0xee,0x2b,0x21,0xfd,0xc9,0x32,0xd8,0x72,0xda, 19 | 0x04,0x3f,0x74,0x5e,0x19,0x7a,0x73,0x27,0x08,0x96, 20 | 0x6c,0x03,0x26,0x2d,0x22,0xed,0x15,0x81,0xd3,0xf3, 21 | 0xf1,0xba,0xb6,0x9d,0xe1,0x12,0xe0,0x91,0xa8,0xdc, 22 | 0xbf,0xdd,0xb7,0x7c,0xae,0x8c,0x24,0x53,0x22,0x1a, 23 | 0x13,0xc3,0x42,0x13,0x39,0xee,0xbe,0x12,0xe2,0xc3, 24 | 0x2f,0xde,0xfd,0x34,0xd7,0x7f,0xac,0xc5,0x9f,0x9a, 25 | 0x22,0x25,0xac,0xc6,0x79,0x99,0x3e,0x02,0xd9,0xbc, 26 | 0x4c,0x98,0x76,0xc8,0x10,0xc5,0x00,0x52,0x24,0xed, 27 | 0xf1,0x7f,0x79,0xdf,0xcc,0x8b,0x6a,0x8f,0xd1,0xdb, 28 | 0xee,0x0c,0xad,0x81,0x13,0x1f,0x10,0x74,0xbe,0x54, 29 | 0xa5,0x40,0x38,0x1a,0x52,0x03,0xcd,0x02,0x22,0x40, 30 | 0x97,0x3e,0xb5,0xc0,0xfe,0xb1,0x29,0x17,0x90,0xa9, 31 | 0xe3,0xef,0x58,0x4c,0xc5,0x72,0xed,0x19,0xfe,0xb7, 32 | 0xbf,0xac,0x5f,0x83,0xe7,0x91,0xc6,0xba,0xa9,0x64, 33 | 0x4d,0xe4,0x36,0xd0,0x93,0xd2,0x4d,0x9b,0x46,0x4f, 34 | 0xf7,0x5c,0xcb,0x66,0x60,0xe4,0xc7,0x46,0x65,0xfe, 35 | 0x7e,0xa1,0x62,0xe1,0x89,0xe8,0xa5,0xca,0x08,0xb7, 36 | 0x9f,0x8c,0x2c,0x24,0xf6,0x54 37 | }; 38 | -------------------------------------------------------------------------------- /examples/C-RESTful-Service/README.md: -------------------------------------------------------------------------------- 1 | # Embedded RESTful Services in C and C++ 2 | 3 | This directory contains the example source code for the tutorial [Designing Embedded RESTful Services in C and C++](https://realtimelogic.com/articles/Designing-Embedded-RESTful-Services-in-C-and-C), which shows how to implement a RESTful API using the [Barracuda Embedded Web Server](https://realtimelogic.com/products/barracuda-web-server/) library. 4 | 5 | --- 6 | 7 | ## 🛠️ Building the Project 8 | 9 | You can build the project on both **Linux** and **Windows**: 10 | 11 | - **Linux**: Use the provided `Makefile` 12 | - **Windows**: Use the Visual Studio project file `RestService.vcxproj` 13 | - To **cross-compile for a custom embedded target**, refer to the Barracuda [porting API documentation](https://github.com/RealTimeLogic/BAS#porting-layers) and use the appropriate thread and socket abstraction layers. 14 | 15 | --- 16 | 17 | ## 📂 File Overview 18 | 19 | | File Path | Description | 20 | |-------------------------------------------|----------------------------------------------| 21 | | `src/RestService.c` / `RestService.cpp` | Main RESTful service implementation (C and C++) | 22 | | `src/RestJsonUtils.c` | Utility functions for JSON parsing/encoding | 23 | | `../HostInit/Main.c` | Entry point for high-level OS (HLOS) targets | 24 | | `../HostInit/HostInit.c` | Generic system initialization for HLOS | 25 | | `../../src/BWS.c` | Barracuda Embedded Web Server core library | 26 | | `../../src/arch/Posix/ThreadLib.c` | POSIX thread abstraction layer | 27 | | `../../src/arch/NET/generic/SoDisp.c` | Generic socket dispatcher (TCP layer) | 28 | 29 | ## Testing the Service 30 | 31 | A Python script is included to test the RESTful API implementation. Before running the script, ensure that the server is listening on **port 80** (on Linux run: sudo ./restservice). 32 | 33 | To run the test: 34 | 35 | ```bash 36 | python TestApi.py 37 | ``` 38 | 39 | -------------------------------------------------------------------------------- /inc/BaMimeTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: BaMimeTypes.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2002 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #ifndef __BaMimeTypes_h 39 | #define __BaMimeTypes_h 40 | 41 | #include 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | BA_API const char* httpFindMime(const char* ext); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /inc/CspCompileCommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: CspCompileCommon.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2002 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #ifndef __cspCompileCommon_h 39 | #define __cspCompileCommon_h 40 | 41 | #include "CspCompileTypes.h" 42 | 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | BA_API void cspCompileTypeIntegrityCheck(void); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | 55 | 56 | 57 | #endif /* __cspCompileCommon_h */ 58 | -------------------------------------------------------------------------------- /inc/CspCompileTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: CspCompileTypes.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2002 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #ifndef __CspCompileTypes_h 39 | #define __CspCompileTypes_h 40 | 41 | #include "TargConfig.h" 42 | 43 | #define HTTP_MAGIC_NO 0x12345678 44 | 45 | typedef struct HttpDiskBlock 46 | { 47 | U32 offset; 48 | U32 size; 49 | } HttpDiskBlock; 50 | 51 | typedef struct HttpDiskPage 52 | { 53 | U32 magicNo; 54 | U32 isDynamic; 55 | U32 noOfBlocks; 56 | HttpDiskBlock blocks[1]; 57 | } HttpDiskPage; 58 | 59 | 60 | #endif /* __CspCompileTypes_h */ 61 | -------------------------------------------------------------------------------- /inc/barracuda.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id$ 15 | * 16 | * COPYRIGHT: Real Time Logic LLC, 2020 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * https://realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * Container header file making it possible to use code with either 37 | * the autogenerated and amalgamated barracuda.h and the standard BAS 38 | * SDK using this header file. 39 | */ 40 | #ifndef __barracuda_h 41 | #define __barracuda_h 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | #ifndef NO_BAIO_DISK 53 | #include 54 | #endif 55 | 56 | #include 57 | #include 58 | #include 59 | #include 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /inc/HttpCmdThreadPoolIntf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | **************************************************************************** 11 | * HEADER 12 | * 13 | * $Id: HttpCmdThreadPoolIntf.h 5385 2023-02-17 19:38:01Z wini $ 14 | * 15 | * COPYRIGHT: Real Time Logic LLC, 2005-2012 16 | * 17 | * This software is copyrighted by and is the sole property of Real 18 | * Time Logic LLC. All rights, title, ownership, or other interests in 19 | * the software remain the property of Real Time Logic LLC. This 20 | * software may only be used in accordance with the terms and 21 | * conditions stipulated in the corresponding license agreement under 22 | * which the software has been supplied. Any unauthorized use, 23 | * duplication, transmission, distribution, or disclosure of this 24 | * software is expressly forbidden. 25 | * 26 | * This Copyright notice may not be removed or modified without prior 27 | * written consent of Real Time Logic LLC. 28 | * 29 | * Real Time Logic LLC. reserves the right to modify this software 30 | * without notice. 31 | * 32 | * http://www.realtimelogic.com 33 | **************************************************************************** 34 | * 35 | */ 36 | 37 | #ifndef _HttpCmdThreadPoolIntf_h 38 | #define _HttpCmdThreadPoolIntf_h 39 | 40 | /* This API provides late bindings between HttpServer and HttpCmdThreadPool. 41 | */ 42 | 43 | #include 44 | 45 | struct HttpCmdThreadPoolIntf; 46 | 47 | typedef int(*HttpCmdThreadPoolIntf_DoDir)( 48 | struct HttpCmdThreadPoolIntf* o,HttpCommand* cmd, 49 | HttpDir* dir); 50 | 51 | typedef struct HttpCmdThreadPoolIntf 52 | { 53 | HttpCmdThreadPoolIntf_DoDir doDir; 54 | } HttpCmdThreadPoolIntf; 55 | 56 | #define HttpCmdThreadPoolIntf_doDir(o, cmd, dir) \ 57 | (o)->doDir(o, cmd, dir) 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /inc/IoBufPrint.h: -------------------------------------------------------------------------------- 1 | 2 | /* ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: IoBufPrint.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2006 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #ifndef _IoBufPrint_h 39 | #define _IoBufPrint_h 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | typedef struct IoBufPrint 46 | { 47 | BufPrint super; 48 | IoIntf* io; 49 | ResIntfPtr res; 50 | } IoBufPrint; 51 | 52 | 53 | BA_API IoBufPrint* IoBufPrint_create(AllocatorIntf* alloc, 54 | IoIntf* io, 55 | size_t bufSize, 56 | const char* name); 57 | BA_API IoBufPrint* IoBufPrint_create2(AllocatorIntf* alloc, 58 | size_t bufSize, 59 | ResIntfPtr out); 60 | BA_API void IoBufPrint_destructor(IoBufPrint* o); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /inc/arch/NET/INtime/HttpCfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: HttpCfg.h 5076 2022-02-10 16:59:48Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2020 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | * Posix 38 | */ 39 | #ifndef _HttpConfig_h 40 | #define _HttpConfig_h 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | #include 54 | #include 55 | #include 56 | 57 | 58 | #define USE_ADDRINFO 59 | #define USE_DGRAM 60 | 61 | 62 | /*********************************************************************** 63 | * The HttpSocket API 64 | ***********************************************************************/ 65 | 66 | 67 | 68 | /* Include the default HttpSocket functions */ 69 | #include 70 | 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /inc/gBsdDspO.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | **************************************************************************** 11 | * HEADER 12 | * 13 | * $Id: gBsdDspO.h 4915 2021-12-01 18:26:55Z wini $ 14 | * 15 | * COPYRIGHT: Real Time Logic, 2004 16 | * 17 | * This software is copyrighted by and is the sole property of Real 18 | * Time Logic LLC. All rights, title, ownership, or other interests in 19 | * the software remain the property of Real Time Logic LLC. This 20 | * software may only be used in accordance with the terms and 21 | * conditions stipulated in the corresponding license agreement under 22 | * which the software has been supplied. Any unauthorized use, 23 | * duplication, transmission, distribution, or disclosure of this 24 | * software is expressly forbidden. 25 | * 26 | * This Copyright notice may not be removed or modified without prior 27 | * written consent of Real Time Logic LLC. 28 | * 29 | * Real Time Logic LLC. reserves the right to modify this software 30 | * without notice. 31 | * 32 | * http://www.realtimelogic.com 33 | **************************************************************************** 34 | * 35 | * Do not directly include this file!!! 36 | */ 37 | 38 | #ifndef _gBsdDspO_h 39 | #define _gBsdDspO_h 40 | 41 | /* gBsdDspO -> generic BSD SoDisp object declarations. */ 42 | 43 | /*********************************************************************** 44 | * SoDisp object in HttpConnection 45 | ***********************************************************************/ 46 | 47 | #define CONNECTION_DISPATCHER_OBJ DoubleLink dispatcherLink; 48 | 49 | 50 | 51 | /*********************************************************************** 52 | * SoDisp object 53 | ***********************************************************************/ 54 | #include 55 | #define DISPATCHER_DATA \ 56 | DoubleList conList; \ 57 | DoubleList pendingList; \ 58 | DoubleLink* curL; \ 59 | DoubleListEnumerator iter; \ 60 | int defaultPollDelay; \ 61 | int pollDelay 62 | #endif 63 | -------------------------------------------------------------------------------- /RaspberryPiBuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Compile Mako Server and embedded Linux Lua bindings as follows: 3 | # wget -O - https://raw.githubusercontent.com/RealTimeLogic/BAS/main/RaspberryPiBuild.sh | bash 4 | # Details: https://makoserver.net/download/raspberry-pi/ 5 | # This script automates: https://makoserver.net/articles/Expedite-Your-Embedded-Linux-Web-Interface-Design 6 | 7 | function abort() { 8 | echo $1 9 | echo "See the following tutorial for how to manually build the code:" 10 | echo "https://makoserver.net/articles/Expedite-Your-Embedded-Linux-Web-Interface-Design" 11 | read -p "Press ENTER to exit script" 12 | exit 1; 13 | } 14 | 15 | function install() { 16 | abort "Run the following prior to running this script:\nsudo apt-get install git zip unzip gcc make" 17 | } 18 | 19 | executables="git zip unzip gcc make" 20 | for i in $executables; do 21 | if ! command -v $i &> /dev/null; then 22 | install 23 | exit 1 24 | fi 25 | done 26 | 27 | 28 | export NOCOMPILE=true 29 | wget --no-check-certificate -O - https://raw.githubusercontent.com/RealTimeLogic/BAS/main/LinuxBuild.sh | bash || abort "LinuxBuild.sh failed" 30 | 31 | cd BAS || abort 32 | 33 | echo "Compiling Mako Server" 34 | export EPOLL=true 35 | make -f mako.mk || abort 36 | cd .. 37 | 38 | if ! [ -f "MakoModuleExample/README.txt" ]; then 39 | echo "Downloading the Mako Server's Lua C Code Module Library" 40 | wget --no-check-certificate https://makoserver.net/download/MakoModuleExample.zip || abort "Cannot download MakoModuleExample.zip" 41 | unzip MakoModuleExample.zip || abort "Unzip failed" 42 | rm MakoModuleExample.zip 43 | fi 44 | 45 | if ! [ -f "lua-periphery/README.md" ]; then 46 | echo "Cloning and building the Raspberry Pi GPIO Lua Bindings (lua-periphery)" 47 | git clone --recursive https://github.com/vsergeev/lua-periphery.git || abort 48 | cd lua-periphery 49 | sed -i -e 's/include /include /' src/lua_periphery.c || abort 50 | sed -i -re 's%(luaopen_periphery[^{]+[{])%\1\nluaintf(L);\n%' src/lua_periphery.c || abort 51 | sed -i -e 's:SRCS =*:&../MakoModuleExample/src/lua/luaintf.c:' Makefile || abort 52 | export LUA_INCDIR=../MakoModuleExample/src/lua || abort 53 | make || abort 54 | cd .. 55 | fi 56 | 57 | if [[ -z "${CROSS_COMPILE}" ]]; then 58 | read -p "Do you want to install the Mako Server in /usr/local/bin (Y/n)?" > 8) | \ 47 | (((U32)(x) & 0xff000000U) >> 24))) 48 | #define baHtons(x) ((U16)((((U16)(x) & 0x00ff) << 8) | \ 49 | (((U16)(x) & 0xff00) >> 8))) 50 | #elif defined B_BIG_ENDIAN 51 | #define baHtonl(x) x 52 | #define baHtons(x) x 53 | #else 54 | #error endian needed 55 | #endif 56 | #define baNtohl(x) baHtonl(x) 57 | #define baNtohs(x) baHtons(x) 58 | 59 | /*********************************************************************** 60 | * Network conversion routines 61 | ***********************************************************************/ 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /inc/arch/NET/CE/HttpCfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: HttpCfg.h 245 2006-10-16 14:07:04Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2002 - 2017 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | * Windows 38 | */ 39 | #ifndef _HttpConfig_h 40 | #define _HttpConfig_h 41 | 42 | #include 43 | #include 44 | #ifdef USE_IPV6 45 | #include 46 | #endif 47 | #include 48 | #include 49 | #include 50 | 51 | /* Settings for Lua: lstate.h: Atomic type 52 | */ 53 | #define l_signalT int 54 | 55 | 56 | /*********************************************************************** 57 | * The HttpSocket API 58 | ***********************************************************************/ 59 | 60 | /* Overload the following default functions */ 61 | #define socketErrno(s) WSAGetLastError() 62 | #define socketWouldBlock(s) (WSAEWOULDBLOCK == WSAGetLastError()) 63 | #define socketClose closesocket 64 | #define socketIoctl ioctlsocket 65 | #define HttpSocket_soReuseaddr(o,status) 66 | 67 | /* Include the default HttpSocket functions */ 68 | #include 69 | 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /inc/RecIoIter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: RecIoIter.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2008 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | * 38 | */ 39 | #ifndef _RecIoIter_h 40 | #define _RecIoIter_h 41 | 42 | #include 43 | #include 44 | 45 | struct RecIoIter; 46 | 47 | typedef int (*RecIoIter_OnResponse)( 48 | struct RecIoIter* o, const char* from, const char* to, IoStat* st); 49 | typedef int (*RecIoIter_OnErr)( 50 | struct RecIoIter* o, const char* name, int err, const char* errMsg); 51 | 52 | typedef struct RecIoIter 53 | { 54 | IoStat st; 55 | AllocatorIntf* alloc; 56 | IoIntf* io; 57 | RecIoIter_OnResponse onResponseFp; 58 | RecIoIter_OnErr onErrFp; 59 | int recCounter; 60 | } RecIoIter; 61 | 62 | #define RecIoIter_constructor( \ 63 | o, allocMA, ioMA, onResponseFpMA, onErrFpMA) do { \ 64 | (o)->alloc=allocMA; \ 65 | (o)->io=ioMA; \ 66 | (o)->onResponseFp=onResponseFpMA; \ 67 | (o)->onErrFp=onErrFpMA; \ 68 | (o)->recCounter=0; \ 69 | } while(0) 70 | 71 | 72 | BA_API int RecIoIter_doResource(RecIoIter* o,const char* from,const char* to); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /QNXBuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Compile Mako Server for QNX as follows: 3 | # wget -O - https://raw.githubusercontent.com/RealTimeLogic/BAS/main/QNXBuild.sh | bash 4 | 5 | 6 | function abort() { 7 | printf "$1\n\n"; 8 | read -p "Press ENTER to exit script" 9 | exit 1; 10 | } 11 | 12 | if [ -z "${QNX_TARGET+x}" ]; then 13 | abort "Oops, you must source qnxsdp-env.sh before running this script." 14 | fi 15 | 16 | executables="git zip unzip make" 17 | for i in $executables; do 18 | if ! command -v $i &> /dev/null; then 19 | abort "Run the following prior to running this script:\nsudo apt-get install git zip unzip make" 20 | exit 1 21 | fi 22 | done 23 | 24 | if [ -n "$TARGET" ]; then 25 | export HEXEFLAGS="-Vgcc_nto$TARGET" 26 | else 27 | export HEXEFLAGS="-Vgcc_ntox86_64" 28 | fi 29 | echo "Target compile flag: $HEXEFLAGS" 30 | 31 | export CFLAGS="$HEXEFLAGS -DBA_QNX -DBA_64BIT -DBA_FILESIZE64 -DUSE_DBGMON=1 -DNDEBUG -DLUA_USE_LINUX -DMAKO -DUSE_EMBEDDED_ZIP=0 -DUSE_IPV6 -DNO_IPV6_MEMBERSHIP -D_POSIX" 32 | export CC=qcc 33 | export XLIB="-lz -lsocket -lm" 34 | 35 | if [ -f src/BAS.c ]; then 36 | abort "Incorrect use! This script should not be run in the BAS directory.\nDetails: https://github.com/RealTimeLogic/BAS" 37 | fi 38 | 39 | if ! [ -d "BAS" ]; then 40 | git clone https://github.com/RealTimeLogic/BAS.git || abort "Cloning BAS failed" 41 | fi 42 | 43 | if ! [ -d "BAS-Resources" ]; then 44 | git clone https://github.com/RealTimeLogic/BAS-Resources.git || abort "Cloning BAS-Resources failed" 45 | chmod +x BAS-Resources/build/*.sh 46 | fi 47 | 48 | if ! [ -f "LPeg/lpcode.c" ]; then 49 | echo "Downloading LPeg" 50 | git clone https://github.com/roberto-ieru/LPeg.git LPeg 51 | fi 52 | 53 | if ! [ -f "lua-protobuf/pb.c" ]; then 54 | echo "Downloading Google Protobuf for Lua" 55 | git clone https://github.com/starwing/lua-protobuf.git lua-protobuf 56 | fi 57 | 58 | if ! [ -f "CBOR/cbor_c.c" ]; then 59 | echo "Downloading CBOR" 60 | git clone https://github.com/spc476/CBOR.git CBOR 61 | fi 62 | 63 | 64 | 65 | cd BAS || abort $LINENO 66 | if ! [ -f "src/sqlite3.c" ]; then 67 | # if SQLITEURL url not set 68 | if [ -z ${SQLITEURL+x} ]; then 69 | # There is no 'latest' with SQLite :-( 70 | SQLITEURL="https://www.sqlite.org/2025/sqlite-amalgamation-3490100.zip" 71 | fi 72 | SQLITE=${SQLITEURL##*/} 73 | pushd /tmp || abort $LINENO 74 | echo "Downloading: $SQLITEURL" 75 | command -v wget >/dev/null 2>&1 76 | if [ $? -eq 0 ]; then 77 | wget --no-check-certificate $SQLITEURL || abort $LINENO 78 | else 79 | curl $SQLITEURL -o $SQLITE 80 | fi 81 | unzip -o $SQLITE || abort $LINENO 82 | popd 83 | mv /tmp/${SQLITE%.zip}/* src/ || abort $LINENO 84 | fi 85 | 86 | if [ -n "${NOCOMPILE+set}" ]; then 87 | exit 0 88 | fi 89 | 90 | make -f mako.mk || abort $LINENO 91 | 92 | echo "Done building 'mako' for QNX" 93 | -------------------------------------------------------------------------------- /examples/MakoServer/src/Windows/servutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * 10 | **************************************************************************** 11 | * HEADER 12 | * 13 | * $Id: servutil.h 4914 2021-12-01 18:24:30Z wini $ 14 | * 15 | * COPYRIGHT: Real Time Logic, 2012 16 | * 17 | * This software is copyrighted by and is the sole property of Real 18 | * Time Logic LLC. All rights, title, ownership, or other interests in 19 | * the software remain the property of Real Time Logic LLC. This 20 | * software may only be used in accordance with the terms and 21 | * conditions stipulated in the corresponding license agreement under 22 | * which the software has been supplied. Any unauthorized use, 23 | * duplication, transmission, distribution, or disclosure of this 24 | * software is expressly forbidden. 25 | * 26 | * This Copyright notice may not be removed or modified without prior 27 | * written consent of Real Time Logic LLC. 28 | * 29 | * Real Time Logic LLC. reserves the right to modify this software 30 | * without notice. 31 | * 32 | * http://www.realtimelogic.com 33 | **************************************************************************** 34 | * 35 | * 36 | */ 37 | #ifndef _CRT_SECURE_NO_WARNINGS 38 | #define _CRT_SECURE_NO_WARNINGS 39 | #endif 40 | #ifndef _CRT_NONSTDC_NO_WARNING 41 | #define _CRT_NONSTDC_NO_WARNING 42 | #endif 43 | #ifndef WIN32_LEAN_AND_MEAN 44 | #define WIN32_LEAN_AND_MEAN 1 45 | #endif 46 | #ifndef STRICT 47 | #define STRICT 1 48 | #endif 49 | #include 50 | #include 51 | 52 | 53 | void servicePrintf(const char* fmt, ...); 54 | void serviceErrPrintf(const char* fmt, ...); 55 | void serviceVPrintf(int isErr, const char* fmt, va_list argList); 56 | 57 | int serviceStart(const char* servname, int argc, const char ** argv); 58 | int serviceStop(const char* servname); 59 | int servicePause(const char* servname); 60 | int serviceContinue(const char* servname); 61 | int serviceUsercode(const char* servname, int action); 62 | int serviceState(const char* servname); 63 | const char* serviceStateDesc(int state); 64 | int serviceGetStartup(const char* servname); 65 | int serviceSetStartup(const char* servname, int startType); 66 | int serviceInstall( 67 | const char* servicename, int autostart, int argc, const char ** argv); 68 | int serviceRemove(const char* servicename); 69 | 70 | -------------------------------------------------------------------------------- /examples/C-RESTful-Service/RestService.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x64 6 | 7 | 8 | Release 9 | x64 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {C899C086-0552-D51B-4049-20C74A049374} 23 | Win32Proj 24 | restservice 25 | 10.0 26 | 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | MultiByte 34 | 35 | 36 | 37 | Application 38 | false 39 | v143 40 | true 41 | MultiByte 42 | 43 | 44 | 45 | 46 | 47 | 48 | ../../inc; 49 | ../../inc/arch/Windows; 50 | ../../inc/arch/NET/Windows; 51 | %(AdditionalIncludeDirectories) 52 | 53 | 54 | 55 | Console 56 | ws2_32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/arch/SMX/ThreadLib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: ThreadLib.cpp 1926 2009-12-23 08:27:06Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2004 17 | * http://www.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 | 29 | 30 | 31 | #include 32 | 33 | #ifndef NDEBUG 34 | void 35 | Thread_cef(BOOLEAN ok, const char* file, int line) 36 | { 37 | if(!ok) 38 | { 39 | baFatalEf(FE_THREAD_LIB, smx_ct->err, file, line); 40 | } 41 | } 42 | #endif 43 | 44 | 45 | static u32 __unixTimeBase; 46 | void baSetUnixTime(u32 time) 47 | { 48 | __unixTimeBase = time; 49 | } 50 | u32 baGetUnixTime(void) 51 | { 52 | return sb_OS_STIME_GET() + __unixTimeBase; 53 | } 54 | 55 | u32 baGetClock() 56 | { 57 | return sb_OS_STIME_GET(); 58 | } 59 | 60 | 61 | 62 | static void 63 | Thread_threadStart(void) 64 | { 65 | TCB_PTR task = sb_OS_TASK_GET_CURRENT(); 66 | Thread* thread = (Thread*)task->thisptr; 67 | thread->runnable(thread); 68 | sb_OS_TASK_DELETE(&task); 69 | baAssert(0); 70 | } 71 | 72 | 73 | void 74 | Thread_constructor( 75 | ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize) 76 | { 77 | u8 taskPrio = sb_OS_TASK_GET_CURRENT()->pri; 78 | o->runnable = r; 79 | switch(priority) 80 | { 81 | case ThreadPrioLowest: taskPrio -= 2; break; 82 | case ThreadPrioLow: taskPrio -= 1; break; 83 | case ThreadPrioNormal: break; 84 | case ThreadPrioHigh: taskPrio += 1; break; 85 | case ThreadPrioHighest: taskPrio += 2; break; 86 | default: 87 | baAssert(0); 88 | } 89 | o->task=smx_TaskCreate(Thread_threadStart,taskPrio,stackSize,SMX_FL_NONE,0); 90 | if(!o->task) 91 | baFatalE(FE_THREAD_LIB,smx_errno); 92 | o->task->thisptr=o; 93 | } 94 | 95 | 96 | void 97 | Thread_start(ThreadBase* o) 98 | { 99 | smx_TaskStart(o->task); 100 | } 101 | -------------------------------------------------------------------------------- /inc/arch/NET/epoll/HttpCfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: HttpCfg.h 4914 2021-12-01 18:24:30Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2008 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | * Posix -> epoll implementation 38 | */ 39 | #ifndef _HttpConfig_h 40 | #include "../Posix/HttpCfg.h" 41 | #include 42 | 43 | 44 | #undef DISPATCHER_DATA 45 | #undef CONNECTION_DISPATCHER_OBJ 46 | 47 | struct SoDispCon; 48 | 49 | typedef struct 50 | { 51 | struct SoDispCon* con; 52 | U32 mask; 53 | } SoDispConBucket; 54 | 55 | typedef SoDispConBucket SoDispConBucketTab[256]; 56 | 57 | /* Max concurrent connections: 1024*256 */ 58 | #define BA_MAX_BUCKETS 1024 59 | 60 | #define DISPATCHER_DATA \ 61 | struct epoll_event * events;\ 62 | DoubleList termList;\ 63 | SoDispConBucketTab* bucket[BA_MAX_BUCKETS];\ 64 | SoDispConBucket* freeList;\ 65 | SoDispConBucket* freeListTail;\ 66 | U16 bucketIx;\ 67 | U16 nextId;\ 68 | int maxevents;\ 69 | int epfd;\ 70 | int defaultPollDelay; \ 71 | int pollDelay 72 | 73 | 74 | #define CONNECTION_DISPATCHER_OBJ DoubleLink dispatcherLink;U32 mask; 75 | 76 | #define SoDisp_destructor _SoDisp_destructor 77 | struct SoDisp; 78 | void _SoDisp_destructor(struct SoDisp* o); 79 | #define BaAddrinfo_connect BaAddrinfo_platConnect 80 | int BaAddrinfo_platConnect(BaAddrinfo* addr, HttpSocket* s, U32 timeout); 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /inc/BaAtoi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: BaAtoi.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic LLC, 2014 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | 39 | 40 | #ifndef __BaAtoi_h 41 | #define __BaAtoi_h 42 | 43 | #include 44 | 45 | #ifndef BA_API 46 | #define BA_API 47 | #endif 48 | 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /** Converts characters of s to type U64. The number is negated if 54 | preceded by '-'. Returns 0 if unable to convert or s is NULL. 55 | */ 56 | BA_API U64 U64_atoll(const char* s); 57 | BA_API U64 U64_atoll2(const char* s, const char* e); 58 | 59 | #define S64_atoll(s) ((S64)U64_atoll(s)) 60 | 61 | 62 | /** Negates a 32 bit number. 63 | */ 64 | BA_API U32 U32_negate(U32 n); 65 | 66 | /** Converts characters of s to type U32. The number is negated if 67 | preceded by '-'. Returns 0 if unable to convert or s is NULL. 68 | */ 69 | BA_API U32 U32_atoi(const char* s); 70 | 71 | /** Works like U32_atoi, but converts from start of string 's' to end 'e'. 72 | */ 73 | BA_API U32 U32_atoi2(const char* s, const char* e); 74 | 75 | /** Converts hex characters of s to type U32. 76 | Returns 0 if unable to convert or s is NULL. 77 | */ 78 | BA_API U32 U32_hextoi(const char *s); 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /inc/SharkSSL_opts.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | 4 | SharkSSL_opts.h is a user file that you can use to configure 5 | SharkSSL. You do not need to define every option that is defined in 6 | the main configuration file SharkSSL_cfg.h; if you do not define an 7 | option, a default value will be used. In other words, SharkSSL_opts.h 8 | provides a way to override the default configuration options for 9 | SharkSSL. 10 | 11 | */ 12 | 13 | /* 14 | The following options configure the smallest possible SharkSSL library: 15 | */ 16 | 17 | #ifdef SHARKSSL_TINY /* DEFAULT value in SharkSsl_cfg.h */ 18 | 19 | #define SHARKSSL_USE_AES_256 0 /* 1 */ 20 | #define SHARKSSL_ENABLE_AES_GCM 0 /* 1 */ 21 | #define SHARKSSL_USE_SHA_384 0 /* 1 */ 22 | #define SHARKSSL_USE_SHA_512 0 /* 0 */ 23 | #define SHARKSSL_SSL_SERVER_CODE 0 /* 1 */ 24 | #define SHARKSSL_ENABLE_CLIENT_AUTH 0 /* 1 */ 25 | #define SHARKSSL_ENABLE_SNI 1 /* 1 */ 26 | #define SHARKSSL_ENABLE_RSA 0 /* 1 */ 27 | #define SHARKSSL_ENABLE_SESSION_CACHE 0 /* 1 */ 28 | #define SHARKSSL_ENABLE_SECURE_RENEGOTIATION 0 /* 1 */ 29 | #define SHARKSSL_ENABLE_DHE_RSA 0 /* 1 */ 30 | #define SHARKSSL_ENABLE_SELECT_CIPHERSUITE 0 /* 1 */ 31 | #define SHARKSSL_ENABLE_ALPN_EXTENSION 1 /* 1 */ 32 | #define SHARKSSL_ENABLE_RSA_API 0 /* 0 */ 33 | #define SHARKSSL_ENABLE_RSA_PKCS1 0 /* 1 */ 34 | #define SHARKSSL_ENABLE_ECDSA_API 0 /* 1 */ 35 | #define SHARKSSL_ENABLE_PEM_API 0 /* 1 */ 36 | #define SHARKSSL_ENABLE_INFO_API 0 /* 1 */ 37 | #define SHARKSSL_ENABLE_CERT_CHAIN 0 /* 1 */ 38 | #define SHARKSSL_ENABLE_CA_LIST 1 /* 1 */ 39 | #define SHARKSSL_ENABLE_CERTSTORE_API 0 /* 0 */ 40 | #define SHARKSSL_SHA256_SMALL_FOOTPRINT 1 /* 0 */ 41 | #define SHARKSSL_BIGINT_EXP_SLIDING_WINDOW_K 1 /* 4 */ 42 | #define SHARKSSL_ENABLE_AES_CTR_MODE 0 /* 1 */ 43 | #define SHARKSSL_AES_CIPHER_LOOP_UNROLL 0 /* 1 */ 44 | #define SHARKSSL_UNALIGNED_ACCESS 1 /* nd */ 45 | #define SHARKSSL_BIGINT_WORDSIZE 32 /* 32 */ 46 | #define SHARKSSL_USE_ECC 1 /* 1 */ 47 | #define SHARKSSL_ENABLE_ECDSA 1 /* 1 */ 48 | #define SHARKSSL_ECC_VERIFY_POINT 0 /* 1 */ 49 | #define SHARKSSL_ECC_TIMING_RESISTANT 0 /* 0 */ 50 | #define SHARKSSL_ECC_USE_SECP521R1 0 /* 1 */ 51 | #define SHARKSSL_ECC_USE_BRAINPOOLP512R1 0 /* 1 */ 52 | #define SHARKSSL_ENABLE_ECDHE_RSA 0 /* 1 */ 53 | #define SHARKSSL_USE_RNG_TINYMT 1 /* 0 */ 54 | 55 | 56 | #ifndef BASIC_TRUST_CHECK 57 | #define BASIC_TRUST_CHECK 58 | #endif 59 | 60 | #ifndef NDEBUG 61 | #define NDEBUG 62 | #endif 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/arch/embOS/ThreadLib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: TargConfig.h 2195 2010-09-16 12:26:20Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2004 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #include /* For some strange reason: compile error if not included */ 39 | #include 40 | #include 41 | 42 | void 43 | Thread_constructor(Thread* o, Thread_Run r, ThreadPriority tp, int stackSize) 44 | { 45 | unsigned char prio; 46 | 47 | prio = OS_GetPriority(OS_GetpCurrentTask()); 48 | switch (tp) 49 | { 50 | case ThreadPrioLowest: prio += 2; break; 51 | case ThreadPrioLow: prio += 1; break; 52 | case ThreadPrioNormal: prio += 0; break; 53 | case ThreadPrioHigh: prio -= 1; break; 54 | case ThreadPrioHighest: prio -= 2; break; 55 | } 56 | 57 | o->stack = baMalloc(sizeof(int) * ((stackSize + sizeof(int) - 1) / sizeof(int))); 58 | if(o->stack == NULL) 59 | { 60 | TRPR(("Thread::Thread, stack creation failed")); 61 | return; 62 | } 63 | OS_EnterRegion(); 64 | OS_CreateTaskEx(&(o)->task, "thread", prio, (void(*)(void*))r, o->stack, stackSize, 0, (void*)o); 65 | OS_Suspend(&(o)->task); 66 | OS_LeaveRegion(); 67 | } 68 | 69 | 70 | U32 71 | baGetUnixTime(void) 72 | { 73 | return (U32)OS_GetTime32() / 1000; /* one tick each ms */ 74 | } 75 | 76 | 77 | U32 78 | baGetMsClock(void) 79 | { 80 | return (U32)OS_GetTime32(); 81 | } 82 | -------------------------------------------------------------------------------- /inc/FileZipReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: FileZipReader.h 4914 2021-12-01 18:24:30Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2003 17 | * http://www.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 __FileZipReader_h 29 | #define __FileZipReader_h 30 | 31 | #include 32 | #include 33 | 34 | /** Example code that shows you how to write a ZipReader interface for 35 | the ZipIo class. 36 | @ingroup IO 37 | 38 | This example code shows you how to write a ZipReader driver object. 39 | The ZipIo class uses the ZipReader driver object when reading Zip-data 40 | from a Zip-File. See class ZipIo for more information. 41 | 42 | This example code uses the file system for reading the Zip-File. 43 | The constructor opens the Zip-File and method "diskRead", see code, uses 44 | the Posix function fseek for setting the file pointer to the requested 45 | offset position and function fread for reading the actual data. 46 | 47 | */ 48 | typedef struct FileZipReader 49 | #ifdef __cplusplus 50 | : public ZipReader 51 | { 52 | /** The ZipReader constructor opens the Zip-File for reading. 53 | You must call CspReader::isValid, which informs you if the constructor 54 | successfully opened the Zip-File for reading. 55 | \param pathName is the path and name to the Zip-File. 56 | */ 57 | FileZipReader(const char* pathName); 58 | 59 | /** The destructor closes the file connection. 60 | */ 61 | ~FileZipReader(); 62 | 63 | private: 64 | #else 65 | { 66 | ZipReader reader; 67 | #endif 68 | U32 currentOffset; 69 | ResIntfPtr fp; 70 | } FileZipReader; 71 | 72 | #ifdef __cplusplus 73 | extern "C" { 74 | #endif 75 | void FileZipReader_constructor(FileZipReader* o, 76 | const char* pathName); 77 | void FileZipReader_destructor(FileZipReader* o); 78 | #ifdef __cplusplus 79 | } 80 | inline FileZipReader::FileZipReader(const char* pathName) { 81 | FileZipReader_constructor(this, pathName); } 82 | inline FileZipReader::~FileZipReader() { 83 | FileZipReader_destructor(this); } 84 | #endif 85 | 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /inc/VirDir.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: VirDir.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2006 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | 39 | #ifndef __VirDir_h 40 | #define __VirDir_h 41 | 42 | #include 43 | 44 | struct VirFileNode; 45 | 46 | typedef struct VirDirNode 47 | { 48 | struct VirDirNode* next; 49 | struct VirDirNode* subDir; 50 | struct VirFileNode* firstFile; 51 | char name[1]; 52 | } VirDirNode; 53 | 54 | 55 | typedef struct VirFileNode 56 | { 57 | struct VirFileNode* next; 58 | const char* name; 59 | } VirFileNode; 60 | 61 | 62 | typedef enum { VirDir_NotFound=0, VirDir_IsDir, VirDir_IsFile } VirDir_Type; 63 | typedef void (*VirFileNode_Free)(VirFileNode* o, AllocatorIntf* alloc); 64 | void VirFileNode_constructor(VirFileNode* o, const char* name); 65 | void VirDirNode_constructor(VirDirNode* o, const char* name, size_t len); 66 | VirDir_Type VirDirNode_find(VirDirNode* o, const char* relPath, void** retVal); 67 | VirDirNode* VirDirNode_findSubDir(VirDirNode* o, const char* name, size_t len); 68 | VirFileNode* VirDirNode_findFile(VirDirNode* o, const char* name); 69 | VirDirNode* VirDirNode_makeDir(VirDirNode* o, const char* pathName, 70 | AllocatorIntf* alloc); 71 | int VirDirNode_mkDirInsertFile(VirDirNode* o, const char* pathName, 72 | VirFileNode* vfn, AllocatorIntf* alloc); 73 | 74 | void VirDirNode_free( 75 | VirDirNode* o,AllocatorIntf* alloc,VirFileNode_Free freeNode); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /examples/MakoServer/src/mako.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: mako.h 5711 2025-12-14 23:15:19Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2012 - 2025 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #include 39 | 40 | #define APPNAME "mako" 41 | 42 | struct MakoOpenAUX; 43 | 44 | /* Function pointer to addSecret() in MakoMain.c */ 45 | typedef void (*AddSecret)( 46 | struct MakoOpenAUX* aux, BaBool unique, const U8* secret, size_t slen); 47 | 48 | 49 | typedef struct MakoOpenAUX { 50 | lua_State* L; /* The main Lua state */ 51 | IoIntfPtr dio; /* The IO instance named "disk" */ 52 | IoIntfPtr hio; /* The IO instance named "home" */ 53 | AddSecret addSecret; /* Callback to addSecret() in MakoMain.c */ 54 | int tpmFuncRef; /* Reference to the TPM seed function in MakoTPM.lua */ 55 | } MakoOpenAUX; 56 | 57 | /* Dummy version in MakoExt.ch 58 | */ 59 | void makoOpenAUX(MakoOpenAUX* aux); 60 | 61 | void makoprintf(int isErr,const char* fmt, ...); 62 | void makovprintf(int isErr,const char* fmt, va_list argList); 63 | void setDispExit(void); 64 | void sendFatalError(const char* eMsg, 65 | BaFatalErrorCodes ecode1, 66 | unsigned int ecode2, 67 | const char* file, 68 | int line); 69 | void errQuit(const char* fmt, ...); 70 | 71 | 72 | #ifdef _WIN32 73 | #define SERVICENAME "mako" 74 | void runMako(int isWinService,int argc, char* argv[], char* envp[]); 75 | void mustBeAdmin(void); 76 | void instalMakoEventSource(void); 77 | int prtok(int ok, const char* okmsg); 78 | #endif 79 | -------------------------------------------------------------------------------- /inc/DeadProp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: DeadProp.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2008 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | * 38 | */ 39 | #ifndef _DeadProp_h 40 | #define _DeadProp_h 41 | 42 | #include 43 | 44 | typedef struct DeadProp 45 | { 46 | SXmlRoot op; 47 | SXmlRoot* nr; 48 | U8* xmlRootBuf; 49 | SXmlNode* oprop; 50 | SXmlNode** nprops; 51 | SXmlNode* oPropIter; /* Used by getFirstPropName & getNextPropName */ 52 | IoIntf* io; 53 | AllocatorIntf* alloc; 54 | char* propFileName; 55 | U16 npropsCursor; 56 | U16 npropsLen; 57 | BaBool noPropFile; 58 | BaBool elemRemoved; 59 | } DeadProp; 60 | 61 | 62 | void DeadProp_constructor(DeadProp* o, IoIntf* io, AllocatorIntf* alloc); 63 | char* DeadProp_fname2PropFName(AllocatorIntf* alloc, const char* filename); 64 | int DeadProp_mkPropDir(IoIntf* io, char* propFileName); 65 | U8* DeadProp_readFile(IoIntf* io, AllocatorIntf* alloc, 66 | const char* name, size_t* size); 67 | int DeadProp_setFile(DeadProp* o, char* propFileName); 68 | int DeadProp_save(DeadProp* o); 69 | SXmlNode* DeadProp_getProp(DeadProp* o, const char* ns, const char* name); 70 | int DeadProp_setProp(DeadProp* o, SXmlNode* nn, SXmlRoot* nr); 71 | int DeadProp_removeProp(DeadProp* o, SXmlNode* nn, SXmlRoot* nr); 72 | SXmlNode* DeadProp_getFirstProp(DeadProp* o); 73 | SXmlNode* DeadProp_getNextProp(DeadProp* o); 74 | void DeadProp_destructor(DeadProp* o); 75 | #define DeadProp_getRoot(o) (&(o)->op) 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /examples/C-WebSockets/html/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | html,body,table { 8 | height:100%; 9 | } 10 | 11 | table{ 12 | width:100%; 13 | } 14 | 15 | body,html{ 16 | background-color: #121211; 17 | } 18 | 19 | body { 20 | font: 13px Helvetica, Arial; 21 | } 22 | 23 | td { 24 | vertical-align: top; 25 | } 26 | 27 | form input { 28 | border-radius:5px; 29 | outline: none; 30 | display: block; 31 | float:left; 32 | border: 0; 33 | padding: 10px; 34 | width: 100%; 35 | } 36 | 37 | form button { 38 | display:none; 39 | float:left; 40 | width:60px; 41 | margin: 0 0 0 -60px; 42 | background: rgb(130, 224, 255); 43 | border: none; 44 | padding: 10px; 45 | } 46 | 47 | #messages{ 48 | width:100%; 49 | height:100%; 50 | position:relative; 51 | } 52 | 53 | #messages ul { 54 | list-style-type: none; 55 | margin: 0; padding: 0; 56 | } 57 | 58 | #messages li { padding: 5px 10px; } 59 | #messages li.enter {color:#1C82A1;} 60 | #messages li.leave {color:#b4201e;} 61 | #messages {background:#414141;} 62 | #users { height:100%;width:250px;} 63 | 64 | .user-header{ 65 | display:block; 66 | color:#fff; 67 | font-size:20px; 68 | font-weight:bold; 69 | margin:10px; 70 | } 71 | 72 | #users,#messages ,#users div ,#messages > div,#dialog { 73 | border-radius:10px; 74 | } 75 | 76 | .top-mk{margin:8px;border-bottom:1px solid #787878;font-weight:bold;font-size:18px;} 77 | 78 | #users li{ 79 | font-size:18px ; 80 | padding:10px; 81 | color:#fff; 82 | background-color:#b4201e; 83 | list-style-type: none; 84 | margin:5px; 85 | border-radius:4px; 86 | } 87 | 88 | #users div,#messages > div{ 89 | background-color: #121211; 90 | } 91 | 92 | #messages > div{ 93 | overflow:auto; 94 | position:absolute; 95 | top: 5px; 96 | bottom: 45px; 97 | left: 5px; 98 | right:5px; 99 | } 100 | 101 | #messages form{ 102 | overflow:auto; 103 | position:absolute; 104 | height: 40px; 105 | bottom: 0px; 106 | left: 5px; 107 | right:5px; 108 | } 109 | 110 | 111 | .dp{position:absolute;margin-top:20px;margin-left:30px;} 112 | 113 | .green{color:#55b60f;margin-right:5px} 114 | 115 | .arrow{ 116 | position:relative; 117 | width:15px;top:3px;margin-left:5px;margin-right:5px;} 118 | 119 | .message-board{ 120 | margin-top:5px; 121 | font-weight:bold; 122 | color:#fff; 123 | padding:10px !important; 124 | border-radius:4px; 125 | background-color:#414141; 126 | margin-left:5px; 127 | margin-right:5px; 128 | } 129 | .blue{color:#4569b9;font-weight:bold;} 130 | #dialog{ 131 | padding:5px; 132 | background:#EDEDEE; 133 | border: 1px solid; 134 | width:400px; 135 | height:80px; 136 | margin:auto; 137 | position: absolute; 138 | top: 0; 139 | left: 0; 140 | bottom: 0; 141 | right: 0; 142 | } 143 | 144 | #nickname{outline:none;padding:5px;} 145 | 146 | #users li { 147 | transition: background 0.8s ease; 148 | } 149 | 150 | #users li.writing { 151 | background: green !important; 152 | } 153 | 154 | table.BasicChat 155 | { 156 | width:100%; 157 | color:white; 158 | } 159 | -------------------------------------------------------------------------------- /src/arch/uCOS-III/ThreadLib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * SOURCE 13 | * 14 | * $Id$ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2022 17 | * http://www.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 | 29 | #ifndef BA_THREAD_PRIO_BASE 30 | #define BA_THREAD_PRIO_BASE 12 31 | #endif 32 | 33 | #ifndef BA_OS_MSG_QTY 34 | #define BA_OS_MSG_QTY 5 35 | #endif 36 | 37 | #include 38 | #include 39 | 40 | 41 | BaTime 42 | baGetUnixTime(void) 43 | { 44 | return (baGetMsClock() / 1000); 45 | } 46 | 47 | 48 | BaTime 49 | baGetMsClock() 50 | { 51 | OS_ERR err; 52 | OS_TICK num_ticks = OSTimeGet(&err); 53 | 54 | (void) err; 55 | return (num_ticks); 56 | } 57 | 58 | 59 | static void 60 | wait4ThreadStart(void) 61 | { 62 | OS_ERR err; 63 | OSTaskSemPend(0, OS_OPT_PEND_BLOCKING, 0, &err); 64 | TST_OK(err); 65 | } 66 | 67 | 68 | static void 69 | Thread_threadStart(void* thread) 70 | { 71 | wait4ThreadStart(); 72 | ((Thread*)thread)->runnable((Thread*)thread); 73 | Thread_destructor((Thread*)thread); 74 | } 75 | 76 | 77 | void 78 | Thread_constructor( 79 | ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize) 80 | { 81 | CPU_STK* stk; 82 | OS_ERR err; 83 | OS_PRIO taskPrio=BA_THREAD_PRIO_BASE; 84 | switch(priority) 85 | { 86 | case ThreadPrioLowest: taskPrio += 2; break; 87 | case ThreadPrioLow: taskPrio += 1; break; 88 | case ThreadPrioNormal: break; 89 | case ThreadPrioHigh: taskPrio -= 1; break; 90 | case ThreadPrioHighest: taskPrio -= 2; break; 91 | default: 92 | baAssert(0); 93 | } 94 | o->runnable = r; 95 | stackSize+=100; 96 | stk = (CPU_STK*)baMalloc(stackSize); 97 | baAssert(0 != stk); 98 | 99 | stackSize /= sizeof (CPU_STK); /* Stack size, in elements (uints) */ 100 | OSTaskCreate(&o->tid, 101 | "BAS", 102 | Thread_threadStart, 103 | o, 104 | taskPrio, 105 | stk, 106 | stackSize / 8, 107 | stackSize, 108 | BA_OS_MSG_QTY, 109 | 0, 110 | 0, 111 | OS_OPT_TASK_STK_CHK + OS_OPT_TASK_STK_CLR, 112 | &err); 113 | TST_OK(err); 114 | } 115 | -------------------------------------------------------------------------------- /inc/BaSharkSslOpt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id$ 15 | * 16 | * COPYRIGHT: Real Time Logic LLC, 2023 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * This header file, included by all the 'arch' TargConfig.h headers, 37 | * sets default SharkSSL settings for BAS. 38 | */ 39 | 40 | #ifndef _TargConfig_h 41 | #error Only TargConfig.h should include this header file 42 | #endif 43 | 44 | #if 1 45 | #ifndef SHARKSSL_ENABLE_ASN1_KEY_CREATION 46 | #define SHARKSSL_ENABLE_ASN1_KEY_CREATION 1 47 | #endif 48 | #ifndef SHARKSSL_ENABLE_RSAKEY_CREATE 49 | #define SHARKSSL_ENABLE_RSAKEY_CREATE 1 50 | #endif 51 | #ifndef SHARKSSL_ENABLE_ECCKEY_CREATE 52 | #define SHARKSSL_ENABLE_ECCKEY_CREATE 1 53 | #endif 54 | #ifndef SHARKSSL_ENABLE_CSR_CREATION 55 | #define SHARKSSL_ENABLE_CSR_CREATION 1 56 | #endif 57 | #ifndef SHARKSSL_ENABLE_CSR_SIGNING 58 | #define SHARKSSL_ENABLE_CSR_SIGNING 1 59 | #endif 60 | #endif 61 | 62 | #ifndef SHARKSSL_USE_SHA_512 63 | #define SHARKSSL_USE_SHA_512 1 64 | #endif 65 | 66 | #ifndef SHARKSSL_ECC_USE_SECP256R1 67 | #define SHARKSSL_ECC_USE_SECP256R1 1 68 | #endif 69 | #ifndef SHARKSSL_ECC_USE_SECP384R1 70 | #define SHARKSSL_ECC_USE_SECP384R1 1 71 | #endif 72 | #ifndef SHARKSSL_ECC_USE_SECP521R1 73 | #define SHARKSSL_ECC_USE_SECP521R1 1 74 | #endif 75 | #ifndef SHARKSSL_ECC_USE_BRAINPOOLP256R1 76 | #define SHARKSSL_ECC_USE_BRAINPOOLP256R1 1 77 | #endif 78 | #ifndef SHARKSSL_ECC_USE_BRAINPOOLP384R1 79 | #define SHARKSSL_ECC_USE_BRAINPOOLP384R1 1 80 | #endif 81 | #ifndef SHARKSSL_ECC_USE_BRAINPOOLP512R1 82 | #define SHARKSSL_ECC_USE_BRAINPOOLP512R1 1 83 | #endif 84 | 85 | #ifndef SHARKSSL_ENABLE_RSA_OAEP 86 | #define SHARKSSL_ENABLE_RSA_OAEP 1 87 | #endif 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /inc/IoIntfCspReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: IoIntfCspReader.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic LLC, 2008 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #ifndef __IoIntfCspReader_h 39 | #define __IoIntfCspReader_h 40 | 41 | #include 42 | #include 43 | 44 | /** The IoIntfCspReader, which implements the abstract CspReader 45 | interface, makes it possible to open a "CSP dat" file via a IoIntf. 46 | @ingroup IO 47 | */ 48 | typedef struct IoIntfCspReader 49 | #ifdef __cplusplus 50 | : public CspReader 51 | { 52 | IoIntfCspReader() {} 53 | 54 | /** The IoIntfCspReader constructor opens the Zip-File for reading. 55 | \param io the I/O-interface to read from. 56 | \param pathName the path+name to the "CSP dat" file. 57 | */ 58 | IoIntfCspReader(IoIntf* io, const char* pathName); 59 | 60 | /** The destructor closes the file connection. 61 | */ 62 | ~IoIntfCspReader(); 63 | 64 | /** Close the file connection. 65 | */ 66 | int close(); 67 | 68 | private: 69 | #else 70 | { 71 | CspReader reader; 72 | #endif 73 | U32 currentOffset; 74 | IoIntf_SeekAndRead seekAndReadFp; 75 | ResIntfPtr fp; 76 | } IoIntfCspReader; 77 | 78 | #ifdef __cplusplus 79 | extern "C" { 80 | #endif 81 | BA_API void IoIntfCspReader_constructor(IoIntfCspReader* o, 82 | IoIntf* io, 83 | const char* pathName); 84 | BA_API int IoIntfCspReader_close(IoIntfCspReader* o); 85 | #define IoIntfCspReader_destructor(o) IoIntfCspReader_close(o); 86 | #ifdef __cplusplus 87 | } 88 | inline IoIntfCspReader::IoIntfCspReader(IoIntf* io, const char* pathName) { 89 | IoIntfCspReader_constructor(this, io, pathName); } 90 | inline IoIntfCspReader::~IoIntfCspReader() { 91 | IoIntfCspReader_destructor(this); } 92 | inline int IoIntfCspReader::close() { 93 | return IoIntfCspReader_close(this); } 94 | #endif 95 | 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /inc/arch/embOS/ThreadLibArch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: TargConfig.h 2195 2010-09-16 12:26:20Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2004 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #ifndef ThreadLib_hpp 39 | #define ThreadLib_hpp 40 | 41 | #include 42 | 43 | #ifdef NDEBUG 44 | #define TST_OK(x) x 45 | #else 46 | #define TST_OK(x) baAssert((x) <= 1) 47 | #endif 48 | 49 | struct ThreadSemaphoreBase; 50 | struct ThreadMutexBase; 51 | 52 | typedef struct ThreadMutexBase 53 | { 54 | OS_RSEMA mutex; 55 | } ThreadMutexBase; 56 | 57 | #define ThreadMutex_constructor(o) OS_CREATERSEMA(&(o)->mutex) 58 | #define ThreadMutex_destructor(o) OS_DeleteRSema(&(o)->mutex) 59 | #define ThreadMutex_set(o) TST_OK(OS_Use(&(o)->mutex)) 60 | #define ThreadMutex_release(o) OS_Unuse(&(o)->mutex) 61 | #define ThreadMutex_isOwner(o) (OS_GetResourceOwner(&(o)->mutex) == OS_GetpCurrentTask()) 62 | 63 | 64 | typedef struct ThreadSemaphoreBase 65 | { 66 | OS_CSEMA sem; 67 | } ThreadSemaphoreBase; 68 | 69 | #define ThreadSemaphore_constructor(o) OS_CREATECSEMA(&(o)->sem) 70 | #define ThreadSemaphore_destructor(o) OS_DeleteCSema(&(o)->sem) 71 | #define ThreadSemaphore_wait(o) OS_WaitCSema(&(o)->sem) 72 | #define ThreadSemaphore_signal(o) OS_SignalCSema(&(o)->sem) 73 | 74 | 75 | typedef struct ThreadBase 76 | { 77 | OS_TASK task; 78 | int *stack; 79 | } ThreadBase; 80 | 81 | #define Thread_sleep(milliseconds) OS_Delay(milliseconds) 82 | #define Thread_start(o) OS_Resume(&(o)->task) 83 | #define Thread_destructor(o) do{\ 84 | OS_Terminate(&(o)->task);\ 85 | baFree(&(o)->stack);\ 86 | }while(0) 87 | 88 | #ifdef __cplusplus 89 | extern "C" { 90 | #endif 91 | void Thread_constructor( 92 | struct ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize); 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | 98 | 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /examples/C-WebSockets/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WebSocket Chat Demo 6 | 7 | 8 | 9 | 100 | 101 | 102 | 103 | 104 | 105 | 113 | 114 |
106 |
107 |
    108 |
    109 | 110 |
    111 |
    112 |
    115 | 116 | 117 | -------------------------------------------------------------------------------- /inc/BaFile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: BaFile.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2006 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #ifndef __BaFile_h 39 | #define __BaFile_h 40 | 41 | /** @defgroup BaFile Standard I/O functions 42 | @ingroup IO 43 | 44 | The BaFile API specifies a number of standard I/O functions for 45 | working with files. The BaFile API is used by some of the examples 46 | in the example directory. The BaFile API is not used by any of the 47 | web-server code. 48 | 49 | The BaFile API provides functions similar to standard ANSI I/O functions. 50 | 51 | @{ 52 | */ 53 | 54 | #include 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | /** Opens a directory for reading. Sub-directories may include '.' and '..' 61 | */ 62 | BA_API DirIntfPtr baOpenDir(const char* dirname, int* status, const char** ecode); 63 | 64 | /** Close a BaDir object. 65 | */ 66 | BA_API int baCloseDir(DirIntfPtr* dirIntf); 67 | 68 | /** Get information for a directory or file. 69 | */ 70 | BA_API int baStat(const char* name, IoStat* st); 71 | 72 | 73 | /** Open a file for binary read. 74 | */ 75 | BA_API ResIntfPtr baOpenRes(const char* name,U32 mode,int* status,const char** ecode); 76 | 77 | /** Close a file descriptor. 78 | */ 79 | BA_API int baCloseRes(ResIntfPtr* fp); 80 | 81 | 82 | /** Create directory. 83 | */ 84 | BA_API int baMkDir(const char* dname, const char** ecode); 85 | 86 | /** Remove empty directory. 87 | */ 88 | BA_API int baRmdDir(const char* dname, const char** ecode); 89 | 90 | 91 | /** Remove file. 92 | */ 93 | BA_API int baRemove(const char* fname, const char** ecode); 94 | 95 | 96 | /* Rename file or directory. 97 | */ 98 | BA_API int baRename(const char* from, const char* to, const char** ecode); 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | /** @} */ /* end of BaFile */ 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /LinuxBuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Compile Mako Server as follows: 3 | # wget -O - https://raw.githubusercontent.com/RealTimeLogic/BAS/main/LinuxBuild.sh | bash 4 | # Details: https://github.com/RealTimeLogic/BAS 5 | 6 | 7 | function abort() { 8 | printf "$1\n\n"; 9 | read -p "Press ENTER to exit script" 10 | exit 1; 11 | } 12 | 13 | function install() { 14 | abort "Run the following prior to running this script:\nsudo apt-get install git zip unzip gcc make" 15 | } 16 | 17 | executables="git zip unzip gcc make" 18 | 19 | for i in $executables; do 20 | if ! command -v $i &> /dev/null; then 21 | install 22 | exit 1 23 | fi 24 | done 25 | 26 | 27 | unameOut="$(uname -s)" 28 | case "${unameOut}" in 29 | Linux*) XLIB=-ldl;XCFLAGS=-DLUA_USE_LINUX;machine=Linux;export EPOLL=TRUE;; 30 | Darwin*) machine=Mac;; 31 | CYGWIN*) XLIB=-ldl;XCFLAGS="-DLUA_USE_LINUX -DUSE_FORKPTY=0";machine=Cygwin;; 32 | # MINGW*) machine=MinGw;; 33 | *) abort "Unknown machine ${unameOut}" 34 | esac 35 | 36 | if [ -z ${CC+x} ]; then 37 | command -v gcc >/dev/null 2>&1 || install 38 | CC=gcc 39 | echo "Setting default compiler" 40 | fi 41 | echo "Using compiler $CC" 42 | 43 | if [ -f src/BAS.c ]; then 44 | abort "Incorrect use! This script should not be run in the BAS directory.\nDetails: https://github.com/RealTimeLogic/BAS" 45 | fi 46 | 47 | if ! [ -d "BAS" ]; then 48 | git clone https://github.com/RealTimeLogic/BAS.git || abort "Cloning BAS failed" 49 | fi 50 | 51 | if ! [ -d "BAS-Resources" ]; then 52 | git clone https://github.com/RealTimeLogic/BAS-Resources.git || abort "Cloning BAS-Resources failed" 53 | chmod +x BAS-Resources/build/*.sh 54 | fi 55 | 56 | if ! [ -f "LPeg/lpcode.c" ]; then 57 | echo "Downloading LPeg" 58 | git clone https://github.com/roberto-ieru/LPeg.git LPeg 59 | fi 60 | 61 | if ! [ -f "lua-protobuf/pb.c" ]; then 62 | echo "Downloading Google Protobuf for Lua" 63 | git clone https://github.com/starwing/lua-protobuf.git lua-protobuf 64 | fi 65 | 66 | if ! [ -f "CBOR/cbor_c.c" ]; then 67 | echo "Downloading CBOR" 68 | git clone https://github.com/spc476/CBOR.git CBOR 69 | fi 70 | 71 | 72 | 73 | cd BAS || abort $LINENO 74 | if ! [ -f "src/sqlite3.c" ]; then 75 | # if SQLITEURL url not set 76 | if [ -z ${SQLITEURL+x} ]; then 77 | # There is no 'latest' with SQLite :-( 78 | SQLITEURL="https://www.sqlite.org/2025/sqlite-amalgamation-3490100.zip" 79 | fi 80 | SQLITE=${SQLITEURL##*/} 81 | pushd /tmp || abort $LINENO 82 | echo "Downloading: $SQLITEURL" 83 | command -v wget >/dev/null 2>&1 84 | if [ $? -eq 0 ]; then 85 | wget --no-check-certificate $SQLITEURL || abort $LINENO 86 | else 87 | curl $SQLITEURL -o $SQLITE 88 | fi 89 | unzip -o $SQLITE || abort $LINENO 90 | popd 91 | mv /tmp/${SQLITE%.zip}/* src/ || abort $LINENO 92 | fi 93 | 94 | if [ -n "${NOCOMPILE+set}" ]; then 95 | exit 0 96 | fi 97 | 98 | make -f mako.mk || abort $LINENO 99 | 100 | if [[ -z "${CROSS_COMPILE}" ]]; then 101 | read -p "Do you want to install the Mako Server in /usr/local/bin (Y/n)?" 33 | #include 34 | #ifdef _WIN32 35 | #include 36 | #elif !__CODEWARRIOR__ 37 | #include 38 | #endif 39 | #include 40 | #include 41 | #include 42 | 43 | extern void hostInit(void); 44 | extern void barracuda(void); 45 | #ifdef USE_DLMALLOC 46 | extern void init_dlmalloc(char* heapstart, char* heapend); 47 | #endif 48 | 49 | /* Changes the current directory to the object directory. 50 | 51 | This functionality is strictly not needed, but simplfifies using 52 | the examples. The example programs, when using the DiskIo, are 53 | designed to run from the object directory and will fail if run from 54 | another directory. 55 | */ 56 | static void 57 | change2ObjDir(const char* argv0) 58 | { 59 | struct stat st; 60 | #ifdef _WIN32 61 | char* path=0; 62 | #else 63 | (void)argv0; 64 | #endif 65 | const char* cpath="obj"; 66 | if( ! stat(cpath,&st) ) 67 | { 68 | const char* cpath2="obj/debug"; 69 | if( ! stat(cpath2,&st) ) cpath = cpath2; 70 | } 71 | else 72 | { 73 | cpath="../obj"; 74 | if( ! stat(cpath,&st) ) 75 | { 76 | const char* cpath2="obj/debug"; 77 | if( ! stat(cpath2,&st) ) cpath = cpath2; 78 | } 79 | else 80 | { 81 | #ifdef _WIN32 82 | char* ptr; 83 | cpath=0; 84 | path = baStrdup(argv0); 85 | ptr = strrchr(path, '\\'); 86 | if(ptr) 87 | { 88 | *ptr=0; 89 | if( ! stat(path,&st) ) cpath=path; 90 | } 91 | #else 92 | cpath=0; 93 | #endif 94 | } 95 | } 96 | if(cpath) 97 | printf("Changing directory to: %s%s\n",cpath,chdir(cpath) ? " FAILED!!!" : ""); 98 | else 99 | printf("Warning: cannot find the object directory\n"); 100 | #ifdef _WIN32 101 | if(path) baFree(path); 102 | #endif 103 | } 104 | 105 | 106 | int 107 | main(int argc, char* argv[]) 108 | { 109 | #ifdef USE_DLMALLOC 110 | static char poolBuf[3 * 1024 * 1024]; 111 | init_dlmalloc(poolBuf, poolBuf + sizeof(poolBuf)); 112 | #endif 113 | 114 | change2ObjDir(argv[0]); 115 | 116 | hostInit(); /* See HostInit.c */ 117 | barracuda(); /* See barracuda.c. Never returns */ 118 | return 0; /* Remove compiler warning */ 119 | } 120 | -------------------------------------------------------------------------------- /src/arch/Quadros/ThreadLib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * 13 | * 14 | * $Id: ThreadLib.c 4914 2021-12-01 18:24:30Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic LLC, 2012 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | 39 | /* 3 <= BA_BASE_PRIO <= 124 */ 40 | #define BA_BASE_PRIO 51 41 | 42 | 43 | #include 44 | 45 | 46 | /**************************************************************************** 47 | * Thread 48 | ***************************************************************************/ 49 | 50 | static void 51 | Thread_threadStart(void) 52 | { 53 | Thread* o = (Thread*)KS_GetTaskEnvArg(KS_GetTaskID()); 54 | o->runnable(o); 55 | KS_TerminateSelfTask(); 56 | } 57 | 58 | 59 | void 60 | Thread_constructor( 61 | ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize) 62 | { 63 | o->tprop.priority = BA_BASE_PRIO; 64 | o->runnable = r; 65 | Thread_ce(KS_OpenTask(0, &o->tid)); 66 | switch(priority) 67 | { 68 | case ThreadPrioLowest: o->tprop.priority += 2; break; 69 | case ThreadPrioLow: o->tprop.priority += 1; break; 70 | case ThreadPrioNormal: break; 71 | case ThreadPrioHigh: o->tprop.priority -= 1; break; 72 | case ThreadPrioHighest: o->tprop.priority -= 2; break; 73 | default: 74 | baAssert(0); 75 | } 76 | o->tprop.stackbase = (char *)baMalloc(stackSize); 77 | if(o->tprop.stackbase) 78 | { 79 | o->tprop.taskentry = ( void(*)(void) )Thread_threadStart; 80 | o->tprop.stacksize = stackSize; 81 | KS_DefTaskProp(o->tid, &o->tprop); 82 | KS_DefTaskEnvArg(o->tid, o); 83 | } 84 | } 85 | 86 | 87 | void 88 | Thread_destructor(struct ThreadBase* o) 89 | { 90 | if(o->tprop.stackbase) 91 | { 92 | void* stackbase = o->tprop.stackbase; 93 | if(KS_GetTaskID() == o->tid) 94 | baFatalE(FE_THREAD_LIB,o->tid); 95 | o->tprop.stackbase=0; 96 | Thread_ce(KS_CloseTask(o->tid)); 97 | baFree(stackbase); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /inc/arch/Zephyr/ThreadLibArch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: ThreadLibArch.h 5672 2025-10-17 00:14:58Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2022 - 2025 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * https://realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * Platform: Zephyr 37 | * 38 | */ 39 | 40 | #ifndef ThreadLib_hpp 41 | #define ThreadLib_hpp 42 | 43 | #include 44 | 45 | #include 46 | #undef KB /* zephyr/Lua conflict */ 47 | 48 | typedef struct ThreadMutexBase 49 | { 50 | k_tid_t tid; /* Lock owner */ 51 | struct k_mutex mutex; 52 | } ThreadMutexBase; 53 | 54 | #define ThreadMutex_constructor(o) do{\ 55 | (o)->tid = 0;\ 56 | k_mutex_init(&(o)->mutex); \ 57 | }while(0) 58 | 59 | #define ThreadMutex_destructor(o) 60 | 61 | #define ThreadMutex_set(o) do{\ 62 | k_mutex_lock(&(o)->mutex, K_FOREVER); \ 63 | (o)->tid = k_current_get(); \ 64 | }while(0) 65 | 66 | #define ThreadMutex_release(o) do{\ 67 | (o)->tid = 0; \ 68 | k_mutex_unlock(&(o)->mutex); \ 69 | }while(0) 70 | 71 | #define ThreadMutex_isOwner(o) ((o)->tid == k_current_get()) 72 | 73 | typedef struct ThreadSemaphoreBase 74 | { 75 | struct k_sem sem; 76 | } ThreadSemaphoreBase; 77 | 78 | #define ThreadSemaphore_constructor(o) k_sem_init(&(o)->sem, 0, 1) 79 | 80 | #define ThreadSemaphore_destructor(o) 81 | 82 | #define ThreadSemaphore_wait(o) k_sem_take(&(o)->sem, K_FOREVER) 83 | 84 | #define ThreadSemaphore_signal(o) k_sem_give(&(o)->sem) 85 | 86 | 87 | typedef struct ThreadBase 88 | { 89 | struct k_thread thread; 90 | Thread_Run runnable; 91 | struct k_sem* startSem; 92 | k_thread_stack_t* stackStart; 93 | k_tid_t tid; 94 | } ThreadBase; 95 | 96 | #ifdef __cplusplus 97 | extern "C" { 98 | #endif 99 | 100 | void Thread_constructor( 101 | ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize); 102 | void Thread_destructor(ThreadBase* o); 103 | #define Thread_sleep(milliseconds) k_msleep(milliseconds) 104 | #define Thread_start(o) k_sem_give((o)->startSem) 105 | #ifdef __cplusplus 106 | } 107 | #endif 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /inc/FixedSizeAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | **************************************************************************** 11 | * HEADER 12 | * 13 | * $Id: FixedSizeAllocator.h 4915 2021-12-01 18:26:55Z wini $ 14 | * 15 | * COPYRIGHT: Real Time Logic LLC, 2005-2008 16 | * 17 | * This software is copyrighted by and is the sole property of Real 18 | * Time Logic LLC. All rights, title, ownership, or other interests in 19 | * the software remain the property of Real Time Logic LLC. This 20 | * software may only be used in accordance with the terms and 21 | * conditions stipulated in the corresponding license agreement under 22 | * which the software has been supplied. Any unauthorized use, 23 | * duplication, transmission, distribution, or disclosure of this 24 | * software is expressly forbidden. 25 | * 26 | * This Copyright notice may not be removed or modified without prior 27 | * written consent of Real Time Logic LLC. 28 | * 29 | * Real Time Logic LLC. reserves the right to modify this software 30 | * without notice. 31 | * 32 | * http://www.realtimelogic.com 33 | **************************************************************************** 34 | * 35 | */ 36 | 37 | #ifndef __FixedSizeAllocator_h 38 | #define __FixedSizeAllocator_h 39 | 40 | #include 41 | #include 42 | 43 | 44 | /** This is a fixed size allocator implementation for the abstract 45 | interface class AllocatorIntf. 46 | 47 | @ingroup DynamicMemory 48 | 49 | The FixedSizeAllocator takes a buffer and splits the buffer up into 50 | equally sized chunks. Allocating memory larger than the chunk size 51 | or using realloc results in an error; i.e., NULL returned. One can 52 | allocate a smaller size than the chunk size, but the size will be 53 | adjusted to the chunk size. 54 | */ 55 | typedef struct FixedSizeAllocator 56 | #ifdef __cplusplus 57 | : public AllocatorIntf 58 | { 59 | FixedSizeAllocator() {} 60 | 61 | /** Create a fixed size allocator. 62 | \param buffer a pointer to the memory location for the fixed 63 | size allocator. 64 | \param bufSize the size of the buffer. The size should be n*blockSize. 65 | \param blockSize the size of the chunks. 66 | */ 67 | FixedSizeAllocator(void* buffer, size_t bufSize, size_t blockSize); 68 | 69 | #else 70 | { 71 | AllocatorIntf super; 72 | #endif 73 | SingleList freeList; 74 | size_t blockSize; 75 | } FixedSizeAllocator; 76 | 77 | 78 | #ifdef __cplusplus 79 | extern "C" { 80 | #endif 81 | BA_API void FixedSizeAllocator_constructor(FixedSizeAllocator* o, 82 | void* buffer, 83 | size_t bufSize, 84 | size_t blockSize); 85 | #ifdef __cplusplus 86 | } 87 | inline FixedSizeAllocator::FixedSizeAllocator(void* buffer, 88 | size_t bufSize, 89 | size_t blockSize) { 90 | FixedSizeAllocator_constructor(this, buffer, bufSize, blockSize); 91 | } 92 | #endif 93 | 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /inc/arch/Nucleus/ThreadLibArch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: ThreadLibArch.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2014 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * Platform: Nucleus. 37 | * 38 | */ 39 | 40 | #ifndef ThreadLib_hpp 41 | #define ThreadLib_hpp 42 | 43 | #include 44 | 45 | struct ThreadSemaphoreBase; 46 | struct ThreadMutexBase; 47 | 48 | typedef struct ThreadMutexBase { 49 | NU_SEMAPHORE mutex; 50 | } ThreadMutexBase; 51 | 52 | #define ThreadMutex_constructor(o) do{ \ 53 | memset(o, 0, sizeof(ThreadMutexBase)); \ 54 | TST_OK(NU_Create_Semaphore(&(o)->mutex, "BAS-M", 1, NU_PRIORITY_INHERIT)); \ 55 | }while(0) 56 | #define ThreadMutex_destructor(o) TST_OK(NU_Delete_Semaphore(&(o)->mutex)) 57 | #define ThreadMutex_set(o) TST_OK(NU_Obtain_Semaphore(&(o)->mutex, NU_SUSPEND)) 58 | #define ThreadMutex_release(o) NU_Release_Semaphore(&(o)->mutex) 59 | #ifdef __cplusplus 60 | extern "C" 61 | #endif 62 | int ThreadMutex_isOwner(ThreadMutex* o); 63 | 64 | typedef struct ThreadSemaphoreBase { 65 | NU_SEMAPHORE sem; 66 | } ThreadSemaphoreBase; 67 | 68 | #define ThreadSemaphore_constructor(o) do{ \ 69 | memset(o, 0, sizeof(ThreadMutexBase)); \ 70 | TST_OK(NU_Create_Semaphore(&(o)->sem, "BAS-S", 0, NU_PRIORITY_INHERIT)); \ 71 | }while(0) 72 | #define ThreadSemaphore_destructor(o) TST_OK(NU_Delete_Semaphore(&(o)->sem)) 73 | #define ThreadSemaphore_wait(o) TST_OK(NU_Obtain_Semaphore(&(o)->sem, NU_SUSPEND)) 74 | #define ThreadSemaphore_signal(o) TST_OK(NU_Release_Semaphore(&(o)->sem)) 75 | 76 | 77 | typedef struct ThreadBase 78 | { 79 | NU_TASK task; 80 | VOID* stackStart; 81 | Thread_Run runnable; 82 | } ThreadBase; 83 | 84 | #ifdef __cplusplus 85 | extern "C" { 86 | #endif 87 | void Thread_constructor( 88 | ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize); 89 | void Thread_destructor(ThreadBase* o); 90 | void Thread_sleep(U32 milliseconds); 91 | #define Thread_start(o) TST_OK(NU_Resume_Task(&(o)->task)) 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /inc/arch/ThreadX/ThreadLibArch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: ThreadLibArch.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2004 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * Platform: ThreadX. 37 | * 38 | */ 39 | 40 | #ifndef ThreadLib_hpp 41 | #define ThreadLib_hpp 42 | 43 | #include 44 | 45 | struct ThreadSemaphoreBase; 46 | struct ThreadMutexBase; 47 | 48 | typedef struct ThreadMutexBase 49 | { 50 | TX_THREAD* tid; /* Lock owner */ 51 | TX_MUTEX mutex; 52 | } ThreadMutexBase; 53 | 54 | #define ThreadMutex_constructor(o) do{\ 55 | (o)->tid = 0;\ 56 | TST_OK(tx_mutex_create(&(o)->mutex, "BM", TX_INHERIT));\ 57 | }while(0) 58 | 59 | #define ThreadMutex_destructor(o) TST_OK(tx_mutex_delete(&(o)->mutex)) 60 | 61 | #define ThreadMutex_set(o) do{\ 62 | TST_OK(tx_mutex_get(&(o)->mutex,TX_WAIT_FOREVER));\ 63 | (o)->tid = tx_thread_identify();\ 64 | }while(0) 65 | 66 | #define ThreadMutex_release(o) do{\ 67 | (o)->tid = 0;\ 68 | TST_OK(tx_mutex_put(&(o)->mutex));\ 69 | }while(0) 70 | 71 | #define ThreadMutex_isOwner(o) ((o)->tid == tx_thread_identify()) 72 | 73 | 74 | typedef struct ThreadSemaphoreBase 75 | { 76 | TX_SEMAPHORE sem; 77 | } ThreadSemaphoreBase; 78 | 79 | #define ThreadSemaphore_constructor(o) \ 80 | TST_OK(tx_semaphore_create(&(o)->sem,"BS",0)) 81 | 82 | #define ThreadSemaphore_destructor(o) TST_OK(tx_semaphore_delete(&(o)->sem)) 83 | 84 | #define ThreadSemaphore_wait(o) \ 85 | TST_OK(tx_semaphore_get(&(o)->sem, TX_WAIT_FOREVER)) 86 | 87 | #define ThreadSemaphore_signal(o) TST_OK(tx_semaphore_put(&(o)->sem)) 88 | 89 | 90 | typedef struct ThreadBase 91 | { 92 | TX_THREAD tid; 93 | VOID* stackStart; 94 | Thread_Run runnable; 95 | } ThreadBase; 96 | 97 | #ifdef __cplusplus 98 | extern "C" { 99 | #endif 100 | void Thread_constructor( 101 | ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize); 102 | void Thread_destructor(ThreadBase* o); 103 | void Thread_sleep(U32 milliseconds); 104 | void Thread_start(ThreadBase* o); 105 | #ifdef __cplusplus 106 | } 107 | #endif 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /inc/arch/Windows/ThreadLibArch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: ThreadLibArch.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2004 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | */ 36 | 37 | #ifndef ThreadLib_hpp 38 | #define ThreadLib_hpp 39 | 40 | #include 41 | #include 42 | #include 43 | 44 | struct ThreadSemaphoreBase; 45 | 46 | typedef struct ThreadMutexBase 47 | { 48 | DWORD tid; /* Lock owner */ 49 | CRITICAL_SECTION section; 50 | } ThreadMutexBase; 51 | 52 | #define ThreadMutex_constructor(o) do{\ 53 | (o)->tid = 0;\ 54 | InitializeCriticalSection(&(o)->section);\ 55 | }while(0) 56 | 57 | #define ThreadMutex_destructor(o) DeleteCriticalSection(&(o)->section) 58 | 59 | #define ThreadMutex_set(o) do{ \ 60 | EnterCriticalSection(&(o)->section);\ 61 | (o)->tid = GetCurrentThreadId(); \ 62 | }while(0) 63 | 64 | #define ThreadMutex_release(o) do{\ 65 | (o)->tid = 0;\ 66 | LeaveCriticalSection(&(o)->section);\ 67 | }while(0) 68 | 69 | #define ThreadMutex_isOwner(o) ((o)->tid == GetCurrentThreadId()) 70 | 71 | typedef struct ThreadSemaphoreBase 72 | { 73 | HANDLE semaphore; 74 | } ThreadSemaphoreBase; 75 | 76 | 77 | #define ThreadSemaphore_constructor(o) \ 78 | (o)->semaphore = CreateSemaphore(0, 0, 0x7ffffff, 0) 79 | #define ThreadSemaphore_destructor(o) \ 80 | CloseHandle((o)->semaphore) 81 | #define ThreadSemaphore_wait(o) \ 82 | WaitForSingleObject((o)->semaphore, INFINITE) 83 | #define ThreadSemaphore_signal(o) \ 84 | ReleaseSemaphore((o)->semaphore, 1, 0) 85 | 86 | 87 | typedef struct ThreadBase 88 | { 89 | HANDLE id; /* actually the hThread */ 90 | Thread_Run runnable; 91 | } ThreadBase; 92 | 93 | #define Thread_start(o) ResumeThread((o)->id) 94 | #define Thread_sleep(milliseconds) Sleep(milliseconds) 95 | 96 | #ifdef __cplusplus 97 | extern "C" { 98 | #endif 99 | BA_API void Thread_constructor( 100 | ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize); 101 | BA_API void Thread_destructor(Thread* o); 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /inc/JConstrCont.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: JConstrCont.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic LLC, 2007 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | */ 37 | 38 | #ifndef __JConstrCont_h 39 | #define __JConstrCont_h 40 | 41 | #include "JUserCont.h" 42 | #include "BaServerLib.h" 43 | #include "HashTable.h" 44 | 45 | /** Constraints Container that accepts JSON encoded data. 46 | */ 47 | typedef struct JConstrCont 48 | #ifdef __cplusplus 49 | : public AuthorizerIntf 50 | { 51 | JConstrCont(JUserCont* userCont, AllocatorIntf* alloc=0); 52 | ~JConstrCont(); 53 | void setConstraints(JVal* constraintsVal, JErr* err); 54 | 55 | /** A system with a case insensitive file system must call this 56 | method after running the constructor. Users may bypass 57 | security constraints if this method is not called. 58 | */ 59 | void setCaseInsensitive(); 60 | 61 | #else 62 | { 63 | AuthorizerIntf super; /* We inherit from AuthorizerIntf */ 64 | #endif 65 | 66 | DoubleList resourceList; 67 | JUserCont* userCont; 68 | HashTable* resourceTable; 69 | int noOfResources; 70 | AllocatorIntf* alloc; 71 | BaBool caseSensensitive; 72 | 73 | } JConstrCont; 74 | 75 | #ifdef __cplusplus 76 | extern "C" { 77 | #endif 78 | BA_API void JConstrCont_constructor(JConstrCont* o, JUserCont* userCont, 79 | AllocatorIntf* alloc); 80 | BA_API void JConstrCont_destructor(JConstrCont* o); 81 | BA_API void JConstrCont_setConstraints(JConstrCont* o, 82 | JVal* constraintsVal, JErr* err); 83 | #define JConstrCont_setCaseInsensitive(o) (o)->caseSensensitive=FALSE 84 | #ifdef __cplusplus 85 | } 86 | inline JConstrCont::JConstrCont(JUserCont* userCont, AllocatorIntf* alloc) { 87 | JConstrCont_constructor(this, userCont, alloc); } 88 | inline JConstrCont::~JConstrCont() { 89 | JConstrCont_destructor(this); } 90 | inline void JConstrCont::setConstraints(JVal* constraintsVal, JErr* err) { 91 | JConstrCont_setConstraints(this,constraintsVal, err); } 92 | inline void JConstrCont::setCaseInsensitive() { 93 | JConstrCont_setCaseInsensitive(this); 94 | } 95 | #endif 96 | 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /examples/C-RESTful-Service/src/RestJsonUtils.c: -------------------------------------------------------------------------------- 1 | #include "RestJsonUtils.h" 2 | #include 3 | #include 4 | 5 | /** 6 | * Parses the HTTP request body if it contains JSON data. 7 | * 8 | * This function checks if the incoming HTTP request has a payload and a 9 | * `Content-Type` of `application/json`. If so, it reads the payload in chunks 10 | * and uses the JParser to construct a JParserValFact (JSON value factory). 11 | * 12 | * @param req Pointer to the HttpRequest. 13 | * @param status Pointer to an integer that will be set to: 14 | * - 0 on success 15 | * - -1 on error (invalid or non-JSON data) 16 | * - If no payload is present, status is set to 0 and NULL is returned. 17 | * 18 | * @return Pointer to a dynamically allocated JParserValFact on success, 19 | * or NULL on error or if no JSON payload is present. 20 | * 21 | * Note: The function terminates the connection if a parsing error occurs. 22 | * Caller must free the returned JParserValFact using JParserValFact_destructor 23 | * and baFree(). 24 | */ 25 | JParserValFact* parseJSON(HttpRequest* req, int* status) 26 | { 27 | JParserValFact* valFact=0; 28 | if(HttpStdHeaders_getContentLength(HttpRequest_getStdHeaders(req)) || 29 | HttpRequest_getHeaderValue(req, "Transfer-encoding")) 30 | { 31 | *status=-1; 32 | const char* ct = HttpRequest_getHeaderValue(req, "Content-Type"); 33 | if(ct && !strcmp("application/json",ct) && HttpRecData_valid(req) >=0) 34 | { 35 | HttpRecData rd; 36 | HttpRecData_constructor(&rd,req); 37 | valFact = baMalloc(sizeof(JParserValFact)+1024+512); // + add two bufs 1024 & 512 38 | if(valFact) 39 | { 40 | S32 len; 41 | JParser parser; 42 | U8* buf = (U8*)(valFact+1)+1024; // Ptr 2 second buf: size 512 43 | JParserValFact_constructor( 44 | valFact, AllocatorIntf_getDefault(), AllocatorIntf_getDefault()); 45 | JParser_constructor(&parser, (JParserIntf*)valFact, 46 | (char*)(valFact+1), 1024, // Ptr 2 first buf & size 47 | AllocatorIntf_getDefault(), 0); 48 | while( (len = HttpRecData_read(&rd,buf, 512)) > 0 ) 49 | { 50 | if(JParser_parse(&parser, buf, len) < 0) 51 | { 52 | break; 53 | } 54 | } 55 | if(JParsStat_DoneEOS == JParser_getStatus(&parser)) 56 | { 57 | *status=0; 58 | } 59 | else 60 | { 61 | JParserValFact_destructor(valFact); 62 | baFree(valFact); 63 | valFact=0; 64 | } 65 | JParser_destructor(&parser); 66 | } 67 | HttpRecData_destructor(&rd); 68 | } 69 | if(*status) 70 | { 71 | // Close connection on error 72 | HttpConnection_setState(HttpRequest_getConnection(req),HttpConnection_Terminated); 73 | } 74 | } 75 | else 76 | { 77 | *status=0; // no payload 78 | } 79 | return valFact; 80 | } 81 | 82 | 83 | /* 84 | * Initializes a JEncoder for the given HTTP response. 85 | * 86 | * This function sets up the JSON encoder that can be used to write structured 87 | * JSON responses to the HTTP output buffer. 88 | * 89 | * @param resp Pointer to the HttpResponse object. 90 | * @param enc Pointer to an uninitialized JEncoder object. 91 | * @param err Pointer to an uninitialized JErr object to track JSON encoding errors. 92 | */ 93 | void initializeJEncoder(HttpResponse* resp, JEncoder* enc, JErr* err) 94 | { 95 | JErr_constructor(err); 96 | BufPrint* out = HttpResponse_getWriter(resp); 97 | JEncoder_constructor(enc, err, out); 98 | } 99 | -------------------------------------------------------------------------------- /inc/arch/Digi/ThreadLibArch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: ThreadLibArch.h 109 2005-01-11 12:48:49Z $ 15 | * 16 | * COPYRIGHT: Real Time Logic LLC, 2008 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * Platform: ThreadX (Digi). 37 | * 38 | */ 39 | 40 | #ifndef ThreadLib_hpp 41 | #define ThreadLib_hpp 42 | 43 | 44 | #include 45 | 46 | struct ThreadSemaphoreBase; 47 | struct ThreadMutexBase; 48 | 49 | typedef struct ThreadMutexBase 50 | { 51 | TX_THREAD* tid; /* Lock owner */ 52 | TX_MUTEX mutex; 53 | } ThreadMutexBase; 54 | 55 | #define ThreadMutex_constructor(o) do{\ 56 | memset(o,0,sizeof(ThreadMutexBase));\ 57 | TST_OK(tx_mutex_create(&(o)->mutex, (CHAR*)"BM", TX_INHERIT));\ 58 | }while(0) 59 | 60 | #define ThreadMutex_destructor(o) TST_OK(tx_mutex_delete(&(o)->mutex)) 61 | 62 | #define ThreadMutex_set(o) do{\ 63 | TST_OK(tx_mutex_get(&(o)->mutex,TX_WAIT_FOREVER));\ 64 | (o)->tid = tx_thread_identify();\ 65 | }while(0) 66 | 67 | #define ThreadMutex_release(o) do{\ 68 | (o)->tid = 0;\ 69 | TST_OK(tx_mutex_put(&(o)->mutex));\ 70 | }while(0) 71 | 72 | #define ThreadMutex_isOwner(o) ((o)->tid == tx_thread_identify()) 73 | 74 | 75 | typedef struct ThreadSemaphoreBase 76 | { 77 | TX_SEMAPHORE sem; 78 | } ThreadSemaphoreBase; 79 | 80 | #define ThreadSemaphore_constructor(o) \ 81 | do {memset(o,0,sizeof(ThreadSemaphore));\ 82 | TST_OK(tx_semaphore_create(&(o)->sem, (CHAR*)"BS", 0));}while(0) 83 | #define ThreadSemaphore_destructor(o) TST_OK(tx_semaphore_delete(&(o)->sem)) 84 | #define ThreadSemaphore_wait(o) TST_OK(tx_semaphore_get(&(o)->sem, TX_WAIT_FOREVER)) 85 | #define ThreadSemaphore_signal(o) TST_OK(tx_semaphore_put(&(o)->sem)) 86 | 87 | 88 | typedef struct ThreadBase 89 | { 90 | TX_THREAD tid; 91 | VOID* stackStart; 92 | Thread_Run runnable; 93 | } ThreadBase; 94 | 95 | #ifdef __cplusplus 96 | extern "C" { 97 | #endif 98 | void Thread_constructor( 99 | ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize); 100 | void Thread_destructor(ThreadBase* o); 101 | void Thread_sleep(U32 milliseconds); 102 | void Thread_start(ThreadBase* o); 103 | #ifdef __cplusplus 104 | } 105 | #endif 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /src/arch/ce/ThreadLib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: ThreadLib.c 3 2006-05-03 01:29:04Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2006 - 2011 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | 39 | #include "ThreadLib.h" 40 | 41 | 42 | static DWORD WINAPI 43 | Thread_threadStart(void* self) 44 | { 45 | Thread* thread = (Thread*)self; 46 | thread->runnable(thread); 47 | return 0; 48 | } 49 | 50 | 51 | BA_API void 52 | Thread_constructor( 53 | Thread* o, Thread_Run r, ThreadPriority priority, int stackSize) 54 | { 55 | DWORD targetThreadId; 56 | HANDLE hT; 57 | int prioNT; 58 | switch(priority) 59 | { 60 | case ThreadPrioLowest: prioNT = THREAD_PRIORITY_LOWEST; break; 61 | case ThreadPrioLow: prioNT = THREAD_PRIORITY_BELOW_NORMAL; break; 62 | case ThreadPrioNormal: prioNT = THREAD_PRIORITY_NORMAL; break; 63 | case ThreadPrioHigh: prioNT = THREAD_PRIORITY_ABOVE_NORMAL; break; 64 | case ThreadPrioHighest: prioNT = THREAD_PRIORITY_HIGHEST; break; 65 | } 66 | hT = CreateThread(NULL, /*LPSECURITY_ATTRIBUTES*/ 67 | stackSize, 68 | Thread_threadStart, 69 | o, 70 | CREATE_SUSPENDED, 71 | &targetThreadId); 72 | if(prioNT != THREAD_PRIORITY_NORMAL) 73 | SetThreadPriority(hT, prioNT); 74 | o->id = hT; 75 | o->runnable = r; 76 | } 77 | 78 | 79 | BA_API void 80 | Thread_destructor(Thread* o) 81 | { 82 | if (o->id && o->id != (HANDLE)-1) { 83 | CloseHandle(o->id); 84 | o->id = (HANDLE)-1; 85 | } 86 | } 87 | 88 | 89 | static unsigned 90 | FileTimeToUnixTime(FILETIME* pft) 91 | { 92 | __int64 t64 = ((((__int64)pft->dwHighDateTime << 32) | 93 | (__int64)pft->dwLowDateTime)) 94 | /* we 1/10 usecs since 1601 - convert to 1/ 10 usecs since 1970 */ 95 | - (__int64)116444736000000000; /* ms magic offset */ 96 | return ((unsigned) (t64 / (__int64)10000000)); 97 | } 98 | 99 | BA_API unsigned 100 | baGetUnixTime(void) 101 | { 102 | SYSTEMTIME st; 103 | FILETIME ft; 104 | GetSystemTime(&st); 105 | if (SystemTimeToFileTime(&st, &ft)) 106 | return FileTimeToUnixTime(&ft); 107 | else 108 | return 0; 109 | } 110 | -------------------------------------------------------------------------------- /inc/arch/MQX/ThreadLibArch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: ThreadLibArch.h 4915 2021-12-01 18:26:55Z wini $ 15 | * $Author$ 16 | * $Date$ 17 | * 18 | * COPYRIGHT: Real Time Logic, 2004 19 | * 20 | * This software is copyrighted by and is the sole property of Real 21 | * Time Logic LLC. All rights, title, ownership, or other interests in 22 | * the software remain the property of Real Time Logic LLC. This 23 | * software may only be used in accordance with the terms and 24 | * conditions stipulated in the corresponding license agreement under 25 | * which the software has been supplied. Any unauthorized use, 26 | * duplication, transmission, distribution, or disclosure of this 27 | * software is expressly forbidden. 28 | * 29 | * This Copyright notice may not be removed or modified without prior 30 | * written consent of Real Time Logic LLC. 31 | * 32 | * Real Time Logic LLC. reserves the right to modify this software 33 | * without notice. 34 | * 35 | * http://www.realtimelogic.com 36 | **************************************************************************** 37 | * 38 | */ 39 | 40 | #ifndef ThreadLib_hpp 41 | #define ThreadLib_hpp 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | #ifdef NDEBUG 48 | #define TST_OK(x) x 49 | #else 50 | #define TST_OK(x) baAssert(MQX_OK == x) 51 | #endif 52 | 53 | struct ThreadSemaphoreBase; 54 | struct ThreadMutexBase; 55 | 56 | typedef struct ThreadMutexBase 57 | { 58 | _task_id tid; /* Lock owner */ 59 | MUTEX_STRUCT mutex; 60 | } ThreadMutexBase; 61 | 62 | #define ThreadMutex_constructor(o) do{\ 63 | (o)->tid = MQX_NULL_TASK_ID;\ 64 | TST_OK(_mutex_init(&(o)->mutex,0));\ 65 | }while(0) 66 | 67 | #define ThreadMutex_destructor(o) TST_OK(_mutex_destroy(&(o)->mutex)) 68 | 69 | #define ThreadMutex_set(o) do{\ 70 | TST_OK(_mutex_lock(&(o)->mutex));\ 71 | (o)->tid = _task_get_id();\ 72 | }while(0) 73 | 74 | #define ThreadMutex_release(o) do{\ 75 | (o)->tid = MQX_NULL_TASK_ID;\ 76 | TST_OK(_mutex_unlock(&(o)->mutex));\ 77 | }while(0) 78 | 79 | #define ThreadMutex_isOwner(o) ((o)->tid == _task_get_id()) 80 | 81 | 82 | typedef struct ThreadSemaphoreBase 83 | { 84 | LWSEM_STRUCT sem; 85 | } ThreadSemaphoreBase; 86 | 87 | #define ThreadSemaphore_constructor(o) \ 88 | TST_OK(_lwsem_create(&(o)->sem,0)) 89 | #define ThreadSemaphore_destructor(o) \ 90 | TST_OK(_lwsem_destroy(&(o)->sem)) 91 | #define ThreadSemaphore_wait(o) \ 92 | TST_OK(_lwsem_wait(&(o)->sem)) 93 | #define ThreadSemaphore_signal(o) \ 94 | TST_OK(_lwsem_post(&(o)->sem)) 95 | 96 | 97 | typedef struct ThreadBase 98 | { 99 | _task_id tid; 100 | Thread_Run runnable; 101 | } ThreadBase; 102 | 103 | #define Thread_sleep(milliseconds) _time_delay(milliseconds) 104 | #define Thread_destructor(o) 105 | 106 | #ifdef __cplusplus 107 | extern "C" { 108 | #endif 109 | void Thread_constructor( 110 | struct ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize); 111 | int Thread_start(struct ThreadBase* o); 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | 117 | 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /src/arch/INtime/ThreadLib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * 13 | * $Id: ThreadLib.c 5076 2022-02-10 16:59:48Z wini $ 14 | * 15 | * COPYRIGHT: Real Time Logic, 2020 16 | * 17 | * This software is copyrighted by and is the sole property of Real 18 | * Time Logic LLC. All rights, title, ownership, or other interests in 19 | * the software remain the property of Real Time Logic LLC. This 20 | * software may only be used in accordance with the terms and 21 | * conditions stipulated in the corresponding license agreement under 22 | * which the software has been supplied. Any unauthorized use, 23 | * duplication, transmission, distribution, or disclosure of this 24 | * software is expressly forbidden. 25 | * 26 | * This Copyright notice may not be removed or modified without prior 27 | * written consent of Real Time Logic LLC. 28 | * 29 | * Real Time Logic LLC. reserves the right to modify this software 30 | * without notice. 31 | * 32 | * http://www.realtimelogic.com 33 | **************************************************************************** 34 | * 35 | * 36 | */ 37 | 38 | #ifndef BA_LIB 39 | #define BA_LIB 1 40 | #endif 41 | 42 | #ifndef BA_THREAD_PRIO_OFFS 43 | #define BA_THREAD_PRIO_OFFS 200 44 | #endif 45 | 46 | #include 47 | #include 48 | 49 | void 50 | _baClckGettime(BaTimeEx* spec) 51 | { 52 | SYSTEMTIME st; 53 | GetRtSystemTime(&st); 54 | spec->sec = st.wSecond; 55 | spec->nsec = st.dwMicroseconds*1000; 56 | spec->offset = 0; 57 | } 58 | 59 | 60 | BA_API U32 61 | baGetMsClock(void) 62 | { 63 | SYSTEMTIME st; 64 | GetRtSystemTime(&st); 65 | return 1000*st.wSecond + st.dwMicroseconds/1000; 66 | } 67 | 68 | 69 | #ifndef NDEBUG 70 | BA_API void 71 | Thread_cef(BOOLEAN ok, const char* file, int line) 72 | { 73 | if( ! ok ) baFatalEf(FE_THREAD_LIB, 0, file, line); 74 | } 75 | BA_API RTHANDLE 76 | Thread_hndlf(RTHANDLE rth, const char* file, int line) 77 | { 78 | if(BAD_RTHANDLE == rth) baFatalEf(FE_THREAD_LIB, 0, file, line); 79 | return rth; 80 | } 81 | #endif 82 | 83 | 84 | static void 85 | Thread_threadStart(void* self) 86 | { 87 | Thread* thread = (Thread*)self; 88 | ThreadSemaphore_wait(&thread->startSem); 89 | ThreadSemaphore_destructor(&thread->startSem); 90 | thread->runnable(thread); 91 | DeleteRtThread(thread->tid); 92 | } 93 | 94 | 95 | BA_API void 96 | Thread_constructor( 97 | Thread* o, Thread_Run r, ThreadPriority priority, int stackSize) 98 | { 99 | BYTE prio; 100 | ThreadSemaphore_constructor(&o->startSem); 101 | o->runnable = r; 102 | switch(priority) 103 | { 104 | case ThreadPrioLowest: prio = BA_THREAD_PRIO_OFFS +2; break; 105 | case ThreadPrioLow: prio = BA_THREAD_PRIO_OFFS +1; break; 106 | case ThreadPrioHigh: prio = BA_THREAD_PRIO_OFFS -1; break; 107 | case ThreadPrioHighest: prio = BA_THREAD_PRIO_OFFS -2; break; 108 | default: prio = BA_THREAD_PRIO_OFFS; break; 109 | } 110 | o->tid = Thread_hndl(CreateRtThread(prio,Thread_threadStart,stackSize,o)); 111 | } 112 | 113 | 114 | BA_API void 115 | Thread_start(Thread* o) 116 | { 117 | ThreadSemaphore_signal(&o->startSem); 118 | } 119 | -------------------------------------------------------------------------------- /inc/JUserCont.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: JUserCont.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic LLC, 2007-2013 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | */ 37 | 38 | #ifndef __JUserCont_h 39 | #define __JUserCont_h 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | typedef struct 46 | { 47 | SplayTreeNode super; 48 | char* name; /* Pointer to memory below roles. */ 49 | char* pwd; /* Pointer to memory below name. */ 50 | BaTime maxInactiveInterval; 51 | U16 noOfRoles; 52 | U16 maxUsers; 53 | BaBool recycle; 54 | BaBool pwdIsHA1; 55 | /* Roles array must be last. */ 56 | U16 roles[1]; /* List of roles. Roles are translated into unique numbers. */ 57 | } JUser; 58 | 59 | 60 | typedef struct 61 | { 62 | SplayTreeNode super; 63 | U16 roleId; 64 | char name[1]; 65 | } JRole; 66 | 67 | 68 | typedef struct JUserCont 69 | #ifdef __cplusplus 70 | : public UserIntf 71 | { 72 | JUserCont(AllocatorIntf* alloc); 73 | ~JUserCont(); 74 | void setUserDb(JVal* usersVal, JErr* err); 75 | #else 76 | { 77 | UserIntf super; /* We inherit from UserIntf. */ 78 | #endif 79 | 80 | SplayTree userdb; /* JUser */ 81 | SplayTree roledb; /* JRole */ 82 | AllocatorIntf* alloc; 83 | U32 noOfUsers; 84 | U16 nextUniqueRoleId; 85 | } JUserCont; 86 | 87 | #ifdef __cplusplus 88 | extern "C" { 89 | #endif 90 | #define JUserCont_findUser(o, uname) \ 91 | (JUser*)SplayTree_find(&(o)->userdb, uname) 92 | U16 JUserCont_role2Id(JUserCont* o, const char* roleName); 93 | U16* JUserCont_copyRoles(JUserCont* o,U16* roles,JVal* rolesVal,JErr* err); 94 | BA_API void JUserCont_constructor(JUserCont* o, AllocatorIntf* alloc); 95 | BA_API void JUserCont_destructor(JUserCont* o); 96 | BA_API void JUserCont_setUserDb(JUserCont* o, JVal* usersVal, JErr* err); 97 | #ifdef __cplusplus 98 | } 99 | inline JUserCont::JUserCont(AllocatorIntf* alloc) { 100 | JUserCont_constructor(this, alloc); } 101 | inline JUserCont::~JUserCont() { 102 | JUserCont_destructor(this); } 103 | inline void JUserCont::setUserDb(JVal* usersVal, JErr* err) { 104 | JUserCont_setUserDb(this, usersVal, err); } 105 | #endif 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /inc/IoIntfZipReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: IoIntfZipReader.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic LLC, 2006-2008 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | */ 38 | #ifndef __IoIntfZipReader_h 39 | #define __IoIntfZipReader_h 40 | 41 | #include 42 | #include 43 | 44 | /** The IoIntfZipReader, which implements the abstract ZipReader 45 | interface, makes it possible for a ZipIo to open a ZIP file via 46 | another IoInterface. 47 | @ingroup IO 48 | */ 49 | typedef struct IoIntfZipReader 50 | #ifdef __cplusplus 51 | : public ZipReader 52 | { 53 | IoIntfZipReader() {} 54 | 55 | /** The IoIntfZipReader constructor opens the Zip-File for reading. 56 | \param io the I/O-interface to read from. 57 | \param pathName the path+name to a ZIP file in the I/O-interface. 58 | */ 59 | IoIntfZipReader(IoIntf* io, const char* pathName); 60 | 61 | /** The destructor closes the file connection. 62 | */ 63 | ~IoIntfZipReader(); 64 | 65 | /** Close the file connection. 66 | */ 67 | int close(); 68 | 69 | /** Returns the last error code, if any. 70 | */ 71 | int getECode(); 72 | 73 | private: 74 | #else 75 | { 76 | ZipReader reader; 77 | #endif 78 | U32 currentOffset; 79 | IoIntf_SeekAndRead seekAndReadFp; 80 | ResIntfPtr fp; 81 | int lastECode; 82 | } IoIntfZipReader; 83 | 84 | #ifdef __cplusplus 85 | extern "C" { 86 | #endif 87 | BA_API void IoIntfZipReader_constructor(IoIntfZipReader* o, 88 | IoIntf* io, 89 | const char* pathName); 90 | BA_API int IoIntfZipReader_close(IoIntfZipReader* o); 91 | #define IoIntfZipReader_destructor(o) IoIntfZipReader_close(o); 92 | #define IoIntfZipReader_getECode(o) (o)->lastECode 93 | #ifdef __cplusplus 94 | } 95 | inline IoIntfZipReader::IoIntfZipReader(IoIntf* io, const char* pathName) { 96 | IoIntfZipReader_constructor(this, io, pathName); } 97 | inline IoIntfZipReader::~IoIntfZipReader() { 98 | IoIntfZipReader_destructor(this); } 99 | inline int IoIntfZipReader::close() { 100 | return IoIntfZipReader_close(this); } 101 | 102 | inline int IoIntfZipReader::getECode() { 103 | return IoIntfZipReader_getECode(this); } 104 | #endif 105 | 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /src/arch/Windows/ThreadLib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * 13 | * $Id: ThreadLib.c 4914 2021-12-01 18:24:30Z wini $ 14 | * 15 | * COPYRIGHT: Real Time Logic, 2002 - 2020 16 | * 17 | * This software is copyrighted by and is the sole property of Real 18 | * Time Logic LLC. All rights, title, ownership, or other interests in 19 | * the software remain the property of Real Time Logic LLC. This 20 | * software may only be used in accordance with the terms and 21 | * conditions stipulated in the corresponding license agreement under 22 | * which the software has been supplied. Any unauthorized use, 23 | * duplication, transmission, distribution, or disclosure of this 24 | * software is expressly forbidden. 25 | * 26 | * This Copyright notice may not be removed or modified without prior 27 | * written consent of Real Time Logic LLC. 28 | * 29 | * Real Time Logic LLC. reserves the right to modify this software 30 | * without notice. 31 | * 32 | * http://www.realtimelogic.com 33 | **************************************************************************** 34 | * 35 | * 36 | */ 37 | 38 | #ifndef BA_LIB 39 | #define BA_LIB 1 40 | #endif 41 | #ifndef WIN32_LEAN_AND_MEAN 42 | #define WIN32_LEAN_AND_MEAN 43 | #endif 44 | 45 | 46 | #include 47 | #include 48 | #include 49 | 50 | void 51 | _baClckGettime(BaTimeEx* spec) 52 | { 53 | FILETIME ft; 54 | ULARGE_INTEGER wintime; 55 | GetSystemTimeAsFileTime(&ft); 56 | wintime.LowPart = ft.dwLowDateTime; 57 | wintime.HighPart = ft.dwHighDateTime; 58 | wintime.QuadPart -= 116444736000000000i64; /* 1jan1601 to 1jan1970 */ 59 | spec->sec = wintime.QuadPart / 10000000i64; /* seconds */ 60 | spec->nsec = wintime.QuadPart % 10000000i64 *100; /* nano-seconds */ 61 | spec->offset=0; 62 | } 63 | 64 | 65 | static unsigned __stdcall Thread_threadStart(void* self) 66 | { 67 | Thread* thread = (Thread*)self; 68 | thread->runnable(thread); 69 | return 0; 70 | } 71 | 72 | BA_API void 73 | Thread_constructor( 74 | Thread* o, Thread_Run r, ThreadPriority priority, int stackSize) 75 | { 76 | unsigned threadid; 77 | HANDLE h; 78 | int prioNT; 79 | 80 | switch(priority) { 81 | case ThreadPrioLowest: prioNT = THREAD_PRIORITY_LOWEST; break; 82 | case ThreadPrioLow: prioNT = THREAD_PRIORITY_BELOW_NORMAL; break; 83 | case ThreadPrioNormal: prioNT = THREAD_PRIORITY_NORMAL; break; 84 | case ThreadPrioHigh: prioNT = THREAD_PRIORITY_ABOVE_NORMAL; break; 85 | case ThreadPrioHighest: prioNT = THREAD_PRIORITY_HIGHEST; break; 86 | default: baAssert(0); prioNT = THREAD_PRIORITY_NORMAL; break; 87 | } 88 | 89 | h = (HANDLE) _beginthreadex(NULL, stackSize, Thread_threadStart, o, 90 | CREATE_SUSPENDED, &threadid); 91 | 92 | if (h && h != (HANDLE)-1) { 93 | if (prioNT != THREAD_PRIORITY_NORMAL) 94 | SetThreadPriority(h, prioNT); 95 | 96 | o->id = h; /* unfortunate name clash */ 97 | o->runnable = r; 98 | } 99 | else { 100 | o->id = (HANDLE)-1; 101 | o->runnable = NULL; 102 | } 103 | } 104 | 105 | 106 | BA_API void Thread_destructor(Thread* o) 107 | { 108 | if (o->id && o->id != (HANDLE)-1) { 109 | CloseHandle(o->id); 110 | o->id = (HANDLE)-1; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /inc/arch/INTEGRITY/ThreadLibArch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: ThreadLibArch.h 4915 2021-12-01 18:26:55Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2011 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | */ 35 | 36 | #ifndef ThreadLib_hpp 37 | #define ThreadLib_hpp 38 | 39 | #include 40 | #include 41 | 42 | #define BA_OS_CHECK 43 | 44 | #if defined(NDEBUG) && !defined(BA_OS_CHECK) 45 | #define Thread_ce(x) x 46 | #else 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | BA_API void Thread_cef(Error status, const char* file, int line); 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #define Thread_ce(x) Thread_cef(x, __FILE__, __LINE__) 55 | #endif 56 | 57 | 58 | typedef struct ThreadMutexBase 59 | { 60 | Value tid; /* Lock owner */ 61 | LocalMutex mutex; 62 | } ThreadMutexBase; 63 | 64 | #define ThreadMutex_constructor(o) \ 65 | Thread_ce(CreateLocalMutex(&(o)->mutex)) 66 | 67 | #define ThreadMutex_destructor(o) \ 68 | Thread_ce(CloseLocalMutex((o)->mutex)) 69 | 70 | #define ThreadMutex_set(o) do {\ 71 | Thread_ce(WaitForLocalMutex((o)->mutex));\ 72 | Thread_ce(GetTaskUniqueId(CurrentTask(), &(o)->tid));\ 73 | } while(0) 74 | 75 | #define ThreadMutex_release(o) do{\ 76 | (o)->tid=0;\ 77 | Thread_ce(ReleaseLocalMutex((o)->mutex));\ 78 | } while(0) 79 | 80 | #ifdef __cplusplus 81 | extern "C" { 82 | #endif 83 | int ThreadMutex_isOwner(ThreadMutex* o); 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | 89 | 90 | typedef struct { 91 | Semaphore sem; 92 | } ThreadSemaphoreBase; 93 | 94 | #define ThreadSemaphore_constructor(o) Thread_ce(CreateSemaphore(0, &(o)->sem)) 95 | #define ThreadSemaphore_destructor(o) Thread_ce(CloseSemaphore((o)->sem)) 96 | #define ThreadSemaphore_wait(o) Thread_ce(WaitForSemaphore((o)->sem)) 97 | #define ThreadSemaphore_signal(o) Thread_ce(ReleaseSemaphore((o)->sem)) 98 | 99 | 100 | 101 | 102 | typedef struct ThreadBase 103 | { 104 | Task task; 105 | Thread_Run runnable; 106 | } ThreadBase; 107 | 108 | 109 | 110 | #define Thread_sleep(milliseconds) usleep(1000*milliseconds) 111 | #define Thread_start(o) Thread_ce(RunTask((o)->task)) 112 | #define Thread_destructor(o) Thread_ce(CommonCloseTask((o)->task)) 113 | 114 | #ifdef __cplusplus 115 | extern "C" { 116 | #endif 117 | BA_API void Thread_constructor( 118 | ThreadBase* o, Thread_Run r, ThreadPriority priority, int stackSize); 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /src/arch/Quadros/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Building Barracuda Embedded Web/Application Server for Quadros and Treck TCP/IP 3 | 4 | * Memory allocation 5 | * Zlib compression 6 | * Time function 7 | * Example code 8 | 9 | 10 | ----------------------------- Prerequisite 11 | View the Barracuda Web Server and Barracuda Application Server Setup 12 | Tutorial video: http://youtu.be/1NqHB79cfpY 13 | 14 | 15 | ----------------------------- Memory allocation 16 | 17 | The Barracuda Server (BA) requires a memory allocator. 18 | When using the LSP plugin, it is important to have a malloc 19 | implementation with an efficient realloc function. The allocation 20 | functions used by BA, which are defined in TargConfig.h, are 21 | therefore configured to use dlmalloc. Consequently, you must include 22 | dlmalloc in the build. It is however possible to redefine the allocation 23 | functions in TargConfig.h if you prefer to use a different allocator. 24 | 25 | -- To use dmalloc 26 | 27 | Include xrc\malloc\dlmalloc.c in your build. 28 | 29 | From your startup code, initiate the allocator as follows: 30 | 31 | extern void init_dlmalloc(char* heapstart, char* heapend); 32 | static char poolBuf[500*1024]; /* Minimum 500K when using LSP */ 33 | init_dlmalloc(poolBuf, poolBuf + sizeof(poolBuf)); 34 | 35 | 36 | ----------------------------- The Zlib compression library 37 | 38 | Barracuda requires the ZLIB inflate/deflate library. You can use the 39 | standard zlib library or build your application with our modified 40 | version: xrc\zip\BaZlib.c 41 | 42 | 43 | ----------------------------- Time function 44 | 45 | You must create the following function, which is used by BA. 46 | 47 | unsigned long baGetUnixTime(void); 48 | 49 | The function must return the number of seconds since January 1970. 50 | UNIX time: https://en.wikipedia.org/wiki/Unix_time 51 | 52 | The time logic required for the function can be setup by creating a 53 | periodic one second tick using the Quadros kernel call 54 | KS_SetCounterAcc. 55 | 56 | The base value for the timer can be setup at system start by using a 57 | hardware clock or by designing a Simple Network Time Protocol (SNTP) 58 | client. 59 | 60 | We provide a SNTP C code example in the Barracuda Server HTML 61 | documentation under section: Manual -> C & C++ -> Examples -> Network 62 | Client. 63 | 64 | 65 | ----------------------------- Example startup code 66 | 67 | #include 68 | #include 69 | 70 | /* xrc\malloc\dlmalloc.c. */ 71 | extern void init_dlmalloc(char* heapstart, char* heapend); 72 | 73 | /* The Barracuda examples entry function. Link with one of 74 | the examples. 75 | */ 76 | extern void barracuda(void); 77 | 78 | 79 | static void 80 | displayFatalError(const char* eMsg, 81 | BaFatalErrorCodes ecode1, 82 | unsigned int ecode2, 83 | const char* file, 84 | int line) 85 | { 86 | // Do error handling 87 | } 88 | 89 | static void 90 | myErrHandler(BaFatalErrorCodes ecode1, 91 | unsigned int ecode2, 92 | const char* file, 93 | int line) 94 | { 95 | displayFatalError("Fatal error in Barracuda", ecode1, ecode2, file, line); 96 | } 97 | 98 | 99 | static void 100 | writeHttpTrace(char* buf, int bufLen) 101 | { 102 | buf[bufLen]=0; /* Zero terminate. Bufsize is at least bufLen+1. */ 103 | //Emit buffer 104 | } 105 | 106 | 107 | /* The Barracuda Quadros socket dispatcher thread. 108 | Create and start this thread at startup. 109 | */ 110 | void barracudaThread(void) 111 | { 112 | static char baPoolBuf[500*1024]; /* Minimum 500K when using LSP */ 113 | /* IMPORTANT: Do this before any Barracuda calls */ 114 | init_dlmalloc(baPoolBuf, baPoolBuf + sizeof(baPoolBuf)); 115 | 116 | HttpTrace_setFLushCallback(writeHttpTrace); 117 | HttpServer_setErrHnd(myErrHandler); 118 | barracuda(); /* Run the Barracuda example code. Function never returns. */ 119 | } 120 | 121 | 122 | /* Implement a function that returns seconds since Jan 1970 123 | */ 124 | unsigned long baGetUnixTime(void) 125 | { 126 | return seconds since jan 1970; 127 | } 128 | -------------------------------------------------------------------------------- /inc/arch/NET/embOSIP/HttpCfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ____ _________ __ _ 3 | * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____ 4 | * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/ 5 | * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__ 6 | * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/ 7 | * /____/ 8 | * 9 | * Barracuda Embedded Web-Server 10 | * 11 | **************************************************************************** 12 | * HEADER 13 | * 14 | * $Id: HttpCfg.h 245 2006-10-16 14:07:04Z wini $ 15 | * 16 | * COPYRIGHT: Real Time Logic, 2002 - 2004 17 | * 18 | * This software is copyrighted by and is the sole property of Real 19 | * Time Logic LLC. All rights, title, ownership, or other interests in 20 | * the software remain the property of Real Time Logic LLC. This 21 | * software may only be used in accordance with the terms and 22 | * conditions stipulated in the corresponding license agreement under 23 | * which the software has been supplied. Any unauthorized use, 24 | * duplication, transmission, distribution, or disclosure of this 25 | * software is expressly forbidden. 26 | * 27 | * This Copyright notice may not be removed or modified without prior 28 | * written consent of Real Time Logic LLC. 29 | * 30 | * Real Time Logic LLC. reserves the right to modify this software 31 | * without notice. 32 | * 33 | * http://www.realtimelogic.com 34 | **************************************************************************** 35 | * 36 | * 37 | * embOS/IP 38 | */ 39 | #ifndef _HttpConfig_h 40 | #define _HttpConfig_h 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | /* Global embOS/IP macros that conflict with the C++ wrappers */ 48 | #ifdef __cplusplus 49 | #undef send 50 | #endif 51 | 52 | 53 | /* Not implemented due to limitations in the TCP/IP stack 54 | */ 55 | #define NO_ASYNCH_RESP 56 | 57 | 58 | /*********************************************************************** 59 | * The HttpSocket API 60 | ***********************************************************************/ 61 | #define SocketHandle SOCKTYPE 62 | 63 | typedef IP_fd_set fd_set; 64 | #define FD_ZERO(set) IP_FD_ZERO(set) 65 | #define FD_ISSET(so,set) IP_FD_ISSET(so,set) 66 | #define FD_SET(so,set) IP_FD_SET(so,set) 67 | #define FD_CLR(so,set) IP_FD_CLR(so,set) 68 | 69 | #define socketSend(s,d,l,f) send(s,(const char*)d,l,f) 70 | #define socketErrno(s) t_errno(s) 71 | #define socketClose closesocket 72 | #define HttpSocket_soReuseaddr(o,status) 73 | 74 | #define HttpSocket_setBlocking(o, status) do { \ 75 | int arg=0; \ 76 | *(status)=setsockopt((o)->hndl, SOL_SOCKET, SO_NONBLOCK, &arg, sizeof(arg)); \ 77 | (void)status; \ 78 | } while(0) 79 | 80 | #define HttpSocket_setNonblocking(o, status) do { \ 81 | int arg=1; \ 82 | *(status)=setsockopt((o)->hndl, SOL_SOCKET, SO_NONBLOCK, &arg, sizeof(arg)); \ 83 | (void)status; \ 84 | } while(0) 85 | 86 | #define HttpSocket_wouldBlock(o, status) do { \ 87 | int opt; \ 88 | getsockopt((o)->hndl, SOL_SOCKET, SO_ERROR, &opt, sizeof(opt)); \ 89 | *(status) = (opt == EWOULDBLOCK) ? TRUE : FALSE; \ 90 | } while(0) 91 | 92 | 93 | #define HttpSockaddr_gethostbyname(o, host, useIp6, status) _HttpSockaddr_gethostbyname(o, host, useIp6, status) 94 | #define HttpSockaddr_gethostbynameIp4(o, host, status) _HttpSockaddr_gethostbyname(o, host, FALSE, status) 95 | 96 | 97 | /* Include the default HttpSocket functions */ 98 | #include 99 | 100 | 101 | #ifdef __cplusplus 102 | extern "C" { 103 | #endif 104 | void _HttpSockaddr_gethostbyname(HttpSockaddr *o, const char *host, BaBool useIp6, int *status); 105 | #ifdef __cplusplus 106 | } 107 | #endif 108 | 109 | #endif 110 | --------------------------------------------------------------------------------