System Documentation // 2026-03-10
The `SimpleConflictsFixer` is a specialized header designed to prevent naming collisions between the Windows API and modern C/C++ libraries or custom user code.
It specifically targets common function names that `windows.h` defines as macros, which often "pollute" the global namespace.
->rarr; Platform Specific: This module only executes logic if_WIN32is defined.
-->rarr;rdsh; Target Version: Forces_WIN32_WINNTto0x0600(Windows Vista or higher).
->rarr;WinCloseWindow->rarr;WinShowCursor->rarr;WinRectangle->rarr;WinDrawTextmacros are#undefafter headers are loaded.to prevent COM conflicts.The following system headers are wrapped by this fixer to ensure they do not break external logic:
1. winsock2.h
2. windows.h
3. objbase.h
High Priority
This header should be included BEFORE other QOL modules that utilize networking or graphics to ensure symbols like "Rectangle" remain available for custom use.
`SimpleFS` provides a high-level API for file manipulation, path normalization, and data extraction.
It abstracts away the differences between Windows and POSIX path separators to ensure code portability.
->rarr; Platform Paths: Automatically detects _WIN32 to set PATH_SEP ('\') and ALT_SEP ('/').
-->rarr;rdsh; Normalizer: The internal _fs_normalize function automatically converts slashes to the system default.
char_to_int(ptr, len)char_to_float(ptr, len)% Efficiency: All path-based functions use a 256-byte internal buffer for normalization. %
fs_size(filename) | Returns file size in bytes, or -1 if the file is missing.fs_read(filename) | Reads an entire file into a malloc'd buffer.fs_write(filename, data) | Overwrites a file with the provided string.fs_append(filename, data) | Appends string data to the end of a file.fs_delete(filename) | Removes a file from the system.fs_exists(filename) | Returns 1 if the file can be opened for reading.fs_mkdir(dirname) | Creates a directory. Returns 1 for success; 0 for fail.fs_dirremove(dirname) | Removes a directory. Returns 1 for success; 0 for fail.fs_listdir(dirname) | Lists the contents of a directory. Returns a string fomratted like: "somedirectory:dir|somefile:file"Note: String-based extraction assumes the data is null-terminated.
* **fs_count** : Counts occurrences of a specific character in a string buffer.
* **fs_getline** : Retrieves a specific line number from a string (Uses a 512-byte static buffer).
* **fs_readto** : Reads a file from the start up to a specific byte offset.
* **fs_readamount** : Reads a specific chunk of a file defined by start and end bytes.
// Reading a specific line from a file
char* content = fs_read("logs.txt");
char* line2 = fs_getline(content, 2);
// Remember to free(content)!
IMPORTANT!
Functions like fs_read, fs_readto, fs_readamount, and fs_listdir allocate memory dynamically. You MUST call free() on the returned pointer to avoid memory leaks.
`SimpleHTTP` provides a straightforward API for hosting local web servers or making external client requests.
It supports both standard TCP and SSL/HTTPS connections through modular definitions.
->rarr; Cross-Platform: Includes socket shims for Windows (winsock2) and POSIX (sys/socket).
-->rarr;rdsh; Buffer Control: Uses MAX_HTTP_BUF (default 65536) for all incoming/outgoing data.
HTTP_SSL : Define to enable HTTPS hosting and SSL termination.HTTP_CURL : Define to enable the http_request client function.% Lifecycle: Host ->rarr; Listen (ReqReady) ->rarr; Reply %
http_host(port) | Starts a standard HTTP server on the specified port.http_host_ssl(port, cert, key) | Starts an HTTPS server using PEM certificate and key files.http_reqready() | Non-blocking check for new connections; returns 1 if a request is active.method and path.http_reply(html) | Sends an HTTP 200 OK response with the provided HTML string.State Logic: Access request data through the internal_http_reqstate.
* **http_is(path)** : Returns true if the current active request matches the specified path.
* **http_param(key)** : Extracts a URL parameter value (e.g., from "?id=123") into a static buffer.
// Simple Server Example
http_host(8080);
while(1) {
if (http_reqready()) {
if (http_is("/index")) http_reply("gt;Welcomegt;");
else http_reply("404 Not Found");
}
}
Note: Requires HTTP_CURL to be defined in your project.
* **http_request(url)** : Performs a GET request to the target URL and returns the response body.
High Priority
The http_reply function automatically handles closing the client socket and resetting the request state.
http_param and http_request use static or internal buffers. Copy the data if you need to preserve it across multiple calls.
`SimpleNet` is a lightweight, cross-platform socket wrapper designed for raw data transmission using both TCP and UDP protocols.
It manages an internal state of up to 10 concurrent connections and provides an abstracted interface for both Windows (Winsock2) and POSIX systems.
->rarr; Protocol Support: Supports both UDP (0) and TCP (1) modes.
-->rarr;rdsh; Cross-Platform: Handles net_close and net_errno shims automatically across platforms.
_net_fds[10] | Array of active socket descriptors._net_active[10] | Boolean flags tracking which connection IDs are in use._net_static_buf | Shared 65,536-byte buffer for incoming data.% Logic: Use unique IDs (0-9) to manage multiple concurrent sockets %
net_host(id, port, proto) | Sets up a listener (TCP) or binds a socket (UDP) on the given port.net_connect(id, host, port, proto) | Connects to a remote host.net_close(id) | Terminates the connection and clears the internal state.Non-Blocking: `net_read` uses non-blocking flags where available (e.g., MSG_DONTWAIT).
* **net_read(id)** : Checks for incoming data. If data exists, returns a pointer to _net_static_buf.
* **net_send(id, data)** : Sends a string to the connected remote peer.
* **net_send_to(id, host, port, data)** : Sends a UDP packet to a specific destination without a persistent connection.
Access the last client information through the _last_client[id] structure
* **net_get_ip(id)** : Returns the IP address of the last sender/client as a string.
* **net_get_port(id)** : Returns the port of the last sender/client as an integer.
// Simple UDP Echo Example
net_host(0, 5000, UDP);
while(1) {
char* msg = net_read(0);
if (msg) {
printf("Received: %s from %s\n", msg, net_get_ip(0));
net_send_to(0, net_get_ip(0), net_get_port(0), "ACK");
}
}
High Priority
Ensure that you call net_host or net_connect before attempting to read/write to a specific ID index!
The internal buffer _net_static_buf is shared across all IDs. If you need to preserve data between consecutive net_read calls across different IDs, you must copy the data to your own buffer.
SimpleParse is a specialized module for extracting data between markers and identifying function-like signatures within string buffers. It is designed for lightweight scripting or configuration parsing where a full regex engine is overkill.
->rarr; Context Aware: Returns a Parsed struct containing global offsets, line numbers, and column positions.
-->rarr;rdsh; Structural Parsing: Automatically separates a match into its "Full String", "Signature", and "Inner Content".
-->rarr;rdsh; Tokenized Arguments: Automatically parses comma-separated arguments into a pointer array for direct access.
% Memory: parselineadv performs heap allocations for arguments in conparsed. Use freeconparsed() to prevent memory leaks. %
Advanced Extraction: parselineadv is the primary engine for identifying lines and extracting their contents in one pass.
* Automatic Tokenization: When parselineadv detects parentheses (), it automatically populates the conparsed array by splitting content by commas.
* Memory Management: Because conparsed stores heap-allocated integers and strings, always call freeconparsed(&p) after processing the struct.
Advanced Parsing Example
const char* code = "something(1, \"Hello!\");";
Parsed p = parselineadv(code, 1);
Accessing parsed arguments:
int val = *(int*)p.conparsed[0];
char* str = (char*)p.conparsed[1];
Cleanup after use:
freeconparsed(&p);
$$High Priority$$
\ All string fields in the Parsed struct have a fixed limit of 256 characters. \
\ The conparsed array supports up to 64 arguments. \
$$$Warning!!$$$
Ensure the haystack buffer is null-terminated before passing it to any SimpleParse function to avoid memory overruns.
SimpleThreads is a zero-boilerplate, single-header library for C. It abstracts away the differences between Win32 API and POSIX Threads (pthreads) using an ID-based system.
->rarr; Uses a static pool of 256 thread slots.
-->rarr;rdsh; Automatic return type detection via C11 _Generic.
-->rarr;rdsh; Argument strings are automatically parsed and passed to functions.
fn returns int, double, or void*args as a comma-separated stringvoid* (Must be cast by user)1 if thread is active, 0 if finished/emptyseconds)Launching background tasks and retrieving data:
int my_calc(int a, int b) {
return a + b;
}
char* my_name(char* input) {
return input;
}
// Inside main
spawnthread(my_calc, "10, 20", 0);
spawnthread(my_name, "\"Ted\"", 1);
int res = *(int*)getreturn(0);
char* name = (char*)getreturn(1);
High Priority
Thread results for int and double are heap-allocated (boxed).
You must call getreturn() to retrieve the data and clear the slot!
Always use an ID between 0 and 255
Accessing an ID outside this range will result in no-op or corruption.
% Efficiency: Lightweight wrappers around native OS calls %
spawnthread(my_func, "5", 1)_st_pkt_st_entryisrunning(1)getreturn(1)_st_results[1]If you are referencing a specific return type, use int or void*.
->rarr; **Integers**: Pass as standard strings: "10, 20, 30"
->rarr; **Strings**: Wrap internal strings in escaped quotes: "\"Hello!\""
->rarr; **Empty**: Use an empty string "" for functions with no parameters.
`SimpleTools` provides cross-platform utility functions for string manipulation, memory inspection, and time tracking.
It operates independently and includes built-in shims for platform-specific timing.
->rarr; Cross-Platform: Automatically handles usleep and sleep for Windows and POSIX.
-->rarr;rdsh; Core Buffer: Default MAX_HTTP_BUF set to 65536.
hexdmp(void* ptr, int buflen)_str_replace_logic% Dynamic Memory: These functions return a malloc'd string. Always free() after use! %
str_replace_first | Replaces only the first match found. str_replace_all | Replaces every occurrence of the target string. str_replace_nth | Replaces a specific occurrence by index. str_replace_count | Replaces matches up to a specific count. str_replace_range | Replaces matches between a start and end index. Failsafe: Returns 0 (False) if input pointers are NULL.
* **str_starts** : Check if string begins with a prefix.
* **str_ends** : Check if string ends with a suffix.
* **str_contains** : Standard substring search.
* **str_is_numeric** : Validates if string consists only of digits.
Note: str_format uses a static allocation of MAX_HTTP_BUF.
// Formatting Examples
char* s = str_format("User ID: %d", 101);
str_upper(s); // "USER ID: 101"
str_trim(s); // Removes whitespace
**Time Tools**
* time_now() : Returns current date/time as "YYYY-MM-DD HH:MM:SS".
* time_unix() : Returns raw unix timestamp as a long.
use json_obj to build JSON strings with type-prefixing (s:string, i:int, f:float, b:bool).
// JSON Example
char* j = json_obj("s:name, i:age, b:active", "Ted", 21, 1);
// Returns: {"name":"Ted", "age":21, "active":true}
This header-only library provides fixed-size, stack-allocated large integer and floating-point structures. It leverages C11_Genericfor a unified printing interface and provides basic arithmetic operations for extreme-scale integers.
->rarr; Supports unsigned and signed integers from 32-bit up to 12,288-bit.
-->rarr;rdsh; Built on "limbs" ofu32(32-bit segments).
-->rarr;rdsh; Includes basic support for large-mantissa floating point via sfloat.
typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64;
typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64;
Generated via theDEF_STRUCTS(BITS, LIMBS)macro:
Pre-defined via DEF_STRUCTS for:
% 32 (1 limb), 64 (2 limbs), 128 (4 limbs), 256 (8 limbs), 512 (16 limbs), 1024 (32 limbs), 2048 (64 limbs), 4096 (128 limbs), 8192 (256 limbs), 12288 (384 limbs) %
The library uses slibprint and slibnfprint via C11 _Generic selection.
slibprint(val): Formatted decimal output.slibnfprint(val): "No-format" raw hex output.Focused on the 12288-bit (384 limb) implementations.
suint12288_add(res, a, b): suint12288_mul(res, a, b): suint12288_pow(res, base_val, exp): suint12288_tetrate(res, base, height): $$High Priority$$
Note: suint12288_tetrate uses current_val.limbs[0] as the exponent for the next layer.
This truncates the exponent to 32-bits during tetration.
Defined viaDEF_SHIFT(BITS, COUNT)macro.
$$$Critical Warning$$$
Shifting by a negative value or 0 returns immediately without modification.
% Memory: _internal_dec_ascii uses local u32 temp[count] and memcpy. %
% Buffer: char digits[5000] used for division-by-10 result extraction. %
// 1. Declare and Initialize to Zero
suint12288 big_val;
memset(&big_val, 0, sizeof(big_val));
// 2. Assign and Manipulate
big_val.limbs[0] = 1;
suint12288_shl(&big_val, 12000); // 2^12000
// 3. Print Results
printf("Decimal Value: ");
slibprint(big_val);