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

1426 {
1427 char tmp_str[MAXLEN];
1428 char ts2[MAXLEN];
1429 char *e;
1430
1431 if (!file_name || !*file_name) {
1432 *file_spec = '\0';
1433 return false;
1434 }
1435 if (dir) {
1436 strnz__cpy(tmp_str, dir, MAXLEN - 1);
1437 } else {
1438 e = getenv("MAPP_DIR");
1439 if (e) {
1440 strnz__cpy(tmp_str, e, MAXLEN - 1);
1441 } else {
1442 strnz__cpy(tmp_str, "~/menuapp", MAXLEN - 1);
1443 }
1444 }
1445 trim_path(tmp_str);
1446 strnz__cpy(ts2, tmp_str, MAXLEN - 1);
1447 // construct the full file specification
1448 // check that the file exists and is readable
1449 strnz__cpy(file_spec, ts2, MAXLEN - 1);
1450 strnz__cat(file_spec, "/", MAXLEN - 1);
1451 strnz__cat(file_spec, file_name, MAXLEN - 1);
1452 return true;
1453}
#define MAXLEN
Definition lf.h:38
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition lf.c:2299
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition lf.c:2330
bool trim_path(char *)
Trims trailing spaces and slashes from directory path in place.
Definition futil.c:1029

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

1458 {
1459 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1460 fprintf(stdout, "\nC-Menu %s\n", CM_VERSION);
1461 fprintf(stdout, "C version: %ld\n", __STDC_VERSION__);
1462}
#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 494 of file init.c.

494 {
495 char term[MAXLEN];
496 char tmp_str[MAXLEN];
497 char *e;
498 setlocale(LC_ALL, "en_US.UTF-8");
499
500 init->sio = (SIO *)calloc(1, sizeof(SIO));
501 if (!init->sio) {
502 ui_perror(_("calloc init->sio failed"));
503 exit(EXIT_FAILURE);
504 }
505 SIO *sio = init->sio;
506 if (!init) {
507 ssnprintf(tmp_str, sizeof(tmp_str), "%s",
508 _("init struct not allocated on entry"));
509 ui_abend(-1, tmp_str);
510 exit(-1);
511 }
512 e = getenv("CMENU_HOME");
513 if (!e || *e == '\0')
514 strnz__cpy(init->mapp_home, "~/menuapp", MAXLEN);
515 else
516 strnz__cpy(init->mapp_home, e, MAXLEN);
517
518 if (init->mapp_home[0] != '\0') {
519 expand_tilde(init->mapp_home, MAXLEN - 1);
520 if (!verify_dir(init->mapp_home, R_OK))
521 ui_abend(-1, _("MAPP_HOME directory invalid"));
522 }
523 // CMENU_RC should be an absolute path
524 e = getenv("CMENU_RC");
525 if (!e || *e == '\0') {
526 strnz__cpy(init->minitrc, init->mapp_home, MAXLEN - 1);
527 strnz__cat(init->minitrc, "/.minitrc", MAXLEN);
528 } else
529 strnz__cpy(init->minitrc, e, MAXLEN);
530 if (init->mapp_user[0] == '\0') {
531 strnz__cpy(init->mapp_user, init->mapp_home, MAXLEN - 1);
532 strnz__cat(init->mapp_user, "/user", MAXLEN - 1);
533 }
534 if (init->mapp_theme[0] == '\0') {
535 strnz__cpy(init->mapp_theme, init->mapp_home, MAXLEN - 1);
536 strnz__cat(init->mapp_theme, "/themes/default", MAXLEN - 1);
537 }
538 if (init->mapp_msrc[0] == '\0') {
539 strnz__cpy(init->mapp_msrc, init->mapp_home, MAXLEN - 1);
540 strnz__cat(init->mapp_msrc, "/msrc", MAXLEN - 1);
541 }
542 if (init->mapp_data[0] == '\0') {
543 strnz__cpy(init->mapp_data, init->mapp_home, MAXLEN - 1);
544 strnz__cat(init->mapp_data, "/data", MAXLEN - 1);
545 }
546 if (init->mapp_help[0] == '\0') {
547 strnz__cpy(init->mapp_help, init->mapp_home, MAXLEN - 1);
548 strnz__cat(init->mapp_help, "/help", MAXLEN - 1);
549 }
550 init->mapp_spec[0] = '\0';
551 // Set default colors and settings in SIO struct
552 // These can be overridden by the config file or command-line options
553 // Included here to ensure SIO has valid defaults even if config parsing fails
554
555 sio->border = 'r';
556 sio->bg = 0x000000;
557 sio->fg = 0xc0c0c0;
558 sio->border = 'r';
559 sio->box_fg = 0xf00000;
560 sio->box_bg = 0x000000;
561 sio->ind_fg = 0xf00000;
562 sio->ind_bg = 0x000000;
563 sio->ran_fg = 0xf00000;
564 sio->ran_bg = 0x000000;
565 sio->title_fg = 0xf0f0f0;
566 sio->title_bg = 0x000000;
567 sio->nt_fg = 0xc0c0c0;
568 sio->nt_bg = 0x000000;
569 sio->nt_rev_fg = 0x000000;
570 sio->nt_rev_bg = 0xc0c0c0;
571 sio->nt_hl_fg = 0xf00000;
572 sio->nt_hl_bg = 0x000000;
573 sio->nt_hl_rev_fg = 0x000000;
574 sio->nt_hl_rev_bg = 0xc0c0c0;
575 sio->ln_fg = 0x0070ff;
576 sio->ln_bg = 0x101010;
577 sio->cmdln_fg = 0xd0d0d0;
578 sio->cmdln_bg = 0x000000;
579 init->f_erase_remainder = true;
580 init->brackets[0] = '\0';
581 strnz__cpy(init->fill_char, " ", MAXLEN - 1);
582 e = getenv("TERM");
583 if (e == nullptr || *e == '\0')
584 strnz__cpy(term, "xterm-256color", MAXLEN);
585 else
586 strnz__cpy(term, e, MAXLEN - 1);
587 e = getenv("EDITOR");
588 if (e && *e != '\0')
589 strnz__cpy(init->editor, "vi", MAXLEN - 1);
590 else
591 strnz__cpy(init->editor, e, MAXLEN - 1);
593 ui_log_ctx.min_level = init->log_min_level;
594 ui_log_ctx.fd = ui_open_log();
595 ui_log(INFO, "mapp_initialization");
596 ui_log(INFO, _("config files processed"));
597 init->mapp_spec[0] = '\0';
598 init->argc = argc;
599 argp_parse(&argp, argc, argv, 0, 0, init);
600 strnz__cpy(sio->fill_char, init->fill_char, 1);
601 strnz__cpy(sio->brackets, init->brackets, 2);
602 if (f_write_config) {
603 write_config(init);
604 exit(EXIT_SUCCESS);
605 }
606}
UiLogContext ui_log_ctx
Definition ui_common.c:53
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
Definition ui_common.c:404
int ui_open_log()
Open the log file for writing.
Definition ui_common.c:1446
bool f_write_config
Definition init.c:90
#define _(String)
Definition amort.c:23
size_t ssnprintf(char *, size_t, const char *,...)
Custom safe string formatting utility (Variadic version).
Definition futil.c:398
bool expand_tilde(char *, uint)
Expand a tilde (~) in a file path to the user's home directory.
Definition lf.c:2089
bool verify_dir(char *, uint)
Verifies that the directory specified by "spec" exists and is accessible with the permissions specifi...
Definition futil.c:1220
int write_config(Init *init)
Write the current configuration to a file specified in init->minitrc.
Definition init.c:1152
int process_config_files(Init *)
parse the configuration file specified in init->minitrc and set Init struct values accordingly
Definition init.c:669
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition ui_common.c:1323
char mapp_data[MAXLEN]
Definition common.h:151
char minitrc[MAXLEN]
Definition common.h:177
UiLogLevel log_min_level
Definition common.h:183
char mapp_help[MAXLEN]
Definition common.h:152
SIO * sio
Definition common.h:117
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
uint32_t ran_bg
Definition ui_backend.h:794
uint32_t ln_bg
Definition ui_backend.h:780
char brackets[3]
Definition ui_backend.h:807
uint32_t cmdln_bg
Definition ui_backend.h:782
uint32_t cmdln_fg
Definition ui_backend.h:781
uint32_t nt_hl_rev_fg
Definition ui_backend.h:789
uint32_t ran_fg
Definition ui_backend.h:793
char fill_char[2]
Definition ui_backend.h:808
uint32_t nt_fg
Definition ui_backend.h:783
uint32_t box_fg
Definition ui_backend.h:771
uint32_t ln_fg
Definition ui_backend.h:779
uint32_t ind_bg
Definition ui_backend.h:774
uint32_t ind_fg
Definition ui_backend.h:773
uint32_t title_bg
Definition ui_backend.h:792
uint32_t fg
Definition ui_backend.h:769
uint32_t nt_hl_rev_bg
Definition ui_backend.h:790
uint32_t title_fg
Definition ui_backend.h:791
uint32_t nt_rev_bg
Definition ui_backend.h:786
uint32_t nt_bg
Definition ui_backend.h:784
uint32_t box_bg
Definition ui_backend.h:772
uint32_t nt_hl_fg
Definition ui_backend.h:787
char border
Definition ui_backend.h:809
uint32_t nt_rev_fg
Definition ui_backend.h:785
uint32_t nt_hl_bg
Definition ui_backend.h:788
uint32_t bg
Definition ui_backend.h:770

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, UiLogContext::fd, SIO::fg, Init::fill_char, SIO::fill_char, SIO::ind_bg, SIO::ind_fg, SIO::ln_bg, SIO::ln_fg, Init::log_min_level, Init::mapp_data, Init::mapp_help, Init::mapp_home, Init::mapp_msrc, Init::mapp_spec, Init::mapp_theme, Init::mapp_user, UiLogContext::min_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_ctx, 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 1515 of file init.c.

1515 {
1516 fprintf(stdout, "%3s %-15s: %s\n", o, name, value ? "true" : "false");
1517}

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

1470 {
1471 fprintf(stdout, "%3s %-15s: %s\n", o, name, value);
1472}

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

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

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

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

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

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

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

618 {
619 init->argc = destroy_argv(init->argc, init->argv);
620 argp_parse(&argp, argc, argv, 0, 0, init);
621 return 0;
622}
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:474
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 669 of file init.c.

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

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

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

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, UiLogContext::level, Init::lines, SIO::ln_bg, SIO::ln_fg, Init::log_min_level, 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, 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_ctx, 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 633 of file init.c.

633 {
634 init->lines = 0;
635 init->cols = 0;
636 init->begx = 0;
637 init->begy = 0;
638 init->f_mapp_desc = false;
639 init->f_provider_cmd = false;
640 init->f_receiver_cmd = false;
641 init->f_title = false;
642 init->f_mapp_spec = false;
643 init->f_help_spec = false;
644 init->f_in_spec = false;
645 init->f_out_spec = false;
646 init->p_view_files = false;
647 init->h_shift = 0;
648 init->mapp_spec[0] = init->help_spec[0] = '\0';
649 init->provider_cmd[0] = init->receiver_cmd[0] = '\0';
650 init->title[0] = '\0';
651 init->cmd[0] = init->cmd_all[0] = '\0';
652 init->parent_cmd[0] = '\0';
653 init->in_spec[0] = init->out_spec[0] = '\0';
654 init->help_spec[0] = '\0';
655 init->in_spec[0] = '\0';
656 init->out_spec[0] = '\0';
657}
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: