C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
init.c File Reference

Initialization for Menu Application Programs. More...

#include <argp.h>
#include <common.h>
#include <locale.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wchar.h>
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE

Enumerations

enum  InitVariables {
  BG = 257 , FG , BOX_FG , BOX_BG ,
  IND_FG , IND_BG , BRACKETS_FG , BRACKETS_BG ,
  FILL_CHAR_FG , FILL_CHAR_BG , NT_FG , NT_BG ,
  NT_REV_FG , NT_REV_BG , NT_HL_FG , NT_HL_BG ,
  NT_HL_REV_FG , NT_HL_REV_BG , TITLE_FG , TITLE_BG ,
  LN_FG , LN_BG , CMDLN_FG , CMDLN_BG ,
  RAN_FG , RAN_BG , BORDER , XBBLACK ,
  XBBLUE , XBCYAN , XBGREEN , XBLACK ,
  XBLUE , XBMAGENTA , XBRED , XBWHITE ,
  XBYELLOW , XCYAN , CM_EDITOR , XGREEN ,
  XMAGENTA , XRED , XWHITE , XYELLOW ,
  GM_BLUE , GM_GRAY , GM_GREEN , GM_RED ,
  MAPP_DATA , MAPP_HELP , MAPP_HOME , MAPP_MSRC ,
  MAPP_USER , MAPP_SPEC , HELP_SPEC , MAPP_THEME ,
  END_INIT_VARS , BG = 257 , FG , BOX_FG ,
  BOX_BG , IND_FG , IND_BG , BRACKETS_FG ,
  BRACKETS_BG , FILL_CHAR_FG , FILL_CHAR_BG , NT_FG ,
  NT_BG , NT_REV_FG , NT_REV_BG , NT_HL_FG ,
  NT_HL_BG , NT_HL_REV_FG , NT_HL_REV_BG , TITLE_FG ,
  TITLE_BG , LN_FG , LN_BG , CMDLN_FG ,
  CMDLN_BG , RAN_FG , RAN_BG , BORDER ,
  XBBLACK , XBBLUE , XBCYAN , XBGREEN ,
  XBLACK , XBLUE , XBMAGENTA , XBRED ,
  XBWHITE , XBYELLOW , XCYAN , CM_EDITOR ,
  XGREEN , XMAGENTA , XRED , XWHITE ,
  XYELLOW , GM_BLUE , GM_GRAY , GM_GREEN ,
  GM_RED , MAPP_DATA , MAPP_HELP , MAPP_HOME ,
  MAPP_MSRC , MAPP_USER , MAPP_SPEC , HELP_SPEC ,
  MAPP_THEME , END_INIT_VARS
}
enum  InitVariables {
  BG = 257 , FG , BOX_FG , BOX_BG ,
  IND_FG , IND_BG , BRACKETS_FG , BRACKETS_BG ,
  FILL_CHAR_FG , FILL_CHAR_BG , NT_FG , NT_BG ,
  NT_REV_FG , NT_REV_BG , NT_HL_FG , NT_HL_BG ,
  NT_HL_REV_FG , NT_HL_REV_BG , TITLE_FG , TITLE_BG ,
  LN_FG , LN_BG , CMDLN_FG , CMDLN_BG ,
  RAN_FG , RAN_BG , BORDER , XBBLACK ,
  XBBLUE , XBCYAN , XBGREEN , XBLACK ,
  XBLUE , XBMAGENTA , XBRED , XBWHITE ,
  XBYELLOW , XCYAN , CM_EDITOR , XGREEN ,
  XMAGENTA , XRED , XWHITE , XYELLOW ,
  GM_BLUE , GM_GRAY , GM_GREEN , GM_RED ,
  MAPP_DATA , MAPP_HELP , MAPP_HOME , MAPP_MSRC ,
  MAPP_USER , MAPP_SPEC , HELP_SPEC , MAPP_THEME ,
  END_INIT_VARS , BG = 257 , FG , BOX_FG ,
  BOX_BG , IND_FG , IND_BG , BRACKETS_FG ,
  BRACKETS_BG , FILL_CHAR_FG , FILL_CHAR_BG , NT_FG ,
  NT_BG , NT_REV_FG , NT_REV_BG , NT_HL_FG ,
  NT_HL_BG , NT_HL_REV_FG , NT_HL_REV_BG , TITLE_FG ,
  TITLE_BG , LN_FG , LN_BG , CMDLN_FG ,
  CMDLN_BG , RAN_FG , RAN_BG , BORDER ,
  XBBLACK , XBBLUE , XBCYAN , XBGREEN ,
  XBLACK , XBLUE , XBMAGENTA , XBRED ,
  XBWHITE , XBYELLOW , XCYAN , CM_EDITOR ,
  XGREEN , XMAGENTA , XRED , XWHITE ,
  XYELLOW , GM_BLUE , GM_GRAY , GM_GREEN ,
  GM_RED , MAPP_DATA , MAPP_HELP , MAPP_HOME ,
  MAPP_MSRC , MAPP_USER , MAPP_SPEC , HELP_SPEC ,
  MAPP_THEME , END_INIT_VARS
}

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.
void print_argp_doc (FILE *, char *, char *)
int process_config_file (char *, Init *)
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.

Variables

const char * argp_program_bug_address = "billxwaller@gmail.com"
const char * argp_program_version = CM_VERSION
int executor = 0
bool f_write_config = false

Detailed Description

Initialization for Menu Application Programs.

Author
Bill Waller Copyright (c) 2025 MIT License billx.nosp@m.wall.nosp@m.er@gm.nosp@m.ail..nosp@m.com
Date
2026-02-09

Definition in file init.c.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 20 of file init.c.

Enumeration Type Documentation

◆ InitVariables [1/2]

Enumerator
BG 
FG 
BOX_FG 
BOX_BG 
IND_FG 
IND_BG 
BRACKETS_FG 
BRACKETS_BG 
FILL_CHAR_FG 
FILL_CHAR_BG 
NT_FG 
NT_BG 
NT_REV_FG 
NT_REV_BG 
NT_HL_FG 
NT_HL_BG 
NT_HL_REV_FG 
NT_HL_REV_BG 
TITLE_FG 
TITLE_BG 
LN_FG 
LN_BG 
CMDLN_FG 
CMDLN_BG 
RAN_FG 
RAN_BG 
BORDER 
XBBLACK 
XBBLUE 
XBCYAN 
XBGREEN 
XBLACK 
XBLUE 
XBMAGENTA 
XBRED 
XBWHITE 
XBYELLOW 
XCYAN 
CM_EDITOR 
XGREEN 
XMAGENTA 
XRED 
XWHITE 
XYELLOW 
GM_BLUE 
GM_GRAY 
GM_GREEN 
GM_RED 
MAPP_DATA 
MAPP_HELP 
MAPP_HOME 
MAPP_MSRC 
MAPP_USER 
MAPP_SPEC 
HELP_SPEC 
MAPP_THEME 
END_INIT_VARS 
BG 
FG 
BOX_FG 
BOX_BG 
IND_FG 
IND_BG 
BRACKETS_FG 
BRACKETS_BG 
FILL_CHAR_FG 
FILL_CHAR_BG 
NT_FG 
NT_BG 
NT_REV_FG 
NT_REV_BG 
NT_HL_FG 
NT_HL_BG 
NT_HL_REV_FG 
NT_HL_REV_BG 
TITLE_FG 
TITLE_BG 
LN_FG 
LN_BG 
CMDLN_FG 
CMDLN_BG 
RAN_FG 
RAN_BG 
BORDER 
XBBLACK 
XBBLUE 
XBCYAN 
XBGREEN 
XBLACK 
XBLUE 
XBMAGENTA 
XBRED 
XBWHITE 
XBYELLOW 
XCYAN 
CM_EDITOR 
XGREEN 
XMAGENTA 
XRED 
XWHITE 
XYELLOW 
GM_BLUE 
GM_GRAY 
GM_GREEN 
GM_RED 
MAPP_DATA 
MAPP_HELP 
MAPP_HOME 
MAPP_MSRC 
MAPP_USER 
MAPP_SPEC 
HELP_SPEC 
MAPP_THEME 
END_INIT_VARS 

Definition at line 30 of file init.c.

30 {
31 BG = 257,
32 FG,
33 BOX_FG,
34 BOX_BG,
35 IND_FG,
36 IND_BG,
41 NT_FG,
42 NT_BG,
51 LN_FG,
52 LN_BG,
55 RAN_FG,
56 RAN_BG,
57 BORDER,
58 XBBLACK,
59 XBBLUE,
60 XBCYAN,
61 XBGREEN,
62 XBLACK,
63 XBLUE,
65 XBRED,
66 XBWHITE,
68 XCYAN,
70 XGREEN,
72 XRED,
73 XWHITE,
74 XYELLOW,
75 GM_BLUE,
76 GM_GRAY,
78 GM_RED,
InitVariables
Definition init.c:30
@ XBBLACK
Definition init.c:58
@ XBCYAN
Definition init.c:60
@ MAPP_THEME
Definition init.c:86
@ IND_BG
Definition init.c:36
@ NT_HL_REV_FG
Definition init.c:47
@ XYELLOW
Definition init.c:74
@ RAN_BG
Definition init.c:56
@ LN_BG
Definition init.c:52
@ XRED
Definition init.c:72
@ MAPP_USER
Definition init.c:83
@ NT_BG
Definition init.c:42
@ XBLACK
Definition init.c:62
@ CMDLN_FG
Definition init.c:53
@ FILL_CHAR_BG
Definition init.c:40
@ XBWHITE
Definition init.c:66
@ XBLUE
Definition init.c:63
@ FILL_CHAR_FG
Definition init.c:39
@ NT_REV_BG
Definition init.c:44
@ BORDER
Definition init.c:57
@ XGREEN
Definition init.c:70
@ NT_HL_FG
Definition init.c:45
@ MAPP_HELP
Definition init.c:80
@ XBBLUE
Definition init.c:59
@ XBYELLOW
Definition init.c:67
@ CMDLN_BG
Definition init.c:54
@ XCYAN
Definition init.c:68
@ TITLE_BG
Definition init.c:50
@ BRACKETS_FG
Definition init.c:37
@ NT_HL_REV_BG
Definition init.c:48
@ NT_FG
Definition init.c:41
@ GM_RED
Definition init.c:78
@ BRACKETS_BG
Definition init.c:38
@ NT_REV_FG
Definition init.c:43
@ HELP_SPEC
Definition init.c:85
@ XBMAGENTA
Definition init.c:64
@ CM_EDITOR
Definition init.c:69
@ FG
Definition init.c:32
@ GM_GRAY
Definition init.c:76
@ BG
Definition init.c:31
@ MAPP_MSRC
Definition init.c:82
@ GM_GREEN
Definition init.c:77
@ XBGREEN
Definition init.c:61
@ IND_FG
Definition init.c:35
@ XWHITE
Definition init.c:73
@ MAPP_HOME
Definition init.c:81
@ RAN_FG
Definition init.c:55
@ BOX_BG
Definition init.c:34
@ XMAGENTA
Definition init.c:71
@ MAPP_DATA
Definition init.c:79
@ NT_HL_BG
Definition init.c:46
@ MAPP_SPEC
Definition init.c:84
@ LN_FG
Definition init.c:51
@ END_INIT_VARS
Definition init.c:87
@ XBRED
Definition init.c:65
@ TITLE_FG
Definition init.c:49
@ BOX_FG
Definition init.c:33
@ GM_BLUE
Definition init.c:75

◆ InitVariables [2/2]

Enumerator
BG 
FG 
BOX_FG 
BOX_BG 
IND_FG 
IND_BG 
BRACKETS_FG 
BRACKETS_BG 
FILL_CHAR_FG 
FILL_CHAR_BG 
NT_FG 
NT_BG 
NT_REV_FG 
NT_REV_BG 
NT_HL_FG 
NT_HL_BG 
NT_HL_REV_FG 
NT_HL_REV_BG 
TITLE_FG 
TITLE_BG 
LN_FG 
LN_BG 
CMDLN_FG 
CMDLN_BG 
RAN_FG 
RAN_BG 
BORDER 
XBBLACK 
XBBLUE 
XBCYAN 
XBGREEN 
XBLACK 
XBLUE 
XBMAGENTA 
XBRED 
XBWHITE 
XBYELLOW 
XCYAN 
CM_EDITOR 
XGREEN 
XMAGENTA 
XRED 
XWHITE 
XYELLOW 
GM_BLUE 
GM_GRAY 
GM_GREEN 
GM_RED 
MAPP_DATA 
MAPP_HELP 
MAPP_HOME 
MAPP_MSRC 
MAPP_USER 
MAPP_SPEC 
HELP_SPEC 
MAPP_THEME 
END_INIT_VARS 
BG 
FG 
BOX_FG 
BOX_BG 
IND_FG 
IND_BG 
BRACKETS_FG 
BRACKETS_BG 
FILL_CHAR_FG 
FILL_CHAR_BG 
NT_FG 
NT_BG 
NT_REV_FG 
NT_REV_BG 
NT_HL_FG 
NT_HL_BG 
NT_HL_REV_FG 
NT_HL_REV_BG 
TITLE_FG 
TITLE_BG 
LN_FG 
LN_BG 
CMDLN_FG 
CMDLN_BG 
RAN_FG 
RAN_BG 
BORDER 
XBBLACK 
XBBLUE 
XBCYAN 
XBGREEN 
XBLACK 
XBLUE 
XBMAGENTA 
XBRED 
XBWHITE 
XBYELLOW 
XCYAN 
CM_EDITOR 
XGREEN 
XMAGENTA 
XRED 
XWHITE 
XYELLOW 
GM_BLUE 
GM_GRAY 
GM_GREEN 
GM_RED 
MAPP_DATA 
MAPP_HELP 
MAPP_HOME 
MAPP_MSRC 
MAPP_USER 
MAPP_SPEC 
HELP_SPEC 
MAPP_THEME 
END_INIT_VARS 

Definition at line 30 of file init.c.

30 {
31 BG = 257,
32 FG,
33 BOX_FG,
34 BOX_BG,
35 IND_FG,
36 IND_BG,
41 NT_FG,
42 NT_BG,
51 LN_FG,
52 LN_BG,
55 RAN_FG,
56 RAN_BG,
57 BORDER,
58 XBBLACK,
59 XBBLUE,
60 XBCYAN,
61 XBGREEN,
62 XBLACK,
63 XBLUE,
65 XBRED,
66 XBWHITE,
68 XCYAN,
70 XGREEN,
72 XRED,
73 XWHITE,
74 XYELLOW,
75 GM_BLUE,
76 GM_GRAY,
78 GM_RED,

Function Documentation

◆ print_argp_doc()

void print_argp_doc ( FILE * minitrc_fp,
char * config_s,
char * key )

Definition at line 1417 of file init.c.

1417 {
1418 char comment[MAXLEN];
1419 comment[0] = '\0';
1420 if (get_argp_doc_by_name(comment, options, key))
1421 (void)fprintf(minitrc_fp, "%-34s # %s\n", config_s, comment);
1422 else
1423 (void)fprintf(minitrc_fp, "%-34s #\n", config_s);
1424}
#define MAXLEN
Definition curskeys.c:15
bool get_argp_doc_by_name(char *comment, const struct argp_option *, const char *)
Retrieves the documentation string for a given key name from an argp options array.
Definition futil.c:164

References get_argp_doc_by_name().

Referenced by write_config().

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

◆ process_config_file()

int process_config_file ( char * config_file_name,
Init * init )

Definition at line 694 of file init.c.

694 {
695 char include_file_name[MAXLEN];
696 char tmp_str[MAXLEN];
697 char *src_p, *dp;
698 SIO *sio = init->sio;
699 char hex_clr_str[8];
700 char key[MAXLEN];
701 char value[MAXLEN];
702 FILE *config_fp = fopen(config_file_name, "r");
703 char quote_char = '\0';
704 if (!config_fp) {
705 fprintf(stderr, "failed to read file: %s %s\n", config_file_name, strerror(errno));
706 return (-1);
707 }
708 while (fgets(tmp_str, sizeof(tmp_str), config_fp)) {
709 bool inquotes = false;
710 if (tmp_str[0] == '#')
711 continue;
712 src_p = tmp_str;
713 key[0] = '\0';
714 dp = key;
715 // copy delimited by "=" into value
716 while (*src_p != '\0') {
717 if (*src_p == '\n')
718 *dp = *src_p = '\0';
719 if (*src_p == '=') {
720 *dp = '\0';
721 src_p++;
722 break;
723 }
724 if (*src_p == '"' && *src_p == ' ') {
725 src_p++;
726 continue;
727 }
728 *dp++ = *src_p++;
729 }
730 value[0] = '\0';
731 dp = value;
732 // copy delimited by newline or unquoted "#" into value, removing quotes, spaces, semicolons, and newlines, but respecting quotes
733 while (*src_p != '\0') {
734 if ((*src_p == '"' || *src_p == '\'') && (*(src_p + 1) != '\\')) {
735 if (!inquotes) {
736 inquotes = true;
737 quote_char = *src_p++;
738 } else if (*src_p == quote_char) {
739 inquotes = false;
740 quote_char = '\0';
741 }
742 }
743 if (!inquotes) {
744 if (*src_p == '#') {
745 if (unstr_hex_clr(hex_clr_str, src_p)) {
746 strnz__cpy(value, hex_clr_str, MAXLEN - 1);
747 dp = value + strlen(value);
748 }
749 break;
750 }
751 }
752 if (*src_p == ' ' || *src_p == ';') {
753 src_p++;
754 continue;
755 }
756 if (*src_p == '\n') {
757 *src_p = '\0';
758 break;
759 }
760 *dp++ = *src_p++;
761 }
762 *dp = '\0';
763 if (key[0] == '\0')
764 continue;
765 if (value[0] == '\0')
766 continue;
767 if (!strcmp(key, "include")) {
768 strnz__cpy(include_file_name, value, MAXLEN - 1);
769 expand_tilde(include_file_name, MAXLEN - 1);
770 process_config_file(include_file_name, init);
771 continue;
772 }
773 if (!strcmp(key, "minitrc")) {
774 strnz__cpy(init->minitrc, value, MAXLEN - 1);
775 continue;
776 }
777 if (!strcmp(key, "lines")) {
778 init->lines = atoi(value);
779 continue;
780 }
781 if (!strcmp(key, "cols")) {
782 init->cols = atoi(value);
783 continue;
784 }
785 if (!strcmp(key, "begy")) {
786 init->begy = atoi(value);
787 continue;
788 }
789 if (!strcmp(key, "begx")) {
790 init->begx = atoi(value);
791 continue;
792 }
793 if (!strcmp(key, "f_ln")) {
794 init->f_ln = str_to_bool(value);
795 continue;
796 }
797 if (!strcmp(key, "f_at_end_remove")) {
798 init->f_at_end_remove = str_to_bool(value);
799 continue;
800 }
801 if (!strcmp(key, "f_erase_remainder")) {
802 init->f_erase_remainder = str_to_bool(value);
803 continue;
804 }
805 if (!strcmp(key, "brackets")) {
806 strnz__cpy(init->brackets, value, 2);
807 continue;
808 }
809 if (!strcmp(key, "fill_char")) {
810 if (strlen(value) > 1)
811 value[1] = '\0';
812 if (wcwidth((int)value[0]) > 1)
813 value[0] = '?';
814 strnz__cpy(init->fill_char, value, 4);
815 continue;
816 }
817 if (!strcmp(key, "f_ignore_case")) {
818 init->f_ignore_case = str_to_bool(value);
819 continue;
820 }
821 if (!strcmp(key, "p_view_files")) {
822 init->p_view_files = str_to_bool(value);
823 continue;
824 }
825 if (!strcmp(key, "f_read_theme")) {
826 init->f_read_theme = str_to_bool(value);
827 continue;
828 }
829 if (!strcmp(key, "f_squeeze")) {
830 init->f_squeeze = str_to_bool(value);
831 continue;
832 }
833 if (!strcmp(key, "f_strip_ansi")) {
834 init->f_strip_ansi = str_to_bool(value);
835 continue;
836 }
837 if (!strcmp(key, "f_multiple_cmd_args")) {
838 init->f_multiple_cmd_args = str_to_bool(value);
839 continue;
840 }
841 if (!strcmp(key, "select_max")) {
842 init->select_max = atoi(value);
843 continue;
844 }
845 if (!strcmp(key, "tab_stop")) {
846 init->tab_stop = atoi(value);
847 continue;
848 }
849 if (!strcmp(key, "timeout_secs")) {
850 init->timeout_secs = atoi(value);
851 continue;
852 }
853 if (!strcmp(key, "h_shift")) {
854 init->h_shift = atoi(value);
855 continue;
856 }
857 if (!strcmp(key, "wrap")) {
858 init->wrap = str_to_bool(value);
859 continue;
860 }
861 if (!strcmp(key, "title")) {
862 strnz__cpy(init->title, value, MAXLEN - 1);
863 continue;
864 }
865 if (!strcmp(key, "cmd")) {
866 strnz__cpy(init->cmd, value, MAXLEN - 1);
867 continue;
868 }
869 if (!strcmp(key, "cmd_all")) {
870 strnz__cpy(init->cmd_all, value, MAXLEN - 1);
871 continue;
872 }
873 if (!strcmp(key, "parent_cmd")) {
874 strnz__cpy(init->parent_cmd, value, MAXLEN - 1);
875 continue;
876 }
877 if (!strcmp(key, "provider_cmd")) {
878 strnz__cpy(init->provider_cmd, value, MAXLEN - 1);
879 continue;
880 }
881 if (!strcmp(key, "receiver_cmd")) {
882 strnz__cpy(init->receiver_cmd, value, MAXLEN - 1);
883 continue;
884 }
885 if (!strcmp(key, "editor")) {
886 strnz__cpy(init->editor, value, MAXLEN - 1);
887 continue;
888 }
889 if (!strcmp(key, "border")) {
890 char c = value[0];
891 if (c == 'r' || c == 'R')
892 sio->border = 'r';
893 else if (c == 's' || c == 'S')
894 sio->border = 's';
895 else if (c == 'd' || c == 'D')
896 sio->border = 'd';
897 else if (c == 'h' || c == 'H')
898 sio->border = 'h';
899 else
900 sio->border = 'n';
901 continue;
902 }
903 if (!strcmp(key, "fg")) {
904 sscanf(value, "#%06x", &sio->fg);
905 continue;
906 }
907 if (!strcmp(key, "bg")) {
908 sscanf(value, "#%06x", &sio->bg);
909 continue;
910 }
911 if (!strcmp(key, "box_fg")) {
912 sscanf(value, "#%06x", &sio->fg);
913 continue;
914 }
915 if (!strcmp(key, "box_bg")) {
916 sscanf(value, "#%06x", &sio->box_bg);
917 continue;
918 }
919 if (!strcmp(key, "ind_fg")) {
920 sscanf(value, "#%06x", &sio->ind_fg);
921 continue;
922 }
923 if (!strcmp(key, "ind_bg")) {
924 sscanf(value, "#%06x", &sio->ind_bg);
925 continue;
926 }
927 if (!strcmp(key, "brackets_fg")) {
928 sscanf(value, "#%06x", &sio->brackets_fg);
929 continue;
930 }
931 if (!strcmp(key, "brackets_bg")) {
932 sscanf(value, "#%06x", &sio->brackets_bg);
933 continue;
934 }
935 if (!strcmp(key, "fill_char_fg")) {
936 sscanf(value, "#%06x", &sio->fill_char_fg);
937 continue;
938 }
939 if (!strcmp(key, "fill_char_bg")) {
940 sscanf(value, "#%06x", &sio->fill_char_bg);
941 continue;
942 }
943 if (!strcmp(key, "ln_fg")) {
944 sscanf(value, "#%06x", &sio->ln_fg);
945 continue;
946 }
947 if (!strcmp(key, "ln_bg")) {
948 sscanf(value, "#%06x", &sio->ln_bg);
949 continue;
950 }
951 if (!strcmp(key, "cmdln_fg")) {
952 sscanf(value, "#%06x", &sio->cmdln_fg);
953 continue;
954 }
955 if (!strcmp(key, "cmdln_bg")) {
956 sscanf(value, "#%06x", &sio->cmdln_bg);
957 continue;
958 }
959 if (!strcmp(key, "nt_fg")) {
960 sscanf(value, "#%06x", &sio->nt_fg);
961 continue;
962 }
963 if (!strcmp(key, "nt_bg")) {
964 sscanf(value, "#%06x", &sio->nt_bg);
965 continue;
966 }
967 if (!strcmp(key, "nt_rev_fg")) {
968 sscanf(value, "#%06x", &sio->nt_rev_fg);
969 continue;
970 }
971 if (!strcmp(key, "nt_rev_bg")) {
972 sscanf(value, "#%06x", &sio->nt_rev_bg);
973 continue;
974 }
975 if (!strcmp(key, "nt_hl_fg")) {
976 sscanf(value, "#%06x", &sio->nt_hl_fg);
977 continue;
978 }
979 if (!strcmp(key, "nt_hl_bg")) {
980 sscanf(value, "#%06x", &sio->nt_hl_bg);
981 continue;
982 }
983 if (!strcmp(key, "nt_hl_rev_fg")) {
984 sscanf(value, "#%06x", &sio->nt_hl_rev_fg);
985 continue;
986 }
987 if (!strcmp(key, "nt_hl_rev_bg")) {
988 sscanf(value, "#%06x", &sio->nt_hl_rev_bg);
989 continue;
990 }
991 if (!strcmp(key, "title_fg")) {
992 sscanf(value, "#%06x", &sio->title_fg);
993 continue;
994 }
995 if (!strcmp(key, "title_bg")) {
996 sscanf(value, "#%06x", &sio->title_bg);
997 continue;
998 }
999 if (!strcmp(key, "ran_fg")) {
1000 sscanf(value, "#%06x", &sio->ran_fg);
1001 continue;
1002 }
1003 if (!strcmp(key, "ran_bg")) {
1004 sscanf(value, "#%06x", &sio->ran_bg);
1005 continue;
1006 }
1007 if (!strcmp(key, "red_gamma")) {
1008 sio->red_gamma = str_to_double(value);
1009 continue;
1010 }
1011 if (!strcmp(key, "green_gamma")) {
1012 sio->green_gamma = str_to_double(value);
1013 continue;
1014 }
1015 if (!strcmp(key, "blue_gamma")) {
1016 sio->blue_gamma = str_to_double(value);
1017 continue;
1018 }
1019 if (!strcmp(key, "gray_gamma")) {
1020 sio->gray_gamma = str_to_double(value);
1021 continue;
1022 }
1023 if (!strcmp(key, "black")) {
1024 sscanf(value, "#%06x", &sio->black);
1025 continue;
1026 }
1027 if (!strcmp(key, "red")) {
1028 sscanf(value, "#%06x", &sio->red);
1029 continue;
1030 }
1031 if (!strcmp(key, "green")) {
1032 sscanf(value, "#%06x", &sio->green);
1033 continue;
1034 }
1035 if (!strcmp(key, "yellow")) {
1036 sscanf(value, "#%06x", &sio->yellow);
1037 continue;
1038 }
1039 if (!strcmp(key, "blue")) {
1040 sscanf(value, "#%06x", &sio->blue);
1041 continue;
1042 }
1043 if (!strcmp(key, "magenta")) {
1044 sscanf(value, "#%06x", &sio->magenta);
1045 continue;
1046 }
1047 if (!strcmp(key, "cyan")) {
1048 sscanf(value, "#%06x", &sio->cyan);
1049 continue;
1050 }
1051 if (!strcmp(key, "white")) {
1052 sscanf(value, "#%06x", &sio->white);
1053 continue;
1054 }
1055 if (!strcmp(key, "orange")) {
1056 sscanf(value, "#%06x", &sio->orange);
1057 continue;
1058 }
1059 if (!strcmp(key, "bblack")) {
1060 sscanf(value, "#%06x", &sio->bblack);
1061 continue;
1062 }
1063 if (!strcmp(key, "bred")) {
1064 sscanf(value, "#%06x", &sio->bred);
1065 continue;
1066 }
1067 if (!strcmp(key, "bgreen")) {
1068 sscanf(value, "#%06x", &sio->bgreen);
1069 continue;
1070 }
1071 if (!strcmp(key, "byellow")) {
1072 sscanf(value, "#%06x", &sio->byellow);
1073 continue;
1074 }
1075 if (!strcmp(key, "bblue")) {
1076 sscanf(value, "#%06x", &sio->bblue);
1077 continue;
1078 }
1079 if (!strcmp(key, "bmagenta")) {
1080 sscanf(value, "#%06x", &sio->bmagenta);
1081 continue;
1082 }
1083 if (!strcmp(key, "bcyan")) {
1084 sscanf(value, "#%06x", &sio->bcyan);
1085 continue;
1086 }
1087 if (!strcmp(key, "bwhite")) {
1088 sscanf(value, "#%06x", &sio->bwhite);
1089 continue;
1090 }
1091 if (!strcmp(key, "borange")) {
1092 sscanf(value, "#%06x", &sio->borange);
1093 continue;
1094 }
1095 if (!strcmp(key, "mapp_spec")) {
1096 strnz__cpy(init->mapp_spec, value, MAXLEN - 1);
1097 continue;
1098 }
1099 if (!strcmp(key, "mapp_data")) {
1100 strnz__cpy(init->mapp_data, value, MAXLEN - 1);
1101 continue;
1102 }
1103 if (!strcmp(key, "mapp_help")) {
1104 strnz__cpy(init->mapp_help, value, MAXLEN - 1);
1105 continue;
1106 }
1107 if (!strcmp(key, "mapp_home")) {
1108 strnz__cpy(init->mapp_home, value, MAXLEN - 1);
1109 continue;
1110 }
1111 if (!strcmp(key, "mapp_msrc")) {
1112 strnz__cpy(init->mapp_msrc, value, MAXLEN - 1);
1113 continue;
1114 }
1115 if (!strcmp(key, "mapp_user")) {
1116 strnz__cpy(init->mapp_user, value, MAXLEN - 1);
1117 continue;
1118 }
1119 if (!strcmp(key, "mapp_theme")) {
1120 strnz__cpy(init->mapp_theme, value, MAXLEN - 1);
1121 continue;
1122 }
1123 if (!strcmp(key, "log_file_spec")) {
1124 strnz__cpy(init->log_file_spec, value, MAXLEN - 1);
1125 continue;
1126 }
1127 if (!strcmp(key, "log_level")) {
1128 str_to_upper(value);
1129 if (!strcmp(value, "SILENT"))
1130 init->min_log_level = SILENT;
1131 else if (!strcmp(value, "DEBUG"))
1132 init->min_log_level = DEBUG;
1133 else if (!strcmp(value, "INFO"))
1134 init->min_log_level = INFO;
1135 else if (!strcmp(value, "WARN"))
1136 init->min_log_level = WARN;
1137 else if (!strcmp(value, "ERROR"))
1138 init->min_log_level = ERROR;
1139 else if (!strcmp(value, "FATAL"))
1140 init->min_log_level = FATAL;
1141 else
1142 init->min_log_level = SILENT;
1143 continue;
1144 }
1145 }
1146 (void)fclose(config_fp);
1147 return 0;
1148}
bool str_to_bool(const char *)
Converts String to boolean true or false.
Definition futil.c:960
int process_config_file(char *, Init *)
Definition init.c:694
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition whence.c:291
bool str_to_upper(char *)
Converts a string to uppercase.
Definition futil.c:496
double str_to_double(char *)
converts string to double
Definition futil.c:948
bool expand_tilde(char *, uint)
Replaces "~/" in string with the user's home directory.
Definition futil.c:989
bool unstr_hex_clr(char *, char *)
Validates that a string is a hex color code in the format "#RRGGBB".
Definition futil.c:220
uint32_t ran_bg
Definition ui_backend.h:740
double green_gamma
Definition ui_backend.h:693
uint32_t ln_bg
Definition ui_backend.h:726
double blue_gamma
Definition ui_backend.h:694
uint32_t magenta
Definition ui_backend.h:701
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
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 nt_fg
Definition ui_backend.h:729
uint32_t yellow
Definition ui_backend.h:699
uint32_t fill_char_fg
Definition ui_backend.h:723
uint32_t orange
Definition ui_backend.h:704
uint32_t ln_fg
Definition ui_backend.h:725
uint32_t ind_bg
Definition ui_backend.h:720
uint32_t bmagenta
Definition ui_backend.h:710
uint32_t ind_fg
Definition ui_backend.h:719
uint32_t byellow
Definition ui_backend.h:708
uint32_t bblue
Definition ui_backend.h:709
uint32_t borange
Definition ui_backend.h:713
uint32_t title_bg
Definition ui_backend.h:738
uint32_t fg
Definition ui_backend.h:715
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 nt_hl_rev_bg
Definition ui_backend.h:736
uint32_t title_fg
Definition ui_backend.h:737
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 nt_rev_bg
Definition ui_backend.h:732
uint32_t brackets_bg
Definition ui_backend.h:722
uint32_t bcyan
Definition ui_backend.h:711
uint32_t nt_bg
Definition ui_backend.h:730
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 box_bg
Definition ui_backend.h:718
uint32_t nt_hl_fg
Definition ui_backend.h:733
uint32_t bwhite
Definition ui_backend.h:712
char border
Definition ui_backend.h:755
uint32_t nt_rev_fg
Definition ui_backend.h:731
double gray_gamma
Definition ui_backend.h:695
uint32_t nt_hl_bg
Definition ui_backend.h:734
uint32_t bg
Definition ui_backend.h:716
char title[MAXLEN]
Definition common.h:132
char mapp_data[MAXLEN]
Definition common.h:151
char minitrc[MAXLEN]
Definition common.h:177
char mapp_help[MAXLEN]
Definition common.h:152
int begx
Definition common.h:121
SIO * sio
Definition common.h:117
char log_file_spec[MAXLEN]
Definition common.h:181
UiLogLevel min_log_level
Definition common.h:183
char cmd_all[MAXLEN]
Definition common.h:126
char fill_char[2]
Definition common.h:149
char mapp_msrc[MAXLEN]
Definition common.h:153
int cols
Definition common.h:119
int tab_stop
Definition common.h:185
bool f_erase_remainder
Definition common.h:144
bool f_read_theme
Definition common.h:145
char mapp_home[MAXLEN]
Definition common.h:150
bool f_squeeze
Definition common.h:140
int begy
Definition common.h:120
char parent_cmd[MAXLEN]
Definition common.h:127
char mapp_spec[MAXLEN]
Definition common.h:179
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
bool f_strip_ansi
Definition common.h:139
bool p_view_files
Definition common.h:137
bool f_at_end_remove
Definition common.h:138
char brackets[3]
Definition common.h:148
bool f_ignore_case
Definition common.h:136
int lines
Definition common.h:118
char mapp_user[MAXLEN]
Definition common.h:154
char cmd[MAXLEN]
Definition common.h:125
char mapp_theme[MAXLEN]
Definition common.h:155
uint timeout_secs
Definition common.h:182
char editor[MAXLEN]
Definition common.h:175

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::borange, SIO::border, SIO::box_bg, 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, expand_tilde(), Init::f_at_end_remove, 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, 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, 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, SIO::orange, Init::p_view_files, Init::parent_cmd, process_config_file(), Init::provider_cmd, SIO::ran_bg, SIO::ran_fg, Init::receiver_cmd, SIO::red, SIO::red_gamma, Init::select_max, Init::sio, str_to_bool(), str_to_double(), str_to_upper(), strnz__cpy(), Init::tab_stop, Init::timeout_secs, Init::title, SIO::title_bg, SIO::title_fg, unstr_hex_clr(), SIO::white, Init::wrap, and SIO::yellow.

Referenced by process_config_file(), process_config_files(), and read_theme().

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

Variable Documentation

◆ argp_program_bug_address

const char * argp_program_bug_address = "billxwaller@gmail.com"

Definition at line 111 of file init.c.

◆ argp_program_version

const char * argp_program_version = CM_VERSION

Definition at line 110 of file init.c.

◆ executor

int executor = 0

Definition at line 108 of file init.c.

◆ f_write_config

bool f_write_config = false

Definition at line 90 of file init.c.

Referenced by mapp_initialization().