Overhaul cmake configuration, add console api, fix http code that caused issues with cgi-bin

This commit is contained in:
2026-05-27 03:02:16 -05:00
parent 266ef5f830
commit 8413c67ec6
177 changed files with 20088 additions and 17948 deletions

View File

@@ -1,26 +1,43 @@
/*
TessesFramework a library to make C++ easier for me, used in CrossLang:
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "Stream.hpp"
namespace Tesses::Framework::Streams
{
class BufferedStream : public Stream
{
private:
std::shared_ptr<Stream> strm;
uint8_t* buffer;
size_t bufferSize;
size_t offset;
size_t read;
public:
BufferedStream(std::shared_ptr<Stream> strm, size_t bufferSize=1024);
bool EndOfStream();
bool CanRead();
bool CanWrite();
size_t Read(uint8_t* buff, size_t sz);
size_t Write(const uint8_t* buff, size_t sz);
namespace Tesses::Framework::Streams {
class BufferedStream : public Stream {
private:
std::shared_ptr<Stream> strm;
uint8_t *buffer;
size_t bufferSize;
size_t offset;
size_t read;
~BufferedStream();
void Close();
};
public:
BufferedStream(std::shared_ptr<Stream> strm, size_t bufferSize = 1024);
bool EndOfStream();
bool CanRead();
bool CanWrite();
size_t Read(uint8_t *buff, size_t sz);
size_t Write(const uint8_t *buff, size_t sz);
}
~BufferedStream();
void Close();
};
} // namespace Tesses::Framework::Streams

View File

@@ -1,33 +1,51 @@
#pragma once
#include "Stream.hpp"
#include "../Uuid.hpp"
/*
TessesFramework a library to make C++ easier for me, used in CrossLang:
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
namespace Tesses::Framework::Streams
{
class ByteReader {
std::shared_ptr<Stream> strm;
public:
std::shared_ptr<Stream> GetStream();
ByteReader(std::shared_ptr<Stream> strm);
uint8_t ReadU8();
uint16_t ReadU16BE();
uint16_t ReadU16LE();
uint32_t ReadU32BE();
uint32_t ReadU32LE();
uint64_t ReadU64BE();
uint64_t ReadU64LE();
int8_t ReadI8();
int16_t ReadI16BE();
int16_t ReadI16LE();
int32_t ReadI32BE();
int32_t ReadI32LE();
int64_t ReadI64BE();
int64_t ReadI64LE();
float ReadF32BE();
float ReadF32LE();
double ReadF64BE();
double ReadF64LE();
Uuid ReadUuid();
void ReadUuid(Uuid& uuid);
};
}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "../Uuid.hpp"
#include "Stream.hpp"
namespace Tesses::Framework::Streams {
class ByteReader {
std::shared_ptr<Stream> strm;
public:
std::shared_ptr<Stream> GetStream();
ByteReader(std::shared_ptr<Stream> strm);
uint8_t ReadU8();
uint16_t ReadU16BE();
uint16_t ReadU16LE();
uint32_t ReadU32BE();
uint32_t ReadU32LE();
uint64_t ReadU64BE();
uint64_t ReadU64LE();
int8_t ReadI8();
int16_t ReadI16BE();
int16_t ReadI16LE();
int32_t ReadI32BE();
int32_t ReadI32LE();
int64_t ReadI64BE();
int64_t ReadI64LE();
float ReadF32BE();
float ReadF32LE();
double ReadF64BE();
double ReadF64LE();
Uuid ReadUuid();
void ReadUuid(Uuid &uuid);
};
} // namespace Tesses::Framework::Streams

View File

@@ -1,32 +1,49 @@
/*
TessesFramework a library to make C++ easier for me, used in CrossLang:
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "Stream.hpp"
#include "../Uuid.hpp"
namespace Tesses::Framework::Streams
{
class ByteWriter {
std::shared_ptr<Stream> strm;
public:
std::shared_ptr<Stream> GetStream();
ByteWriter(std::shared_ptr<Stream> strm);
void WriteU8(uint8_t v);
void WriteU16BE(uint16_t v);
void WriteU16LE(uint16_t v);
void WriteU32BE(uint32_t v);
void WriteU32LE(uint32_t v);
void WriteU64BE(uint64_t v);
void WriteU64LE(uint64_t v);
void WriteI8(int8_t v);
void WriteI16BE(int16_t v);
void WriteI16LE(int16_t v);
void WriteI32BE(int32_t v);
void WriteI32LE(int32_t v);
void WriteI64BE(int64_t v);
void WriteI64LE(int64_t v);
void WriteF32BE(float v);
void WriteF32LE(float v);
void WriteF64BE(double v);
void WriteF64LE(double v);
void WriteUuid(const Uuid& uuid);
};
}
#include "Stream.hpp"
namespace Tesses::Framework::Streams {
class ByteWriter {
std::shared_ptr<Stream> strm;
public:
std::shared_ptr<Stream> GetStream();
ByteWriter(std::shared_ptr<Stream> strm);
void WriteU8(uint8_t v);
void WriteU16BE(uint16_t v);
void WriteU16LE(uint16_t v);
void WriteU32BE(uint32_t v);
void WriteU32LE(uint32_t v);
void WriteU64BE(uint64_t v);
void WriteU64LE(uint64_t v);
void WriteI8(int8_t v);
void WriteI16BE(int16_t v);
void WriteI16LE(int16_t v);
void WriteI32BE(int32_t v);
void WriteI32LE(int32_t v);
void WriteI64BE(int64_t v);
void WriteI64LE(int64_t v);
void WriteF32BE(float v);
void WriteF32LE(float v);
void WriteF64BE(double v);
void WriteF64LE(double v);
void WriteUuid(const Uuid &uuid);
};
} // namespace Tesses::Framework::Streams

View File

@@ -1,28 +1,46 @@
/*
TessesFramework a library to make C++ easier for me, used in CrossLang:
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "Stream.hpp"
#include <cstdio>
namespace Tesses::Framework::Streams
{
class FileStream : public Stream {
bool canRead;
bool canWrite;
bool canSeek;
bool owns;
FILE* f;
void SetMode(std::string mode);
public:
FileStream(std::filesystem::path p, std::string mode);
FileStream(FILE* f, bool owns, std::string mode , bool canSeek=true);
size_t Read(uint8_t* buff, size_t sz);
size_t Write(const uint8_t* buff, size_t sz);
bool EndOfStream();
bool CanRead();
bool CanWrite();
bool CanSeek();
int64_t GetPosition();
void Flush();
void Seek(int64_t pos, SeekOrigin whence);
~FileStream();
void Close();
};
}
namespace Tesses::Framework::Streams {
class FileStream : public Stream {
bool canRead;
bool canWrite;
bool canSeek;
bool owns;
FILE *f;
void SetMode(std::string mode);
public:
FileStream(std::filesystem::path p, std::string mode);
FileStream(FILE *f, bool owns, std::string mode, bool canSeek = true);
size_t Read(uint8_t *buff, size_t sz);
size_t Write(const uint8_t *buff, size_t sz);
bool EndOfStream();
bool CanRead();
bool CanWrite();
bool CanSeek();
int64_t GetPosition();
void Flush();
void Seek(int64_t pos, SeekOrigin whence);
~FileStream();
void Close();
};
} // namespace Tesses::Framework::Streams

View File

@@ -1,22 +1,40 @@
/*
TessesFramework a library to make C++ easier for me, used in CrossLang:
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "Stream.hpp"
namespace Tesses::Framework::Streams
{
class MemoryStream : public Stream {
std::vector<uint8_t> buffer;
size_t offset;
bool writable;
public:
MemoryStream(bool isWritable);
std::vector<uint8_t>& GetBuffer();
size_t Read(uint8_t* buff, size_t sz);
size_t Write(const uint8_t* buff, size_t sz);
bool CanRead();
bool CanWrite();
bool CanSeek();
int64_t GetLength();
int64_t GetPosition();
void Seek(int64_t pos, SeekOrigin whence);
void Close();
};
}
namespace Tesses::Framework::Streams {
class MemoryStream : public Stream {
std::vector<uint8_t> buffer;
size_t offset;
bool writable;
public:
MemoryStream(bool isWritable);
std::vector<uint8_t> &GetBuffer();
size_t Read(uint8_t *buff, size_t sz);
size_t Write(const uint8_t *buff, size_t sz);
bool CanRead();
bool CanWrite();
bool CanSeek();
int64_t GetLength();
int64_t GetPosition();
void Seek(int64_t pos, SeekOrigin whence);
void Close();
};
} // namespace Tesses::Framework::Streams

View File

@@ -1,64 +1,87 @@
/*
TessesFramework a library to make C++ easier for me, used in CrossLang:
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "Stream.hpp"
namespace Tesses::Framework::Streams
{
class NetworkStream;
namespace Tesses::Framework::Streams {
class NetworkStream;
class TcpServer {
int32_t sock;
bool owns;
bool valid;
public:
TcpServer(int32_t backlog);
TcpServer(int32_t sock,bool owns);
TcpServer(uint16_t port, int32_t backlog);
TcpServer(std::string ip, uint16_t port, int32_t backlog);
TcpServer(std::string unixPath,int32_t backlog);
std::shared_ptr<NetworkStream> GetStream(std::string& ip, uint16_t& port);
uint16_t GetPort();
~TcpServer();
bool IsValid();
void Close();
};
enum class SocketType {
ST_IPv4_TCP,
ST_IPv4_UDP,
ST_IPv6_TCP,
ST_IPv6_UDP,
ST_UNIX
};
class NetworkStream : public Stream {
int32_t sock;
bool owns;
bool success;
bool endOfStream;
public:
bool DataAvailable(int timeout=0);
bool EndOfStream();
bool CanRead();
bool CanWrite();
NetworkStream(SocketType type);
NetworkStream(std::string unixPath,bool isServer);
NetworkStream(std::string ipOrFqdn, uint16_t port, bool datagram,bool broadcast,bool supportIPv6);
NetworkStream(int32_t sock, bool owns);
uint16_t GetPort();
void Listen(int32_t backlog);
void Bind(std::string ip, uint16_t port);
void SetBroadcast(bool bC);
void SetReuseAddress(bool reuse);
void SetReusePort(bool reuse);
void SetMulticastTTL(uint8_t ttl);
void SetMulticastMembership(std::string multicastAddress, std::string ifaceIP="0.0.0.0");
std::shared_ptr<NetworkStream> Accept(std::string& ip, uint16_t& port);
size_t Read(uint8_t* buff, size_t sz);
size_t Write(const uint8_t* buff, size_t sz);
size_t ReadFrom(uint8_t* buff, size_t sz, std::string& ip, uint16_t& port);
size_t WriteTo(const uint8_t* buff, size_t sz, std::string ip, uint16_t port);
static std::vector<std::pair<std::string,std::string>> GetIPs(bool ipV6=false);
class TcpServer {
int32_t sock;
bool owns;
bool valid;
~NetworkStream();
void SetNoDelay(bool noDelay);
void Close();
};
}
public:
TcpServer(int32_t backlog);
TcpServer(int32_t sock, bool owns);
TcpServer(uint16_t port, int32_t backlog);
TcpServer(std::string ip, uint16_t port, int32_t backlog);
TcpServer(std::string unixPath, int32_t backlog);
std::shared_ptr<NetworkStream> GetStream(std::string &ip, uint16_t &port);
uint16_t GetPort();
~TcpServer();
bool IsValid();
void Close();
};
enum class SocketType {
ST_IPv4_TCP,
ST_IPv4_UDP,
ST_IPv6_TCP,
ST_IPv6_UDP,
ST_UNIX
};
class NetworkStream : public Stream {
int32_t sock;
bool owns;
bool success;
bool endOfStream;
public:
bool DataAvailable(int timeout = 0);
bool EndOfStream();
bool CanRead();
bool CanWrite();
NetworkStream(SocketType type);
NetworkStream(std::string unixPath, bool isServer);
NetworkStream(std::string ipOrFqdn, uint16_t port, bool datagram,
bool broadcast, bool supportIPv6);
NetworkStream(int32_t sock, bool owns);
uint16_t GetPort();
void Listen(int32_t backlog);
void Bind(std::string ip, uint16_t port);
void SetBroadcast(bool bC);
void SetReuseAddress(bool reuse);
void SetReusePort(bool reuse);
void SetMulticastTTL(uint8_t ttl);
void SetMulticastMembership(std::string multicastAddress,
std::string ifaceIP = "0.0.0.0");
std::shared_ptr<NetworkStream> Accept(std::string &ip, uint16_t &port);
size_t Read(uint8_t *buff, size_t sz);
size_t Write(const uint8_t *buff, size_t sz);
size_t ReadFrom(uint8_t *buff, size_t sz, std::string &ip, uint16_t &port);
size_t WriteTo(const uint8_t *buff, size_t sz, std::string ip,
uint16_t port);
static std::vector<std::pair<std::string, std::string>>
GetIPs(bool ipV6 = false);
~NetworkStream();
void SetNoDelay(bool noDelay);
void Close();
};
} // namespace Tesses::Framework::Streams

View File

@@ -1,30 +1,47 @@
/*
TessesFramework a library to make C++ easier for me, used in CrossLang:
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "Stream.hpp"
namespace Tesses::Framework::Streams
{
struct WindowSize {
uint16_t Width;
uint16_t Height;
uint16_t Columns;
uint16_t Rows;
};
class PtyStream : public Stream
{
int socket;
int64_t pid;
bool eos;
WindowSize wS;
public:
PtyStream(WindowSize sz,std::string filename, std::vector<std::string> args,std::vector<std::string> env);
bool EndOfStream();
bool CanRead();
bool CanWrite();
size_t Read(uint8_t* buff, size_t sz);
size_t Write(const uint8_t* buff, size_t sz);
void Resize(WindowSize sz);
WindowSize GetWindowSize();
~PtyStream();
void Close();
};
}
namespace Tesses::Framework::Streams {
struct WindowSize {
uint16_t Width;
uint16_t Height;
uint16_t Columns;
uint16_t Rows;
};
class PtyStream : public Stream {
int socket;
int64_t pid;
bool eos;
WindowSize wS;
public:
PtyStream(WindowSize sz, std::string filename,
std::vector<std::string> args, std::vector<std::string> env);
bool EndOfStream();
bool CanRead();
bool CanWrite();
size_t Read(uint8_t *buff, size_t sz);
size_t Write(const uint8_t *buff, size_t sz);
void Resize(WindowSize sz);
WindowSize GetWindowSize();
~PtyStream();
void Close();
};
} // namespace Tesses::Framework::Streams

View File

@@ -1,31 +1,45 @@
/*
TessesFramework a library to make C++ easier for me, used in CrossLang:
https://git.tesses.org/tesses50/crosslang Copyright (C) 2026 Mike Nolan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "../Common.hpp"
namespace Tesses::Framework::Streams
{
enum class SeekOrigin : uint8_t {
Begin=0,
Current=1,
End=2
};
class Stream {
public:
int32_t ReadByte();
void WriteByte(uint8_t b);
virtual bool EndOfStream();
virtual size_t Read(uint8_t* buff, size_t sz);
virtual size_t Write(const uint8_t* buff, size_t sz);
size_t ReadBlock(uint8_t* buff, size_t sz);
void WriteBlock(const uint8_t* buff, size_t sz);
virtual bool CanRead();
virtual bool CanWrite();
virtual bool CanSeek();
virtual int64_t GetPosition();
virtual int64_t GetLength();
virtual void Flush();
virtual void Seek(int64_t pos, SeekOrigin whence);
void CopyTo(std::shared_ptr<Stream> strm, size_t buffSize=1024);
void CopyToLimit(std::shared_ptr<Stream> strm,uint64_t len, size_t buffSize=1024);
virtual void Close();
virtual ~Stream();
};
}
namespace Tesses::Framework::Streams {
enum class SeekOrigin : uint8_t { Begin = 0, Current = 1, End = 2 };
class Stream {
public:
int32_t ReadByte();
void WriteByte(uint8_t b);
virtual bool EndOfStream();
virtual size_t Read(uint8_t *buff, size_t sz);
virtual size_t Write(const uint8_t *buff, size_t sz);
size_t ReadBlock(uint8_t *buff, size_t sz);
void WriteBlock(const uint8_t *buff, size_t sz);
virtual bool CanRead();
virtual bool CanWrite();
virtual bool CanSeek();
virtual int64_t GetPosition();
virtual int64_t GetLength();
virtual void Flush();
virtual void Seek(int64_t pos, SeekOrigin whence);
void CopyTo(std::shared_ptr<Stream> strm, size_t buffSize = 1024);
void CopyToLimit(std::shared_ptr<Stream> strm, uint64_t len,
size_t buffSize = 1024);
virtual void Close();
virtual ~Stream();
};
} // namespace Tesses::Framework::Streams