diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cc25cc..64721e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,7 @@ option(TESSESFRAMEWORK_ENABLE_NETWORKING "Enable Networking" ON) option(TESSESFRAMEWORK_ENABLE_THREADING "Enable Threading" ON) option(TESSESFRAMEWORK_ENABLE_SQLITE "Enable sqlite (embedded in source)" ON) option(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS "Enable sago platformfolders (embedded in source)" ON) +option(TESSESFRAMEWORK_ENABLE_PROCESS "Enable process api" ON) if(TESSESFRAMEWORK_DEFINE_SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS) add_definitions(-DSDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS=1) @@ -144,6 +145,10 @@ target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENAB endif() if(TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_PLATFORMFOLDERS) +endif() +if(TESSESFRAMEWORK_ENABLE_PROCESS) +target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_PROCESS) + endif() target_include_directories(${TessesFramework_TARGET} PUBLIC diff --git a/README.md b/README.md index f4d67fa..2907c7e 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ sudo make install ## What libraries have I embeded from other people - [HodwardHinnart's date](https://github.com/HowardHinnant/date) (in folder src/HodwardHinnart_date, modified tz.cpp to point to correct header) +- [PlatformFolders](https://github.com/sago007/PlatformFolders) (in folder src/Platform/sago, modified to conditionally disable for GEKKO, NX etc) +- [Sqlite 3](https://www.sqlite.org/) (in folder src/Serialization/sqlite, modified for GEKKO, NX etc, uses the amalgamation) ## Dependencies - [mbedtls](https://github.com/Mbed-TLS/mbedtls) @@ -27,4 +29,3 @@ sudo make install ## Resources used from others - [ca-certificate.crt (from ubuntu)](ca-certificate.crt) -- [TanoheSans-Regular.ttf (license OFL)](font/License-OFL.txt) diff --git a/TessesFrameworkFeatures.h.in b/TessesFrameworkFeatures.h.in index c5cd465..558552f 100644 --- a/TessesFrameworkFeatures.h.in +++ b/TessesFrameworkFeatures.h.in @@ -22,6 +22,9 @@ #if defined(TESSES_FRAMEWORK_FLAG_@TESSESFRAMEWORK_LOGTOFILE@) && !defined(TESSESFRAMEWORK_LOGTOFILE) #define TESSESFRAMEWORK_LOGTOFILE #endif +#if defined(TESSES_FRAMEWORK_FLAG_@TESSESFRAMEWORK_ENABLE_PROCESS@) && !defined(TESSESFRAMEWORK_ENABLE_PROCESS) +#define TESSESFRAMEWORK_ENABLE_PROCESS +#endif #undef TESSES_FRAMEWORK_FLAG_OFF #undef TESSES_FRAMEWORK_FLAG_ON diff --git a/src/Platform/Process.cpp b/src/Platform/Process.cpp index 7a67d53..a070926 100644 --- a/src/Platform/Process.cpp +++ b/src/Platform/Process.cpp @@ -73,7 +73,7 @@ namespace Tesses::Framework::Platform { } - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) #else int stdin_strm; int stdout_strm; @@ -91,7 +91,7 @@ namespace Tesses::Framework::Platform { - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) #else this->stdin_strm=-1; @@ -105,7 +105,7 @@ namespace Tesses::Framework::Platform { HANDLE strm; bool writing; bool eos; - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) #else int strm; @@ -120,7 +120,7 @@ namespace Tesses::Framework::Platform { this->writing = writing; this->eos = false; } - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) #else ProcessStream(int strm, bool writing) { @@ -134,7 +134,7 @@ namespace Tesses::Framework::Platform { //TODO: Implement for WIN32 #if defined(_WIN32) return this->strm == NULL || eos; - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) return true; #else return this->strm < 0 || eos; @@ -145,7 +145,7 @@ namespace Tesses::Framework::Platform { //TODO: Implement for WIN32 #if defined(_WIN32) return !writing && this->strm != NULL; - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) return false; #else return !writing && this->strm > -1; @@ -157,7 +157,7 @@ namespace Tesses::Framework::Platform { #if defined(_WIN32) return writing && this->strm != NULL; - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) return false; #else return writing && this->strm > -1; @@ -177,7 +177,7 @@ namespace Tesses::Framework::Platform { this->eos = true; } return (size_t)dataR; - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) return 0; #else if(this->strm < 0 || this->eos && writing) return 0; @@ -199,7 +199,7 @@ namespace Tesses::Framework::Platform { return 0; return (size_t)dataW; - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) return 0; #else if(this->strm < 0 || !writing) return 0; @@ -242,7 +242,9 @@ namespace Tesses::Framework::Platform { this->exited = true; return true; } - #else + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) + return true; + #else int r; if (waitpid(this->hidden.GetField()->pid, &r, WNOHANG) != -1) { @@ -282,8 +284,8 @@ namespace Tesses::Framework::Platform { CloseHandle(p->stdin_strm); p->stdin_strm = NULL; } - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) - + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) + #else if (p->stdin_strm > -1) { @@ -313,8 +315,8 @@ namespace Tesses::Framework::Platform { CloseHandle(p->pi.hProcess); CloseHandle(p->pi.hThread); - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) - + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) + #else if (!this->exited) { @@ -496,7 +498,8 @@ CreateProcessW( ); */ return true; - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) + return false; #else @@ -646,7 +649,8 @@ CreateProcessW( else TerminateProcess(this->hidden.GetField()->pi.hProcess,-1); - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) + #else kill(this->hidden.GetField()->pid,signal); #endif @@ -664,7 +668,8 @@ CreateProcessW( this->exited = true; return (int)ret; - #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #elif defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) + return -1; #else int r; @@ -681,7 +686,8 @@ CreateProcessW( Tesses::Framework::Streams::Stream* Process::GetStdinStream() { if (this->exited) return nullptr; - #if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) + return nullptr; #else return new ProcessStream(this->hidden.GetField()->stdin_strm,true); @@ -691,8 +697,8 @@ CreateProcessW( { if (this->exited) return nullptr; - #if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) - return nullptr; + #if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) + return nullptr; #else return new ProcessStream(this->hidden.GetField()->stdout_strm,false); #endif @@ -701,7 +707,7 @@ CreateProcessW( { if (this->exited) return nullptr; - #if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) + #if defined(GEKKO) || defined(__PS2__) || defined(__SWITCH__) || !defined(TESSESFRAMEWORK_ENABLE_PROCESS) return nullptr; #else return new ProcessStream(this->hidden.GetField()->stderr_strm,false); diff --git a/src/Platform/sago/platform_folders.cpp b/src/Platform/sago/platform_folders.cpp index ed4ffd7..5327725 100644 --- a/src/Platform/sago/platform_folders.cpp +++ b/src/Platform/sago/platform_folders.cpp @@ -30,9 +30,9 @@ SOFTWARE. Modified by Mike Nolan for this project I modified it to return home directory and conditionally compile for systems that are not GEKKO / NX etc */ - -#if !defined(SAGO_DISABLE) #include "platform_folders.h" +#if !defined(SAGO_DISABLE) + #include #include #include diff --git a/src/Streams/PtyStream.cpp b/src/Streams/PtyStream.cpp index d5caf7e..2163ca1 100644 --- a/src/Streams/PtyStream.cpp +++ b/src/Streams/PtyStream.cpp @@ -1,5 +1,5 @@ #include "TessesFramework/Streams/PtyStream.hpp" -#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) +#if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS) #include #include #include @@ -10,7 +10,7 @@ namespace Tesses::Framework::Streams { PtyStream::PtyStream(WindowSize windowSize,std::string filename, std::vector args, std::vector env) { - #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) + #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS) this->wS = windowSize; this->eos=false; winsize sz; @@ -80,7 +80,7 @@ namespace Tesses::Framework::Streams { size_t PtyStream::Read(uint8_t* buff, size_t sz) { if(this->eos) return 0; - #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) + #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS) auto res = read(this->socket, buff,sz); if(res == -1) @@ -96,7 +96,7 @@ namespace Tesses::Framework::Streams { } size_t PtyStream::Write(const uint8_t* buff, size_t sz) { - #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) + #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS) auto res = write(this->socket, buff,sz); return res; #else @@ -109,7 +109,7 @@ namespace Tesses::Framework::Streams { } void PtyStream::Resize(WindowSize windowSize) { - #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) + #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS) this->wS = windowSize; winsize sz; sz.ws_col =(unsigned short)windowSize.Columns; @@ -123,7 +123,7 @@ namespace Tesses::Framework::Streams { PtyStream::~PtyStream() { this->eos=true; - #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) + #if !defined(GEKKO) && !defined(__PS2__) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__FreeBSD__) && defined(TESSESFRAMEWORK_ENABLE_PROCESS) close(this->socket); kill((pid_t)this->pid,SIGHUP);