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

Public platform utility API for string, memory, and file operations. More...

Go to the source code of this file.

Macros

#define PLATFORM_O_RDONLY   O_RDONLY
 Open file for reading only.
 
#define PLATFORM_O_WRONLY   O_WRONLY
 Open file for writing only.
 
#define PLATFORM_O_RDWR   O_RDWR
 Open file for reading and writing.
 
#define PLATFORM_O_CREAT   O_CREAT
 Create file if it doesn't exist.
 
#define PLATFORM_O_EXCL   O_EXCL
 Fail if file already exists (with O_CREAT)
 
#define PLATFORM_O_TRUNC   O_TRUNC
 Truncate file to zero length if it exists.
 
#define PLATFORM_O_APPEND   O_APPEND
 Append to end of file.
 
#define PLATFORM_O_BINARY   0
 Open file in binary mode (Windows)
 

Functions

int platform_snprintf (char *str, size_t size, const char *format,...)
 Safe string formatting (snprintf replacement)
 
int platform_vsnprintf (char *str, size_t size, const char *format, va_list ap)
 Safe variable-argument string formatting.
 
char * platform_strdup (const char *s)
 Duplicate string (strdup replacement)
 
char * platform_strndup (const char *s, size_t n)
 Duplicate string with length limit (strndup replacement)
 
int platform_strcasecmp (const char *s1, const char *s2)
 Case-insensitive string comparison.
 
int platform_strncasecmp (const char *s1, const char *s2, size_t n)
 Case-insensitive string comparison with length limit.
 
char * platform_strtok_r (char *str, const char *delim, char **saveptr)
 Thread-safe string tokenization (strtok_r replacement)
 
size_t platform_strlcpy (char *dst, const char *src, size_t size)
 Safe string copy with size tracking (strlcpy)
 
size_t platform_strlcat (char *dst, const char *src, size_t size)
 Safe string concatenation with size tracking (strlcat)
 
int platform_strncpy (char *dst, size_t dst_size, const char *src, size_t count)
 Safe string copy with explicit size bounds (strncpy replacement)
 
void * platform_aligned_alloc (size_t alignment, size_t size)
 Allocate aligned memory.
 
void platform_aligned_free (void *ptr)
 Free aligned memory.
 
void platform_memory_barrier (void)
 Perform memory barrier/fence operation.
 
const char * platform_strerror (int errnum)
 Get thread-safe error string.
 
int platform_get_last_error (void)
 Get last platform error code.
 
void platform_set_last_error (int error)
 Set platform error code.
 
int platform_open (const char *pathname, int flags,...)
 Safe file open (open replacement)
 
FILE * platform_fopen (const char *filename, const char *mode)
 Safe file open stream (fopen replacement)
 
FILE * platform_fdopen (int fd, const char *mode)
 Convert file descriptor to stream (fdopen replacement)
 
ssize_t platform_read (int fd, void *buf, size_t count)
 Safe file read (read replacement)
 
int platform_close (int fd)
 Safe file close (close replacement)
 
int platform_unlink (const char *pathname)
 Delete/unlink file.
 
int platform_chmod (const char *pathname, int mode)
 Change file permissions/mode.
 
Cross-Platform Utility Functions
ssize_t platform_write (int fd, const void *buf, size_t count)
 Platform-safe write function.
 

Detailed Description

Public platform utility API for string, memory, and file operations.

Definition in file platform/util.h.