|
C-Menu 0.2.9
A User Interface Toolkit
|
string manipulation, file handling, and error reporting. More...
Functions | |
| unsigned long | a_to_ul (const char *str) |
| Converts a string to an unsigned long long integer, with support for suffixes K, M, and G for kilobytes, megabytes, and gigabytes respectively. | |
| int | a_toi (char *s, bool *a_toi_error) |
| a safer alternative to atoi() for converting ASCII strings to integers. | |
| bool | base_name (char *buf, char *path) |
| Returns the base name of a file specification. | |
| size_t | canonicalize_file_spec (char *spec) |
| Removes quotes and trims at first space. | |
| bool | chrep (char *s, char old_chr, char new_chr) |
| Replaces all occurrences of old_chr in s with new_chr in place. | |
| int | destroy_argv (int argc, char **argv) |
| Deallocates memory allocated for argument strings in argv. | |
| bool | dir_name (char *buf, char *path) |
| Returns the directory name of a file specification. | |
| bool | expand_tilde (char *str, int path_maxlen) |
| Replaces "~/" in string with the user's home directory. | |
| char * | fdname (int fd, char *out_path) |
| Retrieves the file path associated with a given file descriptor. | |
| bool | file_spec_name (char *file_name, char *fs) |
| extracts the file name component of a file specification | |
| bool | file_spec_path (char *fp, char *fs) |
| extracts the path component of a file specification | |
| char * | format_local_timestamp (time_t t, char *buf, size_t n) |
| Formats a time_t as an ISO 8601 string in local time. | |
| bool | get_argp_doc_by_name (char *comment, const struct argp_option *options, const char *key_name) |
| Retrieves the documentation string for a given key name from an argp options array. | |
| char * | get_ip_addresses (char *ip_str, int maxlen) |
| Retrieves the IP addresses of the local machine and formats them into a string. | |
| char * | get_local_timestamp () |
| Returns the current local time as an ISO 8601 formatted string. | |
| char * | get_user_str (char *user_str, size_t maxlen) |
| Retrieves the current user's name and UID, and formats it into a string. | |
| bool | is_directory (const char *path) |
| Checks if the given path is a directory. | |
| bool | is_hex_str (char *str, int len) |
| Validates that a string consists of exactly len hexadecimal digits. | |
| bool | is_newer (char *control, char *fut) |
| Checks if the file specified by "fut" is newer than the file specified by "control". | |
| bool | is_symlink_to_dir (const char *path) |
| Checks if the given path is a symbolic link to a directory. | |
| bool | is_valid_regex (const char *pattern) |
| Checks if the given regular expression pattern is valid. | |
| char * | iso8601_time (char *buf, int n, time_t *t, bool local) |
| Formats a struct tm as an ISO 8601 string. | |
| bool | locate_file_in_path (char *file_spec, char *file_name) |
| Locates a file in the system PATH. | |
| bool | mk_dir (char *dir) |
| If directory doesn't exist, make it. | |
| bool | normalize_file_spec (char *fs) |
| replace backslashes with forward lashes | |
| void | open_cmenu_log () |
| Open new C-Menu log file. | |
| bool | parse_local_timestamp (const char *s, time_t *out) |
| Parses an ISO 8601 timestamp string in local time and converts it to time_t. | |
| char * | rep_substring (const char *org_s, const char *tgt_s, const char *rep_s) |
| Replace all occurrences of "tgt_s" in "org_s" with "rep_s". | |
| size_t | ssnprintf (char *buf, size_t buf_size, const char *format,...) |
| ssnprintf was designed to be a safer alternative to snprintf. | |
| bool | str_subc (char *d, char *s, char ReplaceChr, char *Withstr, int l) |
| Replaces "ReplaceChr" in "s" with "Withstr" in "d" won't copy more than "l" bytes to "d" Replaces all occurrences of a character in a string with another string, copying the result to a destination buffer. | |
| int | str_to_args (char **argv, char *arg_str, int max_args) |
| Converts a string into an array of argument strings. | |
| double | str_to_double (char *s) |
| converts string to double | |
| bool | str_to_lower (char *s) |
| Converts a string to lowercase. | |
| bool | str_to_upper (char *s) |
| Converts a string to uppercase. | |
| size_t | strip_ansi (char *d, char *s) |
| Strips ANSI SGR escape sequences (ending in 'm') from string s to d. | |
| bool | strip_quotes (char *s) |
| removes leading and trailing double quotes if present | |
| bool | stripz_quotes (char *s) |
| removes leading and trailing double quotes if present | |
| size_t | strnlf (char *s, size_t max_len) |
| terminates string with line feed | |
| size_t | strnz (char *s, size_t max_len) |
| terminates string at New Line, Carriage Return, or max_len | |
| size_t | strnz__cat (char *d, const char *s, size_t max_len) |
| safer alternative to strncat | |
| size_t | strnz__cpy (char *d, const char *s, size_t max_len) |
| safer alternative to strncpy | |
| char * | strnz_dup (char *s, size_t l) |
| Allocates memory for and duplicates string s up to length l or until line feed or carriage return. | |
| size_t | strz (char *s) |
| Terminates string at new line or carriage return. | |
| size_t | trim (char *s) |
| Trims leading and trailing spaces from string s in place. | |
| bool | trim_ext (char *buf, char *filename) |
| trims the file extension from "filename" and copies the result to "buf" | |
| bool | trim_path (char *dir) |
| Trims trailing spaces and slashes from directory path in place. | |
| void | ui_rect_set (UiRect *r, int y, int x, int h, int w) |
| Set the properties of a UiRect structure. | |
| bool | unstr_hex_clr (char *dst, char *str) |
| Validates that a string is a hex color code in the format "#RRGGBB". | |
| bool | verify_dir (char *spec, int imode) |
| Verifies that the directory specified by "spec" exists and is accessible with the permissions specified by "imode". | |
| bool | verify_file (char *in_spec, int imode) |
| Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified by "imode". | |
| int | wccp_to_str (wchar_t cp, uint8_t *buffer) |
| Converts a Unicode code point to a UTF-8 encoded string. | |
| void | write_cmenu_log (char *msg) |
| Write message to C-Menu log file with timestamp. | |
| void | write_cmenu_log_nt (char *msg) |
| Write message to C-Menu log file without timestamp. | |
string manipulation, file handling, and error reporting.
These functions provide common operations such as trimming strings, converting case, safely copying and concatenating strings, verifying file and directory access, and locating files in the system PATH. They are designed to be robust and handle edge cases gracefully, making them useful for a wide range of applications.
| unsigned long a_to_ul | ( | const char * | str | ) |
Converts a string to an unsigned long long integer, with support for suffixes K, M, and G for kilobytes, megabytes, and gigabytes respectively.
| str | - string to convert |
This function is useful for parsing human-readable file sizes or memory sizes that may include suffixes to indicate the scale of the value. If the string is invalid (e.g., contains non-numeric characters other than the optional suffix), this function returns 0. The caller must ensure that the input string is a valid representation of an unsigned long long integer with an optional suffix before calling this function.
Definition at line 793 of file futil.c.
| int a_toi | ( | char * | s, |
| bool * | a_toi_error ) |
a safer alternative to atoi() for converting ASCII strings to integers.
| s | is the input string |
| a_toi_error | is a pointer to a boolean that will be set to true if an error occurs during conversion, or false if the conversion is successful. |
Accepts positive integers only. Sets a_toi_error to (-1) on error
Definition at line 769 of file futil.c.
Referenced by parse_ansi_str().
| bool base_name | ( | char * | buf, |
| char * | path ) |
Returns the base name of a file specification.
| buf | - buffer to receive result |
| path | - file specification |
Definition at line 1123 of file futil.c.
Referenced by build_prompt(), exec_objects(), form_exec_receiver(), form_process(), init_form_files(), init_pick_files(), main(), and view_init_input().
| size_t canonicalize_file_spec | ( | char * | spec | ) |
Removes quotes and trims at first space.
| spec | - file specification to canonicalize |
Definition at line 1341 of file futil.c.
References strnz__cpy().
Referenced by locate_file_in_path(), verify_file(), and verify_spec_arg().
| bool chrep | ( | char * | s, |
| char | old_chr, | ||
| char | new_chr ) |
Replaces all occurrences of old_chr in s with new_chr in place.
| s | - string to modify |
| old_chr | - character to replace |
| new_chr | - character to insert |
Definition at line 750 of file futil.c.
Referenced by parse_menu_description().
| int destroy_argv | ( | int | argc, |
| char ** | argv ) |
Deallocates memory allocated for argument strings in argv.
| argc | - count of allocated vectors in argv |
| argv | - array of pointers to arguments |
Definition at line 494 of file futil.c.
Referenced by destroy_init(), destroy_view(), display_pick_help(), enter_file_spec(), exec_objects(), form_engine(), form_exec_receiver(), form_process(), init_pick(), menu_cmd_processor(), new_pick_view(), parse_opt_args(), view_display_help(), and view_init_input().
| bool dir_name | ( | char * | buf, |
| char * | path ) |
Returns the directory name of a file specification.
| buf | - buffer to receive result |
| path | - file specification |
Definition at line 1149 of file futil.c.
References strnz__cpy().
| bool expand_tilde | ( | char * | str, |
| int | path_maxlen ) |
Replaces "~/" in string with the user's home directory.
| str | - string to modify |
| path_maxlen | - maximum length of resulting string |
Definition at line 970 of file futil.c.
References rep_substring(), strnz__cat(), and strnz__cpy().
Referenced by enter_file_spec(), init_form_files(), init_pick_files(), init_view_files(), main(), mapp_initialization(), mk_dir(), process_config_file(), process_config_files(), read_theme(), verify_dir(), verify_file(), verify_spec_arg(), and view_init_input().
| char * fdname | ( | int | fd, |
| char * | out_path ) |
Retrieves the file path associated with a given file descriptor.
| fd | - file descriptor |
| out_path | - buffer to receive the file path |
This function uses the /proc filesystem to read the symbolic link corresponding to the file descriptor. It constructs the path to the symbolic link in /proc/self/fd/ and uses readlink to retrieve the actual file path. The caller must ensure that out_path has enough space to hold the resulting path. If readlink fails, this function returns -1 and does not modify out_path.
Definition at line 1054 of file futil.c.
Referenced by stdio_fdnames().
| bool file_spec_name | ( | char * | file_name, |
| char * | fs ) |
extracts the file name component of a file specification
| file_name | - name component to return |
| fs | - full file specification |
Definition at line 897 of file futil.c.
| bool file_spec_path | ( | char * | fp, |
| char * | fs ) |
extracts the path component of a file specification
| fp | - path component to return |
| fs | - full file specification |
Definition at line 870 of file futil.c.
| char * format_local_timestamp | ( | time_t | t, |
| char * | buf, | ||
| size_t | n ) |
Formats a time_t as an ISO 8601 string in local time.
| t | - time to format |
| buf | - buffer to receive formatted string |
| n | - size of buffer |
Definition at line 303 of file futil.c.
Referenced by debug_out(), and get_local_timestamp().
| bool get_argp_doc_by_name | ( | char * | comment, |
| const struct argp_option * | options, | ||
| const char * | key_name ) |
Retrieves the documentation string for a given key name from an argp options array.
| comment | - buffer to receive the documentation string |
| options | - array of argp_option structures to search |
| key_name | - the long option name or short option character |
Definition at line 176 of file futil.c.
References strnz__cpy().
Referenced by print_argp_doc().
| char * get_ip_addresses | ( | char * | ip_str, |
| int | maxlen ) |
Retrieves the IP addresses of the local machine and formats them into a string.
| ip_str | - buffer to receive formatted string of IP addresses |
| maxlen | - size of buffer |
This function uses getifaddrs to retrieve a linked list of network interfaces on the local machine. It iterates through the list and checks for interfaces with IPv4 addresses (AF_INET). For each valid interface, it converts the binary IP address to a human-readable string using inet_ntop and appends it to the provided buffer in the format "[interface-name-IP-address]". Multiple interfaces are separated by commas. The caller must ensure that ip_str has enough space to hold the resulting string. If getifaddrs fails, this function returns nullptr and does not modify the buffer.
Definition at line 354 of file futil.c.
References strnz__cat().
Referenced by debug_out().
| char * get_local_timestamp | ( | ) |
Returns the current local time as an ISO 8601 formatted string.
Definition at line 314 of file futil.c.
References format_local_timestamp().
Referenced by debug_out().
| char * get_user_str | ( | char * | user_str, |
| size_t | maxlen ) |
Retrieves the current user's name and UID, and formats it into a string.
| user_str | - buffer to receive formatted string |
| maxlen | - size of buffer |
This function uses getuid to retrieve the current user's UID, then uses getpwuid to get the corresponding passwd structure, which contains the user's name. It formats the user's name and UID into the provided buffer in the format "User: username (uid)\n". The caller must ensure that user_str has enough space to hold the resulting string. If getpwuid fails (e.g., if the UID does not exist), this function returns nullptr and does not modify the buffer.
Definition at line 327 of file futil.c.
References ssnprintf().
Referenced by debug_out().
| bool is_directory | ( | const char * | path | ) |
Checks if the given path is a directory.
| path | - path to check |
Definition at line 1372 of file futil.c.
Referenced by main().
| bool is_hex_str | ( | char * | str, |
| int | len ) |
Validates that a string consists of exactly len hexadecimal digits.
| str | - input string to validate |
| len | - expected number of hexadecimal digits |
This function checks that the input string contains only hexadecimal characters (0-9, A-F, a-f) and that the total number of hex digits matches the specified length. If the input string is valid, it returns true; otherwise, it returns false. The caller must ensure that the input string is not null and has at least one character before calling this function.
Definition at line 209 of file futil.c.
| bool is_newer | ( | char * | control, |
| char * | fut ) |
Checks if the file specified by "fut" is newer than the file specified by "control".
| control | - path to the control file |
| fut | - path to the file to compare against the control file |
This function uses the stat system call to retrieve the modification times of both files. It compares the modification time of "fut" with that of "control" and returns true if "fut" has a more recent modification time. If either file cannot be accessed or if any error occurs during the stat calls, this function returns false. The caller must ensure that both file paths are valid and that the files exist before calling this function.
Definition at line 160 of file futil.c.
| bool is_symlink_to_dir | ( | const char * | path | ) |
Checks if the given path is a symbolic link to a directory.
| path | - path to check |
Definition at line 1385 of file futil.c.
Referenced by main().
| bool is_valid_regex | ( | const char * | pattern | ) |
Checks if the given regular expression pattern is valid.
| pattern | - regular expression pattern to check |
Definition at line 1400 of file futil.c.
Referenced by main().
| char * iso8601_time | ( | char * | buf, |
| int | n, | ||
| time_t * | t, | ||
| bool | local ) |
Formats a struct tm as an ISO 8601 string.
| buf | - buffer to receive formatted string |
| n | - size of buffer |
| t | - struct tm to format |
| local | - if true, include local time zone offset; if false, use 'Z' for UTC |
Definition at line 264 of file futil.c.
| bool locate_file_in_path | ( | char * | file_spec, |
| char * | file_name ) |
Locates a file in the system PATH.
| file_spec | - buffer to receive located file specification |
| file_name | - name of file to locate |
Definition at line 1287 of file futil.c.
References canonicalize_file_spec(), strnz__cat(), and strnz__cpy().
Referenced by init_form_files(), init_pick_files(), and verify_spec_arg().
| bool mk_dir | ( | char * | dir | ) |
If directory doesn't exist, make it.
| dir | directory name |
Directory does not exist and unable to create
Definition at line 1320 of file futil.c.
References display_error(), em0, em1, em2, expand_tilde(), ssnprintf(), strnz__cat(), strnz__cpy(), and verify_dir().
Referenced by enter_file_spec().
| bool normalize_file_spec | ( | char * | fs | ) |
replace backslashes with forward lashes
| fs | - file specification to normalize |
Definition at line 853 of file futil.c.
| void open_cmenu_log | ( | ) |
Open new C-Menu log file.
Definition at line 1667 of file futil.c.
References cmenu_log_fd, em0, ssnprintf(), strnz__cpy(), and write_cmenu_log().
| bool parse_local_timestamp | ( | const char * | s, |
| time_t * | out ) |
Parses an ISO 8601 timestamp string in local time and converts it to time_t.
| s | - ISO 8601 timestamp string to parse (e.g., "2024-06-01T12:34:56") |
| out | - pointer to time_t variable to receive the result |
This function expects the input string to be in the format "YYYY-MM-DDTHH:MM:SS" representing local time. It uses strptime to parse the string into a struct tm, then uses mktime to convert it to time_t. The caller must ensure that the input string is properly formatted and represents a valid date and time. If the input string is invalid or if any error occurs during parsing or conversion, this function returns false and does not modify the output variable.
Definition at line 280 of file futil.c.
| char * rep_substring | ( | const char * | org_s, |
| const char * | tgt_s, | ||
| const char * | rep_s ) |
Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
| org_s | - original string |
| tgt_s | - target substring to replace |
| rep_s | - replacement substring |
Definition at line 1440 of file futil.c.
References strnz__cpy().
Referenced by exec_objects(), expand_tilde(), and form_exec_receiver().
| size_t ssnprintf | ( | char * | buf, |
| size_t | buf_size, | ||
| const char * | format, | ||
| ... ) |
ssnprintf was designed to be a safer alternative to snprintf.
It ensures that the buffer is not overflowed by taking the buffer size as a parameter and using vsnprintf internally. It also returns the number of characters that would have been written if enough space had been available, allowing the caller to detect truncation. This function is particularly useful in situations where the formatted string may exceed the buffer size, as it prevents buffer overflows and provides a way to handle such cases gracefully.
| buf | - buffer to receive formatted string |
| buf_size | - size of buffer |
| format | - printf-style format string |
| ... | - arguments |
Definition at line 420 of file futil.c.
Referenced by action_disposition(), answer_yn(), check_panels(), compile_chyron(), debug_out(), display_error(), display_line(), enter_file_spec(), fork_exec(), form_desc_error(), form_parse_desc(), form_process(), form_write(), get_clr_pair(), get_user_str(), handle_signal(), init_view_boxwin(), init_view_full_screen(), lp(), mapp_initialization(), menu_engine(), mk_dir(), new_init(), new_pick(), new_view(), open_cmenu_log(), open_pick_win(), pad_refresh(), parse_menu_description(), Perror(), picker(), search(), set_chyron_key(), set_chyron_key_cp(), signal_handler(), stdio_fdnames(), stdio_names(), verify_dir(), verify_file(), view_cmd_processor(), view_init_input(), wait_continue(), wait_mk_win(), waitpid_with_timeout(), write_config(), and write_view_buffer().
| bool str_subc | ( | char * | d, |
| char * | s, | ||
| char | ReplaceChr, | ||
| char * | Withstr, | ||
| int | l ) |
Replaces "ReplaceChr" in "s" with "Withstr" in "d" won't copy more than "l" bytes to "d" Replaces all occurrences of a character in a string with another string, copying the result to a destination buffer.
| d | - destination string |
| s | - source string |
| ReplaceChr | - character to replace |
| Withstr | - string to insert |
| l | - maximum length to copy |
This function ensures that the total length of the resulting string does not exceed the specified limit, and that the result is null-terminated. This function is useful for simple string substitutions where you want to replace a single character with a longer string, such as replacing spaces with underscores or tabs with spaces.
Definition at line 690 of file futil.c.
Referenced by view_cmd_processor().
| int str_to_args | ( | char ** | argv, |
| char * | arg_str, | ||
| int | max_args ) |
Converts a string into an array of argument strings.
| argv | - array of pointers to arguments |
| arg_str | - string containing arguments |
| max_args | - maximum number of arguments to parse |
Handles quoted strings and escaped quotes, preserving text inside quotes as individual arguments. It has been in service for many years without problems.
Definition at line 440 of file futil.c.
Referenced by enter_file_spec(), exec_objects(), form_exec_receiver(), form_process(), init_pick(), menu_cmd_processor(), and view_init_input().
| double str_to_double | ( | char * | s | ) |
converts string to double
| s | - string to convert |
Definition at line 929 of file futil.c.
Referenced by process_config_file().
| bool str_to_lower | ( | char * | s | ) |
Converts a string to lowercase.
| s | - string to convert |
Definition at line 508 of file futil.c.
Referenced by clr_name_to_idx(), and form_parse_desc().
| bool str_to_upper | ( | char * | s | ) |
Converts a string to uppercase.
| s | - string to convert |
Definition at line 522 of file futil.c.
| size_t strip_ansi | ( | char * | d, |
| char * | s ) |
Strips ANSI SGR escape sequences (ending in 'm') from string s to d.
| d | Destination string |
| s | Source string |
Only handles SGR sequences ending in 'm' or 'K' Skips non-ASCII characters The caller must ensure that d has enough space to hold the stripped string This function does not allocate memory; it assumes d is pre-allocated This function processes the entire string until the null terminator This function does not modify the source string s
Definition at line 829 of file futil.c.
Referenced by main(), and write_view_buffer().
| bool strip_quotes | ( | char * | s | ) |
removes leading and trailing double quotes if present
| s | - string to strip quotes from |
If the string has a leading double quote and a trailing double quote, this function removes them in place. If the string does not have both leading and trailing double quotes, it is left unchanged. The function returns true if the operation was successful (i.e., if the string was modified or if it was valid), and false if the input string was null or empty.
Definition at line 718 of file futil.c.
Referenced by init_form_files(), and init_view_files().
| bool stripz_quotes | ( | char * | s | ) |
removes leading and trailing double quotes if present
| s | - string to strip quotes from |
Same as STRIP_QUOTES but returns true if quotes were removed
Definition at line 733 of file futil.c.
Referenced by verify_spec_arg().
| size_t strnlf | ( | char * | s, |
| size_t | max_len ) |
terminates string with line feed
| s | string to terminate |
| max_len | maximum length to scan |
Definition at line 633 of file futil.c.
Referenced by write_view_buffer().
| size_t strnz | ( | char * | s, |
| size_t | max_len ) |
terminates string at New Line, Carriage Return, or max_len
| s | string to terminate |
| max_len | - maximum length to scan |
The use case is to ensure that strings read from files or user input do not contain embedded newlines or carriage returns.
Definition at line 615 of file futil.c.
Referenced by answer_yn(), border_hsplit_text(), display_error(), display_form(), enter_file_spec(), form_display_fields(), form_fmt_field(), message_win(), and Perror().
| size_t strnz__cat | ( | char * | d, |
| const char * | s, | ||
| size_t | max_len ) |
safer alternative to strncat
| d | - destination string |
| s | - source string |
| max_len | - maximum length to copy |
Append string s to d, ensuring that the total length of d does not exceed max_len, and that the resulting string is null-terminated. It also treats newline and carriage return characters as string terminators, preventing them from being included in the result. This is particularly useful when concatenating user input or file data, where embedded newlines could cause issues.
Definition at line 573 of file futil.c.
Referenced by build_prompt(), derive_file_spec(), display_form(), display_pick_help(), enter_file_spec(), exec_objects(), expand_tilde(), file_spec_parts(), form_engine(), form_exec_cmd(), form_exec_receiver(), form_parse_desc(), form_process(), form_read_data(), form_write(), get_ip_addresses(), init_form(), init_menu_files(), init_pick(), init_view_files(), locate_file_in_path(), mapp_initialization(), menu_cmd_processor(), mk_dir(), new_pick_view(), new_view_file(), open_curses(), output_objects(), parse_menu_description(), picker(), popup_ckeys(), search(), stdio_fdnames(), stdio_names(), verify_spec_arg(), view_cmd_processor(), view_display_help(), view_init_input(), whence(), write_cmenu_log(), write_config(), and write_view_buffer().
| size_t strnz__cpy | ( | char * | d, |
| const char * | s, | ||
| size_t | max_len ) |
safer alternative to strncpy
copies string s to d, ensuring that the total length of d does not exceed max_len, and that the resulting string is null-terminated. It also treats newline and carriage return characters as string terminators, preventing them from being included in the result. This is particularly useful when copying user input or file data, where embedded newlines could cause issues.
| d | - destination string |
| s | - source string |
| max_len | - maximum length to copy |
Definition at line 544 of file futil.c.
Referenced by answer_yn(), build_prompt(), canonicalize_file_spec(), derive_file_spec(), dir_name(), display_error(), display_form(), display_pick_help(), display_prompt(), enter_file_spec(), exec_objects(), expand_tilde(), file_spec_parts(), form_desc_error(), form_engine(), form_exec_cmd(), form_exec_receiver(), form_fmt_field(), form_parse_desc(), form_process(), form_read_data(), form_write(), get_argp_doc_by_name(), get_cmd_arg(), handle_signal(), init_form(), init_form_files(), init_menu_files(), init_pick(), init_pick_files(), init_view_files(), locate_file_in_path(), main(), mapp_initialization(), menu_cmd_processor(), mk_dir(), new_form(), new_pick_view(), new_view_file(), open_cmenu_log(), open_curses(), output_objects(), parse_menu_description(), Perror(), picker(), popup_ckeys(), process_config_file(), process_config_files(), rep_substring(), save_object(), search(), stdio_fdnames(), stdio_names(), verify_dir(), verify_file(), verify_spec_arg(), view_cmd_processor(), view_display_help(), view_file(), view_init_input(), whence(), write_cmenu_log(), write_config(), and write_view_buffer().
| char * strnz_dup | ( | char * | s, |
| size_t | l ) |
Allocates memory for and duplicates string s up to length l or until line feed or carriage return.
| s | - string to duplicate |
| l | - maximum length to copy |
Definition at line 654 of file futil.c.
Referenced by new_view().
| size_t strz | ( | char * | s | ) |
Terminates string at new line or carriage return.
| s | string to terminate |
Definition at line 597 of file futil.c.
| size_t trim | ( | char * | s | ) |
Trims leading and trailing spaces from string s in place.
| s | - string to trim |
Definition at line 391 of file futil.c.
Referenced by form_fmt_field(), form_parse_desc(), left_justify(), menu_cmd_processor(), parse_menu_description(), and right_justify().
| bool trim_ext | ( | char * | buf, |
| char * | filename ) |
trims the file extension from "filename" and copies the result to "buf"
| buf | - buffer to receive result |
| filename | - filename to trim |
Definition at line 1016 of file futil.c.
| bool trim_path | ( | char * | dir | ) |
Trims trailing spaces and slashes from directory path in place.
| dir | - directory path to trim |
Definition at line 988 of file futil.c.
Referenced by derive_file_spec().
| void ui_rect_set | ( | UiRect * | r, |
| int | y, | ||
| int | x, | ||
| int | h, | ||
| int | w ) |
Set the properties of a UiRect structure.
ui_rect_set
| r | Pointer to the UiRect structure to set |
| y | Y-coordinate (row) of the rectangle's top-left corner |
| x | X-coordinate (column) of the rectangle's top-left corner |
| h | Height (number of rows) of the rectangle |
| w | Width (number of columns) of the rectangle |
This function initializes the fields of a UiRect structure with the specified values for position and size. It is used to define rectangular areas in a user interface.
Definition at line 908 of file dwin.c.
References UiRect::cols, UiRect::rows, UiRect::x, and UiRect::y.
| bool unstr_hex_clr | ( | char * | dst, |
| char * | str ) |
Validates that a string is a hex color code in the format "#RRGGBB".
| dst | - buffer to receive validated hex color string |
| str | - input string to validate |
This function checks that the input string starts with a '#' character, followed by exactly six hexadecimal digits (0-9, A-F, a-f). If the input string is valid, it copies the hex color code into the provided destination buffer. The caller must ensure that dst has enough space to hold the resulting string (at least 8 characters including the null terminator). If the input string is invalid (e.g., does not start with '#', contains non-hex characters, or does not have exactly six hex digits), this function returns false and does not modify the destination buffer.
Definition at line 232 of file futil.c.
Referenced by process_config_file().
| bool verify_dir | ( | char * | spec, |
| int | imode ) |
Verifies that the directory specified by "spec" exists and is accessible with the permissions specified by "imode".
| spec | - directory specification |
| imode | - access mode F_OK - existence R_OK - read W_OK - Write X_OK - Execute S_WCOK - Write or Create S_QUIET - Suppress Error Messages |
S_WCOK and S_QUIET are stripped before calling faccessat
Definition at line 1189 of file futil.c.
References display_error(), em0, em1, em2, em3, expand_tilde(), fn, src_line, src_name, ssnprintf(), and strnz__cpy().
Referenced by mapp_initialization(), mk_dir(), and verify_spec_arg().
| bool verify_file | ( | char * | in_spec, |
| int | imode ) |
Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified by "imode".
| in_spec | - directory specification |
| imode | - access mode F_OK - existence R_OK - read W_OK - Write X_OK - Execute S_WCOK - Write or Create S_QUIET - Suppress Error Messages |
S_WCOK and S_QUIET are stripped before calling faccessat
Definition at line 1240 of file futil.c.
References canonicalize_file_spec(), display_error(), em0, em1, em2, em3, expand_tilde(), fn, src_line, src_name, ssnprintf(), and strnz__cpy().
Referenced by verify_spec_arg().
| int wccp_to_str | ( | wchar_t | cp, |
| uint8_t * | buffer ) |
Converts a Unicode code point to a UTF-8 encoded string.
| cp | - Unicode code point to convert |
| buffer | - buffer to receive UTF-8 encoded string (must be at least 4 bytes) |
This function encodes the given Unicode code point into its UTF-8 representation and stores it in the provided buffer. The caller must ensure that the buffer has enough space to hold the resulting UTF-8 string (up to 4 bytes for code points up to U+10FFFF). If the code point is invalid (e.g., greater than U+10FFFF), this function returns 0 and does not modify the buffer.
Definition at line 871 of file dwin.c.
| void write_cmenu_log | ( | char * | msg | ) |
Write message to C-Menu log file with timestamp.
| msg | - string to write to log file |
Definition at line 1685 of file futil.c.
References cmenu_log_fd, em1, strnz__cat(), and strnz__cpy().
Referenced by open_cmenu_log().
| void write_cmenu_log_nt | ( | char * | msg | ) |
Write message to C-Menu log file without timestamp.
| msg | - string to write to log file |
Definition at line 1701 of file futil.c.
References cmenu_log_fd.