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

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

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

31 {
32 BG = 257,
33 FG,
34 BOX_FG,
35 BOX_BG,
36 IND_FG,
37 IND_BG,
42 NT_FG,
43 NT_BG,
52 LN_FG,
53 LN_BG,
56 RAN_FG,
57 RAN_BG,
58 BORDER,
59 XBBLACK,
60 XBBLUE,
61 XBCYAN,
62 XBGREEN,
63 XBLACK,
64 XBLUE,
66 XBRED,
67 XBWHITE,
69 XCYAN,
71 XGREEN,
73 XRED,
74 XWHITE,
75 XYELLOW,
76 GM_BLUE,
77 GM_GRAY,
79 GM_RED,

Function Documentation

◆ print_argp_doc()

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

Definition at line 1348 of file init.c.

1348 {
1349 char comment[MAXLEN];
1350 comment[0] = '\0';
1351 if (get_argp_doc_by_name(comment, options, key))
1352 (void)fprintf(minitrc_fp, "%-34s # %s\n", config_s, comment);
1353 else
1354 (void)fprintf(minitrc_fp, "%-34s #\n", config_s);
1355}
#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:169

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

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

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, 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(), strnz__cpy(), Init::tab_stop, 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 112 of file init.c.

◆ argp_program_version

const char * argp_program_version = CM_VERSION

Definition at line 111 of file init.c.

◆ executor

int executor = 0

Definition at line 109 of file init.c.

◆ f_write_config

bool f_write_config = false

Definition at line 91 of file init.c.

Referenced by mapp_initialization().