|
C-Menu 0.2.9
A User Interface Toolkit
|
Headder for C-Menu API library, libcm.so. More...
#include "version.h"#include <argp.h>#include <pthread.h>#include <signal.h>#include <stdbool.h>#include <stddef.h>#include <stdlib.h>#include <time.h>#include <wait.h>#include <wchar.h>#include <stdio.h>Go to the source code of this file.
Data Structures | |
| struct | Arg |
| struct | Argv |
| struct | CmField |
| struct | Date |
| struct | String |
| struct | Time |
| struct | WCStr |
Macros | |
| #define | _(String) |
| #define | __atexit |
| This macro registers the end_pgm function to be called when the program exits. | |
| #define | _GNU_SOURCE |
| #define | _XOPEN_SOURCE_EXTENDED 1 |
| #define | ABS(x) |
| ABS macro for absolute value, which evaluates the expression once and returns the absolute value. | |
| #define | bindtextdomain(Package, Directory) |
| #define | Ctrl(c) |
| #define | DEFAULTSHELL "/bin/bash" |
| #define | DIV_ROUND_UP(n, d) |
| #define | F_NO_STDERR 1 |
| #define | KEY_ALTF(n) |
| #define | KEY_ALTF0 0x138 |
| #define | MAX(a, b) |
| MIN macro for compatibility with code that uses the same name, while avoiding multiple evaluations of the arguments. | |
| #define | max(a, b) |
| max macro evaluates two expressions, returning greatest result. | |
| #define | MAX_ARGS 64 |
| #define | MAXARGS 64 |
| #define | MAXLEN 256 |
| #define | MAXWIN 30 |
| #define | MAXWIN 30 |
| #define | MIN(x, y) |
| MAX macro for compatibility with code that uses the same name, while avoiding multiple evaluations of the arguments. | |
| #define | min(x, y) |
| min macro evaluates two expressions, returning least result | |
| #define | N_(String) |
| #define | NCURSES_WIDECHAR 1 |
| #define | nullptr NULL |
| #define | S_QUIET 0x2000 |
| #define | S_TOLOWER(c) |
| #define | S_TOUPPER(c) |
| #define | S_WCOK 0x1000 |
| #define | SCR_COLS 1024 |
| #define | SCREEN_MAX_LINES 100 |
| #define | textdomain(Domain) |
| #define | to_lowercase(c) |
| #define | to_uppercase(c) |
| #define | to_uppercase(c) |
Typedefs | |
| typedef unsigned char | uchar |
Enumerations | |
| enum | F_Type { F_F0 , F_FIFO , F_CHR , F_F1 , F_DIR , F_F2 , F_BLK , F_F3 , F_REG , F_F4 , F_LNK , F_F5 , F_SOCK , F_F6 , F_UNKNOWN } |
| enum | LFFlags { LF_HIDE = 0b00000001 , LF_ICASE = 0b00000010 , LF_EXC_REGEX = 0b00000100 , LF_REGEX = 0b00001000 , LF_EXEC = 0b00010000 , LF_USER = 0b00100000 , LF_IXUSR = 0b00000001 , LF_IWUSR = 0b00000010 , LF_IRUSR = 0b00000100 , LF_ISGID = 0b00010000 , LF_ISUID = 0b00100000 } |
| Used for xterm256 color conversions. More... | |
| enum | LFTypes { LF_FIFO = 0b00000001 , LF_CHR = 0b00000010 , LF_DIR = 0b00000100 , LF_BLK = 0b00001000 , LF_REG = 0b00010000 , LF_LNK = 0b00100000 , LF_SOCK = 0b01000000 , LF_UNKNOWN = 0b10000000 } |
Functions | |
| unsigned long | a_to_ul (const char *) |
| 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 *, bool *) |
| a safer alternative to atoi() for converting ASCII strings to integers. | |
| bool | base_name (char *, char *) |
| Returns the base name of a file specification. | |
| size_t | canonicalize_file_spec (char *) |
| Removes quotes and trims at first space. | |
| bool | capture_program_tioctl () |
| capture_program_tioctl() - capture program terminal settings | |
| bool | capture_shell_tioctl () |
| capture_shell_tioctl() - capture shell terminal settings | |
| int | cf_accept (UiSurface *, ss_t w, char *, uint, uint, uint) |
| Accepts input for a field in a C-Menu window. | |
| bool | chrep (char *, char, char) |
| Replaces all occurrences of old_chr in s with new_chr in place. | |
| bool | construct_file_spec (char *, char *, char *, char *, char *, uint) |
| int | destroy_argv (uint argc, char **argv) |
| Deallocates memory allocated for argument strings in argv. | |
| char | di_getch () |
| get single character from terminal in raw mode | |
| bool | dir_name (char *, char *) |
| Returns the directory name of a file specification. | |
| void | display_argv_error_msg (char *, char **) |
| int | display_curses_keys () |
| void | dump_opts () |
| void | dump_opts_by_use (char *, char *) |
| uint | enter_option () |
| bool | expand_tilde (char *, uint) |
| Replaces "~/" in string with the user's home directory. | |
| char * | fdname (int, char *) |
| Retrieves the file path associated with a given file descriptor. | |
| bool | file_spec_name (char *, char *) |
| extracts the file name component of a file specification | |
| bool | file_spec_path (char *, char *) |
| extracts the path component of a file specification | |
| char * | fill_field (char *, char *, char, uint) |
| int | fork_detach_execvp (char **) |
| Fork, set new session ID, close files, and execute detached command. | |
| int | fork_exec (char **) |
| Fork and exec a command. | |
| char * | format_local_timestamp (time_t, char *, size_t) |
| Formats a time_t as an ISO 8601 string in local time. | |
| String | free_string (String) |
| Free the dynamically allocated String. | |
| int | full_screen_fork_exec (char **) |
| Execute a command in full screen mode. | |
| int | full_screen_shell (char *) |
| Execute a shell command in full screen mode. | |
| bool | get_argp_doc_by_name (char *comment, const struct argp_option *, const char *) |
| Retrieves the documentation string for a given key name from an argp options array. | |
| char * | get_ip_addresses (char *, uint) |
| 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. | |
| void | get_rfc3339_s (char *, size_t) |
| char * | get_user_str (char *, size_t) |
| Retrieves the current user's name and UID, and formats it into a string. | |
| bool | handle_signal (sig_atomic_t) |
| void | init_stdscr () |
| bool | is_directory (const char *) |
| Checks if the given path is a directory. | |
| bool | is_hex_str (char *, uint) |
| Validates that a string consists of exactly len hexadecimal digits. | |
| bool | is_image_file (const char *filename) |
| bool | is_newer (char *, char *) |
| Checks if the file specified by "fut" is newer than the file specified by "control". | |
| bool | is_symlink_to_dir (const char *) |
| Checks if the given path is a symbolic link to a directory. | |
| bool | is_valid_date (uint yyyy, uint mm, uint dd) |
| Check if a given date is valid, including leap years. | |
| bool | is_valid_regex (const char *) |
| Checks if the given regular expression pattern is valid. | |
| bool | is_valid_time (uint hh, uint mm, uint ss) |
| Check if a given time is valid. | |
| void | left_justify (char *s) |
| Left justify string by removing leading spaces. | |
| bool | locate_file_in_path (char *, char *) |
| Locates a file in the system PATH. | |
| bool | mk_dir (char *dir) |
| If directory doesn't exist, make it. | |
| bool | mk_raw_tioctl (struct termios *) |
| mk_raw_tioctl() - set terminal to raw mode | |
| String | mk_string (size_t) |
| Create a String struct with a dynamically allocated string. | |
| bool | normalize_file_spec (char *) |
| replace backslashes with forward lashes | |
| void | numeric (char *d, char *s) |
| Extract numeric characters from source string to destination string. | |
| bool | parse_local_timestamp (const char *, time_t *) |
| Parses an ISO 8601 timestamp string in local time and converts it to time_t. | |
| char * | rep_substring (const char *, const char *, const char *) __attribute__((nonnull(1 |
| Replace all occurrences of "tgt_s" in "org_s" with "rep_s". | |
| bool | restore_program_tioctl () |
| restore_program_tioctl() - restore program terminal settings | |
| bool | restore_shell_tioctl () |
| restore_shell_tioctl() - restore shell terminal settings | |
| void | restore_wins () |
| void | right_justify (char *, uint) |
| Right justify string by removing trailing spaces and adding leadingspaces. | |
| size_t | rtrim (char *) |
| Trims trailing spaces from string s in place. | |
| int | segmentation_fault () |
| Function to intentionally cause a segmentation fault for testing purposes. | |
| bool | set_sane_tioctl (struct termios *) |
| set_sane_tioctl() - set terminal to sane settings for C-MENU | |
| int | shell (char *) |
| Execute a shell command. | |
| void | sig_dfl_mode () |
| Set signal handlers to default behavior. | |
| void | sig_prog_mode () |
| Set up signal handlers for interrupt signals. | |
| void | sig_shell_mode () |
| void | signal_handler (int) |
| Signal handler for interrupt signals. | |
| size_t | ssnprintf (char *, size_t, const char *,...) |
| ssnprintf was designed to be a safer alternative to snprintf. | |
| char * | stdio_fdnames (char *, char *) |
| char * | stdio_names (char *, char *) |
| bool | str_subc (char *, char *, char, char *, uint) |
| 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 **, char *, uint) |
| Converts a string into an array of argument strings. | |
| bool | str_to_bool (const char *) |
| Converts String to boolean true or false. | |
| double | str_to_double (char *) |
| converts string to double | |
| bool | str_to_lower (char *) |
| Converts a string to lowercase. | |
| bool | str_to_upper (char *) |
| Converts a string to uppercase. | |
| char * | strerror__r (int errnum, char *buf, size_t buflen) |
| A thread-safe alternative to strerror() that writes the error message corresponding to errnum into the provided buffer. | |
| size_t | string_cat (String *, const String *) |
| Concatenates src String to dest String, allocating additional memory for dest String if necessary. | |
| size_t | string_cpy (String *, const String *) |
| Copy src String to dest String, allocating additional memory for dest String if necessary. | |
| size_t | string_ncat (String *, const String *, size_t) |
| Concatenates up to n characters from src String to dest String, allocating additional memory for dest String if necessary. | |
| size_t | string_ncpy (String *, const String *, size_t) |
| copies up to n characters from src String to dest String, allocating additional memory for dest String if necessary | |
| char size_t | strip_ansi (char *, char *) |
| Strips ANSI SGR escape sequences (ending in 'm') from string s to d. | |
| bool | strip_quotes (char *) |
| removes leading and trailing double quotes if present | |
| bool | stripz_quotes (char *) |
| removes leading and trailing double quotes if present | |
| bool | strnfill (char *, char, uint) |
| size_t | strnlf (char *, size_t) |
| terminates string with line feed | |
| size_t | strnz (char *, size_t) |
| terminates string at New Line, Carriage Return, or max_len | |
| size_t | strnz__cat (char *, const char *, size_t) |
| safer alternative to strncat | |
| size_t | strnz__cpy (char *, const char *, size_t) |
| safer alternative to strncpy | |
| char * | strnz_dup (char *, size_t) |
| Allocates memory for and duplicates string s up to length l or until line feed or carriage return. | |
| String | to_string (const char *) |
| String functions provide a simple string library to facilitate string manipulation in C, allowing developers to easily create, copy, concatenate, and free strings without having to manage memory manually. | |
| size_t | trim (char *) |
| Trims leading and trailing spaces from string s in place. | |
| bool | trim_ext (char *, char *) |
| trims the file extension from "filename" and copies the result to "buf" | |
| bool | trim_path (char *) |
| Trims trailing spaces and slashes from directory path in place. | |
| bool | unstr_hex_clr (char *, char *) |
| Validates that a string is a hex color code in the format "#RRGGBB". | |
| void | user_end () |
| bool | verify_dir (char *, uint) |
| Verifies that the directory specified by "spec" exists and is accessible with the permissions specified by "imode". | |
| bool | verify_dir_q (char *, uint) |
| bool | verify_file (char *, uint) |
| Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified by "imode". | |
| bool | verify_file_q (char *, uint) |
| bool | verify_spec_arg (char *, char *, char *, char *, uint) |
| Verify file specification argument. | |
| bool | wait_destroy (UiChyron *) |
| UiChyron * | wait_mk_chyron () |
| bool | waitpid_with_timeout (pid_t, uint) |
| void | win_del () |
| void | win_init_attrs () |
| void | win_resize (uint, uint, char *) |
| void | win_Toggle_Attrs () |
Variables | |
| uint | dbgfd |
| char | errmsg [] |
| int | exit_code |
| bool | f_debug |
| bool | f_have_program_tioctl = false |
| bool | f_have_shell_tioctl = false |
| bool | f_program_open |
| bool | f_restore_screen |
| char | fn [MAXLEN] |
| uint | mbegx |
| uint | mbegy |
| uint | mcols |
| uint | mg_action |
| uint | mg_col |
| uint | mg_line |
| uint | mlines |
| uint | n_cols |
| uint | n_lines |
| struct termios shell_err_tioctl | program_err_tioctl |
| struct termios shell_in_tioctl | program_in_tioctl |
| struct termios shell_out_tioctl | program_out_tioctl |
| struct termios shell_tioctl | program_tioctl |
| volatile sig_atomic_t | sig_received = 0 |
| uint | src_line |
| char * | src_name |
| int | stderr_fd |
| int | stdin_fd |
| char | stdio_names_str [4096] |
| int | stdout_fd |
| FILE * | tty_fp |
| int | wait_timeout |
| uint16_t | win_attr |
| #define __atexit |
This macro registers the end_pgm function to be called when the program exits.
It checks the return value of atexit() to ensure that the registration was successful, and if not, it prints an error message and exits with a failure status. Programs using libcm should call __atexit in their main function to ensure that the end_pgm function is registered to be called on program exit. This will help ensure that the terminal is properly restored to its original state, even if the program encounters an error or is terminated unexpectedly.
Definition at line 275 of file cm.h.
| #define ABS | ( | x | ) |
ABS macro for absolute value, which evaluates the expression once and returns the absolute value.
This macro uses a compound statement to create a local scope for the temporary variable _a, which stores the value of x. This ensures that if x has side effects (such as being incremented), it will only be evaluated once when the macro is expanded. The use of typeof allows the macro to work with any data type that supports comparison with zero and negation.
Definition at line 152 of file cm.h.
| #define DEFAULTSHELL "/bin/bash" |
Include Exclude
---------- ----------
LF_FIFO 1 0 00000001 7 11111110 named pipe LF_CHR 2 1 00000010 6 11111101 character device LF_DIR 4 2 00000100 5 11111011 directory LF_BLK 8 3 00001000 4 11110111 block device LF_REG 16 4 00010000 3 11101111 regular file LF_LNK 32 5 00100000 2 11011111 link LF_SOCK 64 6 01000000 1 10111111 socket LF_UNKNOWN 128 7 10000000 0 01111111 unknown
| #define KEY_ALTF | ( | n | ) |
| #define MAX | ( | a, | |
| b ) |
MIN macro for compatibility with code that uses the same name, while avoiding multiple evaluations of the arguments.
/usr/include/sys/param.h contains implementations of the MIN and MAX macros, which are simple but can lead to issues with multiple evaluations of the arguments if they have side effects. These macros provides a safer alternative to param.h Here are the macros from /usr/include/sys/param.h. You may comment out the macros defined herein and use the macros in param.h if you prefer.
Definition at line 127 of file cm.h.
| #define max | ( | a, | |
| b ) |
max macro evaluates two expressions, returning greatest result.
These macros use compound statements to create local scopes for the temporary variables _x and _y, which store the values of x and y, respectively. This ensures that if x or y have side effects (such as being incremented), they will only be evaluated once when the macro is expanded. The use of typeof allows the macro to work with any data type. The line (void)(&_x == &_y) is a compile-time check to ensure that the types of the arguments are compatible. This implementation of the min and max macros provides a safer and more robust way to determine the minimum and maximum values between two expressions without risking unintended consequences from multiple evaluations.
Definition at line 97 of file cm.h.
| #define MAX_ARGS 64 |
| #define MIN | ( | x, | |
| y ) |
MAX macro for compatibility with code that uses the same name, while avoiding multiple evaluations of the arguments.
Definition at line 137 of file cm.h.
| #define min | ( | x, | |
| y ) |
min macro evaluates two expressions, returning least result
Definition at line 104 of file cm.h.
| #define S_TOLOWER | ( | c | ) |
| #define S_TOUPPER | ( | c | ) |
| #define SCR_COLS 1024 |
| #define to_lowercase | ( | c | ) |
to_lowercase(c) - convert an uppercase letter to lowercase
Definition at line 173 of file cm.h.
| #define to_uppercase | ( | c | ) |
to_uppercase(c) - convert a lowercase letter to uppercase
simple macro to convert a character to uppercase
Definition at line 169 of file cm.h.
| #define to_uppercase | ( | c | ) |
to_uppercase(c) - convert a lowercase letter to uppercase
simple macro to convert a character to uppercase
Definition at line 169 of file cm.h.
| enum F_Type |
| enum LFFlags |
Used for xterm256 color conversions.
Definition at line 180 of file cm.h.
| enum LFTypes |
byte 2 - bits 16-23 File types
| Enumerator | |
|---|---|
| LF_FIFO | 1 named pipe |
| LF_CHR | 2 character device |
| LF_DIR | 4 directory |
| LF_BLK | 8 block |
| LF_REG | 16 regular file |
| LF_LNK | 32 link |
| LF_SOCK | 64 socket |
| LF_UNKNOWN | 128 unknown |
Accepts input for a field in a C-Menu window.
| UiSurface | *sfc The surface to accept input from |
| win | The window to accept input from |
| accept_s | The string to accept input into |
| flin | The line number of the field |
| fcol | The column number of the field |
| flen | The length of the field |
< Enter accepts the field and moves to the next field if f_erase_remainder is set, it will clear the remaining characters above and after the current cursor location
UIKEY_IC toggles insert mode
UIKEY_DC deletes character at cursor
UIKEY_HOME moves cursor to start of field
UIKEY_BACKSPACE deletes character before cursor
UIKEY_LEFT moves cursor left one character
UIKEY_RIGHT moves cursor right one character
Handles mouse events for field editing
Definition at line 41 of file cm_fields.c.
References click_x, click_y, f_erase_remainder, ui_curs_set(), ui_cursor_move(), ui_get_event(), ui_mvwaddstr(), ui_render(), and ui_wclrtoeol().
Referenced by get_cmd_arg().
|
extern |
|
extern |
|
extern |
|
extern |
dump options to stdout
|
extern |
dump options to stdout
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
Create a String struct with a dynamically allocated string.
| l | length of string to create including null terminator |
The returned String struct contains a dynamically allocated string of he specified length
|
extern |
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 1449 of file futil.c.
References strnz__cpy().
Referenced by exec_objects(), expand_tilde(), and form_exec_receiver().
|
extern |
|
extern |
Trims trailing spaces from string s in place.
| s | - string to trim |
Definition at line 308 of file futil.c.
Referenced by fmt_line(), and picker().
|
extern |
|
extern |
Definition at line 1108 of file futil.c.
References fdname(), ssnprintf(), strnz__cat(), and strnz__cpy().
Referenced by form_process(), init_pick(), and view_init_input().
|
extern |
Definition at line 1083 of file futil.c.
References ssnprintf(), strnz__cat(), and strnz__cpy().
Referenced by fork_exec(), and menu_cmd_processor().
|
extern |
Converts String to boolean true or false.
| s | - string to convert |
Definition at line 960 of file futil.c.
Referenced by process_config_file().
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
the file descriptor for debug output, for debugging purposes
|
extern |
the exit code for the program, for error messages and other output
Definition at line 31 of file ui_common.c.
|
extern |
a flag to indicate whether debug output should be printed, for debugging purposes see termios.h
|
extern |
program tioctl captured
Definition at line 25 of file scriou.c.
Referenced by capture_program_tioctl(), and restore_program_tioctl().
|
extern |
shell tioctl captured
Definition at line 24 of file scriou.c.
Referenced by capture_shell_tioctl(), and restore_shell_tioctl().
|
extern |
program mode is active
|
extern |
whether to restore the screen
|
extern |
function name for error messages
Definition at line 45 of file ui_common.c.
Referenced by verify_dir(), and verify_file().
|
extern |
beginning x coordinate of the current window, which can be used to determine the position of the window on the terminal screen.
|
extern |
beginning y coordinate of the current window, which can be used to determine the position of the window on the terminal screen.
|
extern |
number of columns in the current window, which may be less than the total number of columns in the terminal if the window is resized or if multiple windows are being used.
|
extern |
action in progress, which can be used to keep track of the current state of the program and determine how to respond to user input or other events.
|
extern |
window column, which can be used to determine the current column position in the window for displaying text or other content.
|
extern |
window line, which can be used to determine the current line position in the window for displaying text or other content.
|
extern |
number of lines in the current window, which may be less than the total number of lines in the terminal if the window is resized or if multiple windows are being used.
|
extern |
number of columns in the terminal
|
extern |
number of lines in the terminal
|
extern |
Definition at line 37 of file scriou.c.
Referenced by capture_program_tioctl(), and restore_program_tioctl().
|
extern |
Definition at line 35 of file scriou.c.
Referenced by capture_program_tioctl(), and restore_program_tioctl().
|
extern |
Definition at line 36 of file scriou.c.
Referenced by capture_program_tioctl(), and restore_program_tioctl().
|
extern |
|
extern |
Definition at line 32 of file sig.c.
Referenced by handle_signal(), signal_handler(), and ui_get_event().
|
extern |
the line number of the source file being processed, for error messages
Definition at line 43 of file ui_common.c.
Referenced by verify_dir(), and verify_file().
|
extern |
the name of the source file being processed, for error messages
Definition at line 44 of file ui_common.c.
Referenced by verify_dir(), and verify_file().
|
extern |
the file descriptor for the terminal, for error messages and other output
Definition at line 61 of file ui_common.c.
|
extern |
the file descriptor for the terminal, for error messages
Definition at line 61 of file ui_common.c.
|
extern |
Definition at line 122 of file futil.c.
Referenced by fork_exec(), form_process(), init_pick(), menu_cmd_processor(), and view_init_input().
|
extern |
the file descriptor for the terminal, for error messages
Definition at line 61 of file ui_common.c.
|
extern |
|
extern |
Ncurses attributes for the current window, such as color pair, bold, etc.
Definition at line 34 of file ui_common.c.