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

1407 {
1408 char comment[MAXLEN];
1409 comment[0] = '\0';
1410 if (get_argp_doc_by_name(comment, options, key))
1411 (void)fprintf(minitrc_fp, "%-34s # %s\n", config_s, comment);
1412 else
1413 (void)fprintf(minitrc_fp, "%-34s #\n", config_s);
1414}
#define MAXLEN
Definition lf.h:38
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:163

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

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

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_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, 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().