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

1436 {
1437 char tmp_str[MAXLEN];
1438 char ts2[MAXLEN];
1439 char *e;
1440
1441 if (!file_name || !*file_name) {
1442 *file_spec = '\0';
1443 return false;
1444 }
1445 if (dir) {
1446 strnz__cpy(tmp_str, dir, MAXLEN - 1);
1447 } else {
1448 e = getenv("MAPP_DIR");
1449 if (e) {
1450 strnz__cpy(tmp_str, e, MAXLEN - 1);
1451 } else {
1452 strnz__cpy(tmp_str, "~/menuapp", MAXLEN - 1);
1453 }
1454 }
1455 trim_path(tmp_str);
1456 strnz__cpy(ts2, tmp_str, MAXLEN - 1);
1457 // construct the full file specification
1458 // check that the file exists and is readable
1459 strnz__cpy(file_spec, ts2, MAXLEN - 1);
1460 strnz__cat(file_spec, "/", MAXLEN - 1);
1461 strnz__cat(file_spec, file_name, MAXLEN - 1);
1462 return true;
1463}
#define MAXLEN
Definition curskeys.c:15
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition whence.c:291
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition whence.c:320
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
Definition futil.c:1007

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

1468 {
1469 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1470 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1471 fprintf(stdout, "C version: %ld\n", __STDC_VERSION__);
1472}
#define CM_VERSION
Definition version.h:5

◆ 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

< menu specification file

< default border style

< erase remainder on enter

< field enclosure brackets

< field fill character

Definition at line 498 of file init.c.

498 {
499 char term[MAXLEN];
500 char tmp_str[MAXLEN];
501 char *e;
502 setlocale(LC_ALL, "en_US.UTF-8");
503
504 init->sio = (SIO *)calloc(1, sizeof(SIO));
505 if (!init->sio) {
506 ui_perror(_("calloc init->sio failed"));
507 exit(EXIT_FAILURE);
508 }
509 SIO *sio = init->sio;
510 if (!init) {
511 ssnprintf(tmp_str, sizeof(tmp_str), "%s",
512 _("init struct not allocated on entry"));
513 ui_abend(-1, tmp_str);
514 exit(-1);
515 }
516 e = getenv("CMENU_HOME");
517 if (!e || *e == '\0')
518 strnz__cpy(init->mapp_home, "~/menuapp", MAXLEN);
519 else
520 strnz__cpy(init->mapp_home, e, MAXLEN);
521
522 if (init->mapp_home[0] != '\0') {
523 expand_tilde(init->mapp_home, MAXLEN - 1);
524 if (!verify_dir(init->mapp_home, R_OK))
525 ui_abend(-1, _("MAPP_HOME directory invalid"));
526 }
527 // CMENU_RC should be an absolute path
528 e = getenv("CMENU_RC");
529 if (!e || *e == '\0') {
530 strnz__cpy(init->minitrc, init->mapp_home, MAXLEN - 1);
531 strnz__cat(init->minitrc, "/.minitrc", MAXLEN);
532 } else
533 strnz__cpy(init->minitrc, e, MAXLEN);
534 if (init->mapp_user[0] == '\0') {
535 strnz__cpy(init->mapp_user, init->mapp_home, MAXLEN - 1);
536 strnz__cat(init->mapp_user, "/user", MAXLEN - 1);
537 }
538 if (init->mapp_theme[0] == '\0') {
539 strnz__cpy(init->mapp_theme, init->mapp_home, MAXLEN - 1);
540 strnz__cat(init->mapp_theme, "/themes/default", MAXLEN - 1);
541 }
542 if (init->mapp_msrc[0] == '\0') {
543 strnz__cpy(init->mapp_msrc, init->mapp_home, MAXLEN - 1);
544 strnz__cat(init->mapp_msrc, "/msrc", MAXLEN - 1);
545 }
546 if (init->mapp_data[0] == '\0') {
547 strnz__cpy(init->mapp_data, init->mapp_home, MAXLEN - 1);
548 strnz__cat(init->mapp_data, "/data", MAXLEN - 1);
549 }
550 if (init->mapp_help[0] == '\0') {
551 strnz__cpy(init->mapp_help, init->mapp_home, MAXLEN - 1);
552 strnz__cat(init->mapp_help, "/help", MAXLEN - 1);
553 }
554 init->mapp_spec[0] = '\0';
555 // Set default colors and settings in SIO struct
556 // These can be overridden by the config file or command-line options
557 // Included here to ensure SIO has valid defaults even if config parsing fails
558
559 sio->border = 'r';
560 sio->bg = 0x000000;
561 sio->fg = 0xc0c0c0;
562 sio->border = 'r';
563 sio->box_fg = 0xf00000;
564 sio->box_bg = 0x000000;
565 sio->ind_fg = 0xf00000;
566 sio->ind_bg = 0x000000;
567 sio->ran_fg = 0xf00000;
568 sio->ran_bg = 0x000000;
569 sio->title_fg = 0xf0f0f0;
570 sio->title_bg = 0x000000;
571 sio->nt_fg = 0xc0c0c0;
572 sio->nt_bg = 0x000000;
573 sio->nt_rev_fg = 0x000000;
574 sio->nt_rev_bg = 0xc0c0c0;
575 sio->nt_hl_fg = 0xf00000;
576 sio->nt_hl_bg = 0x000000;
577 sio->nt_hl_rev_fg = 0x000000;
578 sio->nt_hl_rev_bg = 0xc0c0c0;
579 sio->ln_fg = 0x0070ff;
580 sio->ln_bg = 0x101010;
581 sio->cmdln_fg = 0xd0d0d0;
582 sio->cmdln_bg = 0x000000;
583 init->f_erase_remainder = true;
584 init->brackets[0] = '\0';
585 strnz__cpy(init->fill_char, " ", MAXLEN - 1);
586 e = getenv("TERM");
587 if (e == nullptr || *e == '\0')
588 strnz__cpy(term, "xterm-256color", MAXLEN);
589 else
590 strnz__cpy(term, e, MAXLEN - 1);
591 e = getenv("EDITOR");
592 if (e && *e != '\0')
593 strnz__cpy(init->editor, "vi", MAXLEN - 1);
594 else
595 strnz__cpy(init->editor, e, MAXLEN - 1);
599 ui_log(INFO, "mapp_initialization");
600 ui_log(INFO, _("config files processed"));
601 init->mapp_spec[0] = '\0';
602 init->argc = argc;
603 argp_parse(&argp, argc, argv, 0, 0, init);
604 strnz__cpy(sio->fill_char, init->fill_char, 1);
605 strnz__cpy(sio->brackets, init->brackets, 2);
606 if (f_write_config) {
607 write_config(init);
608 exit(EXIT_SUCCESS);
609 }
610}
FILE * ui_open_log()
Open the log file for writing.
Definition ui_common.c:1397
UiLogLevel ui_min_log_level
Definition ui_common.c:1390
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
Definition ui_common.c:362
FILE * ui_log_fp
Definition ui_common.c:1387
bool f_write_config
Definition init.c:90
#define _(String)
Definition amort.c:23
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:390
bool expand_tilde(char *, uint)
Replaces "~/" in string with the user's home directory.
Definition futil.c:989
bool verify_dir(char *, uint)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:1198
int write_config(Init *init)
Write the current configuration to a file specified in init->minitrc.
Definition init.c:1160
int process_config_files(Init *)
parse the configuration file specified in init->minitrc and set Init struct values accordingly
Definition init.c:673
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition ui_common.c:1257
uint32_t ran_bg
Definition ui_backend.h:740
uint32_t ln_bg
Definition ui_backend.h:726
char brackets[3]
Definition ui_backend.h:753
uint32_t cmdln_bg
Definition ui_backend.h:728
uint32_t cmdln_fg
Definition ui_backend.h:727
uint32_t nt_hl_rev_fg
Definition ui_backend.h:735
uint32_t ran_fg
Definition ui_backend.h:739
char fill_char[2]
Definition ui_backend.h:754
uint32_t nt_fg
Definition ui_backend.h:729
uint32_t box_fg
Definition ui_backend.h:717
uint32_t ln_fg
Definition ui_backend.h:725
uint32_t ind_bg
Definition ui_backend.h:720
uint32_t ind_fg
Definition ui_backend.h:719
uint32_t title_bg
Definition ui_backend.h:738
uint32_t fg
Definition ui_backend.h:715
uint32_t nt_hl_rev_bg
Definition ui_backend.h:736
uint32_t title_fg
Definition ui_backend.h:737
uint32_t nt_rev_bg
Definition ui_backend.h:732
uint32_t nt_bg
Definition ui_backend.h:730
uint32_t box_bg
Definition ui_backend.h:718
uint32_t nt_hl_fg
Definition ui_backend.h:733
char border
Definition ui_backend.h:755
uint32_t nt_rev_fg
Definition ui_backend.h:731
uint32_t nt_hl_bg
Definition ui_backend.h:734
uint32_t bg
Definition ui_backend.h:716
char mapp_data[MAXLEN]
Definition common.h:151
char minitrc[MAXLEN]
Definition common.h:177
char mapp_help[MAXLEN]
Definition common.h:152
SIO * sio
Definition common.h:117
UiLogLevel min_log_level
Definition common.h:183
int argc
Definition common.h:133
char fill_char[2]
Definition common.h:149
char mapp_msrc[MAXLEN]
Definition common.h:153
bool f_erase_remainder
Definition common.h:144
char mapp_home[MAXLEN]
Definition common.h:150
char mapp_spec[MAXLEN]
Definition common.h:179
char brackets[3]
Definition common.h:148
char mapp_user[MAXLEN]
Definition common.h:154
char mapp_theme[MAXLEN]
Definition common.h:155
char editor[MAXLEN]
Definition common.h:175

References 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::min_log_level, 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, ui_abend(), ui_log_fp, ui_min_log_level, ui_open_log(), ui_perror(), 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 1525 of file init.c.

1525 {
1526 fprintf(stdout, "%3s %-15s: %s\n", o, name, value ? "true" : "false");
1527}

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

1480 {
1481 fprintf(stdout, "%3s %-15s: %s\n", o, name, value);
1482}

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

1513 {
1514 fprintf(stdout, "%3s %-15s: %0.2f\n", o, name, value);
1515}

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

1502 {
1503 fprintf(stdout, "%3s %-15s: %d\n", o, name, value);
1504}

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

1491 {
1492 fprintf(stdout, "%3s %-15s: %s\n", o, name, value);
1493}

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

622 {
623 init->argc = destroy_argv(init->argc, init->argv);
624 argp_parse(&argp, argc, argv, 0, 0, init);
625 return 0;
626}
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:468
char ** argv
Definition common.h:134

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

673 {
674 char config_file_name[MAXLEN];
675 int rc;
676 if (!init->minitrc[0]) {
677 char *e = getenv("MINITRC");
678 if (e)
679 strnz__cpy(init->minitrc, e, MAXLEN - 1);
680 else
681 strnz__cpy(init->minitrc, "~/.minitrc", MAXLEN - 1);
682 }
683
684 expand_tilde(init->minitrc, MAXLEN - 1);
685 strnz__cpy(config_file_name, init->minitrc, MAXLEN - 1);
686 rc = process_config_file(config_file_name, init);
687
688 expand_tilde(init->mapp_theme, MAXLEN - 1);
689 strnz__cpy(config_file_name, init->mapp_theme, MAXLEN - 1);
690 rc = process_config_file(config_file_name, init);
691 return rc;
692}
int process_config_file(char *, Init *)
Definition init.c:694

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

1160 {
1161 char *e;
1162 char minitrc_dmp[MAXLEN];
1163 char tmp_str[MAXLEN];
1164 SIO *sio = init->sio;
1165 e = getenv("CMENU_HOME");
1166 minitrc_dmp[0] = '\0';
1167 char config_s[MAXLEN];
1168 if (e) {
1169 strnz__cpy(minitrc_dmp, e, MAXLEN - 1);
1170 strnz__cat(minitrc_dmp, "/", MAXLEN - 1);
1171 }
1172 strnz__cat(minitrc_dmp, "minitrc.dmp", MAXLEN - 1);
1173 ui_log(INFO, _("writing config file to: %s"), minitrc_dmp);
1174 FILE *minitrc_fp = fopen(minitrc_dmp, "w");
1175 if (minitrc_fp == (FILE *)0) {
1176 ssnprintf(em0, MAXLEN - 1, _("failed to open file: %s"), minitrc_dmp);
1177 ui_log(ERROR, "em0");
1178 return (-1);
1179 }
1180 (void)fprintf(minitrc_fp, "# %s\n", minitrc_dmp);
1181 char *doc_tbl[50] = {
1182 _("# C-Menu example configuration file"),
1183 "#",
1184 _("# This file is generated by C-Menu when run with the -W option."),
1185 _("# Copy this file and edit the copy because this file will be"),
1186 _("# overwritten each time C-Menu is run with the - W option."),
1187 "#",
1188 _("# C-Menu processes key value pairs in reading order from its"),
1189 _("# main configuraiton file, ~/ menuapp /.minitrc, and any other"),
1190 _("# configuration files sourced with include statements such as"),
1191 _("# the following:"),
1192 "#",
1193 _("# include = ~/menuapp/theme/default"),
1194 "#",
1195 _("# Assuming your configuration file is in ~/menuapp/theme/Red,"),
1196 _("# you could create a symbolic link named default that points to"),
1197 _("# Red, and then include default in your main configuration file."),
1198 _("# (Actually ~/menuapp/.minitrc already includes default, so you"),
1199 _("# would only need to create the theme file and the symbolic link."),
1200 "#",
1201 _("# ln -s Red default"),
1202 "#",
1203 _("# Key value pairs included from configuration files are"),
1204 _("# processed in reading order as they are included."),
1205 "#",
1206 _("# This is significant in the event that a key is included more"),
1207 _("# than once in the configuration file and / or included files."),
1208 _("# Only the last value read for a key will be used by C-Menu."),
1209 "#",
1210 _("# If you want to override key values in the C-Menu configuration"),
1211 _("# file, you can do so by inserting an include statement for a"),
1212 _("# supplemental configuration file below the keys you want to"),
1213 _("# override in the C-Menu configuration file. Conversely, if you"),
1214 _("# want to use a supplemental configuration as the default,"),
1215 _("# include it first."),
1216 "#",
1217 _("# Parsing: Lines beginning with # are comments and are ignored."),
1218 _("# Lines containing key=value pairs are parsed and the key and"),
1219 _("# value are extracted. Lines without an '=' are ignored. Values"),
1220 _("# are stripped of leading and trailing whitespace and quotes."),
1221 _("# Values can be enclosed in single or double quotes to preserve"),
1222 _("# leading and trailing whitespace. Values can also be specified"),
1223 _("# as hex color codes such as #ff0000 for red. If a value is"),
1224 _("# specified as a hex color code, it is parsed and stored as a"),
1225 _("# hex color code in the configuration. An unquoted '#' that is"),
1226 _("# not part of a six digit hex color code and after key values"),
1227 _("# have been extracted is the beginning of a comment."), ""};
1228 for (int i = 0; doc_tbl[i][0] != '\0'; i++)
1229 (void)fprintf(minitrc_fp, "%s\n", doc_tbl[i]);
1230 (void)fprintf(minitrc_fp, "#\n");
1231 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "parent_cmd", init->parent_cmd);
1232 print_argp_doc(minitrc_fp, config_s, "parent_cmd");
1233 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "cols", init->cols);
1234 print_argp_doc(minitrc_fp, config_s, "cols");
1235 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "lines", init->lines);
1236 print_argp_doc(minitrc_fp, config_s, "lines");
1237 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "title", init->title);
1238 print_argp_doc(minitrc_fp, config_s, "title");
1239 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "begx", init->begx);
1240 print_argp_doc(minitrc_fp, config_s, "begx");
1241 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "begy", init->begy);
1242 print_argp_doc(minitrc_fp, config_s, "begy");
1243 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmd_all", init->cmd_all);
1244 print_argp_doc(minitrc_fp, config_s, "cmd_all");
1245 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "cmd", init->cmd);
1246 print_argp_doc(minitrc_fp, config_s, "cmd");
1247 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_spec", init->mapp_spec);
1248 print_argp_doc(minitrc_fp, config_s, "mapp_spec");
1249 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "help_spec", init->help_spec);
1250 print_argp_doc(minitrc_fp, config_s, "help_spec");
1251 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "in_spec", init->in_spec);
1252 print_argp_doc(minitrc_fp, config_s, "in_spec");
1253 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "out_spec", init->out_spec);
1254 print_argp_doc(minitrc_fp, config_s, "out_spec");
1255
1256 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "log_file_spec", init->log_file_spec);
1257 print_argp_doc(minitrc_fp, config_s, "log_file_spec");
1258 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "log_level", ui_log_level_s[init->min_log_level]);
1259 print_argp_doc(minitrc_fp, config_s, "log_level");
1260
1261 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "receiver_cmd", init->receiver_cmd);
1262 print_argp_doc(minitrc_fp, config_s, "receiver_cmd");
1263 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "provider_cmd", init->provider_cmd);
1264 print_argp_doc(minitrc_fp, config_s, "provider_cmd");
1265 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_erase_remainder", init->f_erase_remainder ? "true" : "false");
1266 print_argp_doc(minitrc_fp, config_s, "f_erase_remainder");
1267 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "fill_char", init->fill_char);
1268 print_argp_doc(minitrc_fp, config_s, "fill_char");
1269 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_strip_ansi", init->f_strip_ansi ? "true" : "false");
1270 print_argp_doc(minitrc_fp, config_s, "f_strip_ansi");
1271 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_multiple_cmd_args", init->f_multiple_cmd_args ? "true" : "false");
1272 print_argp_doc(minitrc_fp, config_s, "f_multiple_cmd_args");
1273 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "select_max", init->select_max);
1274 print_argp_doc(minitrc_fp, config_s, "select_max");
1275
1276 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_ln", init->f_ln ? "true" : "false");
1277 print_argp_doc(minitrc_fp, config_s, "f_ln");
1278
1279 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_squeeze", init->f_squeeze ? "true" : "false");
1280 print_argp_doc(minitrc_fp, config_s, "f_squeeze");
1281 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "tab_stop", init->tab_stop);
1282 print_argp_doc(minitrc_fp, config_s, "tab_stop");
1283
1284 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "timeout_secs", init->timeout_secs);
1285 print_argp_doc(minitrc_fp, config_s, "timeout_secs");
1286
1287 ssnprintf(config_s, MAXLEN - 1, "%s=%d", "h_shift", init->h_shift);
1288 print_argp_doc(minitrc_fp, config_s, "h_shift");
1289 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "brackets", init->brackets);
1290 print_argp_doc(minitrc_fp, config_s, "brackets");
1291
1292 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "wrap", init->wrap ? "true" : "false");
1293 print_argp_doc(minitrc_fp, config_s, "wrap");
1294
1295 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_ignore_case", init->f_ignore_case ? "true" : "false");
1296 print_argp_doc(minitrc_fp, config_s, "f_ignore_case");
1297 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "p_view_files", init->p_view_files ? "true" : "false");
1298 print_argp_doc(minitrc_fp, config_s, "p_view_files");
1299 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "f_read_theme", init->f_read_theme ? "true" : "false");
1300 print_argp_doc(minitrc_fp, config_s, "f_read_theme");
1301 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "editor", init->editor);
1302 print_argp_doc(minitrc_fp, config_s, "editor");
1303 ssnprintf(config_s, MAXLEN - 1, "%s=%c", "border", sio->border);
1304 print_argp_doc(minitrc_fp, config_s, "border");
1305 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bg", sio->bg);
1306 print_argp_doc(minitrc_fp, config_s, "bg");
1307 ssnprintf(config_s, MAXLEN - 1, "%s=#%6x", "fg", sio->fg);
1308 print_argp_doc(minitrc_fp, config_s, "fg");
1309 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "box_fg", sio->box_fg);
1310 print_argp_doc(minitrc_fp, config_s, "box_fg");
1311 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "box_bg", sio->box_bg);
1312 print_argp_doc(minitrc_fp, config_s, "box_bg");
1313 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ind_fg", sio->ind_fg);
1314 print_argp_doc(minitrc_fp, config_s, "ind_fg");
1315 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ind_bg", sio->ind_bg);
1316 print_argp_doc(minitrc_fp, config_s, "ind_bg");
1317 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "brackets_fg", sio->brackets_fg);
1318 print_argp_doc(minitrc_fp, config_s, "brackets_fg");
1319 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "brackets_bg", sio->brackets_bg);
1320 print_argp_doc(minitrc_fp, config_s, "brackets_bg");
1321 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "fill_char_fg", sio->fill_char_fg);
1322 print_argp_doc(minitrc_fp, config_s, "fill_char_fg");
1323 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "fill_char_bg", sio->fill_char_bg);
1324 print_argp_doc(minitrc_fp, config_s, "fill_char_bg");
1325 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ln_bg", sio->ln_bg);
1326 print_argp_doc(minitrc_fp, config_s, "ln_bg");
1327 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ln_fg", sio->ln_fg);
1328 print_argp_doc(minitrc_fp, config_s, "ln_bg");
1329 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "cmdln_bg", sio->cmdln_bg);
1330 print_argp_doc(minitrc_fp, config_s, "cmdln_bg");
1331 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "cmdln_fg", sio->cmdln_fg);
1332 print_argp_doc(minitrc_fp, config_s, "cmdln_fg");
1333
1334 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_fg", sio->nt_fg);
1335 print_argp_doc(minitrc_fp, config_s, "nt_fg");
1336 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_bg", sio->nt_bg);
1337 print_argp_doc(minitrc_fp, config_s, "nt_bg");
1338 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_fg", sio->nt_hl_fg);
1339 print_argp_doc(minitrc_fp, config_s, "nt_hl_fg");
1340 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_bg", sio->nt_hl_bg);
1341 print_argp_doc(minitrc_fp, config_s, "nt_hl_bg");
1342 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_rev_fg", sio->nt_rev_fg);
1343 print_argp_doc(minitrc_fp, config_s, "nt_rev_fg");
1344 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_rev_bg", sio->nt_rev_bg);
1345 print_argp_doc(minitrc_fp, config_s, "nt_rev_bg");
1346 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_rev_fg", sio->nt_hl_rev_fg);
1347 print_argp_doc(minitrc_fp, config_s, "nt_hl_rev_fg");
1348 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "nt_hl_rev_bg", sio->nt_hl_rev_bg);
1349 print_argp_doc(minitrc_fp, config_s, "nt_hl_rev_bg");
1350 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "title_fg", sio->title_fg);
1351 print_argp_doc(minitrc_fp, config_s, "title_fg");
1352 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "title_bg", sio->title_bg);
1353 print_argp_doc(minitrc_fp, config_s, "title_bg");
1354 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ran_fg", sio->ran_fg);
1355 print_argp_doc(minitrc_fp, config_s, "ran_fg");
1356 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "ran_bg", sio->ran_bg);
1357 print_argp_doc(minitrc_fp, config_s, "ran_bg");
1358 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "blue_gamma", sio->blue_gamma);
1359 print_argp_doc(minitrc_fp, config_s, "blue_gamma");
1360 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "gray_gamma", sio->gray_gamma);
1361 print_argp_doc(minitrc_fp, config_s, "gray_gamma");
1362 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "green_gamma", sio->green_gamma);
1363 print_argp_doc(minitrc_fp, config_s, "green_gamma");
1364 ssnprintf(config_s, MAXLEN - 1, "%s=%0.2f", "red_gamma", sio->red_gamma);
1365 print_argp_doc(minitrc_fp, config_s, "red_gamma");
1366 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "black", sio->black);
1367 print_argp_doc(minitrc_fp, config_s, "black");
1368 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "red", sio->red);
1369 print_argp_doc(minitrc_fp, config_s, "red");
1370 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "green", sio->green);
1371 print_argp_doc(minitrc_fp, config_s, "green");
1372 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "yellow", sio->yellow);
1373 print_argp_doc(minitrc_fp, config_s, "yellow");
1374 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "blue", sio->blue);
1375 print_argp_doc(minitrc_fp, config_s, "blue");
1376 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "magenta", sio->magenta);
1377 print_argp_doc(minitrc_fp, config_s, "magenta");
1378 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "cyan", sio->cyan);
1379 print_argp_doc(minitrc_fp, config_s, "cyan");
1380 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "white", sio->white);
1381 print_argp_doc(minitrc_fp, config_s, "white");
1382 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bblack", sio->bblack);
1383 print_argp_doc(minitrc_fp, config_s, "bblack");
1384 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bred", sio->bred);
1385 print_argp_doc(minitrc_fp, config_s, "bred");
1386 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bgreen", sio->bgreen);
1387 print_argp_doc(minitrc_fp, config_s, "bgreen");
1388 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "byellow", sio->byellow);
1389 print_argp_doc(minitrc_fp, config_s, "byellow");
1390 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bblue", sio->bblue);
1391 print_argp_doc(minitrc_fp, config_s, "bblue");
1392 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bmagenta", sio->bmagenta);
1393 print_argp_doc(minitrc_fp, config_s, "bmagenta");
1394 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bcyan", sio->bcyan);
1395 print_argp_doc(minitrc_fp, config_s, "bcyan");
1396 ssnprintf(config_s, MAXLEN - 1, "%s=#%06x", "bwhite", sio->bwhite);
1397 print_argp_doc(minitrc_fp, config_s, "bwhite");
1398 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_data", init->mapp_data);
1399 print_argp_doc(minitrc_fp, config_s, "mapp_data");
1400 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_help", init->mapp_help);
1401 print_argp_doc(minitrc_fp, config_s, "mapp_help");
1402 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_home", init->mapp_home);
1403 print_argp_doc(minitrc_fp, config_s, "mapp_home");
1404 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_msrc", init->mapp_msrc);
1405 print_argp_doc(minitrc_fp, config_s, "mapp_msrc");
1406 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_user", init->mapp_user);
1407 print_argp_doc(minitrc_fp, config_s, "mapp_user");
1408 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "mapp_theme", init->mapp_theme);
1409 print_argp_doc(minitrc_fp, config_s, "mapp_theme");
1410 ssnprintf(config_s, MAXLEN - 1, "%s=%s", "include", init->mapp_theme);
1411 (void)fprintf(minitrc_fp, "%-34s # default theme file\n", config_s);
1412 strnz__cpy(tmp_str, "Configuration written to file: ", MAXLEN - 1);
1413 strnz__cat(tmp_str, minitrc_dmp, MAXLEN - 1);
1414 ui_perror(tmp_str);
1415 return 0;
1416}
char em0[MAXLEN]
Definition ui_common.c:46
const char *const ui_log_level_s[]
Definition ui_common.c:1374
void print_argp_doc(FILE *, char *, char *)
Definition init.c:1417
double green_gamma
Definition ui_backend.h:693
double blue_gamma
Definition ui_backend.h:694
uint32_t magenta
Definition ui_backend.h:701
uint32_t bgreen
Definition ui_backend.h:707
double red_gamma
Definition ui_backend.h:692
uint32_t green
Definition ui_backend.h:698
uint32_t yellow
Definition ui_backend.h:699
uint32_t fill_char_fg
Definition ui_backend.h:723
uint32_t bmagenta
Definition ui_backend.h:710
uint32_t byellow
Definition ui_backend.h:708
uint32_t bblue
Definition ui_backend.h:709
uint32_t cyan
Definition ui_backend.h:702
uint32_t bblack
Definition ui_backend.h:705
uint32_t red
Definition ui_backend.h:697
uint32_t bred
Definition ui_backend.h:706
uint32_t fill_char_bg
Definition ui_backend.h:724
uint32_t black
Definition ui_backend.h:696
uint32_t brackets_bg
Definition ui_backend.h:722
uint32_t bcyan
Definition ui_backend.h:711
uint32_t blue
Definition ui_backend.h:700
uint32_t brackets_fg
Definition ui_backend.h:721
uint32_t white
Definition ui_backend.h:703
uint32_t bwhite
Definition ui_backend.h:712
double gray_gamma
Definition ui_backend.h:695
char title[MAXLEN]
Definition common.h:132
int begx
Definition common.h:121
char in_spec[MAXLEN]
Definition common.h:171
char log_file_spec[MAXLEN]
Definition common.h:181
char cmd_all[MAXLEN]
Definition common.h:126
int cols
Definition common.h:119
int tab_stop
Definition common.h:185
bool f_read_theme
Definition common.h:145
bool f_squeeze
Definition common.h:140
int begy
Definition common.h:120
char parent_cmd[MAXLEN]
Definition common.h:127
char receiver_cmd[MAXLEN]
Definition common.h:124
int h_shift
Definition common.h:186
bool wrap
Definition common.h:147
bool f_multiple_cmd_args
Definition common.h:142
int select_max
Definition common.h:184
bool f_ln
Definition common.h:146
char provider_cmd[MAXLEN]
Definition common.h:123
char out_spec[MAXLEN]
Definition common.h:172
bool f_strip_ansi
Definition common.h:139
bool p_view_files
Definition common.h:137
bool f_ignore_case
Definition common.h:136
int lines
Definition common.h:118
char cmd[MAXLEN]
Definition common.h:125
uint timeout_secs
Definition common.h:182
char help_spec[MAXLEN]
Definition common.h:180

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, em0, 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, Init::log_file_spec, SIO::magenta, Init::mapp_data, Init::mapp_help, Init::mapp_home, Init::mapp_msrc, Init::mapp_spec, Init::mapp_theme, Init::mapp_user, Init::min_log_level, 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, 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::timeout_secs, Init::title, SIO::title_bg, SIO::title_fg, ui_log_level_s, ui_perror(), 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 637 of file init.c.

637 {
638 init->lines = 0;
639 init->cols = 0;
640 init->begx = 0;
641 init->begy = 0;
642 init->f_mapp_desc = false;
643 init->f_provider_cmd = false;
644 init->f_receiver_cmd = false;
645 init->f_title = false;
646 init->f_mapp_spec = false;
647 init->f_help_spec = false;
648 init->f_in_spec = false;
649 init->f_out_spec = false;
650 init->p_view_files = false;
651 init->h_shift = 0;
652 init->mapp_spec[0] = init->help_spec[0] = '\0';
653 init->provider_cmd[0] = init->receiver_cmd[0] = '\0';
654 init->title[0] = '\0';
655 init->cmd[0] = init->cmd_all[0] = '\0';
656 init->parent_cmd[0] = '\0';
657 init->in_spec[0] = init->out_spec[0] = '\0';
658 init->help_spec[0] = '\0';
659 init->in_spec[0] = '\0';
660 init->out_spec[0] = '\0';
661}
bool f_out_spec
Definition common.h:174
bool f_title
Definition common.h:169
bool f_mapp_desc
Definition common.h:164
bool f_mapp_spec
Definition common.h:159
bool f_help_spec
Definition common.h:170
bool f_receiver_cmd
Definition common.h:166
bool f_provider_cmd
Definition common.h:165
bool f_in_spec
Definition common.h:173

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: