From 1d4318a2be963bcaff9983b05d66697be1b595c4 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Fri, 25 Sep 2009 12:32:55 +0300 Subject: [PATCH] Renamed global variable mc_home into mc_main_sysconf_dir Signed-off-by: Slava Zanko --- edit/editcmd.c | 10 +++++----- edit/syntax.c | 6 +++--- src/args.c | 4 ++-- src/charsets.c | 2 +- src/cmd.c | 10 +++++----- src/ext.c | 8 ++++---- src/filehighlight/ini-file-read.c | 2 +- src/main.c | 23 +++++++++-------------- src/main.h | 2 +- src/setup.c | 13 +++++++------ src/skin/ini-file.c | 2 +- src/user.c | 2 +- src/util.c | 4 ++-- vfs/extfs.c | 2 +- vfs/ftpfs.c | 2 +- vfs/sfs.c | 2 +- 16 files changed, 45 insertions(+), 49 deletions(-) diff --git a/edit/editcmd.c b/edit/editcmd.c index 9437aae5b..47696d89a 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -53,7 +53,7 @@ #include "../src/history.h" #include "../src/widget.h" /* listbox_new() */ #include "../src/layout.h" /* clr_scr() */ -#include "../src/main.h" /* mc_home source_codepage */ +#include "../src/main.h" /* mc_main_sysconf_dir source_codepage */ #include "../src/help.h" /* interactive_display() */ #include "../src/wtools.h" /* message() */ #include "../src/charsets.h" @@ -898,7 +898,7 @@ edit_load_syntax_file (WEdit * edit) _("&User"), _("&System Wide")); } - extdir = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax"); + extdir = concat_dir_and_file (mc_main_sysconf_dir, "syntax" PATH_SEP_STR "Syntax"); if (!exist_file(extdir)) { g_free (extdir); extdir = concat_dir_and_file (mc_main_sharedata_dir, "syntax" PATH_SEP_STR "Syntax"); @@ -930,7 +930,7 @@ edit_load_menu_file (WEdit * edit) geteuid() ? 2 : 3, _("&Local"), _("&User"), _("&System Wide") ); - menufile = concat_dir_and_file (mc_home, EDIT_GLOBAL_MENU); + menufile = concat_dir_and_file (mc_main_sysconf_dir, EDIT_GLOBAL_MENU); if (!exist_file (menufile)) { g_free (menufile); @@ -950,7 +950,7 @@ edit_load_menu_file (WEdit * edit) break; case 2: - buffer = concat_dir_and_file (mc_home, EDIT_GLOBAL_MENU); + buffer = concat_dir_and_file (mc_main_sysconf_dir, EDIT_GLOBAL_MENU); if (!exist_file (buffer)) { g_free (buffer); buffer = concat_dir_and_file (mc_main_sharedata_dir, EDIT_GLOBAL_MENU); @@ -2125,7 +2125,7 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block) gchar *o, *h, *b, *tmp; char *quoted_name = NULL; - o = g_strconcat (mc_home, shell_cmd, (char *) NULL); /* original source script */ + o = g_strconcat (mc_main_sysconf_dir, shell_cmd, (char *) NULL); /* original source script */ h = g_strconcat (home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, (char *) NULL); /* home script */ b = concat_dir_and_file (home_dir, EDIT_BLOCK_FILE); /* block file */ diff --git a/edit/syntax.c b/edit/syntax.c index 1da8797cb..467987f0f 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -58,7 +58,7 @@ #include "edit-impl.h" #include "edit-widget.h" -#include "../src/main.h" /* mc_home */ +#include "../src/main.h" /* mc_main_sysconf_dir */ #include "../src/wtools.h" /* message() */ #include "../src/strutil.h" /* utf string functions */ @@ -690,7 +690,7 @@ static FILE *open_include_file (const char *filename) return f; g_free (error_file_name); - error_file_name = g_strconcat (mc_home, PATH_SEP_STR, "syntax", PATH_SEP_STR, + error_file_name = g_strconcat (mc_main_sysconf_dir, PATH_SEP_STR, "syntax", PATH_SEP_STR, filename, (char *) NULL); if ((f = fopen (error_file_name, "r"))) { @@ -1045,7 +1045,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, f = fopen (syntax_file, "r"); if (!f){ - lib_file = concat_dir_and_file (mc_home, "Syntax"); + lib_file = concat_dir_and_file (mc_main_sysconf_dir, "Syntax"); f = fopen (lib_file, "r"); g_free (lib_file); if (!f) diff --git a/src/args.c b/src/args.c index d18708432..8824b56f6 100644 --- a/src/args.c +++ b/src/args.c @@ -38,7 +38,7 @@ extern int reset_hp_softkeys; -extern char *mc_home; +extern char *mc_main_sysconf_dir; extern char *mc_main_sharedata_dir; /* colors specified on the command line: they override any other setting */ @@ -380,7 +380,7 @@ mc_args_process(void) return FALSE; } if (mc_args__show_datadirs){ - printf ("%s (%s)\n", mc_home, mc_main_sharedata_dir); + printf ("%s (%s)\n", mc_main_sysconf_dir, mc_main_sharedata_dir); return FALSE; } diff --git a/src/charsets.c b/src/charsets.c index f249fa9e5..2eb459fe0 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -55,7 +55,7 @@ load_codepages_list (void) char buf[BUF_MEDIUM]; char *default_codepage = NULL; - fname = concat_dir_and_file (mc_home, CHARSETS_INDEX); + fname = concat_dir_and_file (mc_main_sysconf_dir, CHARSETS_INDEX); if (!(f = fopen (fname, "r"))) { fprintf (stderr, _("Warning: file %s not found\n"), fname); g_free (fname); diff --git a/src/cmd.c b/src/cmd.c index 67ce2b126..b66676c92 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -598,7 +598,7 @@ void ext_cmd (void) _(" Which extension file you want to edit? "), D_NORMAL, 2, _("&User"), _("&System Wide")); } - extdir = concat_dir_and_file (mc_home, MC_LIB_EXT); + extdir = concat_dir_and_file (mc_main_sysconf_dir, MC_LIB_EXT); if (dir == 0){ buffer = concat_dir_and_file (home_dir, MC_USER_EXT); @@ -631,7 +631,7 @@ edit_mc_menu_cmd (void) _("&Local"), _("&User"), _("&System Wide") ); - menufile = concat_dir_and_file (mc_home, MC_GLOBAL_MENU); + menufile = concat_dir_and_file (mc_main_sysconf_dir, MC_GLOBAL_MENU); if (!exist_file(menufile)) { g_free (menufile); @@ -651,7 +651,7 @@ edit_mc_menu_cmd (void) break; case 2: - buffer = concat_dir_and_file (mc_home, MC_GLOBAL_MENU); + buffer = concat_dir_and_file (mc_main_sysconf_dir, MC_GLOBAL_MENU); if (!exist_file(buffer)) { g_free (buffer); buffer = concat_dir_and_file (mc_main_sharedata_dir, MC_GLOBAL_MENU); @@ -683,7 +683,7 @@ void edit_fhl_cmd (void) _(" Which highlighting file you want to edit? "), D_NORMAL, 2, _("&User"), _("&System Wide")); } - fhlfile = concat_dir_and_file (mc_home, MC_FHL_INI_FILE); + fhlfile = concat_dir_and_file (mc_main_sysconf_dir, MC_FHL_INI_FILE); if (dir == 0){ user_mc_dir = concat_dir_and_file (home_dir, MC_BASE); @@ -695,7 +695,7 @@ void edit_fhl_cmd (void) } else if (dir == 1) { if (!exist_file(fhlfile)) { g_free (fhlfile); - fhlfile = concat_dir_and_file (mc_home, MC_FHL_INI_FILE); + fhlfile = concat_dir_and_file (mc_main_sysconf_dir, MC_FHL_INI_FILE); } do_edit (fhlfile); } diff --git a/src/ext.c b/src/ext.c index dd4250564..256abff61 100644 --- a/src/ext.c +++ b/src/ext.c @@ -453,7 +453,7 @@ regex_command (const char *filename, const char *action, int *move_dir) if (!exist_file (extension_file)) { g_free (extension_file); check_stock_mc_ext: - extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT); + extension_file = concat_dir_and_file (mc_main_sysconf_dir, MC_LIB_EXT); if (!exist_file (extension_file)) { g_free (extension_file); extension_file = concat_dir_and_file (mc_main_sharedata_dir, MC_LIB_EXT); @@ -476,12 +476,12 @@ regex_command (const char *filename, const char *action, int *move_dir) } else { char *title = g_strdup_printf (_(" %s%s file error"), - mc_home, MC_LIB_EXT); + mc_main_sysconf_dir, MC_LIB_EXT); message (D_ERROR, title, _("The format of the %smc.ext " "file has changed with version 3.0. It seems that " "the installation failed. Please fetch a fresh " "copy from the Midnight Commander package."), - mc_home); + mc_main_sysconf_dir); g_free (title); return 0; } @@ -493,7 +493,7 @@ regex_command (const char *filename, const char *action, int *move_dir) message (D_ERROR, title, _("The format of the ~/%s file has " "changed with version 3.0. You may either want to copy " "it from %smc.ext or use that file as an example of how " - "to write it."), MC_USER_EXT, mc_home); + "to write it."), MC_USER_EXT, mc_main_sysconf_dir); g_free (title); } } diff --git a/src/filehighlight/ini-file-read.c b/src/filehighlight/ini-file-read.c index ef7bc93dc..6ae2f426a 100644 --- a/src/filehighlight/ini-file-read.c +++ b/src/filehighlight/ini-file-read.c @@ -216,7 +216,7 @@ mc_fhl_init_from_standart_files (mc_fhl_t * fhl) g_free (name); /* ${sysconfdir}/mc/filehighlight.ini */ - name = concat_dir_and_file (mc_home, MC_FHL_INI_FILE); + name = concat_dir_and_file (mc_main_sysconf_dir, MC_FHL_INI_FILE); if (exist_file (name) && (!mc_fhl_read_ini_file (fhl, name))) { g_free (name); return FALSE; diff --git a/src/main.c b/src/main.c index 6b997da5e..f3af4ac05 100644 --- a/src/main.c +++ b/src/main.c @@ -289,10 +289,10 @@ int midnight_shutdown = 0; /* The user's shell */ char *shell = NULL; -/* mc_home: The home of MC - /etc/mc or defined by MC_DATADIR */ -char *mc_home = NULL; +/* mc_main_sysconf_dir: The main config dir for MC - ${prefix}/etc/mc or defined by MC_CONFDIR */ +char *mc_main_sysconf_dir = NULL; -/* mc_main_sharedata_dir: Alternative home of MC - deprecated /usr/share/mc */ +/* mc_main_sharedata_dir: Share data dir for MC - ${prefix}/share/mc or defined by MC_DATADIR */ char *mc_main_sharedata_dir = NULL; char cmd_buf[512]; @@ -1876,22 +1876,17 @@ OS_Setup (void) shell = g_strdup ("/bin/sh"); } - /* This is the directory, where MC was installed, on Unix this is DATADIR */ - /* and can be overriden by the MC_DATADIR environment variable */ mc_libdir = getenv ("MC_DATADIR"); - if (mc_libdir != NULL) { - mc_home = g_strdup (mc_libdir); - mc_main_sharedata_dir = g_strdup (SYSCONFDIR); - } else { - mc_home = g_strdup (SYSCONFDIR); - mc_main_sharedata_dir = g_strdup (DATADIR); - } + mc_main_sharedata_dir = (mc_libdir != NULL) ? g_strdup (mc_libdir) : g_strdup (DATADIR); + + mc_libdir = getenv ("MC_CONFDIR"); + mc_main_sysconf_dir = (mc_libdir != NULL) ? g_strdup (mc_libdir) : g_strdup (SYSCONFDIR); /* This variable is used by the subshell */ home_dir = getenv ("HOME"); if (!home_dir) - home_dir = mc_home; + home_dir = mc_main_sysconf_dir; } @@ -2213,7 +2208,7 @@ main (int argc, char *argv[]) g_free (last_wd_string); g_free (mc_main_sharedata_dir); - g_free (mc_home); + g_free (mc_main_sysconf_dir); g_free (shell); done_key (); diff --git a/src/main.h b/src/main.h index 8dfb20e62..a82010bfc 100644 --- a/src/main.h +++ b/src/main.h @@ -107,7 +107,7 @@ void print_vfs_message(const char *msg, ...) extern const char *prompt; extern const char *edit_one_file; -extern char *mc_home; +extern char *mc_main_sysconf_dir; extern char *mc_main_sharedata_dir; struct mc_fhl_struct; diff --git a/src/setup.c b/src/setup.c index 09c7a7ea2..37c7400d2 100644 --- a/src/setup.c +++ b/src/setup.c @@ -600,9 +600,9 @@ load_setup_get_full_config_name(const char *subdir, const char *config_file_name if (subdir) - ret = g_build_filename (mc_home, subdir, basename, NULL); + ret = g_build_filename (mc_main_sysconf_dir, subdir, basename, NULL); else - ret = g_build_filename (mc_home, basename, NULL); + ret = g_build_filename (mc_main_sysconf_dir, basename, NULL); if (exist_file(ret)) { g_free(basename); @@ -661,8 +661,8 @@ load_setup_get_keymap_profile_config(void) load_setup_init_config_from_file( &keymap_config, fname); g_free(fname); - /* 2) /etc/mc (mc_home) */ - fname = g_build_filename (mc_home, GLOBAL_KEYMAP_FILE, NULL); + /* 2) /etc/mc (mc_main_sysconf_dir) */ + fname = g_build_filename (mc_main_sysconf_dir, GLOBAL_KEYMAP_FILE, NULL); load_setup_init_config_from_file( &keymap_config, fname); g_free(fname); @@ -712,7 +712,7 @@ setup_init (void) profile = concat_dir_and_file (home_dir, PROFILE_NAME); if (!exist_file (profile)){ - inifile = concat_dir_and_file (mc_home, "mc.ini"); + inifile = concat_dir_and_file (mc_main_sysconf_dir, "mc.ini"); if (exist_file (inifile)){ g_free (profile); profile = inifile; @@ -743,7 +743,8 @@ load_setup (void) /* mc.lib is common for all users, but has priority lower than ~/.mc/ini. FIXME: it's only used for keys and treestore now */ - global_profile_name = concat_dir_and_file (mc_home, "mc.lib"); + global_profile_name = concat_dir_and_file (mc_main_sysconf_dir, "mc.lib"); + if (!exist_file(global_profile_name)) { g_free (global_profile_name); global_profile_name = concat_dir_and_file (mc_main_sharedata_dir, "mc.lib"); diff --git a/src/skin/ini-file.c b/src/skin/ini-file.c index b2a54a1e9..e0d70bca9 100644 --- a/src/skin/ini-file.c +++ b/src/skin/ini-file.c @@ -99,7 +99,7 @@ mc_skin_ini_file_load (mc_skin_t * mc_skin) g_free (user_home_dir); /* /etc/mc/skins/ */ - if (mc_skin_ini_file_load_search_in_dir (mc_skin, mc_home)) + if (mc_skin_ini_file_load_search_in_dir (mc_skin, mc_main_sysconf_dir)) return TRUE; /* /usr/share/mc/skins/ */ diff --git a/src/user.c b/src/user.c index d5da796bc..2210fe6dd 100644 --- a/src/user.c +++ b/src/user.c @@ -763,7 +763,7 @@ user_menu_cmd (WEdit *edit_widget) if (!exist_file (menu)){ g_free (menu); menu = concat_dir_and_file - (mc_home, edit_widget ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU); + (mc_main_sysconf_dir, edit_widget ? EDIT_GLOBAL_MENU : MC_GLOBAL_MENU); if (!exist_file (menu)) { g_free (menu); menu = concat_dir_and_file diff --git a/src/util.c b/src/util.c index 2fb90c072..ad268095c 100644 --- a/src/util.c +++ b/src/util.c @@ -46,7 +46,7 @@ #include "../src/search/search.h" -#include "main.h" /* mc_home */ +#include "main.h" /* mc_main_sysconf_dir */ #include "cmd.h" /* guess_message_value */ #include "mountlist.h" #include "timefmt.h" @@ -592,7 +592,7 @@ load_mc_home_file (const char *filename, char **allocated_filename) char *lang; char *data; - hintfile_base = concat_dir_and_file (mc_home, filename); + hintfile_base = concat_dir_and_file (mc_main_sysconf_dir, filename); lang = guess_message_value (); hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); diff --git a/vfs/extfs.c b/vfs/extfs.c index db1d40556..08418f696 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -1306,7 +1306,7 @@ static int extfs_init (struct vfs_class *me) (void) me; - mc_extfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "extfs.ini"); + mc_extfsini = concat_dir_and_file (mc_main_sysconf_dir, "extfs" PATH_SEP_STR "extfs.ini"); cfg = fopen (mc_extfsini, "r"); /* We may not use vfs_die() message or message or similar, diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 135733270..7d20ce5d5 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -570,7 +570,7 @@ ftpfs_load_no_proxy_list (void) if (mc_file) return; - mc_file = concat_dir_and_file (mc_home, "mc.no_proxy"); + mc_file = concat_dir_and_file (mc_main_sysconf_dir, "mc.no_proxy"); if (exist_file (mc_file) && (npf = fopen (mc_file, "r"))) { while (fgets (s, sizeof (s), npf)) { diff --git a/vfs/sfs.c b/vfs/sfs.c index 1e5ed1973..37cd10fe1 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -344,7 +344,7 @@ static int sfs_init (struct vfs_class *me) (void) me; - mc_sfsini = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR "sfs.ini"); + mc_sfsini = concat_dir_and_file (mc_main_sysconf_dir, "extfs" PATH_SEP_STR "sfs.ini"); cfg = fopen (mc_sfsini, "r"); if (!cfg){