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 1367 of file init.c.

1367 {
1368 char tmp_str[MAXLEN];
1369 char ts2[MAXLEN];
1370 char *e;
1371
1372 if (!file_name || !*file_name) {
1373 *file_spec = '\0';
1374 return false;
1375 }
1376 if (dir) {
1377 strnz__cpy(tmp_str, dir, MAXLEN - 1);
1378 } else {
1379 e = getenv("MAPP_DIR");
1380 if (e) {
1381 strnz__cpy(tmp_str, e, MAXLEN - 1);
1382 } else {
1383 strnz__cpy(tmp_str, "~/menuapp", MAXLEN - 1);
1384 }
1385 }
1386 trim_path(tmp_str);
1387 strnz__cpy(ts2, tmp_str, MAXLEN - 1);
1388 // construct the full file specification
1389 // check that the file exists and is readable
1390 strnz__cpy(file_spec, ts2, MAXLEN - 1);
1391 strnz__cat(file_spec, "/", MAXLEN - 1);
1392 strnz__cat(file_spec, file_name, MAXLEN - 1);
1393 return true;
1394}
#define MAXLEN
Definition curskeys.c:15
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:537
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:566
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
Definition futil.c:981

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 1399 of file init.c.

1399 {
1400 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1401 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1402 fprintf(stdout, "C version: %ld\n", __STDC_VERSION__);
1403}
#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:688

< menu specification file

< default border style

< erase remainder on enter

< field enclosure brackets

< field fill character

Definition at line 474 of file init.c.

474 {
475 char term[MAXLEN];
476 char tmp_str[MAXLEN];
477 char *e;
478 setlocale(LC_ALL, "en_US.UTF-8");
479 SIO *sio = init->sio;
480 if (!init) {
481 ssnprintf(tmp_str, sizeof(tmp_str), "%s",
482 "init struct not allocated on entry");
483 abend(-1, tmp_str);
484 exit(-1);
485 }
486#ifdef DEBUG_LOG
488#endif
489 e = getenv("CMENU_HOME");
490 if (!e || *e == '\0')
491 strnz__cpy(init->mapp_home, "~/menuapp", MAXLEN);
492 else
493 strnz__cpy(init->mapp_home, e, MAXLEN);
494
495 if (init->mapp_home[0] != '\0') {
496 expand_tilde(init->mapp_home, MAXLEN - 1);
497 if (!verify_dir(init->mapp_home, R_OK))
498 abend(-1, "MAPP_HOME directory invalid");
499 }
500 // CMENU_RC should be an absolute path
501 e = getenv("CMENU_RC");
502 if (!e || *e == '\0') {
503 strnz__cpy(init->minitrc, init->mapp_home, MAXLEN - 1);
504 strnz__cat(init->minitrc, "/.minitrc", MAXLEN);
505 } else
506 strnz__cpy(init->minitrc, e, MAXLEN);
507 if (init->mapp_user[0] == '\0') {
508 strnz__cpy(init->mapp_user, init->mapp_home, MAXLEN - 1);
509 strnz__cat(init->mapp_user, "/user", MAXLEN - 1);
510 }
511 if (init->mapp_theme[0] == '\0') {
512 strnz__cpy(init->mapp_theme, init->mapp_home, MAXLEN - 1);
513 strnz__cat(init->mapp_theme, "/themes/default", MAXLEN - 1);
514 }
515 if (init->mapp_msrc[0] == '\0') {
516 strnz__cpy(init->mapp_msrc, init->mapp_home, MAXLEN - 1);
517 strnz__cat(init->mapp_msrc, "/msrc", MAXLEN - 1);
518 }
519 if (init->mapp_data[0] == '\0') {
520 strnz__cpy(init->mapp_data, init->mapp_home, MAXLEN - 1);
521 strnz__cat(init->mapp_data, "/data", MAXLEN - 1);
522 }
523 if (init->mapp_help[0] == '\0') {
524 strnz__cpy(init->mapp_help, init->mapp_home, MAXLEN - 1);
525 strnz__cat(init->mapp_help, "/help", MAXLEN - 1);
526 }
527 init->mapp_spec[0] = '\0';
528 // Set default colors and settings in SIO struct
529 // These can be overridden by the config file or command-line options
530 // Included here to ensure SIO has valid defaults even if config parsing fails
531
532 sio->border = 'r';
533 sio->bg = 0x000000;
534 sio->fg = 0xc0c0c0;
535 sio->border = 'r';
536 sio->box_fg = 0xf00000;
537 sio->box_bg = 0x000000;
538 sio->ind_fg = 0xf00000;
539 sio->ind_bg = 0x000000;
540 sio->ran_fg = 0xf00000;
541 sio->ran_bg = 0x000000;
542 sio->title_fg = 0xf0f0f0;
543 sio->title_bg = 0x000000;
544 sio->nt_fg = 0xc0c0c0;
545 sio->nt_bg = 0x000000;
546 sio->nt_rev_fg = 0x000000;
547 sio->nt_rev_bg = 0xc0c0c0;
548 sio->nt_hl_fg = 0xf00000;
549 sio->nt_hl_bg = 0x000000;
550 sio->nt_hl_rev_fg = 0x000000;
551 sio->nt_hl_rev_bg = 0xc0c0c0;
552 sio->ln_fg = 0x0070ff;
553 sio->ln_bg = 0x101010;
554 sio->cmdln_fg = 0xd0d0d0;
555 sio->cmdln_bg = 0x000000;
556 init->f_erase_remainder = true;
557 init->brackets[0] = '\0';
558 strnz__cpy(init->fill_char, " ", MAXLEN - 1);
559 e = getenv("TERM");
560 if (e == nullptr || *e == '\0')
561 strnz__cpy(term, "xterm-256color", MAXLEN);
562 else
563 strnz__cpy(term, e, MAXLEN - 1);
564 e = getenv("EDITOR");
565 if (e && *e != '\0')
566 strnz__cpy(init->editor, "vi", MAXLEN - 1);
567 else
568 strnz__cpy(init->editor, e, MAXLEN - 1);
570 init->mapp_spec[0] = '\0';
571 init->argc = argc;
572 argp_parse(&argp, argc, argv, 0, 0, init);
573 strnz__cpy(sio->fill_char, init->fill_char, 1);
574 strnz__cpy(sio->brackets, init->brackets, 2);
575 if (f_write_config) {
576 write_config(init);
577 exit(EXIT_SUCCESS);
578 }
579}
bool f_write_config
Definition init.c:91
void abend(int ec, char *s)
Abnormal program termination.
Definition dwin.c:1204
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:413
void open_cmenu_log()
Open new C-Menu log file.
Definition futil.c:1650
bool expand_tilde(char *, uint)
Replaces "~/" in string with the user's home directory.
Definition futil.c:963
bool verify_dir(char *, uint)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:1172
int write_config(Init *init)
Write the current configuration to a file specified in init->minitrc.
Definition init.c:1103
int process_config_files(Init *)
parse the configuration file specified in init->minitrc and set Init struct values accordingly
Definition init.c:642
uint32_t ran_bg
Definition cm.h:737
uint32_t ln_bg
Definition cm.h:723
char brackets[3]
Definition cm.h:750
uint32_t cmdln_bg
Definition cm.h:725
uint32_t cmdln_fg
Definition cm.h:724
uint32_t nt_hl_rev_fg
Definition cm.h:732
uint32_t ran_fg
Definition cm.h:736
char fill_char[2]
Definition cm.h:751
uint32_t nt_fg
Definition cm.h:726
uint32_t box_fg
Definition cm.h:714
uint32_t ln_fg
Definition cm.h:722
uint32_t ind_bg
Definition cm.h:717
uint32_t ind_fg
Definition cm.h:716
uint32_t title_bg
Definition cm.h:735
uint32_t fg
Definition cm.h:712
uint32_t nt_hl_rev_bg
Definition cm.h:733
uint32_t title_fg
Definition cm.h:734
uint32_t nt_rev_bg
Definition cm.h:729
uint32_t nt_bg
Definition cm.h:727
uint32_t box_bg
Definition cm.h:715
uint32_t nt_hl_fg
Definition cm.h:730
char border
Definition cm.h:752
uint32_t nt_rev_fg
Definition cm.h:728
uint32_t nt_hl_bg
Definition cm.h:731
uint32_t bg
Definition cm.h:713
char mapp_data[MAXLEN]
Definition common.h:148
char minitrc[MAXLEN]
Definition common.h:174
char mapp_help[MAXLEN]
Definition common.h:149
SIO * sio
Definition common.h:114
int argc
Definition common.h:130
char fill_char[2]
Definition common.h:146
char mapp_msrc[MAXLEN]
Definition common.h:150
bool f_erase_remainder
Definition common.h:141
char mapp_home[MAXLEN]
Definition common.h:147
char mapp_spec[MAXLEN]
Definition common.h:176
char brackets[3]
Definition common.h:145
char mapp_user[MAXLEN]
Definition common.h:151
char mapp_theme[MAXLEN]
Definition common.h:152
char editor[MAXLEN]
Definition common.h:172

References abend(), Init::argc, SIO::bg, SIO::border, SIO::box_bg, SIO::box_fg, Init::brackets, SIO::brackets, SIO::cmdln_bg, SIO::cmdln_fg, Init::editor, expand_tilde(), Init::f_erase_remainder, f_write_config, SIO::fg, Init::fill_char, SIO::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(), SIO::ran_bg, SIO::ran_fg, 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 1456 of file init.c.

1456 {
1457 fprintf(stdout, "%3s %-15s: %s\n", o, name, value ? "true" : "false");
1458}

◆ 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 1411 of file init.c.

1411 {
1412 fprintf(stdout, "%3s %-15s: %s\n", o, name, value);
1413}

◆ 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 1444 of file init.c.

1444 {
1445 fprintf(stdout, "%3s %-15s: %0.2f\n", o, name, value);
1446}

◆ 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 1433 of file init.c.

1433 {
1434 fprintf(stdout, "%3s %-15s: %d\n", o, name, value);
1435}

◆ 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 1422 of file init.c.

1422 {
1423 fprintf(stdout, "%3s %-15s: %s\n", o, name, value);
1424}

◆ 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 591 of file init.c.

591 {
592 init->argc = destroy_argv(init->argc, init->argv);
593 argp_parse(&argp, argc, argv, 0, 0, init);
594 return 0;
595}
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:487
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 642 of file init.c.

642 {
643 char config_file_name[MAXLEN];
644 int rc;
645 if (!init->minitrc[0]) {
646 char *e = getenv("MINITRC");
647 if (e)
648 strnz__cpy(init->minitrc, e, MAXLEN - 1);
649 else
650 strnz__cpy(init->minitrc, "~/.minitrc", MAXLEN - 1);
651 }
652
653 expand_tilde(init->minitrc, MAXLEN - 1);
654 strnz__cpy(config_file_name, init->minitrc, MAXLEN - 1);
655 rc = process_config_file(config_file_name, init);
656
657 expand_tilde(init->mapp_theme, MAXLEN - 1);
658 strnz__cpy(config_file_name, init->mapp_theme, MAXLEN - 1);
659 rc = process_config_file(config_file_name, init);
660 return rc;
661}
int process_config_file(char *, Init *)
Definition init.c:663

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 1103 of file init.c.

1103 {
1104 char *e;
1105 char minitrc_dmp[MAXLEN];
1106 char tmp_str[MAXLEN];
1107 SIO *sio = init->sio;
1108 e = getenv("CMENU_HOME");
1109 minitrc_dmp[0] = '\0';
1110 char config_s[MAXLEN];
1111 if (e) {
1112 strnz__cpy(minitrc_dmp, e, MAXLEN - 1);
1113 strnz__cat(minitrc_dmp, "/", MAXLEN - 1);
1114 }
1115 strnz__cat(minitrc_dmp, "minitrc.dmp", MAXLEN - 1);
1116 FILE *minitrc_fp = fopen(minitrc_dmp, "w");
1117 if (minitrc_fp == (FILE *)0) {
1118 fprintf(stderr, "failed to open file: %s\n", minitrc_dmp);
1119 return (-1);
1120 }
1121 (void)fprintf(minitrc_fp, "# %s\n", minitrc_dmp);
1122 char *doc_tbl[50] = {
1123 "# C-Menu example configuration file",
1124 "#",
1125 "# This file is generated by C-Menu when run with the -W option.",
1126 "# Copy this file and edit the copy because this file will be",
1127 "# overwritten each time C-Menu is run with the - W option.",
1128 "#",
1129 "# C-Menu processes key value pairs in reading order from its",
1130 "# main configuraiton file, ~/ menuapp /.minitrc, and any other",
1131 "# configuration files sourced with include statements such as",
1132 "# the following:",
1133 "#",
1134 "# include = ~/menuapp/theme/default",
1135 "#",
1136 "# Assuming your configuration file is in ~/menuapp/theme/Red,",
1137 "# you could create a symbolic link named default that points to",
1138 "# Red, and then include default in your main configuration file.",
1139 "# (Actually ~/menuapp/.minitrc already includes default, so you",
1140 "# would only need to create the theme file and the symbolic link.",
1141 "#",
1142 "# ln -s Red default",
1143 "#",
1144 "# Key value pairs included from configuration files are",
1145 "# processed in reading order as they are included.",
1146 "#",
1147 "# This is significant in the event that a key is included more",
1148 "# than once in the configuration file and / or included files.",
1149 "# Only the last value read for a key will be used by C-Menu.",
1150 "#",
1151 "# If you want to override key values in the C-Menu configuration",
1152 "# file, you can do so by inserting an include statement for a",
1153 "# supplemental configuration file below the keys you want to",
1154 "# override in the C-Menu configuration file. Conversely, if you",
1155 "# want to use a supplemental configuration as the default,",
1156 "# include it first.",
1157 "#",
1158 "# Parsing: Lines beginning with # are comments and are ignored.",
1159 "# Lines containing key=value pairs are parsed and the key and",
1160 "# value are extracted. Lines without an '=' are ignored. Values",
1161 "# are stripped of leading and trailing whitespace and quotes.",
1162 "# Values can be enclosed in single or double quotes to preserve",
1163 "# leading and trailing whitespace. Values can also be specified",
1164 "# as hex color codes such as #ff0000 for red. If a value is",
1165 "# specified as a hex color code, it is parsed and stored as a",
1166 "# hex color code in the configuration. An unquoted '#' that is",
1167 "# not part of a six digit hex color code and after key values",
1168 "# have been extracted is the beginning of a comment.", ""};
1169 for (int i = 0; doc_tbl[i][0] != '\0'; i++)
1170 (void)fprintf(minitrc_fp, "%s\n", doc_tbl[i]);
1171 (void)fprintf(minitrc_fp, "#\n");
1172 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "parent_cmd", init->parent_cmd);
1173 print_argp_doc(minitrc_fp, config_s, "parent_cmd");
1174 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "cols", init->cols);
1175 print_argp_doc(minitrc_fp, config_s, "cols");
1176 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "lines", init->lines);
1177 print_argp_doc(minitrc_fp, config_s, "lines");
1178 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "title", init->title);
1179 print_argp_doc(minitrc_fp, config_s, "title");
1180 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "begx", init->begx);
1181 print_argp_doc(minitrc_fp, config_s, "begx");
1182 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "begy", init->begy);
1183 print_argp_doc(minitrc_fp, config_s, "begy");
1184 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmd_all", init->cmd_all);
1185 print_argp_doc(minitrc_fp, config_s, "cmd_all");
1186 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmd", init->cmd);
1187 print_argp_doc(minitrc_fp, config_s, "cmd");
1188 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_spec", init->mapp_spec);
1189 print_argp_doc(minitrc_fp, config_s, "mapp_spec");
1190 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "help_spec", init->help_spec);
1191 print_argp_doc(minitrc_fp, config_s, "help_spec");
1192 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "in_spec", init->in_spec);
1193 print_argp_doc(minitrc_fp, config_s, "in_spec");
1194 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "out_spec", init->out_spec);
1195 print_argp_doc(minitrc_fp, config_s, "out_spec");
1196 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "receiver_cmd", init->receiver_cmd);
1197 print_argp_doc(minitrc_fp, config_s, "receiver_cmd");
1198 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "provider_cmd", init->provider_cmd);
1199 print_argp_doc(minitrc_fp, config_s, "provider_cmd");
1200 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_erase_remainder", init->f_erase_remainder ? "true" : "false");
1201 print_argp_doc(minitrc_fp, config_s, "f_erase_remainder");
1202 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "fill_char", init->fill_char);
1203 print_argp_doc(minitrc_fp, config_s, "fill_char");
1204 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_strip_ansi", init->f_strip_ansi ? "true" : "false");
1205 print_argp_doc(minitrc_fp, config_s, "f_strip_ansi");
1206 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_multiple_cmd_args", init->f_multiple_cmd_args ? "true" : "false");
1207 print_argp_doc(minitrc_fp, config_s, "f_multiple_cmd_args");
1208 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "select_max", init->select_max);
1209 print_argp_doc(minitrc_fp, config_s, "select_max");
1210
1211 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_ln", init->f_ln ? "true" : "false");
1212 print_argp_doc(minitrc_fp, config_s, "f_ln");
1213
1214 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_squeeze", init->f_squeeze ? "true" : "false");
1215 print_argp_doc(minitrc_fp, config_s, "f_squeeze");
1216 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "tab_stop", init->tab_stop);
1217 print_argp_doc(minitrc_fp, config_s, "tab_stop");
1218 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "h_shift", init->h_shift);
1219 print_argp_doc(minitrc_fp, config_s, "h_shift");
1220 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "brackets", init->brackets);
1221 print_argp_doc(minitrc_fp, config_s, "brackets");
1222
1223 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "wrap", init->wrap ? "true" : "false");
1224 print_argp_doc(minitrc_fp, config_s, "wrap");
1225
1226 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_ignore_case", init->f_ignore_case ? "true" : "false");
1227 print_argp_doc(minitrc_fp, config_s, "f_ignore_case");
1228 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "p_view_files", init->p_view_files ? "true" : "false");
1229 print_argp_doc(minitrc_fp, config_s, "p_view_files");
1230 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_read_theme", init->f_read_theme ? "true" : "false");
1231 print_argp_doc(minitrc_fp, config_s, "f_read_theme");
1232 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "editor", init->editor);
1233 print_argp_doc(minitrc_fp, config_s, "editor");
1234 ssnprintf(config_s, MAXLEN - 1, "%s=%c", "border", sio->border);
1235 print_argp_doc(minitrc_fp, config_s, "border");
1236 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bg", sio->bg);
1237 print_argp_doc(minitrc_fp, config_s, "bg");
1238 ssnprintf(config_s, MAXLEN - 1, "%s=#%6x", "fg", sio->fg);
1239 print_argp_doc(minitrc_fp, config_s, "fg");
1240 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "box_fg", sio->box_fg);
1241 print_argp_doc(minitrc_fp, config_s, "box_fg");
1242 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "box_bg", sio->box_bg);
1243 print_argp_doc(minitrc_fp, config_s, "box_bg");
1244 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ind_fg", sio->ind_fg);
1245 print_argp_doc(minitrc_fp, config_s, "ind_fg");
1246 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ind_bg", sio->ind_bg);
1247 print_argp_doc(minitrc_fp, config_s, "ind_bg");
1248 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "brackets_fg", sio->brackets_fg);
1249 print_argp_doc(minitrc_fp, config_s, "brackets_fg");
1250 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "brackets_bg", sio->brackets_bg);
1251 print_argp_doc(minitrc_fp, config_s, "brackets_bg");
1252 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "fill_char_fg", sio->fill_char_fg);
1253 print_argp_doc(minitrc_fp, config_s, "fill_char_fg");
1254 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "fill_char_bg", sio->fill_char_bg);
1255 print_argp_doc(minitrc_fp, config_s, "fill_char_bg");
1256 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ln_bg", sio->ln_bg);
1257 print_argp_doc(minitrc_fp, config_s, "ln_bg");
1258 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ln_fg", sio->ln_fg);
1259 print_argp_doc(minitrc_fp, config_s, "ln_bg");
1260 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "cmdln_bg", sio->cmdln_bg);
1261 print_argp_doc(minitrc_fp, config_s, "cmdln_bg");
1262 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "cmdln_fg", sio->cmdln_fg);
1263 print_argp_doc(minitrc_fp, config_s, "cmdln_fg");
1264
1265 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_fg", sio->nt_fg);
1266 print_argp_doc(minitrc_fp, config_s, "nt_fg");
1267 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_bg", sio->nt_bg);
1268 print_argp_doc(minitrc_fp, config_s, "nt_bg");
1269 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_fg", sio->nt_hl_fg);
1270 print_argp_doc(minitrc_fp, config_s, "nt_hl_fg");
1271 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_bg", sio->nt_hl_bg);
1272 print_argp_doc(minitrc_fp, config_s, "nt_hl_bg");
1273 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_rev_fg", sio->nt_rev_fg);
1274 print_argp_doc(minitrc_fp, config_s, "nt_rev_fg");
1275 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_rev_bg", sio->nt_rev_bg);
1276 print_argp_doc(minitrc_fp, config_s, "nt_rev_bg");
1277 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_rev_fg", sio->nt_hl_rev_fg);
1278 print_argp_doc(minitrc_fp, config_s, "nt_hl_rev_fg");
1279 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_rev_bg", sio->nt_hl_rev_bg);
1280 print_argp_doc(minitrc_fp, config_s, "nt_hl_rev_bg");
1281 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "title_fg", sio->title_fg);
1282 print_argp_doc(minitrc_fp, config_s, "title_fg");
1283 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "title_bg", sio->title_bg);
1284 print_argp_doc(minitrc_fp, config_s, "title_bg");
1285 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ran_fg", sio->ran_fg);
1286 print_argp_doc(minitrc_fp, config_s, "ran_fg");
1287 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ran_bg", sio->ran_bg);
1288 print_argp_doc(minitrc_fp, config_s, "ran_bg");
1289 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "blue_gamma", sio->blue_gamma);
1290 print_argp_doc(minitrc_fp, config_s, "blue_gamma");
1291 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "gray_gamma", sio->gray_gamma);
1292 print_argp_doc(minitrc_fp, config_s, "gray_gamma");
1293 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "green_gamma", sio->green_gamma);
1294 print_argp_doc(minitrc_fp, config_s, "green_gamma");
1295 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "red_gamma", sio->red_gamma);
1296 print_argp_doc(minitrc_fp, config_s, "red_gamma");
1297 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "black", sio->black);
1298 print_argp_doc(minitrc_fp, config_s, "black");
1299 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "red", sio->red);
1300 print_argp_doc(minitrc_fp, config_s, "red");
1301 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "green", sio->green);
1302 print_argp_doc(minitrc_fp, config_s, "green");
1303 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "yellow", sio->yellow);
1304 print_argp_doc(minitrc_fp, config_s, "yellow");
1305 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "blue", sio->blue);
1306 print_argp_doc(minitrc_fp, config_s, "blue");
1307 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "magenta", sio->magenta);
1308 print_argp_doc(minitrc_fp, config_s, "magenta");
1309 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "cyan", sio->cyan);
1310 print_argp_doc(minitrc_fp, config_s, "cyan");
1311 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "white", sio->white);
1312 print_argp_doc(minitrc_fp, config_s, "white");
1313 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bblack", sio->bblack);
1314 print_argp_doc(minitrc_fp, config_s, "bblack");
1315 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bred", sio->bred);
1316 print_argp_doc(minitrc_fp, config_s, "bred");
1317 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bgreen", sio->bgreen);
1318 print_argp_doc(minitrc_fp, config_s, "bgreen");
1319 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "byellow", sio->byellow);
1320 print_argp_doc(minitrc_fp, config_s, "byellow");
1321 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bblue", sio->bblue);
1322 print_argp_doc(minitrc_fp, config_s, "bblue");
1323 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bmagenta", sio->bmagenta);
1324 print_argp_doc(minitrc_fp, config_s, "bmagenta");
1325 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bcyan", sio->bcyan);
1326 print_argp_doc(minitrc_fp, config_s, "bcyan");
1327 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bwhite", sio->bwhite);
1328 print_argp_doc(minitrc_fp, config_s, "bwhite");
1329 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_data", init->mapp_data);
1330 print_argp_doc(minitrc_fp, config_s, "mapp_data");
1331 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_help", init->mapp_help);
1332 print_argp_doc(minitrc_fp, config_s, "mapp_help");
1333 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_home", init->mapp_home);
1334 print_argp_doc(minitrc_fp, config_s, "mapp_home");
1335 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_msrc", init->mapp_msrc);
1336 print_argp_doc(minitrc_fp, config_s, "mapp_msrc");
1337 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_user", init->mapp_user);
1338 print_argp_doc(minitrc_fp, config_s, "mapp_user");
1339 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_theme", init->mapp_theme);
1340 print_argp_doc(minitrc_fp, config_s, "mapp_theme");
1341 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "include", init->mapp_theme);
1342 (void)fprintf(minitrc_fp, "%-34s # default theme file\n", config_s);
1343 strnz__cpy(tmp_str, "Configuration written to file: ", MAXLEN - 1);
1344 strnz__cat(tmp_str, minitrc_dmp, MAXLEN - 1);
1345 Perror(tmp_str);
1346 return 0;
1347}
void print_argp_doc(FILE *, char *, char *)
Definition init.c:1348
int Perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition dwin.c:841
double green_gamma
Definition cm.h:690
double blue_gamma
Definition cm.h:691
uint32_t magenta
Definition cm.h:698
uint32_t bgreen
Definition cm.h:704
double red_gamma
Definition cm.h:689
uint32_t green
Definition cm.h:695
uint32_t yellow
Definition cm.h:696
uint32_t fill_char_fg
Definition cm.h:720
uint32_t bmagenta
Definition cm.h:707
uint32_t byellow
Definition cm.h:705
uint32_t bblue
Definition cm.h:706
uint32_t cyan
Definition cm.h:699
uint32_t bblack
Definition cm.h:702
uint32_t red
Definition cm.h:694
uint32_t bred
Definition cm.h:703
uint32_t fill_char_bg
Definition cm.h:721
uint32_t black
Definition cm.h:693
uint32_t brackets_bg
Definition cm.h:719
uint32_t bcyan
Definition cm.h:708
uint32_t blue
Definition cm.h:697
uint32_t brackets_fg
Definition cm.h:718
uint32_t white
Definition cm.h:700
uint32_t bwhite
Definition cm.h:709
double gray_gamma
Definition cm.h:692
char title[MAXLEN]
Definition common.h:129
int begx
Definition common.h:118
char in_spec[MAXLEN]
Definition common.h:168
char cmd_all[MAXLEN]
Definition common.h:123
int cols
Definition common.h:116
int tab_stop
Definition common.h:181
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:182
bool wrap
Definition common.h:144
bool f_multiple_cmd_args
Definition common.h:139
int select_max
Definition common.h:179
bool f_ln
Definition common.h:143
char provider_cmd[MAXLEN]
Definition common.h:120
char out_spec[MAXLEN]
Definition common.h:169
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:177

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::border, 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, SIO::ran_bg, SIO::ran_fg, 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, SIO::white, Init::wrap, 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 606 of file init.c.

606 {
607 init->lines = 0;
608 init->cols = 0;
609 init->begx = 0;
610 init->begy = 0;
611 init->f_mapp_desc = false;
612 init->f_provider_cmd = false;
613 init->f_receiver_cmd = false;
614 init->f_title = false;
615 init->f_mapp_spec = false;
616 init->f_help_spec = false;
617 init->f_in_spec = false;
618 init->f_out_spec = false;
619 init->p_view_files = false;
620 init->h_shift = 0;
621 init->mapp_spec[0] = init->help_spec[0] = '\0';
622 init->provider_cmd[0] = init->receiver_cmd[0] = '\0';
623 init->title[0] = '\0';
624 init->cmd[0] = init->cmd_all[0] = '\0';
625 init->parent_cmd[0] = '\0';
626 init->in_spec[0] = init->out_spec[0] = '\0';
627 init->help_spec[0] = '\0';
628 init->in_spec[0] = '\0';
629 init->out_spec[0] = '\0';
630}
bool f_out_spec
Definition common.h:171
bool f_title
Definition common.h:166
bool f_mapp_desc
Definition common.h:161
bool f_mapp_spec
Definition common.h:156
bool f_help_spec
Definition common.h:167
bool f_receiver_cmd
Definition common.h:163
bool f_provider_cmd
Definition common.h:162
bool f_in_spec
Definition common.h:170

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: