ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
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 NONSTRING   /* nothing */
#define FATAL(code, ...)
 Exit with error code and custom message, with stack trace in debug builds.
#define MIN(a, b)
 Return the minimum of two values.
#define MAX(a, b)
 Return the maximum of two values.
#define ARRAY_SIZE(arr)
 Calculate the number of elements in an array.
#define RUN_BURST_AND_THROTTLE(burst_ns, throttle_ns, code_block)
#define ALLOC_MALLOC(size)
#define ALLOC_CALLOC(count, size)
#define ALLOC_REALLOC(ptr, size)
#define ALLOC_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)
#define SAFE_MALLOC_ALIGNED(size, alignment, cast)
#define SAFE_MALLOC_SIMD(size, cast)
#define SAFE_CALLOC_SIMD(count, size, cast)
#define SAFE_FREE(ptr)
#define SAFE_MALLOC_DEFER_FREE(name, size, cast)
#define SAFE_CALLOC_DEFER_FREE(name, count, size, cast)
#define SAFE_FCLOSE(fp)
#define UNTRACKED_MALLOC(size, cast)
#define UNTRACKED_FREE(ptr)
#define SAFE_STRNCPY(dst, src, size)
#define SAFE_STRDUP(dst, src)
#define SAFE_GETENV(name)
#define SAFE_SSCANF(str, format, ...)
#define SAFE_STRERROR(errnum)
#define SAFE_MEMCPY(dest, dest_size, src, count)
#define SAFE_MEMSET(dest, dest_size, ch, count)
#define SAFE_MEMMOVE(dest, dest_size, src, count)
#define SAFE_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, ...)
#define SAFE_BUFFER_SIZE(buffer_size, 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,...)
asciichat_error_t asciichat_shared_init (const char *log_file, bool is_client, bool quiet_startup)
 Initialize common subsystems shared by client and server.
void asciichat_shared_destroy (void)
 Clean up shared library subsystems.

Variables

int g_argc
 Global argc for early argument inspection (e.g., –color flag detection) Set by main() for access from lib/platform/terminal.c during early execution.
char ** g_argv
 Global argv for early argument inspection (e.g., –color flag detection) Set by main() for access from lib/platform/terminal.c during early execution.
bool g_color_flag_passed
 Was –color explicitly passed in command-line arguments? Set by options_init() before RCU is initialized, used by terminal_should_color_output().
bool g_color_flag_value
 Value of –color flag (true if –color was in argv) Set by options_init() before RCU is initialized, used by terminal_should_color_output().

Detailed Description

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

Definition in file common.h.