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

⚙️ Common definitions, error codes, macros, and types shared throughout the application More...

Go to the source code of this file.

Macros

#define ASCII_CHAT_APP_NAME   "ascii-chat"
 Application name for key comments ("ascii-chat")
 
#define PLATFORM_MAX_PATH_LENGTH   4096
 
#define FATAL(code, ...)   asciichat_fatal_with_context(code, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
 Exit with error code and custom message, with stack trace in debug builds.
 
#define ALLOC_MALLOC(size)   malloc(size)
 Return the minimum of two values.
 
#define ALLOC_CALLOC(count, size)   calloc((count), (size))
 
#define ALLOC_REALLOC(ptr, size)   realloc((ptr), (size))
 
#define ALLOC_FREE(ptr)   free(ptr)
 
#define ASCIICHAT_CHECK_AND_LOG(expr, ok_value, msg, ...)
 Check result and log error if operation failed.
 
Memory Debugging Macros
#define SAFE_MALLOC(size, cast)
 
#define SAFE_CALLOC(count, size, cast)
 
#define SAFE_REALLOC(ptr, size, cast)
 
#define TRACK_ALIGNED_ALLOC(ptr, size, file, line)   ((void)0)
 
#define SAFE_MALLOC_ALIGNED(size, alignment, cast)
 
#define SAFE_MALLOC_SIMD(size, cast)   SAFE_MALLOC_ALIGNED(size, 16, cast)
 
#define SAFE_CALLOC_SIMD(count, size, cast)
 
#define SAFE_FREE(ptr)
 
#define SAFE_FCLOSE(fp)
 
#define UNTRACKED_MALLOC(size, cast)
 
#define UNTRACKED_FREE(ptr)
 
#define SAFE_STRNCPY(dst, src, size)   platform_strlcpy((dst), (src), (size))
 
#define SAFE_STRDUP(dst, src)
 
#define SAFE_GETENV(name)   platform_getenv(name)
 
#define SAFE_SSCANF(str, format, ...)   sscanf(str, format, __VA_ARGS__)
 
#define SAFE_STRERROR(errnum)   platform_strerror(errnum)
 
#define SAFE_MEMCPY(dest, dest_size, src, count)   platform_memcpy((dest), (dest_size), (src), (count))
 
#define SAFE_MEMSET(dest, dest_size, ch, count)   platform_memset((dest), (dest_size), (ch), (count))
 
#define SAFE_MEMMOVE(dest, dest_size, src, count)   platform_memmove((dest), (dest_size), (src), (count))
 
#define SAFE_STRCPY(dest, dest_size, src)   platform_strcpy((dest), (dest_size), (src))
 
#define read_u16_unaligned   bytes_read_u16_unaligned
 
#define read_u32_unaligned   bytes_read_u32_unaligned
 
#define write_u16_unaligned   bytes_write_u16_unaligned
 
#define write_u32_unaligned   bytes_write_u32_unaligned
 
#define safe_size_mul   bytes_safe_size_mul
 
#define SAFE_SNPRINTF(buffer, buffer_size, ...)   (size_t)safe_snprintf((buffer), (buffer_size), __VA_ARGS__)
 
#define SAFE_BUFFER_SIZE(buffer_size, offset)    ((offset) < 0 || (size_t)(offset) >= (buffer_size) ? 0 : (buffer_size) - (size_t)(offset))
 Safe buffer size calculation for snprintf.
 
#define THREAD_CREATE_OR_RETURN(thread, func, arg)
 Create a thread or log error and return.
 
#define MUTEX_INIT_OR_RETURN(m)
 Initialize a mutex or log error and return.
 

Typedefs

typedef unsigned char uint8_t
 
typedef unsigned short uint16_t
 
typedef unsigned int uint32_t
 
typedef unsigned long long uint64_t
 

Functions

void asciichat_fatal_with_context (asciichat_error_t code, const char *file, int line, const char *function, const char *format,...)
 Exit with error code and context (used by FATAL macro)
 
asciichat_error_t asciichat_shared_init (const char *default_log_filename, bool is_client)
 Initialize common subsystems shared by client and server.
 

Detailed Description

⚙️ Common definitions, error codes, macros, and types shared throughout the application

Definition in file common.h.