ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
wasm/system.c
Go to the documentation of this file.
1
11#ifndef __EMSCRIPTEN__
12#error "This file is for WASM/Emscripten builds only"
13#endif
14
17#include <ascii-chat/common.h>
20#include <ascii-chat/util/ip.h>
26#include <stdlib.h>
27#include <string.h>
28#include <stdio.h>
29#include <stdarg.h>
30#include <ascii-chat/atomic.h>
31#include <sys/types.h>
32#include <sys/stat.h>
33#include <unistd.h>
34
35// ============================================================================
36// WASM-Specific Implementations
37// ============================================================================
38
39const char *platform_getenv(const char *name) {
40 (void)name;
41 // Environment variables not supported in WASM browser context
42 // Calling getenv() causes "memory access out of bounds" errors
43 return NULL;
44}
45
46const char *platform_strerror(int errnum) {
47 return strerror(errnum);
48}
49
50int platform_setenv(const char *name, const char *value) {
51 (void)name;
52 (void)value;
53 return -1; // Not supported in WASM
54}
55
56int platform_unsetenv(const char *name) {
57 (void)name;
58 return -1; // Not supported in WASM
59}
60
61pid_t platform_get_pid(void) {
62 return 1; // WASM runs in browser - no process ID concept
63}
64
65// ============================================================================
66// I/O Redirection for WASM Terminal
67// ============================================================================
68
72ssize_t platform_write(int fd, const void *buf, size_t count) {
73 if (!buf || count == 0) {
74 // Don't warn about these - it's a valid case (empty write)
75 return 0;
76 }
77
78 // Use the default write()
79 return write(fd, buf, count);
80}
81
82// ============================================================================
83// Include Generic Implementations
84// ============================================================================
85// Generic implementations (safe_snprintf, safe_fprintf, platform_print_backtrace_symbols, etc.)
86// are provided by the generic system.c which is included here
87#include "../system.c"
DLL export/import macros for cross-platform symbol visibility.
⚠️‼️ Comprehensive thread-local error context system for ascii-chat
⚛️ Atomic operations abstraction layer with debug tracking
Common buffer size definitions.
⚙️ Common definitions, error codes, macros, and types shared throughout the application
int platform_setenv(const char *name, const char *value)
Set an environment variable.
Definition wasm/system.c:50
pid_t platform_get_pid(void)
Get the current process ID.
Definition wasm/system.c:61
const char * platform_getenv(const char *name)
Get an environment variable value.
Definition wasm/system.c:39
const char * platform_strerror(int errnum)
Get human-readable error message for a system error code.
Definition wasm/system.c:46
ssize_t platform_write(int fd, const void *buf, size_t count)
Safe file write (write replacement)
Definition wasm/system.c:72
int platform_unsetenv(const char *name)
Remove an environment variable.
Definition wasm/system.c:56
⚙️ Unified options parsing system for ascii-chat with builder pattern and lock-free access
🌍 IP Address Parsing and Formatting Utilities
Private implementation helpers for platform abstraction layer.
Symbol Resolution Cache for Backtrace Addresses.
⏱️ High-precision timing utilities using sokol_time.h and uthash
🔤 UTF-8 Encoding and Decoding Utilities
🔤 String Manipulation and Shell Escaping Utilities