C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
C-Menu Initialization

Capture Data from the Environment, Command Line, and Configuration File and Populate the Init and SIO Data Structures. More...

Functions

bool derive_file_spec (char *file_spec, char *dir, char *file_name)
 Derive full file specification from directory and file name.
void display_version ()
 Display the version information of the application.
void mapp_initialization (Init *init, int argc, char **argv)
 Main initialization function for MAPP - Menu Application.
void opt_prt_bool (const char *o, const char *name, bool value)
 Print an option and its value in a formatted manner for boolean values.
void opt_prt_char (const char *o, const char *name, const char *value)
 Print an option and its value in a formatted manner.
void opt_prt_double (const char *o, const char *name, double value)
 Print an option and its value in a formatted manner for double values.
void opt_prt_int (const char *o, const char *name, int value)
 Print an option and its value in a formatted manner for integer values.
void opt_prt_str (const char *o, const char *name, const char *value)
 Print an option and its value in a formatted manner for integer values.
int parse_opt_args (Init *init, int argc, char **argv)
 Parse command-line options and set Init struct values accordingly.
int process_config_files (Init *init)
 parse the configuration file specified in init->minitrc and set Init struct values accordingly
int write_config (Init *init)
 Write the current configuration to a file specified in init->minitrc.
void zero_opt_args (Init *init)
 Initialize optional arguments in the Init struct to default values.

Detailed Description

Capture Data from the Environment, Command Line, and Configuration File and Populate the Init and SIO Data Structures.

    SIO   Struct for screen I/O settings (colors, gamma, etc.)
    Init  Struct for application settings (file paths, commands, flags, etc.)

Function Documentation

◆ derive_file_spec()

bool derive_file_spec ( char * file_spec,
char * dir,
char * file_name )

Derive full file specification from directory and file name.

Parameters
file_spec- output full file specification
dir- directory path
file_name- file name
Returns
true if file_spec is derived, false otherwise

If dir is nullptr, use MAPP_DIR environment variable or default directory, ~/menuapp. file_spec should be a pre-allocated char array of size MAXLEN to hold the resulting file specification

Definition at line 1306 of file init.c.

1306 {
1307 char tmp_str[MAXLEN];
1308 char ts2[MAXLEN];
1309 char *e;
1310
1311 if (!file_name || !*file_name) {
1312 *file_spec = '\0';
1313 return false;
1314 }
1315 if (dir) {
1316 strnz__cpy(tmp_str, dir, MAXLEN - 1);
1317 } else {
1318 e = getenv("MAPP_DIR");
1319 if (e) {
1320 strnz__cpy(tmp_str, e, MAXLEN - 1);
1321 } else {
1322 strnz__cpy(tmp_str, "~/menuapp", MAXLEN - 1);
1323 }
1324 }
1325 trim_path(tmp_str);
1326 strnz__cpy(ts2, tmp_str, MAXLEN - 1);
1327 // construct the full file specification
1328 // check that the file exists and is readable
1329 strnz__cpy(file_spec, ts2, MAXLEN - 1);
1330 strnz__cat(file_spec, "/", MAXLEN - 1);
1331 strnz__cat(file_spec, file_name, MAXLEN - 1);
1332 return true;
1333}
#define MAXLEN
Definition curskeys.c:15
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:544
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:573
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
Definition futil.c:988

References strnz__cat(), strnz__cpy(), and trim_path().

Here is the call graph for this function:

◆ display_version()

void display_version ( )

Display the version information of the application.

The version information is defined in the mapp_version variable and is printed to stdout when this function is called.

Definition at line 1338 of file init.c.

1338 {
1339 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1340 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1341 fprintf(stdout, "C version: %ld\n", __STDC_VERSION__);
1342}
#define CM_VERSION
Definition version.h:7

◆ mapp_initialization()

void mapp_initialization ( Init * init,
int argc,
char ** argv )

Main initialization function for MAPP - Menu Application.

Parameters
init- pointer to Init struct to be initialized
argc- argument count from main()
argv- argument vector from main()
1. Read environment variables and set defaults
2. Parse configuration file
3. Parse command-line options
4. Set up SIO struct with colors and other settings
5. Handle special options like help and version
The SIO structure encapsulates various aspects of the terminal's state and configuration,...
Definition cm.h:805

< menu specification file

< background color

< foreground color

< bold color

< bold color

< bold color

< bold color

< title foreground color

< title background color

< normal foreground color

< normal background color

< normal reverse foreground color

< normal reverse background color

< normal highlight foreground color

< normal highlight background color

< normal reverse foreground color

< normal reverse background color

< line number olor

< line number background

< line number olor

< line number background

< erase remainder on enter

< field enclosure brackets

< field fill character

Definition at line 441 of file init.c.

441 {
442 char term[MAXLEN];
443 char tmp_str[MAXLEN];
444 char *e;
445 setlocale(LC_ALL, "en_US.UTF-8");
446 SIO *sio = init->sio;
447 if (!init) {
448 ssnprintf(tmp_str, sizeof(tmp_str), "%s",
449 "init struct not allocated on entry");
450 abend(-1, tmp_str);
451 exit(-1);
452 }
453#ifdef DEBUG_LOG
455#endif
456 e = getenv("CMENU_HOME");
457 if (!e || *e == '\0')
458 strnz__cpy(init->mapp_home, "~/menuapp", MAXLEN);
459 else
460 strnz__cpy(init->mapp_home, e, MAXLEN);
461
462 if (init->mapp_home[0] != '\0') {
463 expand_tilde(init->mapp_home, MAXLEN - 1);
464 if (!verify_dir(init->mapp_home, R_OK))
465 abend(-1, "MAPP_HOME directory invalid");
466 }
467 // CMENU_RC should be an absolute path
468 e = getenv("CMENU_RC");
469 if (!e || *e == '\0') {
470 strnz__cpy(init->minitrc, init->mapp_home, MAXLEN - 1);
471 strnz__cat(init->minitrc, "/.minitrc", MAXLEN);
472 } else
473 strnz__cpy(init->minitrc, e, MAXLEN);
474 if (init->mapp_user[0] == '\0') {
475 strnz__cpy(init->mapp_user, init->mapp_home, MAXLEN - 1);
476 strnz__cat(init->mapp_user, "/user", MAXLEN - 1);
477 }
478 if (init->mapp_theme[0] == '\0') {
479 strnz__cpy(init->mapp_theme, init->mapp_home, MAXLEN - 1);
480 strnz__cat(init->mapp_theme, "/themes/default", MAXLEN - 1);
481 }
482 if (init->mapp_msrc[0] == '\0') {
483 strnz__cpy(init->mapp_msrc, init->mapp_home, MAXLEN - 1);
484 strnz__cat(init->mapp_msrc, "/msrc", MAXLEN - 1);
485 }
486 if (init->mapp_data[0] == '\0') {
487 strnz__cpy(init->mapp_data, init->mapp_home, MAXLEN - 1);
488 strnz__cat(init->mapp_data, "/data", MAXLEN - 1);
489 }
490 if (init->mapp_help[0] == '\0') {
491 strnz__cpy(init->mapp_help, init->mapp_home, MAXLEN - 1);
492 strnz__cat(init->mapp_help, "/help", MAXLEN - 1);
493 }
494 init->mapp_spec[0] = '\0';
495 // Set default colors and settings in SIO struct
496 // These can be overridden by the config file or command-line options
497 // Included here to ensure SIO has valid defaults even if config parsing fails
498 strnz__cpy(sio->bg, "#000000",
499 COLOR_LEN - 1);
500 strnz__cpy(sio->fg, "#c0c0c0",
501 COLOR_LEN - 1);
502 strnz__cpy(sio->box_fg, "#f00000", COLOR_LEN - 1);
503 strnz__cpy(sio->box_bg, "#000000", COLOR_LEN - 1);
504 strnz__cpy(sio->ind_fg, "#f00000", COLOR_LEN - 1);
505 strnz__cpy(sio->ind_bg, "#000000", COLOR_LEN - 1);
506 strnz__cpy(sio->title_fg, "#f0f0f0", COLOR_LEN - 1);
507 strnz__cpy(sio->title_bg, "#000000", COLOR_LEN - 1);
508 strnz__cpy(sio->nt_fg, "#c0c0c0", COLOR_LEN - 1);
509 strnz__cpy(sio->nt_bg, "#000000", COLOR_LEN - 1);
510 strnz__cpy(sio->nt_rev_fg, "#000000", COLOR_LEN - 1);
511 strnz__cpy(sio->nt_rev_bg, "#c0c0c0", COLOR_LEN - 1);
512 strnz__cpy(sio->nt_hl_fg, "#f00000", COLOR_LEN - 1);
513 strnz__cpy(sio->nt_hl_bg, "#000000", COLOR_LEN - 1);
514 strnz__cpy(sio->nt_hl_rev_fg, "#000000", COLOR_LEN - 1);
515 strnz__cpy(sio->nt_hl_rev_bg, "#c0c0c0", COLOR_LEN - 1);
516 strnz__cpy(sio->ln_fg, "#0070ff",
517 COLOR_LEN - 1);
518 strnz__cpy(sio->ln_bg, "#101010",
519 COLOR_LEN - 1);
520
521 strnz__cpy(sio->cmdln_fg, "#d0d0d0",
522 COLOR_LEN - 1);
523 strnz__cpy(sio->cmdln_bg, "#000000",
524 COLOR_LEN - 1);
525
526 init->f_erase_remainder = true;
527 init->brackets[0] = '\0';
528 strnz__cpy(init->fill_char, " ", MAXLEN - 1);
529 e = getenv("TERM");
530 if (e == nullptr || *e == '\0')
531 strnz__cpy(term, "xterm-256color", MAXLEN);
532 else
533 strnz__cpy(term, e, MAXLEN - 1);
534 e = getenv("EDITOR");
535 if (e && *e != '\0')
536 strnz__cpy(init->editor, "vi", MAXLEN - 1);
537 else
538 strnz__cpy(init->editor, e, MAXLEN - 1);
540 init->mapp_spec[0] = '\0';
541 init->argc = argc;
542 argp_parse(&argp, argc, argv, 0, 0, init);
543 if (f_write_config) {
544 write_config(init);
545 exit(EXIT_SUCCESS);
546 }
547}
#define COLOR_LEN
Definition cm.h:283
bool f_write_config
Definition init.c:88
void abend(int, char *)
Abnormal program termination.
Definition dwin.c:2018
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:420
bool expand_tilde(char *, int)
Replaces "~/" in string with the user's home directory.
Definition futil.c:970
void open_cmenu_log()
Open new C-Menu log file.
Definition futil.c:1667
bool verify_dir(char *, int)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:1189
int write_config(Init *init)
Write the current configuration to a file specified in init->minitrc.
Definition init.c:1049
int process_config_files(Init *)
parse the configuration file specified in init->minitrc and set Init struct values accordingly
Definition init.c:610
char mapp_data[MAXLEN]
Definition common.h:147
char minitrc[MAXLEN]
Definition common.h:173
char mapp_help[MAXLEN]
Definition common.h:148
SIO * sio
Definition common.h:114
int argc
Definition common.h:130
char mapp_msrc[MAXLEN]
Definition common.h:149
bool f_erase_remainder
Definition common.h:141
char mapp_home[MAXLEN]
Definition common.h:146
char fill_char[4]
Definition common.h:145
char mapp_spec[MAXLEN]
Definition common.h:175
char brackets[3]
Definition common.h:144
char mapp_user[MAXLEN]
Definition common.h:150
char mapp_theme[MAXLEN]
Definition common.h:151
char editor[MAXLEN]
Definition common.h:171
char nt_hl_rev_bg[COLOR_LEN]
Definition cm.h:852
char nt_rev_bg[COLOR_LEN]
Definition cm.h:846
char ln_fg[COLOR_LEN]
Definition cm.h:839
char title_bg[COLOR_LEN]
Definition cm.h:854
char nt_hl_bg[COLOR_LEN]
Definition cm.h:848
char nt_hl_fg[COLOR_LEN]
Definition cm.h:847
char cmdln_bg[COLOR_LEN]
Definition cm.h:842
char ind_fg[COLOR_LEN]
Definition cm.h:833
char nt_fg[COLOR_LEN]
Definition cm.h:843
char ln_bg[COLOR_LEN]
Definition cm.h:840
char nt_rev_fg[COLOR_LEN]
Definition cm.h:845
char box_bg[COLOR_LEN]
Definition cm.h:832
char fg[COLOR_LEN]
Definition cm.h:829
char box_fg[COLOR_LEN]
Definition cm.h:831
char bg[COLOR_LEN]
Definition cm.h:830
char title_fg[COLOR_LEN]
Definition cm.h:853
char cmdln_fg[COLOR_LEN]
Definition cm.h:841
char nt_hl_rev_fg[COLOR_LEN]
Definition cm.h:850
char ind_bg[COLOR_LEN]
Definition cm.h:834
char nt_bg[COLOR_LEN]
Definition cm.h:844

References abend(), Init::argc, SIO::bg, SIO::box_bg, SIO::box_fg, Init::brackets, SIO::cmdln_bg, SIO::cmdln_fg, Init::editor, expand_tilde(), Init::f_erase_remainder, f_write_config, SIO::fg, Init::fill_char, SIO::ind_bg, SIO::ind_fg, SIO::ln_bg, SIO::ln_fg, Init::mapp_data, Init::mapp_help, Init::mapp_home, Init::mapp_msrc, Init::mapp_spec, Init::mapp_theme, Init::mapp_user, Init::minitrc, SIO::nt_bg, SIO::nt_fg, SIO::nt_hl_bg, SIO::nt_hl_fg, SIO::nt_hl_rev_bg, SIO::nt_hl_rev_fg, SIO::nt_rev_bg, SIO::nt_rev_fg, process_config_files(), Init::sio, ssnprintf(), strnz__cat(), strnz__cpy(), SIO::title_bg, SIO::title_fg, verify_dir(), and write_config().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ opt_prt_bool()

void opt_prt_bool ( const char * o,
const char * name,
bool value )

Print an option and its value in a formatted manner for boolean values.

Parameters
o- option flag (e.g., "-z")
name- option name (e.g., "f_squeeze")
value- boolean option value to print

This function is used to display the current configuration options and their boolean values in a readable format, printing "true" or "false" based on the value.

Definition at line 1395 of file init.c.

1395 {
1396 fprintf(stdout, "%3s %-15s: %s\n", o, name, value ? "true" : "false");
1397}

◆ opt_prt_char()

void opt_prt_char ( const char * o,
const char * name,
const char * value )

Print an option and its value in a formatted manner.

Parameters
o- option flag (e.g., "-a:")
name- option name (e.g., "--minitrc")
value- option value to print

This function is used to display the current configuration options and their values in a readable format.

Definition at line 1350 of file init.c.

1350 {
1351 fprintf(stdout, "%3s %-15s: %s\n", o, name, value);
1352}

◆ opt_prt_double()

void opt_prt_double ( const char * o,
const char * name,
double value )

Print an option and its value in a formatted manner for double values.

Parameters
o- option flag (e.g., "-r:")
name- option name (e.g., "red_gamma")
value- double option value to print

This function is used to display the current configuration options and their double values in a readable format.

Definition at line 1383 of file init.c.

1383 {
1384 fprintf(stdout, "%3s %-15s: %0.2f\n", o, name, value);
1385}

◆ opt_prt_int()

void opt_prt_int ( const char * o,
const char * name,
int value )

Print an option and its value in a formatted manner for integer values.

Parameters
o- option flag (e.g., "-C:")
name- option name (e.g., "--cols")
value- integer option value to print

This function is used to display the current configuration options and their integer values in a readable format.

Definition at line 1372 of file init.c.

1372 {
1373 fprintf(stdout, "%3s %-15s: %d\n", o, name, value);
1374}

◆ opt_prt_str()

void opt_prt_str ( const char * o,
const char * name,
const char * value )

Print an option and its value in a formatted manner for integer values.

Parameters
o- option flag (e.g., "-C:")
name- option name (e.g., "--cols")
value- integer option value to print

This function is used to display the current configuration options and their integer values in a readable format.

Definition at line 1361 of file init.c.

1361 {
1362 fprintf(stdout, "%3s %-15s: %s\n", o, name, value);
1363}

◆ parse_opt_args()

int parse_opt_args ( Init * init,
int argc,
char ** argv )

Parse command-line options and set Init struct values accordingly.

Parameters
init- pointer to Init struct to be populated with option values
argc- argument count from main()
argv- argument vector from main()
Returns
0 on success, -1 on failure

This function uses the argp library to parse command-line options defined in the options array. It updates the Init struct with values from the options and handles any special flags for dumping or writing configuration.

Definition at line 559 of file init.c.

559 {
560 init->argc = destroy_argv(init->argc, init->argv);
561 argp_parse(&argp, argc, argv, 0, 0, init);
562 return 0;
563}
int destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:494
char ** argv
Definition common.h:131

References Init::argc, Init::argv, and destroy_argv().

Referenced by popup_form(), popup_menu(), popup_pick(), and popup_view().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_config_files()

int process_config_files ( Init * init)

parse the configuration file specified in init->minitrc and set Init struct values accordingly

Returns
on success, -1 on failure

Lines beginning with '#" are comments, discard. Copy line to tmp_str removing quotes, spaces, semicolons, and newlines. Record structure is "parse key=value pairs". Skip lines without '='. Set init struct values based on key. Skip unknown keys.

Definition at line 610 of file init.c.

610 {
611 char config_file_name[MAXLEN];
612 int rc;
613 if (!init->minitrc[0]) {
614 char *e = getenv("MINITRC");
615 if (e)
616 strnz__cpy(init->minitrc, e, MAXLEN - 1);
617 else
618 strnz__cpy(init->minitrc, "~/.minitrc", MAXLEN - 1);
619 }
620
621 expand_tilde(init->minitrc, MAXLEN - 1);
622 strnz__cpy(config_file_name, init->minitrc, MAXLEN - 1);
623 rc = process_config_file(config_file_name, init);
624
625 expand_tilde(init->mapp_theme, MAXLEN - 1);
626 strnz__cpy(config_file_name, init->mapp_theme, MAXLEN - 1);
627 rc = process_config_file(config_file_name, init);
628 return rc;
629}
int process_config_file(char *, Init *)
Definition init.c:631

References expand_tilde(), Init::mapp_theme, Init::minitrc, process_config_file(), and strnz__cpy().

Referenced by mapp_initialization().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_config()

int write_config ( Init * init)

Write the current configuration to a file specified in init->minitrc.

Parameters
init- pointer to Init struct containing current configuration
Returns
0 on success, -1 on failure

The configuration is written in key=value format, one per line. Lines beginning with '#' are comments and are ignored when reading the config file. The file is created if it does not exist, and overwritten if it does exist

Definition at line 1049 of file init.c.

1049 {
1050 char *e;
1051 char minitrc_dmp[MAXLEN];
1052 char tmp_str[MAXLEN];
1053 SIO *sio = init->sio;
1054 e = getenv("CMENU_HOME");
1055 minitrc_dmp[0] = '\0';
1056 char config_s[MAXLEN];
1057 if (e) {
1058 strnz__cpy(minitrc_dmp, e, MAXLEN - 1);
1059 strnz__cat(minitrc_dmp, "/", MAXLEN - 1);
1060 }
1061 strnz__cat(minitrc_dmp, "minitrc.dmp", MAXLEN - 1);
1062 FILE *minitrc_fp = fopen(minitrc_dmp, "w");
1063 if (minitrc_fp == (FILE *)0) {
1064 fprintf(stderr, "failed to open file: %s\n", minitrc_dmp);
1065 return (-1);
1066 }
1067 (void)fprintf(minitrc_fp, "# %s\n", minitrc_dmp);
1068 char *doc_tbl[50] = {
1069 "# C-Menu example configuration file",
1070 "#",
1071 "# This file is generated by C-Menu when run with the -W option.",
1072 "# Copy this file and edit the copy because this file will be",
1073 "# overwritten each time C-Menu is run with the - W option.",
1074 "#",
1075 "# C-Menu processes key value pairs in reading order from its",
1076 "# main configuraiton file, ~/ menuapp /.minitrc, and any other",
1077 "# configuration files sourced with include statements such as",
1078 "# the following:",
1079 "#",
1080 "# include = ~/menuapp/theme/default",
1081 "#",
1082 "# Assuming your configuration file is in ~/menuapp/theme/Red,",
1083 "# you could create a symbolic link named default that points to",
1084 "# Red, and then include default in your main configuration file.",
1085 "# (Actually ~/menuapp/.minitrc already includes default, so you",
1086 "# would only need to create the theme file and the symbolic link.",
1087 "#",
1088 "# ln -s Red default",
1089 "#",
1090 "# Key value pairs included from configuration files are",
1091 "# processed in reading order as they are included.",
1092 "#",
1093 "# This is significant in the event that a key is included more",
1094 "# than once in the configuration file and / or included files.",
1095 "# Only the last value read for a key will be used by C-Menu.",
1096 "#",
1097 "# If you want to override key values in the C-Menu configuration",
1098 "# file, you can do so by inserting an include statement for a",
1099 "# supplemental configuration file below the keys you want to",
1100 "# override in the C-Menu configuration file. Conversely, if you",
1101 "# want to use a supplemental configuration as the default,",
1102 "# include it first.",
1103 "#",
1104 "# Parsing: Lines beginning with # are comments and are ignored.",
1105 "# Lines containing key=value pairs are parsed and the key and",
1106 "# value are extracted. Lines without an '=' are ignored. Values",
1107 "# are stripped of leading and trailing whitespace and quotes.",
1108 "# Values can be enclosed in single or double quotes to preserve",
1109 "# leading and trailing whitespace. Values can also be specified",
1110 "# as hex color codes such as #ff0000 for red. If a value is",
1111 "# specified as a hex color code, it is parsed and stored as a",
1112 "# hex color code in the configuration. An unquoted '#' that is",
1113 "# not part of a six digit hex color code and after key values",
1114 "# have been extracted is the beginning of a comment.", ""};
1115 for (int i = 0; doc_tbl[i][0] != '\0'; i++)
1116 (void)fprintf(minitrc_fp, "%s\n", doc_tbl[i]);
1117 (void)fprintf(minitrc_fp, "#\n");
1118 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "parent_cmd", init->parent_cmd);
1119 print_argp_doc(minitrc_fp, config_s, "parent_cmd");
1120 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "cols", init->cols);
1121 print_argp_doc(minitrc_fp, config_s, "cols");
1122 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "lines", init->lines);
1123 print_argp_doc(minitrc_fp, config_s, "lines");
1124 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "title", init->title);
1125 print_argp_doc(minitrc_fp, config_s, "title");
1126 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "begx", init->begx);
1127 print_argp_doc(minitrc_fp, config_s, "begx");
1128 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "begy", init->begy);
1129 print_argp_doc(minitrc_fp, config_s, "begy");
1130 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmd_all", init->cmd_all);
1131 print_argp_doc(minitrc_fp, config_s, "cmd_all");
1132 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmd", init->cmd);
1133 print_argp_doc(minitrc_fp, config_s, "cmd");
1134 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_spec", init->mapp_spec);
1135 print_argp_doc(minitrc_fp, config_s, "mapp_spec");
1136 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "help_spec", init->help_spec);
1137 print_argp_doc(minitrc_fp, config_s, "help_spec");
1138 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "in_spec", init->in_spec);
1139 print_argp_doc(minitrc_fp, config_s, "in_spec");
1140 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "out_spec", init->out_spec);
1141 print_argp_doc(minitrc_fp, config_s, "out_spec");
1142 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "receiver_cmd", init->receiver_cmd);
1143 print_argp_doc(minitrc_fp, config_s, "receiver_cmd");
1144 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "provider_cmd", init->provider_cmd);
1145 print_argp_doc(minitrc_fp, config_s, "provider_cmd");
1146 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_erase_remainder", init->f_erase_remainder ? "true" : "false");
1147 print_argp_doc(minitrc_fp, config_s, "f_erase_remainder");
1148 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "fill_char", init->fill_char);
1149 print_argp_doc(minitrc_fp, config_s, "fill_char");
1150 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_strip_ansi", init->f_strip_ansi ? "true" : "false");
1151 print_argp_doc(minitrc_fp, config_s, "f_strip_ansi");
1152 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_multiple_cmd_args", init->f_multiple_cmd_args ? "true" : "false");
1153 print_argp_doc(minitrc_fp, config_s, "f_multiple_cmd_args");
1154 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "select_max", init->select_max);
1155 print_argp_doc(minitrc_fp, config_s, "select_max");
1156 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_ln", init->f_ln ? "true" : "false");
1157 print_argp_doc(minitrc_fp, config_s, "f_ln");
1158 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_squeeze", init->f_squeeze ? "true" : "false");
1159 print_argp_doc(minitrc_fp, config_s, "f_squeeze");
1160 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "tab_stop", init->tab_stop);
1161 print_argp_doc(minitrc_fp, config_s, "tab_stop");
1162 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "h_shift", init->h_shift);
1163 print_argp_doc(minitrc_fp, config_s, "h_shift");
1164 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "brackets", init->brackets);
1165 print_argp_doc(minitrc_fp, config_s, "brackets");
1166 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "wait_timeout", wait_timeout);
1167 print_argp_doc(minitrc_fp, config_s, "wait_timeout");
1168 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_ignore_case", init->f_ignore_case ? "true" : "false");
1169 print_argp_doc(minitrc_fp, config_s, "f_ignore_case");
1170 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "p_view_files", init->p_view_files ? "true" : "false");
1171 print_argp_doc(minitrc_fp, config_s, "p_view_files");
1172 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_read_theme", init->f_read_theme ? "true" : "false");
1173 print_argp_doc(minitrc_fp, config_s, "f_read_theme");
1174 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "editor", init->editor);
1175 print_argp_doc(minitrc_fp, config_s, "editor");
1176 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "bg", sio->bg);
1177 print_argp_doc(minitrc_fp, config_s, "bg");
1178 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "fg", sio->fg);
1179 print_argp_doc(minitrc_fp, config_s, "fg");
1180 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "box_fg", sio->box_fg);
1181 print_argp_doc(minitrc_fp, config_s, "box_fg");
1182 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "box_bg", sio->box_bg);
1183 print_argp_doc(minitrc_fp, config_s, "box_bg");
1184 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "ind_fg", sio->ind_fg);
1185 print_argp_doc(minitrc_fp, config_s, "ind_fg");
1186 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "ind_bg", sio->ind_bg);
1187 print_argp_doc(minitrc_fp, config_s, "ind_bg");
1188 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "brackets_fg", sio->brackets_fg);
1189 print_argp_doc(minitrc_fp, config_s, "brackets_fg");
1190 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "brackets_bg", sio->brackets_bg);
1191 print_argp_doc(minitrc_fp, config_s, "brackets_bg");
1192 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "fill_char_fg", sio->fill_char_fg);
1193 print_argp_doc(minitrc_fp, config_s, "fill_char_fg");
1194 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "fill_char_bg", sio->fill_char_bg);
1195 print_argp_doc(minitrc_fp, config_s, "fill_char_bg");
1196
1197 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "ln_bg", sio->ln_bg);
1198 print_argp_doc(minitrc_fp, config_s, "ln_bg");
1199
1200 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "ln_fg", sio->ln_fg);
1201 print_argp_doc(minitrc_fp, config_s, "ln_bg");
1202
1203 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmdln_bg", sio->cmdln_bg);
1204 print_argp_doc(minitrc_fp, config_s, "cmdln_bg");
1205 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmdln_fg", sio->cmdln_fg);
1206 print_argp_doc(minitrc_fp, config_s, "cmdln_fg");
1207
1208 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "nt_fg", sio->nt_fg);
1209 print_argp_doc(minitrc_fp, config_s, "nt_fg");
1210 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "nt_bg", sio->nt_bg);
1211 print_argp_doc(minitrc_fp, config_s, "nt_bg");
1212 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "nt_hl_fg", sio->nt_hl_fg);
1213 print_argp_doc(minitrc_fp, config_s, "nt_hl_fg");
1214 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "nt_hl_bg", sio->nt_hl_bg);
1215 print_argp_doc(minitrc_fp, config_s, "nt_hl_bg");
1216 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "nt_rev_fg", sio->nt_rev_fg);
1217 print_argp_doc(minitrc_fp, config_s, "nt_rev_fg");
1218 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "nt_rev_bg", sio->nt_rev_bg);
1219 print_argp_doc(minitrc_fp, config_s, "nt_rev_bg");
1220 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "nt_hl_rev_fg", sio->nt_hl_rev_fg);
1221 print_argp_doc(minitrc_fp, config_s, "nt_hl_rev_fg");
1222 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "nt_hl_rev_bg", sio->nt_hl_rev_bg);
1223 print_argp_doc(minitrc_fp, config_s, "nt_hl_rev_bg");
1224 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "title_fg", sio->title_fg);
1225 print_argp_doc(minitrc_fp, config_s, "title_fg");
1226 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "title_bg", sio->title_bg);
1227 print_argp_doc(minitrc_fp, config_s, "title_bg");
1228 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "blue_gamma", sio->blue_gamma);
1229 print_argp_doc(minitrc_fp, config_s, "blue_gamma");
1230 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "gray_gamma", sio->gray_gamma);
1231 print_argp_doc(minitrc_fp, config_s, "gray_gamma");
1232 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "green_gamma", sio->green_gamma);
1233 print_argp_doc(minitrc_fp, config_s, "green_gamma");
1234 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "red_gamma", sio->red_gamma);
1235 print_argp_doc(minitrc_fp, config_s, "red_gamma");
1236 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "black", sio->black);
1237 print_argp_doc(minitrc_fp, config_s, "black");
1238 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "red", sio->red);
1239 print_argp_doc(minitrc_fp, config_s, "red");
1240 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "green", sio->green);
1241 print_argp_doc(minitrc_fp, config_s, "green");
1242 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "yellow", sio->yellow);
1243 print_argp_doc(minitrc_fp, config_s, "yellow");
1244 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "blue", sio->blue);
1245 print_argp_doc(minitrc_fp, config_s, "blue");
1246 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "magenta", sio->magenta);
1247 print_argp_doc(minitrc_fp, config_s, "magenta");
1248 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cyan", sio->cyan);
1249 print_argp_doc(minitrc_fp, config_s, "cyan");
1250 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "white", sio->white);
1251 print_argp_doc(minitrc_fp, config_s, "white");
1252 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "bblack", sio->bblack);
1253 print_argp_doc(minitrc_fp, config_s, "bblack");
1254 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "bred", sio->bred);
1255 print_argp_doc(minitrc_fp, config_s, "bred");
1256 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "bgreen", sio->bgreen);
1257 print_argp_doc(minitrc_fp, config_s, "bgreen");
1258 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "byellow", sio->byellow);
1259 print_argp_doc(minitrc_fp, config_s, "byellow");
1260 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "bblue", sio->bblue);
1261 print_argp_doc(minitrc_fp, config_s, "bblue");
1262 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "bmagenta", sio->bmagenta);
1263 print_argp_doc(minitrc_fp, config_s, "bmagenta");
1264 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "bcyan", sio->bcyan);
1265 print_argp_doc(minitrc_fp, config_s, "bcyan");
1266 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "bwhite", sio->bwhite);
1267 print_argp_doc(minitrc_fp, config_s, "bwhite");
1268 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_data", init->mapp_data);
1269 print_argp_doc(minitrc_fp, config_s, "mapp_data");
1270 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_help", init->mapp_help);
1271 print_argp_doc(minitrc_fp, config_s, "mapp_help");
1272 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_home", init->mapp_home);
1273 print_argp_doc(minitrc_fp, config_s, "mapp_home");
1274 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_msrc", init->mapp_msrc);
1275 print_argp_doc(minitrc_fp, config_s, "mapp_msrc");
1276 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_user", init->mapp_user);
1277 print_argp_doc(minitrc_fp, config_s, "mapp_user");
1278 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_theme", init->mapp_theme);
1279 print_argp_doc(minitrc_fp, config_s, "mapp_theme");
1280 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "include", init->mapp_theme);
1281 (void)fprintf(minitrc_fp, "%-34s # default theme file\n", config_s);
1282 strnz__cpy(tmp_str, "Configuration written to file: ", MAXLEN - 1);
1283 strnz__cat(tmp_str, minitrc_dmp, MAXLEN - 1);
1284 Perror(tmp_str);
1285 return 0;
1286}
int wait_timeout
Definition futil.c:152
void print_argp_doc(FILE *, char *, char *)
Definition init.c:1287
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1526
char title[MAXLEN]
Definition common.h:129
int begx
Definition common.h:118
char in_spec[MAXLEN]
Definition common.h:167
char cmd_all[MAXLEN]
Definition common.h:123
int cols
Definition common.h:116
int tab_stop
Definition common.h:180
bool f_read_theme
Definition common.h:142
bool f_squeeze
Definition common.h:137
int begy
Definition common.h:117
char parent_cmd[MAXLEN]
Definition common.h:124
char receiver_cmd[MAXLEN]
Definition common.h:121
int h_shift
Definition common.h:181
bool f_multiple_cmd_args
Definition common.h:139
int select_max
Definition common.h:178
bool f_ln
Definition common.h:143
char provider_cmd[MAXLEN]
Definition common.h:120
char out_spec[MAXLEN]
Definition common.h:168
bool f_strip_ansi
Definition common.h:136
bool p_view_files
Definition common.h:134
bool f_ignore_case
Definition common.h:133
int lines
Definition common.h:115
char cmd[MAXLEN]
Definition common.h:122
char help_spec[MAXLEN]
Definition common.h:176
double green_gamma
Definition cm.h:807
char black[COLOR_LEN]
Definition cm.h:810
double blue_gamma
Definition cm.h:808
char bred[COLOR_LEN]
Definition cm.h:820
char yellow[COLOR_LEN]
Definition cm.h:813
char bcyan[COLOR_LEN]
Definition cm.h:825
double red_gamma
Definition cm.h:806
char red[COLOR_LEN]
Definition cm.h:811
char magenta[COLOR_LEN]
Definition cm.h:815
char bgreen[COLOR_LEN]
Definition cm.h:821
char brackets_fg[COLOR_LEN]
Definition cm.h:835
char fill_char_fg[COLOR_LEN]
Definition cm.h:837
char byellow[COLOR_LEN]
Definition cm.h:822
char bwhite[COLOR_LEN]
Definition cm.h:826
char cyan[COLOR_LEN]
Definition cm.h:816
char brackets_bg[COLOR_LEN]
Definition cm.h:836
char fill_char_bg[COLOR_LEN]
Definition cm.h:838
char green[COLOR_LEN]
Definition cm.h:812
char white[COLOR_LEN]
Definition cm.h:817
char bblue[COLOR_LEN]
Definition cm.h:823
char bmagenta[COLOR_LEN]
Definition cm.h:824
char blue[COLOR_LEN]
Definition cm.h:814
double gray_gamma
Definition cm.h:809
char bblack[COLOR_LEN]
Definition cm.h:819

References SIO::bblack, SIO::bblue, SIO::bcyan, Init::begx, Init::begy, SIO::bg, SIO::bgreen, SIO::black, SIO::blue, SIO::blue_gamma, SIO::bmagenta, SIO::box_bg, SIO::box_fg, Init::brackets, SIO::brackets_bg, SIO::brackets_fg, SIO::bred, SIO::bwhite, SIO::byellow, Init::cmd, Init::cmd_all, SIO::cmdln_bg, SIO::cmdln_fg, Init::cols, SIO::cyan, Init::editor, Init::f_erase_remainder, Init::f_ignore_case, Init::f_ln, Init::f_multiple_cmd_args, Init::f_read_theme, Init::f_squeeze, Init::f_strip_ansi, SIO::fg, Init::fill_char, SIO::fill_char_bg, SIO::fill_char_fg, SIO::gray_gamma, SIO::green, SIO::green_gamma, Init::h_shift, Init::help_spec, Init::in_spec, SIO::ind_bg, SIO::ind_fg, Init::lines, SIO::ln_bg, SIO::ln_fg, SIO::magenta, Init::mapp_data, Init::mapp_help, Init::mapp_home, Init::mapp_msrc, Init::mapp_spec, Init::mapp_theme, Init::mapp_user, SIO::nt_bg, SIO::nt_fg, SIO::nt_hl_bg, SIO::nt_hl_fg, SIO::nt_hl_rev_bg, SIO::nt_hl_rev_fg, SIO::nt_rev_bg, SIO::nt_rev_fg, Init::out_spec, Init::p_view_files, Init::parent_cmd, Perror(), print_argp_doc(), Init::provider_cmd, Init::receiver_cmd, SIO::red, SIO::red_gamma, Init::select_max, Init::sio, ssnprintf(), strnz__cat(), strnz__cpy(), Init::tab_stop, Init::title, SIO::title_bg, SIO::title_fg, wait_timeout, SIO::white, and SIO::yellow.

Referenced by mapp_initialization(), and menu_cmd_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zero_opt_args()

void zero_opt_args ( Init * init)

Initialize optional arguments in the Init struct to default values.

Parameters
init- pointer to Init struct to be initialized This function sets all optional argument fields in the Init struct to their default values before parsing command-line options or configuration file. This ensures that any fields not specified by the user will have known default values.

Definition at line 574 of file init.c.

574 {
575 init->lines = 0;
576 init->cols = 0;
577 init->begx = 0;
578 init->begy = 0;
579 init->f_mapp_desc = false;
580 init->f_provider_cmd = false;
581 init->f_receiver_cmd = false;
582 init->f_title = false;
583 init->f_mapp_spec = false;
584 init->f_help_spec = false;
585 init->f_in_spec = false;
586 init->f_out_spec = false;
587 init->p_view_files = false;
588 init->h_shift = 0;
589 init->mapp_spec[0] = init->help_spec[0] = '\0';
590 init->provider_cmd[0] = init->receiver_cmd[0] = '\0';
591 init->title[0] = '\0';
592 init->cmd[0] = init->cmd_all[0] = '\0';
593 init->parent_cmd[0] = '\0';
594 init->in_spec[0] = init->out_spec[0] = '\0';
595 init->help_spec[0] = '\0';
596 init->in_spec[0] = '\0';
597 init->out_spec[0] = '\0';
598}
bool f_out_spec
Definition common.h:170
bool f_title
Definition common.h:165
bool f_mapp_desc
Definition common.h:160
bool f_mapp_spec
Definition common.h:155
bool f_help_spec
Definition common.h:166
bool f_receiver_cmd
Definition common.h:162
bool f_provider_cmd
Definition common.h:161
bool f_in_spec
Definition common.h:169

References Init::begx, Init::begy, Init::cmd, Init::cmd_all, Init::cols, Init::f_help_spec, Init::f_in_spec, Init::f_mapp_desc, Init::f_mapp_spec, Init::f_out_spec, Init::f_provider_cmd, Init::f_receiver_cmd, Init::f_title, Init::h_shift, Init::help_spec, Init::in_spec, Init::lines, Init::mapp_spec, Init::out_spec, Init::p_view_files, Init::parent_cmd, Init::provider_cmd, Init::receiver_cmd, and Init::title.

Referenced by popup_form(), popup_menu(), popup_pick(), and popup_view().

Here is the caller graph for this function: