ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
system.c
Go to the documentation of this file.
1
10
11#ifndef __EMSCRIPTEN__
12#error "This file is for WASM/Emscripten builds only"
13#endif
14
15#include <ascii-chat/common.h>
18#include <ascii-chat/util/ip.h>
19#include <libplatform/util/string.h>
22#include <libplatform/symbols.h>
23#include <stdlib.h>
24#include <string.h>
25#include <stdio.h>
26#include <stdarg.h>
27#include <sys/types.h>
28#include <sys/stat.h>
29#include <unistd.h>
30
31// ============================================================================
32// WASM-Specific Implementations
33// ============================================================================
34
35int platform_execute_subprocess(const char *executable, const char **argv, char *output_buffer, size_t output_size, bool (*cancel)(void *), void *data) {
36 (void)executable;
37 (void)argv;
38 (void)output_buffer;
39 (void)output_size;
40 (void)cancel;
41 (void)data;
42 return -1;
43}
44
45const char *platform_getenv(const char *name) {
46 (void)name;
47 // Environment variables not supported in WASM browser context
48 // Calling getenv() causes "memory access out of bounds" errors
49 return NULL;
50}
51
52const char *platform_strerror(int errnum) {
53 return strerror(errnum);
54}
55
56int platform_setenv(const char *name, const char *value) {
57 (void)name;
58 (void)value;
59 return -1; // Not supported in WASM
60}
61
62int platform_unsetenv(const char *name) {
63 (void)name;
64 return -1; // Not supported in WASM
65}
66
67pid_t platform_get_pid(void) {
68 return 1; // WASM runs in browser - no process ID concept
69}
70
71// ============================================================================
72// I/O Redirection for WASM Terminal
73// ============================================================================
74
78ssize_t platform_write(int fd, const void *buf, size_t count) {
79 if (!buf || count == 0) {
80 // Don't warn about these - it's a valid case (empty write)
81 return 0;
82 }
83
84 // Use the default write()
85 return write(fd, buf, count);
86}
87
88// ============================================================================
89// Include Generic Implementations
90// ============================================================================
91// Generic implementations (safe_snprintf, safe_fprintf, platform_print_backtrace_symbols, etc.)
92// are provided by the generic system.c which is included here
93#include "../../../deps/ascii-chat-deps/libplatform/lib/system.c"
Synchronized per-thread pending error stacks and value snapshots. SET_ERRNO pushes,...
Common buffer size definitions.
⚙️ Common definitions, error codes, macros, and types shared throughout the application
🌍 IP Address Parsing and Formatting Utilities
🔤 String Manipulation and Shell Escaping Utilities
int platform_setenv(const char *name, const char *value)
Definition system.c:56
pid_t platform_get_pid(void)
Definition system.c:67
int platform_execute_subprocess(const char *executable, const char **argv, char *output_buffer, size_t output_size, bool(*cancel)(void *), void *data)
Definition system.c:35
const char * platform_getenv(const char *name)
Definition system.c:45
const char * platform_strerror(int errnum)
Definition system.c:52
ssize_t platform_write(int fd, const void *buf, size_t count)
Definition system.c:78
int platform_unsetenv(const char *name)
Definition system.c:62
⏱️ High-precision timing utilities using sokol_time.h and uthash
🔤 UTF-8 Encoding and Decoding Utilities