|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
🔧 Shared cross-platform system utilities (included by posix/system.c and windows/system.c) More...
Go to the source code of this file.
Data Structures | |
| struct | bin_cache_entry_t |
| Binary PATH cache entry structure for binary detection caching. More... | |
Macros | |
| #define | BIN_SUFFIX "" |
| #define | PLATFORM_MAX_PATH_LENGTH 4096 |
Functions | |
| void | platform_cleanup_binary_path_cache (void) |
| Cleanup the binary PATH cache. | |
| bool | platform_is_binary_in_path (const char *bin_name) |
| bool | platform_get_executable_path (char *exe_path, size_t path_size) |
| Get the path to the current executable. | |
| int | safe_snprintf (char *buffer, size_t buffer_size, const char *format,...) |
| Safe formatted string printing to buffer. | |
| int | safe_fprintf (FILE *stream, const char *format,...) |
| Safe formatted output to file stream. | |
| int | safe_vsnprintf (char *buffer, size_t buffer_size, const char *format, va_list ap) |
| Safe formatted string printing with va_list. | |
| 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 colored terminal output and plain log file output. | |
🔧 Shared cross-platform system utilities (included by posix/system.c and windows/system.c)
Definition in file system.c.
| #define PLATFORM_MAX_PATH_LENGTH 4096 |
Maximum path length supported by the operating system
Platform-specific values:
Note: Windows legacy MAX_PATH (260) is too restrictive for modern use. We use the extended-length limit instead.
| void platform_cleanup_binary_path_cache | ( | void | ) |
Cleanup the binary PATH cache.
Definition at line 304 of file system.c.
Referenced by server_main().
| bool platform_get_executable_path | ( | char * | exe_path, |
| size_t | path_size | ||
| ) |
Get the path to the current executable.
| exe_path | Buffer to store the executable path |
| path_size | Size of the buffer |
Definition at line 393 of file system.c.
| bool platform_is_binary_in_path | ( | const char * | bin_name | ) |
Definition at line 331 of file system.c.
References bin_cache_entry_t::bin_name, colored_string(), bin_cache_entry_t::in_path, and platform_strdup().
| 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 colored terminal output and plain log file output.
This is a cross-platform function that formats backtrace symbols with:
| label | Header label (e.g., "Backtrace") |
| symbols | Array of pre-resolved symbol strings |
| count | Number of symbols in the array |
| skip_frames | Number of frames to skip from the start |
| max_frames | Maximum frames to print (0 = unlimited) |
| filter | Optional filter callback to skip specific frames (NULL = no filtering) |
Definition at line 535 of file system.c.
References asciichat_thread_self(), colored_string(), log_file_msg(), log_get_template(), log_template_apply(), platform_get_monotonic_time_us(), and safe_snprintf().
Referenced by asciichat_fatal_with_context(), and asciichat_print_error_context().
| int safe_fprintf | ( | FILE * | stream, |
| const char * | format, | ||
| ... | |||
| ) |
Safe formatted output to file stream.
| stream | Output file stream |
| format | Printf-style format string |
Safely formats and prints output to a file stream. Returns the number of characters written, or -1 on error.
Definition at line 480 of file system.c.
References args.
Referenced by add_known_host(), asciichat_fatal_with_context(), asciichat_print_error_context(), log_init(), log_labeled(), log_msg(), log_plain_msg(), and webcam_print_init_error_help().
| int safe_snprintf | ( | char * | buffer, |
| size_t | buffer_size, | ||
| const char * | format, | ||
| ... | |||
| ) |
Safe formatted string printing to buffer.
| buffer | Output buffer |
| buffer_size | Size of output buffer |
| format | Printf-style format string |
Safely formats a string into a buffer with bounds checking. Uses platform_snprintf for cross-platform implementation. Returns the number of characters written (not including null terminator). Returns -1 if buffer is too small.
Definition at line 456 of file system.c.
References args, buffer_size, and platform_vsnprintf().
Referenced by acds_client_connect(), acds_identity_default_path(), acds_identity_fingerprint(), acds_main(), acds_string_generate(), add_client(), add_webrtc_client(), asciichat_instr_log_line(), asciichat_instr_log_pc(), build_github_gpg_url(), build_github_ssh_url(), build_gitlab_gpg_url(), build_gitlab_ssh_url(), capture_init(), check_gpg_key_expiry(), check_known_host(), check_known_host_no_identity(), colored_string(), colorize_log_message(), colorscheme_compile_scheme(), colorscheme_export_scheme(), config_load_and_apply(), create_client_render_threads(), crypto_get_rekey_status(), crypto_handshake_client_key_exchange(), crypto_handshake_server_auth_challenge(), crypto_handshake_server_start(), discovery_keys_fetch_github(), discovery_keys_fetch_gitlab(), discovery_keys_get_cache_path(), discovery_keys_save_cached(), display_mitm_warning(), expand_path(), find_similar_option_with_mode(), format_available_modes(), format_bytes_pretty(), format_duration_ns(), format_gpg_key_display(), format_mode_names(), format_option_default_value_str(), format_public_key(), format_uptime_hms(), get_current_time_formatted(), get_discovery_database_dir(), get_known_hosts_path(), get_log_dir(), get_manpage_template(), gpg_agent_sign(), gpg_get_public_key(), gpg_sign_detached_ed25519(), gpg_sign_with_key(), gpg_verify_detached_ed25519(), gpg_verify_signature(), gpg_verify_signature_with_binary(), https_get(), ice_format_candidate(), image_print_color(), log_mmap_write(), log_recolor_plain_entry(), log_template_apply(), manpage_content_generate_environment(), manpage_content_generate_environment_with_manual(), manpage_content_generate_examples(), manpage_content_generate_options(), manpage_content_generate_positional(), manpage_content_generate_usage(), manpage_fmt_write_title(), manpage_merger_generate_synopsis(), manpage_merger_generate_usage(), nat_upnp_get_address(), options_config_calculate_max_col_width(), options_config_print_options_sections_with_width(), options_config_print_usage(), options_format_default_value(), options_init(), options_preset_unified(), options_print_help_for_mode(), parallel_connect(), parse_client_address(), parse_color_filter(), parse_color_mode(), parse_gpg_key(), parse_gpg_key_binary(), parse_gpg_keys_from_response(), parse_log_level(), parse_palette_chars(), parse_palette_type(), parse_port_option(), parse_private_key(), parse_render_mode(), parse_server_bind_address(), parse_ssh_private_key(), path_validate_user_path(), platform_print_backtrace_symbols(), prompt_unknown_host(), prompt_unknown_host_no_identity(), pubkey_to_hex(), query_init(), remove_known_host(), rgb_to_truecolor_ansi(), sdp_generate_answer(), sdp_generate_offer(), server_main(), session_capture_create(), session_network_capture_create(), stats_logger_thread(), test_get_binary_path(), turn_generate_credentials(), and yt_dlp_extract_stream_url().
| int safe_vsnprintf | ( | char * | buffer, |
| size_t | buffer_size, | ||
| const char * | format, | ||
| va_list | ap | ||
| ) |
Safe formatted string printing with va_list.
| buffer | Output buffer (can be NULL if buffer_size is 0 for size calculation) |
| buffer_size | Size of output buffer |
| format | Printf-style format string |
| ap | Variable argument list |
Safely formats a string into a buffer with bounds checking using va_list. Uses platform_vsnprintf for cross-platform implementation. Returns the number of characters written (not including null terminator). Special case: NULL buffer with size 0 returns required buffer size for size calculation. Returns -1 if buffer is too small, format is invalid, or buffer is NULL with size > 0.
Definition at line 507 of file system.c.
References buffer_size, and platform_vsnprintf().
Referenced by disconnect_client_for_bad_data(), format_message(), log_file_msg(), log_mmap_write(), log_msg(), log_plain_msg(), and str_printf().