ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
system.h File Reference

Cross-platform system functions interface for ascii-chat. More...

Go to the source code of this file.

Macros

#define SAFE_IGNORE_PRINTF_RESULT(expr)   ((void)(expr))
 
#define PATH_DELIM   '/'
 Platform-specific path separator character.
 
#define PATH_SEPARATOR_STR   "/"
 
#define PATH_ENV_SEPARATOR   ":"
 Platform-specific PATH environment variable separator.
 
#define FILE_PERM_PRIVATE   0600
 File permission: Private (owner read/write only)
 
#define DIR_PERM_PRIVATE   0700
 Directory permission: Private (owner read/write/execute only)
 
#define FILE_PERM_PUBLIC_READ   0644
 File permission: Public read, owner write.
 
#define FILE_PERM_MASK   0777
 Permission mask for all permissions.
 
#define PLATFORM_MAX_PATH_LENGTH   4096
 Maximum path length supported by the operating system.
 
#define PLATFORM_ACCESS_EXISTS   0
 Access modes for platform_access()
 
#define PLATFORM_ACCESS_WRITE   2
 Check if file/directory is writable.
 
#define PLATFORM_ACCESS_READ   4
 Check if file/directory is readable.
 

Typedefs

typedef void(* signal_handler_t) (int)
 Signal handler function type.
 
typedef bool(* console_ctrl_handler_t) (console_ctrl_event_t event)
 Console control handler callback type.
 
typedef bool(* backtrace_frame_filter_t) (const char *frame)
 Callback type for filtering backtrace frames.
 

Enumerations

enum  console_ctrl_event_t {
  CONSOLE_CTRL_C = 0 , CONSOLE_CTRL_BREAK = 1 , CONSOLE_CLOSE = 2 , CONSOLE_LOGOFF = 3 ,
  CONSOLE_SHUTDOWN = 4
}
 Console control event types (cross-platform Ctrl+C handling) More...
 

Functions

asciichat_error_t platform_init (void)
 Initialize platform-specific subsystems.
 
void platform_cleanup (void)
 Cleanup platform-specific subsystems.
 
void platform_sleep_ms (unsigned int ms)
 Sleep for a specified number of milliseconds.
 
uint64_t platform_get_monotonic_time_us (void)
 Get monotonic time in microseconds.
 
asciichat_error_t platform_localtime (const time_t *timer, struct tm *result)
 Platform-safe localtime wrapper.
 
asciichat_error_t platform_gtime (const time_t *timer, struct tm *result)
 Platform-safe gmtime wrapper.
 
int platform_get_pid (void)
 Get the current process ID.
 
const char * platform_get_username (void)
 Get the current username.
 
signal_handler_t platform_signal (int sig, signal_handler_t handler)
 Set a signal handler.
 
bool platform_set_console_ctrl_handler (console_ctrl_handler_t handler)
 Register a console control handler (for Ctrl+C, etc.)
 
const char * platform_getenv (const char *name)
 Get an environment variable value.
 
int platform_setenv (const char *name, const char *value)
 Set an environment variable.
 
int platform_isatty (int fd)
 Check if a file descriptor is a terminal.
 
const char * platform_ttyname (int fd)
 Get the name of the terminal associated with a file descriptor.
 
int platform_fsync (int fd)
 Synchronize a file descriptor to disk.
 
int platform_backtrace (void **buffer, int size)
 Get a backtrace of the current call stack.
 
char ** platform_backtrace_symbols (void *const *buffer, int size)
 Convert backtrace addresses to symbol names.
 
void platform_backtrace_symbols_free (char **strings)
 Free symbol array returned by platform_backtrace_symbols()
 
void platform_install_crash_handler (void)
 Install crash handlers for the application.
 
void platform_print_backtrace_symbols (const char *label, char **symbols, int count, int skip_frames, int max_frames, backtrace_frame_filter_t filter)
 Print pre-resolved backtrace symbols with consistent formatting.
 
int platform_format_backtrace_symbols (char *buffer, size_t buffer_size, const char *label, char **symbols, int count, int skip_frames, int max_frames, backtrace_frame_filter_t filter)
 Format pre-resolved backtrace symbols to a buffer.
 
void platform_print_backtrace (int skip_frames)
 Print a backtrace of the current call stack.
 
asciichat_error_t platform_memcpy (void *dest, size_t dest_size, const void *src, size_t count)
 Platform-safe memcpy wrapper.
 
asciichat_error_t platform_memset (void *dest, size_t dest_size, int ch, size_t count)
 Platform-safe memset wrapper.
 
asciichat_error_t platform_memmove (void *dest, size_t dest_size, const void *src, size_t count)
 Platform-safe memmove wrapper.
 
asciichat_error_t platform_strcpy (char *dest, size_t dest_size, const char *src)
 Platform-safe strcpy wrapper.
 
asciichat_error_t platform_resolve_hostname_to_ipv4 (const char *hostname, char *ipv4_out, size_t ipv4_out_size)
 Resolve hostname to IPv4 address.
 
asciichat_error_t platform_load_system_ca_certs (char **pem_data_out, size_t *pem_size_out)
 Load system CA certificates for TLS/HTTPS.
 
bool platform_is_binary_in_path (const char *bin_name)
 Check if a binary is available in the system PATH.
 
void platform_cleanup_binary_path_cache (void)
 Cleanup the binary PATH cache.
 
bool platform_get_executable_path (char *exe_path, size_t path_size)
 Get the path to the current executable.
 
bool platform_get_temp_dir (char *temp_dir, size_t path_size)
 Get the system temporary directory path.
 
bool platform_get_cwd (char *cwd, size_t path_size)
 Get the current working directory of the process.
 
int platform_access (const char *path, int mode)
 Check file/directory access permissions.
 
Safe String Formatting Functions
int safe_snprintf (char *buffer, size_t buffer_size, const char *format,...)
 Safe version of snprintf that ensures null termination.
 
int safe_fprintf (FILE *stream, const char *format,...)
 Safe version of fprintf.
 

Detailed Description

Cross-platform system functions interface for ascii-chat.

Definition in file system.h.