static void load_keys_from_section (const char *terminal, mc_config_t * cfg) { char *section_name; gchar **profile_keys, **keys; char *valcopy, *value; long key_code; if (terminal == NULL) return; section_name = g_strconcat ("terminal:", terminal, (char *) NULL); keys = mc_config_get_keys (cfg, section_name, NULL); for (profile_keys = keys; *profile_keys != NULL; profile_keys++) { /* copy=other causes all keys from [terminal:other] to be loaded. */ if (g_ascii_strcasecmp (*profile_keys, "copy") == 0) { valcopy = mc_config_get_string (cfg, section_name, *profile_keys, ""); load_keys_from_section (valcopy, cfg); g_free (valcopy); continue; } key_code = lookup_key (*profile_keys, NULL); if (key_code != 0) { gchar **values; values = mc_config_get_string_list (cfg, section_name, *profile_keys, NULL); if (values != NULL) { gchar **curr_values; for (curr_values = values; *curr_values != NULL; curr_values++) { valcopy = convert_controls (*curr_values); define_sequence (key_code, valcopy, MCKEY_NOACTION); g_free (valcopy); } g_strfreev (values); } else { value = mc_config_get_string (cfg, section_name, *profile_keys, ""); valcopy = convert_controls (value); define_sequence (key_code, valcopy, MCKEY_NOACTION); g_free (valcopy); g_free (value); } } } g_strfreev (keys); g_free (section_name); }
/* *INDENT-OFF* */ START_PARAMETRIZED_TEST (test_create_ini_file_paths, test_create_ini_file_ds) /* *INDENT-ON* */ { /* given */ char *actual_value, *actual_raw_value; mc_config_set_string (mc_config, "test-group1", "test-param1", " some value "); mc_config_set_string (mc_config, "test-group1", "test-param2", " \tkoi8-r: Тестовое значение "); mc_config_set_string (mc_config, "test-group1", "test-param3", " \tsome value2\n\nf\b\005fff "); mc_config_set_string_raw (mc_config, "test-group2", "test-param1", " some value "); mc_config_set_string_raw (mc_config, "test-group2", "test-param2", " koi8-r: Тестовое значение"); mc_config_set_string_raw (mc_config, "test-group2", "test-param3", " \tsome value2\n\nf\b\005fff "); config_object__reopen (); /* when */ actual_value = mc_config_get_string (mc_config, data->input_group, data->input_param, data->input_default_value); actual_raw_value = mc_config_get_string_raw (mc_config, data->input_group, data->input_param, data->input_default_value); /* then */ mctest_assert_str_eq (actual_value, data->expected_value); mctest_assert_str_eq (actual_raw_value, data->expected_raw_value); g_free (actual_value); g_free (actual_raw_value); }
void panel_load_setup (WPanel * panel, const char *section) { size_t i; char *buffer, buffer2[BUF_TINY]; panel->sort_info.reverse = mc_config_get_int (mc_panels_config, section, "reverse", 0); panel->sort_info.case_sensitive = mc_config_get_int (mc_panels_config, section, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT); panel->sort_info.exec_first = mc_config_get_int (mc_panels_config, section, "exec_first", 0); /* Load sort order */ buffer = mc_config_get_string (mc_panels_config, section, "sort_order", "name"); panel->sort_field = panel_get_field_by_id (buffer); if (panel->sort_field == NULL) panel->sort_field = panel_get_field_by_id ("name"); g_free (buffer); /* Load the listing mode */ buffer = mc_config_get_string (mc_panels_config, section, "list_mode", "full"); panel->list_type = list_full; for (i = 0; list_types[i].key != NULL; i++) if (g_ascii_strcasecmp (list_types[i].key, buffer) == 0) { panel->list_type = list_types[i].list_type; break; } g_free (buffer); /* User formats */ g_free (panel->user_format); panel->user_format = mc_config_get_string (mc_panels_config, section, "user_format", DEFAULT_USER_FORMAT); for (i = 0; i < LIST_TYPES; i++) { g_free (panel->user_status_format[i]); g_snprintf (buffer2, BUF_TINY, "user_status%lld", (long long) i); panel->user_status_format[i] = mc_config_get_string (mc_panels_config, section, buffer2, DEFAULT_USER_FORMAT); } panel->user_mini_status = mc_config_get_int (mc_panels_config, section, "user_mini_status", 0); }
/* *INDENT-OFF* */ END_PARAMETRIZED_TEST /* *INDENT-ON* */ /* --------------------------------------------------------------------------------------------- */ /* *INDENT-OFF* */ START_TEST (test_deserialize_config) /* *INDENT-ON* */ { /* given */ mc_config_t *actual; char *actual_value; /* when */ actual = mc_deserialize_config (deserialize_input_value1, &error); /* then */ mctest_assert_not_null (actual); actual_value = mc_config_get_string_raw (actual, "group1", "param1", ""); mctest_assert_str_eq (actual_value, "some value"); g_free (actual_value); actual_value = mc_config_get_string (actual, "group1", "param2", ""); mctest_assert_str_eq (actual_value, "some value "); g_free (actual_value); mctest_assert_int_eq (mc_config_get_bool (actual, "group2", "param1", FALSE), TRUE); mctest_assert_int_eq (mc_config_get_int (actual, "group2", "param2", 0), 123456); actual_value = mc_config_get_string_raw (actual, "group3", "param1", ""); mctest_assert_str_eq (actual_value, "::bla-bla::"); g_free (actual_value); actual_value = mc_config_get_string (actual, "group3", "param2", ""); mctest_assert_str_eq (actual_value, "bla-:p1:w:v2:12:g3:123:bla-bla\n"); g_free (actual_value); mctest_assert_int_eq (mc_config_get_bool (actual, "group4", "param1", TRUE), FALSE); mctest_assert_int_eq (mc_config_get_int (actual, "group4", "param2", 0), 654321); mc_config_deinit (actual); }
gchar * mc_skin_get (const gchar * group, const gchar * key, const gchar * default_value) { if (mc_global.tty.ugly_line_drawing) { return g_strdup (default_value); } return mc_config_get_string (mc_skin__default.config, group, key, default_value); }
static mc_config_t * load_setup_get_keymap_profile_config (void) { /* TODO: IMHO, in future this function must be placed into mc_config module. */ mc_config_t *keymap_config = NULL; char *fname, *fname2; /* 1) /usr/share/mc (mc_share_data_dir) */ fname = g_build_filename (mc_share_data_dir, GLOBAL_KEYMAP_FILE, NULL); load_setup_init_config_from_file (&keymap_config, fname); g_free (fname); /* 2) /etc/mc (mc_sysconfig_dir) */ fname = g_build_filename (mc_sysconfig_dir, GLOBAL_KEYMAP_FILE, NULL); load_setup_init_config_from_file (&keymap_config, fname); g_free (fname); /* 3) ${XDG_CONFIG_HOME}/mc */ fname = g_build_filename (mc_config_get_path (), GLOBAL_KEYMAP_FILE, NULL); load_setup_init_config_from_file (&keymap_config, fname); g_free (fname); /* 4) main config; [Midnight Commander] -> keymap */ fname2 = mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "keymap", GLOBAL_KEYMAP_FILE); fname = load_setup_get_full_config_name (NULL, fname2); if (fname != NULL) { load_setup_init_config_from_file (&keymap_config, fname); g_free (fname); } g_free (fname2); /* 5) getenv("MC_KEYMAP") */ fname = load_setup_get_full_config_name (NULL, g_getenv ("MC_KEYMAP")); if (fname != NULL) { load_setup_init_config_from_file (&keymap_config, fname); g_free (fname); } /* 6) --keymap=<keymap> */ fname = load_setup_get_full_config_name (NULL, mc_args__keymap_file); if (fname != NULL) { load_setup_init_config_from_file (&keymap_config, fname); g_free (fname); } return keymap_config; }
char * load_anon_passwd (void) { char *buffer; buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "ftpfs_password", ""); if ((buffer != NULL) && (buffer[0] != '\0')) return buffer; g_free (buffer); return NULL; }
gboolean mc_skin_ini_file_parse (mc_skin_t * mc_skin) { mc_skin->description = mc_config_get_string (mc_skin->config, "skin", "description", "- no description -"); if (!mc_skin_color_parse_ini_file (mc_skin)) return FALSE; mc_skin_lines_parse_ini_file (mc_skin); mc_skin->have_256_colors = mc_config_get_bool (mc_skin->config, "skin", "256colors", FALSE); mc_skin->have_true_colors = mc_config_get_bool (mc_skin->config, "skin", "truecolors", FALSE); return TRUE; }
static void load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t * cfg) { gchar **profile_keys, **keys; gchar **values, **curr_values; char *valcopy, *value; int action; gsize len, values_len; if (section_name == NULL) return; profile_keys = keys = mc_config_get_keys (cfg, section_name, &len); while (*profile_keys != NULL) { curr_values = values = mc_config_get_string_list (cfg, section_name, *profile_keys, &values_len); action = keybind_lookup_action (*profile_keys); if (action > 0) { if (curr_values != NULL) { while (*curr_values != NULL) { valcopy = convert_controls (*curr_values); keybind_cmd_bind (keymap, valcopy, action); g_free (valcopy); curr_values++; } } else { value = mc_config_get_string (cfg, section_name, *profile_keys, ""); valcopy = convert_controls (value); /* define_sequence (key_code, valcopy, MCKEY_NOACTION); */ g_free (valcopy); g_free (value); } } profile_keys++; g_strfreev (values); } g_strfreev (keys); }
static char * mc_skin_get_default_name (void) { char *tmp_str; /* from command line */ if (mc_global.tty.skin != NULL) return g_strdup (mc_global.tty.skin); /* from envirovement variable */ tmp_str = getenv ("MC_SKIN"); if (tmp_str != NULL) return g_strdup (tmp_str); /* from config. Or 'default' if no present in config */ return mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "skin", "default"); }
static panel_view_mode_t setup__load_panel_state (const char *section) { char *buffer; size_t i; panel_view_mode_t mode = view_listing; /* Load the display mode */ buffer = mc_config_get_string (mc_panels_config, section, "display", "listing"); for (i = 0; panel_types[i].opt_name != NULL; i++) if (g_ascii_strcasecmp (panel_types[i].opt_name, buffer) == 0) { mode = panel_types[i].opt_type; break; } g_free (buffer); return mode; }
static gboolean mc_fhl_parse_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name) { mc_fhl_filter_t *mc_filter; const gchar *types[] = { "FILE", "FILE_EXE", "DIR", "LINK_DIR", "LINK", "HARDLINK", "SYMLINK", "STALE_LINK", "DEVICE", "DEVICE_BLOCK", "DEVICE_CHAR", "SPECIAL", "SPECIAL_SOCKET", "SPECIAL_FIFO", "SPECIAL_DOOR", NULL }; int i; gchar *param_type = mc_config_get_string (fhl->config, group_name, "type", ""); if (*param_type == '\0') { g_free (param_type); return FALSE; } for (i = 0; types[i] != NULL; i++) { if (strcmp (types[i], param_type) == 0) break; } g_free (param_type); if (types[i] == NULL) return FALSE; mc_filter = g_new0 (mc_fhl_filter_t, 1); mc_filter->type = MC_FLHGH_T_FTYPE; mc_filter->file_type = (mc_flhgh_ftype_type) i; mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name); g_ptr_array_add (fhl->filters, (gpointer) mc_filter); return TRUE; }
static gboolean mc_fhl_parse_get_regexp (mc_fhl_t * fhl, const gchar * group_name) { mc_fhl_filter_t *mc_filter; gchar *regexp = mc_config_get_string (fhl->config, group_name, "regexp", ""); if (*regexp == '\0') { g_free (regexp); return FALSE; } mc_filter = g_new0 (mc_fhl_filter_t, 1); mc_filter->type = MC_FLHGH_T_FREGEXP; mc_filter->search_condition = mc_search_new (regexp, -1, DEFAULT_CHARSET); mc_filter->search_condition->is_case_sensitive = TRUE; mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX; mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name); g_ptr_array_add (fhl->filters, (gpointer) mc_filter); g_free (regexp); return TRUE; }
int main (int argc, char *argv[]) { GError *mcerror = NULL; gboolean config_migrated = FALSE; char *config_migrate_msg; int exit_code = EXIT_FAILURE; mc_global.timer = mc_timer_new (); /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */ #ifdef HAVE_SETLOCALE (void) setlocale (LC_ALL, ""); #endif (void) bindtextdomain (PACKAGE, LOCALEDIR); (void) textdomain (PACKAGE); /* do this before args parsing */ str_init_strings (NULL); if (!mc_args_parse (&argc, &argv, "mc", &mcerror)) { startup_exit_falure: fprintf (stderr, _("Failed to run:\n%s\n"), mcerror->message); g_error_free (mcerror); g_free (mc_global.tty.shell); startup_exit_ok: str_uninit_strings (); mc_timer_destroy (mc_global.timer); return exit_code; } /* do this before mc_args_show_info () to view paths in the --datadir-info output */ OS_Setup (); if (!g_path_is_absolute (mc_config_get_home_dir ())) { mc_propagate_error (&mcerror, 0, "%s: %s", _("Home directory path is not absolute"), mc_config_get_home_dir ()); mc_event_deinit (NULL); goto startup_exit_falure; } if (!mc_args_show_info ()) { exit_code = EXIT_SUCCESS; goto startup_exit_ok; } if (!events_init (&mcerror)) goto startup_exit_falure; mc_config_init_config_paths (&mcerror); config_migrated = mc_config_migrate_from_old_place (&mcerror, &config_migrate_msg); if (mcerror != NULL) { mc_event_deinit (NULL); goto startup_exit_falure; } vfs_init (); vfs_plugins_init (); load_setup (); /* Must be done after load_setup because depends on mc_global.vfs.cd_symlinks */ vfs_setup_work_dir (); /* Resolve the other_dir panel option. Must be done after vfs_setup_work_dir */ { char *buffer; vfs_path_t *vpath; buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", "."); vpath = vfs_path_from_str (buffer); if (vfs_file_is_local (vpath)) saved_other_dir = buffer; else g_free (buffer); vfs_path_free (vpath); } /* Set up temporary directory after VFS initialization */ mc_tmpdir (); /* do this after vfs initialization and vfs working directory setup due to mc_setctl() and mcedit_arg_vpath_new() calls in mc_setup_by_args() */ if (!mc_setup_by_args (argc, argv, &mcerror)) { vfs_shut (); done_setup (); g_free (saved_other_dir); mc_event_deinit (NULL); goto startup_exit_falure; } /* check terminal type * $TEMR must be set and not empty * mc_global.tty.xterm_flag is used in init_key() and tty_init() * Do this after mc_args_handle() where mc_args__force_xterm is set up. */ mc_global.tty.xterm_flag = tty_check_term (mc_args__force_xterm); /* NOTE: This has to be called before tty_init or whatever routine calls any define_sequence */ init_key (); /* Must be done before installing the SIGCHLD handler [[FIXME]] */ handle_console (CONSOLE_INIT); #ifdef ENABLE_SUBSHELL /* Don't use subshell when invoked as viewer or editor */ if (mc_global.mc_run_mode != MC_RUN_FULL) mc_global.tty.use_subshell = FALSE; if (mc_global.tty.use_subshell) subshell_get_console_attributes (); #endif /* ENABLE_SUBSHELL */ /* Install the SIGCHLD handler; must be done before init_subshell() */ init_sigchld (); /* We need this, since ncurses endwin () doesn't restore the signals */ save_stop_handler (); /* Must be done before init_subshell, to set up the terminal size: */ /* FIXME: Should be removed and LINES and COLS computed on subshell */ tty_init (!mc_args__nomouse, mc_global.tty.xterm_flag); /* start check mc_global.display_codepage and mc_global.source_codepage */ check_codeset (); /* Removing this from the X code let's us type C-c */ load_key_defs (); load_keymap_defs (!mc_args__nokeymap); macros_list = g_array_new (TRUE, FALSE, sizeof (macros_t)); tty_init_colors (mc_global.tty.disable_colors, mc_args__force_colors); mc_skin_init (NULL, &mcerror); dlg_set_default_colors (); input_set_default_colors (); if (mc_global.mc_run_mode == MC_RUN_FULL) command_set_default_colors (); mc_error_message (&mcerror); #ifdef ENABLE_SUBSHELL /* Done here to ensure that the subshell doesn't */ /* inherit the file descriptors opened below, etc */ if (mc_global.tty.use_subshell) init_subshell (); #endif /* ENABLE_SUBSHELL */ /* Also done after init_subshell, to save any shell init file messages */ if (mc_global.tty.console_flag != '\0') handle_console (CONSOLE_SAVE); if (mc_global.tty.alternate_plus_minus) application_keypad_mode (); /* Done after subshell initialization to allow select and paste text by mouse w/o Shift button in subshell in the native console */ init_mouse (); /* Done after do_enter_ca_mode (tty_init) because in VTE bracketed mode is separate for the normal and alternate screens */ enable_bracketed_paste (); /* subshell_prompt is NULL here */ mc_prompt = (geteuid () == 0) ? "# " : "$ "; if (config_migrated) { message (D_ERROR, _("Warning"), "%s", config_migrate_msg); g_free (config_migrate_msg); } /* Program main loop */ if (mc_global.midnight_shutdown) exit_code = EXIT_SUCCESS; else exit_code = do_nc ()? EXIT_SUCCESS : EXIT_FAILURE; /* Save the tree store */ (void) tree_store_save (); free_keymap_defs (); /* Virtual File System shutdown */ vfs_shut (); flush_extension_file (); /* does only free memory */ mc_skin_deinit (); tty_colors_done (); tty_shutdown (); done_setup (); if (mc_global.tty.console_flag != '\0' && (quit & SUBSHELL_EXIT) == 0) handle_console (CONSOLE_RESTORE); if (mc_global.tty.alternate_plus_minus) numeric_keypad_mode (); (void) signal (SIGCHLD, SIG_DFL); /* Disable the SIGCHLD handler */ if (mc_global.tty.console_flag != '\0') handle_console (CONSOLE_DONE); if (mc_global.mc_run_mode == MC_RUN_FULL && mc_args__last_wd_file != NULL && last_wd_string != NULL && !print_last_revert) { int last_wd_fd; last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR); if (last_wd_fd != -1) { ssize_t ret1; int ret2; ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string)); ret2 = close (last_wd_fd); (void) ret1; (void) ret2; } } g_free (last_wd_string); g_free (mc_global.tty.shell); done_key (); if (macros_list != NULL) { guint i; for (i = 0; i < macros_list->len; i++) { macros_t *macros; macros = &g_array_index (macros_list, struct macros_t, i); if (macros != NULL && macros->macro != NULL) (void) g_array_free (macros->macro, FALSE); } (void) g_array_free (macros_list, TRUE); }
END_TEST /* --------------------------------------------------------------------------------------------- */ #undef deserialize_check_incorrect #define deserialize_check_incorrect( etalon_code, etalon_str ) { \ if (actual != NULL) \ { \ fail("actual value but should be NULL", actual); \ mc_config_deinit(actual); \ } \ else \ { \ fail_unless (error->code == etalon_code && strcmp(error->message, etalon_str) == 0, \ "\nerror code is %d (should be %d);\nerror message is '%s' (should be '%s')", \ error->code, etalon_code, error->message, etalon_str); \ g_clear_error(&error); \ } \ } START_TEST (test_deserialize_config) { mc_config_t *actual; GError *error = NULL; char *actual_value; actual = mc_deserialize_config ("g123error in group name", &error); deserialize_check_incorrect( -3, "mc_deserialize_config() at 1: mc_serialize_str(): Length delimiter ':' doesn't exists"); actual = mc_deserialize_config ("p6:param1v10:some valuep6:param2v11:some value ", &error); deserialize_check_incorrect( -2, "mc_deserialize_config() at 1: mc_serialize_str(): String prefix doesn't equal to 'g'"); actual = mc_deserialize_config ("g6:group1v10:some valuep6:param2v11:some value ", &error); deserialize_check_incorrect( -2, "mc_deserialize_config() at 10: mc_serialize_str(): String prefix doesn't equal to 'p'"); actual = mc_deserialize_config ("g6:group1p6000:param2v11:some value ", &error); deserialize_check_incorrect( -3, "mc_deserialize_config() at 10: mc_serialize_str(): Specified data length (6000) is greater than actual data length (21)"); actual = mc_deserialize_config (etalon_str, &error); if (actual == NULL) { fail("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code, error->message); g_clear_error(&error); return; } actual_value = mc_config_get_string_raw(actual, "group1", "param1", ""); fail_unless( strcmp(actual_value, "some value") == 0, "group1->param1(%s) should be equal to 'some value'", actual_value); g_free(actual_value); actual_value = mc_config_get_string(actual, "group1", "param2", ""); fail_unless( strcmp(actual_value, "some value ") == 0, "group1->param2(%s) should be equal to 'some value '", actual_value); g_free(actual_value); fail_unless( mc_config_get_bool(actual, "group2", "param1", FALSE) == TRUE, "group2->param1(FALSE) should be equal to TRUE"); fail_unless( mc_config_get_int(actual, "group2", "param2", 0) == 123456, "group2->param2(%d) should be equal to 123456", mc_config_get_int(actual, "group2", "param2", 0)); actual_value = mc_config_get_string_raw(actual, "group3", "param1", ""); fail_unless( strcmp(actual_value, "::bla-bla::") == 0, "group3->param1(%s) should be equal to '::bla-bla::'", actual_value); g_free(actual_value); actual_value = mc_config_get_string(actual, "group3", "param2", ""); fail_unless( strcmp(actual_value, "bla-:p1:w:v2:12:g3:123:bla-bla\n") == 0, "group3->param2(%s) should be equal to 'bla-:p1:w:v2:12:g3:123:bla-bla\n'", actual_value); g_free(actual_value); fail_unless( mc_config_get_bool(actual, "group4", "param1", TRUE) == FALSE, "group4->param1(TRUE) should be equal to FALSE"); fail_unless( mc_config_get_int(actual, "group4", "param2", 0) == 654321, "group4->param2(%d) should be equal to 654321", mc_config_get_int(actual, "group4", "param2", 0)); mc_config_deinit (actual); }
void load_setup (void) { const char *profile; size_t i; const char *kt; #ifdef HAVE_CHARSET char *buffer; load_codepages_list (); #endif /* HAVE_CHARSET */ profile = setup_init (); /* mc.lib is common for all users, but has priority lower than ${XDG_CONFIG_HOME}/mc/ini. FIXME: it's only used for keys and treestore now */ global_profile_name = g_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL); if (!exist_file (global_profile_name)) { g_free (global_profile_name); global_profile_name = g_build_filename (mc_global.share_data_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL); } panels_profile_name = mc_config_get_full_path (MC_PANELS_FILE); mc_main_config = mc_config_init (profile, FALSE); if (!exist_file (panels_profile_name)) setup__move_panels_config_into_separate_file (profile); mc_panels_config = mc_config_init (panels_profile_name, FALSE); /* Load integer boolean options */ for (i = 0; int_options[i].opt_name != NULL; i++) *int_options[i].opt_addr = mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name, *int_options[i].opt_addr); #ifndef USE_INTERNAL_EDIT /* reset forced in case of build without internal editor */ use_internal_edit = 0; #endif /* USE_INTERNAL_EDIT */ if (option_tab_spacing <= 0) option_tab_spacing = DEFAULT_TAB_SPACING; #ifdef USE_INTERNAL_EDIT if (option_word_wrap_line_length <= 0) option_word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH; #endif /* USE_INTERNAL_EDIT */ /* overwrite old_esc_mode_timeout */ kt = getenv ("KEYBOARD_KEY_TIMEOUT_US"); if ((kt != NULL) && (kt[0] != '\0')) old_esc_mode_timeout = atoi (kt); /* Load string options */ for (i = 0; str_options[i].opt_name != NULL; i++) *str_options[i].opt_addr = mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name, str_options[i].opt_defval); load_layout (); panels_load_options (); load_panelize (); startup_left_mode = setup__load_panel_state ("New Left Panel"); startup_right_mode = setup__load_panel_state ("New Right Panel"); /* At least one of the panels is a listing panel */ if (startup_left_mode != view_listing && startup_right_mode != view_listing) startup_left_mode = view_listing; boot_current_is_left = mc_config_get_bool (mc_panels_config, "Dirs", "current_is_left", TRUE); /* Load time formats */ user_recent_timeformat = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "timeformat_recent", FMTTIME); user_old_timeformat = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "timeformat_old", FMTYEAR); #ifdef ENABLE_VFS_FTP ftpfs_proxy_host = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "ftp_proxy_host", "gate"); ftpfs_ignore_chattr_errors = mc_config_get_bool (mc_main_config, CONFIG_APP_SECTION, "ignore_ftp_chattr_errors", TRUE); ftpfs_init_passwd (); #endif /* ENABLE_VFS_FTP */ /* The default color and the terminal dependent color */ mc_global.tty.setup_color_string = mc_config_get_string (mc_main_config, "Colors", "base_color", ""); mc_global.tty.term_color_string = mc_config_get_string (mc_main_config, "Colors", getenv ("TERM"), ""); mc_global.tty.color_terminal_string = mc_config_get_string (mc_main_config, "Colors", "color_terminals", ""); /* Load the directory history */ /* directory_history_load (); */ /* Remove the temporal entries */ #ifdef HAVE_CHARSET if (codepages->len > 1) { buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "display_codepage", ""); if (buffer[0] != '\0') { mc_global.display_codepage = get_codepage_index (buffer); cp_display = get_codepage_id (mc_global.display_codepage); } g_free (buffer); buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "source_codepage", ""); if (buffer[0] != '\0') { default_source_codepage = get_codepage_index (buffer); mc_global.source_codepage = default_source_codepage; /* May be source_codepage doesn't need this */ cp_source = get_codepage_id (mc_global.source_codepage); } g_free (buffer); } autodetect_codeset = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "autodetect_codeset", ""); if ((autodetect_codeset[0] != '\0') && (strcmp (autodetect_codeset, "off") != 0)) is_autodetect_codeset_enabled = TRUE; g_free (init_translation_table (mc_global.source_codepage, mc_global.display_codepage)); buffer = (char *) get_codepage_id (mc_global.display_codepage); if (buffer != NULL) mc_global.utf8_display = str_isutf8 (buffer); #endif /* HAVE_CHARSET */ #ifdef HAVE_ASPELL spell_language = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "spell_language", "en"); #endif /* HAVE_ASPELL */ clipboard_store_path = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store", ""); clipboard_paste_path = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_paste", ""); }
static mc_config_t * load_setup_get_keymap_profile_config (gboolean load_from_file) { /* TODO: IMHO, in future, this function shall be placed in mcconfig module. */ mc_config_t *keymap_config; char *share_keymap, *sysconfig_keymap; char *fname, *fname2; /* 0) Create default keymap */ keymap_config = create_default_keymap (); if (!load_from_file) return keymap_config; /* load and merge global keymaps */ /* 1) /usr/share/mc (mc_global.share_data_dir) */ share_keymap = g_build_filename (mc_global.share_data_dir, GLOBAL_KEYMAP_FILE, NULL); load_setup_init_config_from_file (&keymap_config, share_keymap, TRUE); /* 2) /etc/mc (mc_global.sysconfig_dir) */ sysconfig_keymap = g_build_filename (mc_global.sysconfig_dir, GLOBAL_KEYMAP_FILE, NULL); load_setup_init_config_from_file (&keymap_config, sysconfig_keymap, TRUE); /* then load and merge one of user-defined keymap */ /* 3) --keymap=<keymap> */ fname = load_setup_get_full_config_name (NULL, mc_args__keymap_file); if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0) { load_setup_init_config_from_file (&keymap_config, fname, TRUE); goto done; } g_free (fname); /* 4) getenv("MC_KEYMAP") */ fname = load_setup_get_full_config_name (NULL, g_getenv ("MC_KEYMAP")); if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0) { load_setup_init_config_from_file (&keymap_config, fname, TRUE); goto done; } g_free (fname); /* 5) main config; [Midnight Commander] -> keymap */ fname2 = mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "keymap", NULL); if (fname2 != NULL && *fname2 != '\0') fname = load_setup_get_full_config_name (NULL, fname2); g_free (fname2); if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0) { load_setup_init_config_from_file (&keymap_config, fname, TRUE); goto done; } g_free (fname); /* 6) ${XDG_CONFIG_HOME}/mc/mc.keymap */ fname = mc_config_get_full_path (GLOBAL_KEYMAP_FILE); load_setup_init_config_from_file (&keymap_config, fname, TRUE); done: g_free (fname); g_free (sysconfig_keymap); g_free (share_keymap); return keymap_config; }