mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-18 17:29:28 +03:00
Reorganization of sources. Part 2
* moved src/fileloc.h into lib/fileloc.h * moved src/timefmt.h into lib/timefmt.h * removed unneedded includes into src/util.c Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
93dbc46e9c
commit
dbaff2b6f6
@ -3,9 +3,11 @@ SUBDIRS = filehighlight mcconfig search skin tty vfs
|
||||
noinst_LTLIBRARIES = libmc.la
|
||||
|
||||
libmc_la_SOURCES = \
|
||||
fileloc.h \
|
||||
fs.h \
|
||||
glibcompat.c glibcompat.h \
|
||||
global.h
|
||||
global.h \
|
||||
timefmt.h
|
||||
|
||||
|
||||
libmc_la_CFLAGS= $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "src/main.h"
|
||||
#include "src/fileloc.h"
|
||||
#include "lib/fileloc.h"
|
||||
#include "src/strescape.h"
|
||||
#include "lib/skin/skin.h"
|
||||
#include "fhl.h"
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "src/main.h"
|
||||
#include "src/fileloc.h"
|
||||
#include "lib/fileloc.h"
|
||||
#include "skin.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
@ -118,7 +118,6 @@ mc_SOURCES = \
|
||||
ext.c ext.h \
|
||||
file.c file.h \
|
||||
filegui.c filegui.h \
|
||||
fileloc.h \
|
||||
filenot.c \
|
||||
fileopctx.c fileopctx.h \
|
||||
find.c find.h \
|
||||
@ -134,7 +133,6 @@ mc_SOURCES = \
|
||||
panelize.c panelize.h \
|
||||
subshell.c subshell.h \
|
||||
textconf.c textconf.h \
|
||||
timefmt.h \
|
||||
treestore.c treestore.h \
|
||||
user.c user.h
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "strutil.h" /* utf-8 functions */
|
||||
#include "main.h"
|
||||
#include "util.h" /* concat_dir_and_file() */
|
||||
#include "fileloc.h"
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
int n_codepages = 0;
|
||||
|
||||
|
36
src/cmd.c
36
src/cmd.c
@ -55,6 +55,7 @@
|
||||
#include "src/viewer/mcviewer.h"
|
||||
#include "lib/filehighlight/fhl.h" /* MC_FHL_INI_FILE */
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
#include "cmd.h" /* Our definitions */
|
||||
#include "fileopctx.h"
|
||||
@ -80,7 +81,6 @@
|
||||
#include "strutil.h"
|
||||
#include "dir.h"
|
||||
#include "cmddef.h" /* CK_InputHistoryShow */
|
||||
#include "fileloc.h"
|
||||
|
||||
#ifndef MAP_FILE
|
||||
# define MAP_FILE 0
|
||||
@ -1025,38 +1025,6 @@ user_file_menu_cmd (void)
|
||||
user_menu_cmd (NULL);
|
||||
}
|
||||
|
||||
/* partly taken from dcigettext.c, returns "" for default locale */
|
||||
/* value should be freed by calling function g_free() */
|
||||
char *guess_message_value (void)
|
||||
{
|
||||
static const char * const var[] = {
|
||||
/* Setting of LC_ALL overwrites all other. */
|
||||
/* Do not use LANGUAGE for check user locale and drowing hints */
|
||||
"LC_ALL",
|
||||
/* Next comes the name of the desired category. */
|
||||
"LC_MESSAGES",
|
||||
/* Last possibility is the LANG environment variable. */
|
||||
"LANG",
|
||||
/* NULL exit loops */
|
||||
NULL
|
||||
};
|
||||
|
||||
unsigned i = 0;
|
||||
const char *locale = NULL;
|
||||
|
||||
while (var[i] != NULL) {
|
||||
locale = getenv (var[i]);
|
||||
if (locale != NULL && locale[0] != '\0')
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (locale == NULL)
|
||||
locale = "";
|
||||
|
||||
return g_strdup (locale);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a random hint. If force is not 0, ignore the timeout.
|
||||
*/
|
||||
@ -1077,7 +1045,7 @@ get_random_hint (int force)
|
||||
return g_strdup ("");
|
||||
last_sec = tv.tv_sec;
|
||||
|
||||
data = load_mc_home_file (MC_HINT, NULL);
|
||||
data = load_mc_home_file (mc_home, mc_home_alt, MC_HINT, NULL);
|
||||
if (!data)
|
||||
return 0;
|
||||
|
||||
|
@ -57,7 +57,6 @@ void quick_cd_cmd (void);
|
||||
void save_setup_cmd (void);
|
||||
char *get_random_hint (int force);
|
||||
void user_file_menu_cmd (void);
|
||||
char *guess_message_value (void);
|
||||
void info_cmd (void);
|
||||
void listing_cmd (void);
|
||||
void quick_cmd_no_menu (void);
|
||||
|
@ -48,13 +48,6 @@ int show_backups = 1;
|
||||
/* If false then directories are shown separately from files */
|
||||
int mix_all_files = 0;
|
||||
|
||||
/*
|
||||
* If true, SI units (1000 based) will be used for
|
||||
* larger units (kilobyte, megabyte, ...).
|
||||
* If false binary units (1024 based) will be used.
|
||||
*/
|
||||
int kilobyte_si = 0;
|
||||
|
||||
/* Reverse flag */
|
||||
static int reverse = 1;
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include "src/cmd.h" /* view_other_cmd() */
|
||||
#include "src/user.h" /* user_menu_cmd() */
|
||||
#include "src/wtools.h" /* query_dialog() */
|
||||
#include "src/timefmt.h" /* time formatting */
|
||||
#include "lib/timefmt.h" /* time formatting */
|
||||
#include "src/strutil.h" /* utf string functions */
|
||||
#include "src/charsets.h" /* get_codepage_id */
|
||||
#include "src/main.h" /* source_codepage */
|
||||
|
@ -33,7 +33,7 @@
|
||||
#define MC_EDIT_H
|
||||
|
||||
#include "lib/global.h" /* PATH_SEP_STR */
|
||||
#include "src/fileloc.h"
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
/* Editor widget */
|
||||
struct WEdit;
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include "cmddef.h"
|
||||
#include "keybind.h"
|
||||
#include "help.h"
|
||||
#include "main.h"
|
||||
|
||||
const global_keymap_t *help_map;
|
||||
|
||||
@ -894,7 +895,7 @@ interactive_display (const char *filename, const char *node)
|
||||
if (filename != NULL)
|
||||
filedata = load_file (filename);
|
||||
else
|
||||
filedata = load_mc_home_file ("mc.hlp", &hlpfile);
|
||||
filedata = load_mc_home_file (mc_home, mc_home_alt, "mc.hlp", &hlpfile);
|
||||
|
||||
if (filedata == NULL)
|
||||
message (D_ERROR, MSG_ERROR, _(" Cannot open file %s \n %s "), filename ? filename : hlpfile,
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "lib/tty/tty.h" /* COLS */
|
||||
#include "lib/skin/skin.h"
|
||||
#include "lib/tty/key.h" /* KEY_M_CTRL */
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
#include "dialog.h"
|
||||
#include "widget.h"
|
||||
@ -59,7 +60,6 @@
|
||||
#include "history.h"
|
||||
#include "strutil.h"
|
||||
#include "util.h"
|
||||
#include "fileloc.h"
|
||||
|
||||
#define UX 5
|
||||
#define UY 2
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "logging.h"
|
||||
#include "setup.h"
|
||||
#include "lib/mcconfig/mcconfig.h"
|
||||
#include "fileloc.h"
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
/*** file scope functions **********************************************/
|
||||
|
||||
|
22
src/main.c
22
src/main.c
@ -48,8 +48,20 @@
|
||||
#include "lib/tty/win.h" /* xterm_flag */
|
||||
|
||||
#include "lib/mcconfig/mcconfig.h"
|
||||
#include "src/args.h"
|
||||
#include "lib/filehighlight/fhl.h"
|
||||
#include "lib/fileloc.h" /* MC_USERCONF_DIR */
|
||||
|
||||
#include "lib/vfs/mc-vfs/vfs.h" /* vfs_translate_url() */
|
||||
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
#include "lib/vfs/mc-vfs/smbfs.h" /* smbfs_set_debug() */
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
|
||||
#ifdef ENABLE_VFS
|
||||
#include "lib/vfs/mc-vfs/gc.h"
|
||||
#endif
|
||||
|
||||
#include "src/args.h"
|
||||
|
||||
#include "dir.h"
|
||||
#include "dialog.h"
|
||||
@ -75,10 +87,8 @@
|
||||
#include "command.h"
|
||||
#include "wtools.h"
|
||||
#include "cmddef.h" /* CK_ cmd name const */
|
||||
#include "fileloc.h" /* MC_USERCONF_DIR */
|
||||
#include "user.h" /* user_file_menu_cmd() */
|
||||
|
||||
#include "lib/vfs/mc-vfs/vfs.h" /* vfs_translate_url() */
|
||||
|
||||
#include "chmod.h"
|
||||
#include "chown.h"
|
||||
@ -86,9 +96,6 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
#include "lib/vfs/mc-vfs/smbfs.h" /* smbfs_set_debug() */
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
# include "src/editor/edit.h"
|
||||
@ -98,9 +105,6 @@
|
||||
#include "charsets.h"
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
#ifdef ENABLE_VFS
|
||||
#include "lib/vfs/mc-vfs/gc.h"
|
||||
#endif
|
||||
|
||||
#include "keybind.h" /* type global_keymap_t */
|
||||
|
||||
|
@ -34,13 +34,14 @@
|
||||
#include "lib/tty/key.h"
|
||||
#include "lib/tty/mouse.h" /* To make view.h happy */
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/mcconfig/mcconfig.h"
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
#include "args.h"
|
||||
#include "dir.h"
|
||||
#include "panel.h"
|
||||
#include "main.h"
|
||||
#include "tree.h" /* xtree_mode */
|
||||
#include "lib/mcconfig/mcconfig.h"
|
||||
#include "setup.h"
|
||||
#include "src/viewer/mcviewer.h" /* For the externs */
|
||||
#include "hotlist.h" /* load/save/done hotlist */
|
||||
@ -50,7 +51,6 @@
|
||||
#include "cmd.h"
|
||||
#include "file.h" /* safe_delete */
|
||||
#include "keybind.h" /* lookup_action */
|
||||
#include "fileloc.h"
|
||||
#include "wtools.h"
|
||||
|
||||
#ifdef ENABLE_VFS
|
||||
|
@ -56,7 +56,6 @@
|
||||
#include "lib/tty/key.h" /* XCTRL */
|
||||
#include "subshell.h"
|
||||
#include "strutil.h"
|
||||
#include "fileloc.h"
|
||||
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "lib/tty/mouse.h"
|
||||
#include "lib/tty/key.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
#include "wtools.h" /* message() */
|
||||
#include "dir.h"
|
||||
@ -64,7 +65,6 @@
|
||||
#include "keybind.h"
|
||||
#include "history.h"
|
||||
#include "strutil.h"
|
||||
#include "fileloc.h"
|
||||
#include "tree.h"
|
||||
|
||||
const global_keymap_t *tree_map;
|
||||
|
@ -48,11 +48,12 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "treestore.h"
|
||||
#include "lib/mcconfig/mcconfig.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
#include "treestore.h"
|
||||
#include "setup.h"
|
||||
#include "fileloc.h"
|
||||
|
||||
#define TREE_SIGNATURE "Midnight Commander TreeStore v 2.0"
|
||||
|
||||
|
69
src/util.c
69
src/util.c
@ -41,28 +41,18 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
#include "lib/tty/win.h" /* xterm_flag */
|
||||
|
||||
#include "lib/search/search.h"
|
||||
|
||||
#include "main.h" /* mc_home */
|
||||
#include "cmd.h" /* guess_message_value */
|
||||
#include "mountlist.h"
|
||||
#include "timefmt.h"
|
||||
#include "strutil.h"
|
||||
#include "lib/mcconfig/mcconfig.h"
|
||||
#include "fileopctx.h"
|
||||
#include "file.h" /* copy_file_file() */
|
||||
#include "dir.h"
|
||||
#include "fileloc.h"
|
||||
#include "lib/timefmt.h"
|
||||
|
||||
#include "strutil.h"
|
||||
|
||||
#include "src/file.h" /* copy_file_file() */
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "charsets.h"
|
||||
#endif
|
||||
|
||||
/*In order to use everywhere the same setup
|
||||
for the locale we use defines */
|
||||
#define FMTYEAR _("%b %e %Y")
|
||||
@ -71,6 +61,15 @@
|
||||
|
||||
int easy_patterns = 1;
|
||||
|
||||
/*
|
||||
* If true, SI units (1000 based) will be used for
|
||||
* larger units (kilobyte, megabyte, ...).
|
||||
* If false binary units (1024 based) will be used.
|
||||
*/
|
||||
int kilobyte_si = 0;
|
||||
|
||||
|
||||
|
||||
extern void str_replace(char *s, char from, char to)
|
||||
{
|
||||
for (; *s != '\0'; s++) {
|
||||
@ -590,13 +589,13 @@ load_file (const char *filename)
|
||||
}
|
||||
|
||||
char *
|
||||
load_mc_home_file (const char *filename, char **allocated_filename)
|
||||
load_mc_home_file (const char *_mc_home, const char *_mc_home_alt, const char *filename, char **allocated_filename)
|
||||
{
|
||||
char *hintfile_base, *hintfile;
|
||||
char *lang;
|
||||
char *data;
|
||||
|
||||
hintfile_base = concat_dir_and_file (mc_home, filename);
|
||||
hintfile_base = concat_dir_and_file (_mc_home, filename);
|
||||
lang = guess_message_value ();
|
||||
|
||||
hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL);
|
||||
@ -605,7 +604,7 @@ load_mc_home_file (const char *filename, char **allocated_filename)
|
||||
if (!data) {
|
||||
g_free (hintfile);
|
||||
g_free (hintfile_base);
|
||||
hintfile_base = concat_dir_and_file (mc_home_alt, filename);
|
||||
hintfile_base = concat_dir_and_file (_mc_home_alt, filename);
|
||||
|
||||
hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL);
|
||||
data = load_file (hintfile);
|
||||
@ -1587,3 +1586,35 @@ mc_util_unlink_backup_if_possible (const char *file_name, const char *backup_suf
|
||||
g_free(backup_path);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* partly taken from dcigettext.c, returns "" for default locale */
|
||||
/* value should be freed by calling function g_free() */
|
||||
char *guess_message_value (void)
|
||||
{
|
||||
static const char * const var[] = {
|
||||
/* Setting of LC_ALL overwrites all other. */
|
||||
/* Do not use LANGUAGE for check user locale and drowing hints */
|
||||
"LC_ALL",
|
||||
/* Next comes the name of the desired category. */
|
||||
"LC_MESSAGES",
|
||||
/* Last possibility is the LANG environment variable. */
|
||||
"LANG",
|
||||
/* NULL exit loops */
|
||||
NULL
|
||||
};
|
||||
|
||||
unsigned i = 0;
|
||||
const char *locale = NULL;
|
||||
|
||||
while (var[i] != NULL) {
|
||||
locale = getenv (var[i]);
|
||||
if (locale != NULL && locale[0] != '\0')
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (locale == NULL)
|
||||
locale = "";
|
||||
|
||||
return g_strdup (locale);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ char *diff_two_paths (const char *first, const char *second);
|
||||
const char *x_basename (const char *fname);
|
||||
|
||||
char *load_file (const char *filename);
|
||||
char *load_mc_home_file (const char *filename, char ** allocated_filename);
|
||||
char *load_mc_home_file (const char *, const char *, const char *filename, char ** allocated_filename);
|
||||
|
||||
/* uid/gid managing */
|
||||
void init_groups (void);
|
||||
@ -295,6 +295,8 @@ gboolean mc_util_make_backup_if_possible (const char *, const char *);
|
||||
gboolean mc_util_restore_from_backup_if_possible (const char *, const char *);
|
||||
gboolean mc_util_unlink_backup_if_possible (const char *, const char *);
|
||||
|
||||
char *guess_message_value (void);
|
||||
|
||||
#define MC_PTR_FREE(ptr) do { g_free(ptr); (ptr) = NULL; } while (0)
|
||||
|
||||
#endif
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "lib/tty/mouse.h"
|
||||
#include "lib/tty/key.h" /* XCTRL and ALT macros */
|
||||
#include "lib/mcconfig/mcconfig.h" /* for history loading and saving */
|
||||
#include "lib/fileloc.h"
|
||||
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
|
||||
@ -57,7 +58,6 @@
|
||||
|
||||
#include "cmddef.h" /* CK_ cmd name const */
|
||||
#include "keybind.h" /* global_keymap_t */
|
||||
#include "fileloc.h"
|
||||
#include "panel.h" /* current_panel */
|
||||
|
||||
const global_keymap_t *input_map;
|
||||
|
Loading…
Reference in New Issue
Block a user