2009-09-01 15:05:01 +04:00
|
|
|
/*
|
|
|
|
Handle command line arguments.
|
|
|
|
|
2023-01-03 11:30:57 +03:00
|
|
|
Copyright (C) 2009-2023
|
2014-02-12 10:33:10 +04:00
|
|
|
Free Software Foundation, Inc.
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
Written by:
|
|
|
|
Slava Zanko <slavazanko@gmail.com>, 2009.
|
2012-01-07 14:35:01 +04:00
|
|
|
Andrew Borodin <aborodin@vmail.ru>, 2011, 2012.
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
This file is part of the Midnight Commander.
|
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
The Midnight Commander is free software: you can redistribute it
|
2009-09-01 15:05:01 +04:00
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
2011-10-15 14:56:47 +04:00
|
|
|
published by the Free Software Foundation, either version 3 of the License,
|
|
|
|
or (at your option) any later version.
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
The Midnight Commander is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2011-10-15 14:56:47 +04:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-09-01 15:05:01 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2010-02-15 14:21:30 +03:00
|
|
|
#include <stdlib.h>
|
2009-09-01 15:05:01 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2010-01-20 18:11:52 +03:00
|
|
|
#include "lib/global.h"
|
2010-01-08 17:47:19 +03:00
|
|
|
#include "lib/tty/tty.h"
|
2010-01-21 15:17:26 +03:00
|
|
|
#include "lib/strutil.h"
|
2011-02-15 16:44:17 +03:00
|
|
|
#include "lib/vfs/vfs.h"
|
|
|
|
#include "lib/util.h" /* x_basename() */
|
|
|
|
|
2010-01-08 17:47:19 +03:00
|
|
|
#include "src/textconf.h"
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2010-02-15 14:21:30 +03:00
|
|
|
#include "src/args.h"
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2010-02-15 14:21:30 +03:00
|
|
|
/*** external variables **************************************************************************/
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
/*** global variables ****************************************************************************/
|
|
|
|
|
|
|
|
/* If true, assume we are running on an xterm terminal */
|
|
|
|
gboolean mc_args__force_xterm = FALSE;
|
|
|
|
|
|
|
|
gboolean mc_args__nomouse = FALSE;
|
|
|
|
|
|
|
|
/* Force colors, only used by Slang */
|
|
|
|
gboolean mc_args__force_colors = FALSE;
|
|
|
|
|
2015-10-25 07:40:34 +03:00
|
|
|
/* Don't load keymap from file and use default one */
|
2011-02-21 13:49:45 +03:00
|
|
|
gboolean mc_args__nokeymap = FALSE;
|
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
char *mc_args__last_wd_file = NULL;
|
|
|
|
|
Fix various typos in the source code (closes MidnightCommander/mc#177).
Found via `codespell -S
po,doc,./misc/syntax,./src/vfs/extfs/helpers/README.it -L
parm,rouge,sav,ect,vie,te,dum,clen,wee,dynamc,childs,ths,fo,nin,unx,nd,iif,iterm,ser,makrs,wil`
Co-authored-by: Yury V. Zaytsev <yury@shurup.com>
Signed-off-by: Kian-Meng Ang <kianmeng@cpan.org>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2023-01-10 06:02:52 +03:00
|
|
|
/* when enabled NETCODE, use following file as logfile */
|
2009-09-01 15:05:01 +04:00
|
|
|
char *mc_args__netfs_logfile = NULL;
|
|
|
|
|
2009-09-15 16:48:30 +04:00
|
|
|
/* keymap file */
|
|
|
|
char *mc_args__keymap_file = NULL;
|
|
|
|
|
2012-10-19 13:08:54 +04:00
|
|
|
void *mc_run_param0 = NULL;
|
|
|
|
char *mc_run_param1 = NULL;
|
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
/*** file scope macro definitions ****************************************************************/
|
|
|
|
|
|
|
|
/*** file scope type declarations ****************************************************************/
|
|
|
|
|
|
|
|
/*** file scope variables ************************************************************************/
|
|
|
|
|
2015-05-10 17:55:54 +03:00
|
|
|
/* If true, show version info and exit */
|
|
|
|
static gboolean mc_args__show_version = FALSE;
|
|
|
|
|
2010-05-12 11:12:27 +04:00
|
|
|
/* forward declarations */
|
2010-11-09 14:02:28 +03:00
|
|
|
static gboolean parse_mc_e_argument (const gchar * option_name, const gchar * value,
|
2014-07-15 16:53:06 +04:00
|
|
|
gpointer data, GError ** mcerror);
|
2010-11-09 14:02:28 +03:00
|
|
|
static gboolean parse_mc_v_argument (const gchar * option_name, const gchar * value,
|
2014-07-15 16:53:06 +04:00
|
|
|
gpointer data, GError ** mcerror);
|
2010-05-12 11:12:27 +04:00
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
static GOptionContext *context;
|
|
|
|
|
2012-10-19 19:24:57 +04:00
|
|
|
#ifdef ENABLE_SUBSHELL
|
2009-09-01 15:05:01 +04:00
|
|
|
static gboolean mc_args__nouse_subshell = FALSE;
|
2012-10-19 19:24:57 +04:00
|
|
|
#endif /* ENABLE_SUBSHELL */
|
2009-09-01 15:05:01 +04:00
|
|
|
static gboolean mc_args__show_datadirs = FALSE;
|
2011-03-24 15:28:31 +03:00
|
|
|
static gboolean mc_args__show_datadirs_extended = FALSE;
|
2019-11-10 05:01:48 +03:00
|
|
|
#ifdef ENABLE_CONFIGURE_ARGS
|
2011-03-24 15:40:18 +03:00
|
|
|
static gboolean mc_args__show_configure_opts = FALSE;
|
2019-11-10 05:01:48 +03:00
|
|
|
#endif
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2010-02-15 14:21:30 +03:00
|
|
|
static GOptionGroup *main_group;
|
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
static const GOptionEntry argument_main_table[] = {
|
2010-03-31 14:33:24 +04:00
|
|
|
/* *INDENT-OFF* */
|
2009-09-01 15:05:01 +04:00
|
|
|
/* generic options */
|
|
|
|
{
|
|
|
|
"version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
|
2010-05-12 10:29:57 +04:00
|
|
|
&mc_args__show_version,
|
2009-09-01 15:05:01 +04:00
|
|
|
N_("Displays the current version"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
/* options for wrappers */
|
|
|
|
{
|
|
|
|
"datadir", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
|
|
|
|
&mc_args__show_datadirs,
|
|
|
|
N_("Print data directory"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2011-03-24 15:28:31 +03:00
|
|
|
/* show extended information about used data directories */
|
|
|
|
{
|
|
|
|
"datadir-info", 'F', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
|
|
|
|
&mc_args__show_datadirs_extended,
|
|
|
|
N_("Print extended info about used data directories"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
|
2019-11-10 05:01:48 +03:00
|
|
|
#ifdef ENABLE_CONFIGURE_ARGS
|
2011-03-24 15:40:18 +03:00
|
|
|
/* show configure options */
|
|
|
|
{
|
|
|
|
"configure-options", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
|
|
|
|
&mc_args__show_configure_opts,
|
|
|
|
N_("Print configure options"),
|
|
|
|
NULL
|
|
|
|
},
|
2019-11-10 05:01:48 +03:00
|
|
|
#endif
|
2011-03-24 15:40:18 +03:00
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
{
|
|
|
|
"printwd", 'P', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
|
|
|
|
&mc_args__last_wd_file,
|
|
|
|
N_("Print last working directory to specified file"),
|
2017-12-02 11:24:46 +03:00
|
|
|
N_("<file>")
|
2010-03-31 14:33:24 +04:00
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2012-10-19 19:24:57 +04:00
|
|
|
#ifdef ENABLE_SUBSHELL
|
2009-09-01 15:05:01 +04:00
|
|
|
{
|
|
|
|
"subshell", 'U', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
|
2011-02-10 18:02:54 +03:00
|
|
|
&mc_global.tty.use_subshell,
|
2009-09-01 15:05:01 +04:00
|
|
|
N_("Enables subshell support (default)"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
"nosubshell", 'u', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
|
|
|
|
&mc_args__nouse_subshell,
|
|
|
|
N_("Disables subshell support"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* debug options */
|
2010-07-13 15:58:44 +04:00
|
|
|
#ifdef ENABLE_VFS_FTP
|
2009-09-01 15:05:01 +04:00
|
|
|
{
|
|
|
|
"ftplog", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
|
|
|
|
&mc_args__netfs_logfile,
|
|
|
|
N_("Log ftp dialog to specified file"),
|
2017-12-02 11:24:46 +03:00
|
|
|
N_("<file>")
|
2010-03-31 14:33:24 +04:00
|
|
|
},
|
2010-07-13 15:58:44 +04:00
|
|
|
#endif /* ENABLE_VFS_FTP */
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
{
|
2015-05-09 16:33:27 +03:00
|
|
|
/* handle arguments manually */
|
|
|
|
"view", 'v', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
2016-03-15 20:37:45 +03:00
|
|
|
(gpointer) parse_mc_v_argument,
|
2009-09-01 15:05:01 +04:00
|
|
|
N_("Launches the file viewer on a file"),
|
2017-12-02 11:24:46 +03:00
|
|
|
N_("<file>")
|
2010-03-31 14:33:24 +04:00
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
{
|
2015-05-09 16:33:27 +03:00
|
|
|
/* handle arguments manually */
|
2012-01-07 14:35:01 +04:00
|
|
|
"edit", 'e', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
2016-03-15 20:37:45 +03:00
|
|
|
(gpointer) parse_mc_e_argument,
|
2012-01-07 14:35:01 +04:00
|
|
|
N_("Edit files"),
|
2021-01-24 19:02:56 +03:00
|
|
|
N_("<file> ...")
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2021-05-16 11:21:40 +03:00
|
|
|
G_OPTION_ENTRY_NULL
|
2010-03-31 14:33:24 +04:00
|
|
|
/* *INDENT-ON* */
|
2009-09-01 15:05:01 +04:00
|
|
|
};
|
|
|
|
|
2015-05-10 17:55:54 +03:00
|
|
|
static GOptionGroup *terminal_group;
|
2009-09-01 15:05:01 +04:00
|
|
|
#define ARGS_TERM_OPTIONS 0
|
|
|
|
static const GOptionEntry argument_terminal_table[] = {
|
2010-03-31 14:33:24 +04:00
|
|
|
/* *INDENT-OFF* */
|
2009-09-01 15:05:01 +04:00
|
|
|
/* terminal options */
|
|
|
|
{
|
|
|
|
"xterm", 'x', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
|
|
|
&mc_args__force_xterm,
|
|
|
|
N_("Forces xterm features"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2011-10-28 16:09:44 +04:00
|
|
|
{
|
|
|
|
"no-x11", 'X', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
|
|
|
&mc_global.tty.disable_x11,
|
|
|
|
N_("Disable X11 support"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
|
2011-09-07 11:17:03 +04:00
|
|
|
{
|
|
|
|
"oldmouse", 'g', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
|
|
|
&mc_global.tty.old_mouse,
|
|
|
|
N_("Tries to use an old highlight mouse tracking"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
{
|
|
|
|
"nomouse", 'd', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
|
|
|
&mc_args__nomouse,
|
|
|
|
N_("Disable mouse support in text version"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
#ifdef HAVE_SLANG
|
|
|
|
{
|
|
|
|
"termcap", 't', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
|
|
|
&SLtt_Try_Termcap,
|
|
|
|
N_("Tries to use termcap instead of terminfo"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
|
|
|
"slow", 's', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
2011-09-06 19:24:18 +04:00
|
|
|
&mc_global.tty.slow_terminal,
|
2009-09-01 15:05:01 +04:00
|
|
|
N_("To run on slow terminals"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
"stickchars", 'a', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
2011-09-07 13:06:03 +04:00
|
|
|
&mc_global.tty.ugly_line_drawing,
|
2009-09-01 15:05:01 +04:00
|
|
|
N_("Use stickchars to draw"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2015-03-31 20:50:20 +03:00
|
|
|
#ifdef HAVE_SLANG
|
2009-09-01 15:05:01 +04:00
|
|
|
{
|
|
|
|
"resetsoft", 'k', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
|
|
|
&reset_hp_softkeys,
|
|
|
|
N_("Resets soft keys on HP terminals"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2015-03-31 20:50:20 +03:00
|
|
|
#endif
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2009-09-15 16:48:30 +04:00
|
|
|
{
|
|
|
|
"keymap", 'K', ARGS_TERM_OPTIONS, G_OPTION_ARG_STRING,
|
|
|
|
&mc_args__keymap_file,
|
|
|
|
N_("Load definitions of key bindings from specified file"),
|
2017-12-02 11:24:46 +03:00
|
|
|
N_("<file>")
|
2010-03-31 14:33:24 +04:00
|
|
|
},
|
2009-09-15 16:48:30 +04:00
|
|
|
|
2011-02-21 13:49:45 +03:00
|
|
|
{
|
|
|
|
"nokeymap", '\0', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
|
|
|
&mc_args__nokeymap,
|
|
|
|
N_("Don't load definitions of key bindings from file, use defaults"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
|
2021-05-16 11:21:40 +03:00
|
|
|
G_OPTION_ENTRY_NULL
|
2010-03-31 14:33:24 +04:00
|
|
|
/* *INDENT-ON* */
|
2009-09-01 15:05:01 +04:00
|
|
|
};
|
2010-04-23 11:54:25 +04:00
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
#undef ARGS_TERM_OPTIONS
|
|
|
|
|
2015-05-10 17:55:54 +03:00
|
|
|
static GOptionGroup *color_group;
|
2009-09-01 15:05:01 +04:00
|
|
|
#define ARGS_COLOR_OPTIONS 0
|
2011-02-10 18:02:54 +03:00
|
|
|
/* #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN */
|
2009-09-01 15:05:01 +04:00
|
|
|
static const GOptionEntry argument_color_table[] = {
|
2010-03-31 14:33:24 +04:00
|
|
|
/* *INDENT-OFF* */
|
2009-09-01 15:05:01 +04:00
|
|
|
/* color options */
|
|
|
|
{
|
|
|
|
"nocolor", 'b', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
|
2011-09-07 13:06:03 +04:00
|
|
|
&mc_global.tty.disable_colors,
|
2009-09-01 15:05:01 +04:00
|
|
|
N_("Requests to run in black and white"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
"color", 'c', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
|
|
|
|
&mc_args__force_colors,
|
|
|
|
N_("Request to run in color mode"),
|
2010-03-31 14:33:24 +04:00
|
|
|
NULL
|
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
"colors", 'C', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
|
2011-02-10 18:02:54 +03:00
|
|
|
&mc_global.tty.command_line_colors,
|
2009-09-01 15:05:01 +04:00
|
|
|
N_("Specifies a color configuration"),
|
2017-12-02 11:24:46 +03:00
|
|
|
N_("<string>")
|
2010-03-31 14:33:24 +04:00
|
|
|
},
|
2009-09-01 15:05:01 +04:00
|
|
|
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
|
|
|
"skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
|
2012-01-28 14:13:32 +04:00
|
|
|
&mc_global.tty.skin,
|
2009-09-04 18:22:49 +04:00
|
|
|
N_("Show mc with specified skin"),
|
2017-12-02 11:24:46 +03:00
|
|
|
N_("<string>")
|
2010-03-31 14:33:24 +04:00
|
|
|
},
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2021-05-16 11:21:40 +03:00
|
|
|
G_OPTION_ENTRY_NULL
|
2010-03-31 14:33:24 +04:00
|
|
|
/* *INDENT-ON* */
|
2009-09-01 15:05:01 +04:00
|
|
|
};
|
2010-04-23 11:54:25 +04:00
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
#undef ARGS_COLOR_OPTIONS
|
|
|
|
|
|
|
|
static gchar *mc_args__loc__colors_string = NULL;
|
|
|
|
static gchar *mc_args__loc__footer_string = NULL;
|
|
|
|
static gchar *mc_args__loc__header_string = NULL;
|
|
|
|
static gchar *mc_args__loc__usage_string = NULL;
|
|
|
|
|
2021-01-24 19:02:56 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2009-09-01 15:05:01 +04:00
|
|
|
/*** file scope functions ************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2021-01-24 19:02:56 +03:00
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
static void
|
2010-04-23 11:54:25 +04:00
|
|
|
mc_args_clean_temp_help_strings (void)
|
2009-09-01 15:05:01 +04:00
|
|
|
{
|
2014-08-05 11:18:30 +04:00
|
|
|
MC_PTR_FREE (mc_args__loc__colors_string);
|
|
|
|
MC_PTR_FREE (mc_args__loc__footer_string);
|
|
|
|
MC_PTR_FREE (mc_args__loc__header_string);
|
|
|
|
MC_PTR_FREE (mc_args__loc__usage_string);
|
2009-09-01 15:05:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static GOptionGroup *
|
2010-04-23 11:54:25 +04:00
|
|
|
mc_args_new_color_group (void)
|
2009-09-01 15:05:01 +04:00
|
|
|
{
|
2021-01-24 19:02:56 +03:00
|
|
|
/* *INDENT-OFF* */
|
2010-11-29 21:46:11 +03:00
|
|
|
/* FIXME: to preserve translations, lines should be split. */
|
|
|
|
mc_args__loc__colors_string = g_strdup_printf ("%s\n%s",
|
|
|
|
/* TRANSLATORS: don't translate keywords */
|
2010-12-29 12:58:10 +03:00
|
|
|
_("--colors KEYWORD={FORE},{BACK},{ATTR}:KEYWORD2=...\n\n"
|
|
|
|
"{FORE}, {BACK} and {ATTR} can be omitted, and the default will be used\n"
|
2010-11-29 21:46:11 +03:00
|
|
|
"\n Keywords:\n"
|
2010-12-29 10:02:27 +03:00
|
|
|
" Global: errors, disabled, reverse, gauge, header\n"
|
2010-05-03 02:33:08 +04:00
|
|
|
" input, inputmark, inputunchanged, commandlinemark\n"
|
2010-11-11 14:05:34 +03:00
|
|
|
" bbarhotkey, bbarbutton, statusbar\n"
|
2010-04-23 11:54:25 +04:00
|
|
|
" File display: normal, selected, marked, markselect\n"
|
|
|
|
" Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"
|
|
|
|
" errdhotfocus\n"
|
|
|
|
" Menus: menunormal, menuhot, menusel, menuhotsel, menuinactive\n"
|
2010-11-29 21:46:11 +03:00
|
|
|
" Popup menus: pmenunormal, pmenusel, pmenutitle\n"
|
2010-04-23 11:54:25 +04:00
|
|
|
" Editor: editnormal, editbold, editmarked, editwhitespace,\n"
|
2011-10-28 13:57:00 +04:00
|
|
|
" editlinestate, editbg, editframe, editframeactive\n"
|
|
|
|
" editframedrag\n"
|
2014-05-02 10:22:34 +04:00
|
|
|
" Viewer: viewnormal,viewbold, viewunderline, viewselected\n"
|
2010-11-29 21:46:11 +03:00
|
|
|
" Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n"),
|
2010-12-29 12:58:10 +03:00
|
|
|
/* TRANSLATORS: don't translate color names and attributes */
|
|
|
|
_("Standard Colors:\n"
|
2010-04-23 11:54:25 +04:00
|
|
|
" black, gray, red, brightred, green, brightgreen, brown,\n"
|
|
|
|
" yellow, blue, brightblue, magenta, brightmagenta, cyan,\n"
|
2010-12-29 12:58:10 +03:00
|
|
|
" brightcyan, lightgray and white\n\n"
|
|
|
|
"Extended colors, when 256 colors are available:\n"
|
|
|
|
" color16 to color255, or rgb000 to rgb555 and gray0 to gray23\n\n"
|
|
|
|
"Attributes:\n"
|
2015-02-17 15:22:53 +03:00
|
|
|
" bold, italic, underline, reverse, blink; append more with '+'\n")
|
2010-12-29 12:58:10 +03:00
|
|
|
);
|
2021-01-24 19:02:56 +03:00
|
|
|
/* *INDENT-ON* */
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
return g_option_group_new ("color", mc_args__loc__colors_string,
|
2010-04-23 11:54:25 +04:00
|
|
|
_("Color options"), NULL, NULL);
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static gchar *
|
2010-04-23 11:54:25 +04:00
|
|
|
mc_args_add_usage_info (void)
|
2009-09-01 15:05:01 +04:00
|
|
|
{
|
2017-04-13 20:27:46 +03:00
|
|
|
gchar *s;
|
|
|
|
|
|
|
|
switch (mc_global.mc_run_mode)
|
|
|
|
{
|
|
|
|
case MC_RUN_EDITOR:
|
|
|
|
s = g_strdup_printf ("%s\n", _("[+lineno] file1[:lineno] [file2[:lineno]...]"));
|
|
|
|
break;
|
|
|
|
case MC_RUN_VIEWER:
|
|
|
|
s = g_strdup_printf ("%s\n", _("file"));
|
|
|
|
break;
|
|
|
|
#ifdef USE_DIFF_VIEW
|
|
|
|
case MC_RUN_DIFFVIEWER:
|
|
|
|
s = g_strdup_printf ("%s\n", _("file1 file2"));
|
|
|
|
break;
|
|
|
|
#endif /* USE_DIFF_VIEW */
|
|
|
|
case MC_RUN_FULL:
|
|
|
|
default:
|
|
|
|
s = g_strdup_printf ("%s\n", _("[this_dir] [other_panel_dir]"));
|
|
|
|
}
|
|
|
|
|
|
|
|
mc_args__loc__usage_string = s;
|
|
|
|
|
2009-09-01 15:05:01 +04:00
|
|
|
return mc_args__loc__usage_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
2010-04-23 11:54:25 +04:00
|
|
|
mc_args_add_extended_info_to_help (void)
|
2009-09-01 15:05:01 +04:00
|
|
|
{
|
2010-04-23 11:54:25 +04:00
|
|
|
mc_args__loc__footer_string = g_strdup_printf ("%s",
|
|
|
|
_
|
|
|
|
("\n"
|
2013-05-26 10:11:06 +04:00
|
|
|
"Please send any bug reports (including the output of 'mc -V')\n"
|
2010-04-22 10:53:23 +04:00
|
|
|
"as tickets at www.midnight-commander.org\n"));
|
2021-03-18 15:28:35 +03:00
|
|
|
mc_args__loc__header_string =
|
|
|
|
g_strdup_printf (_("GNU Midnight Commander %s\n"), mc_global.mc_version);
|
2009-09-01 15:05:01 +04:00
|
|
|
|
|
|
|
g_option_context_set_description (context, mc_args__loc__footer_string);
|
|
|
|
g_option_context_set_summary (context, mc_args__loc__header_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2012-03-16 11:06:17 +04:00
|
|
|
static gchar *
|
2014-07-15 16:53:06 +04:00
|
|
|
mc_args__convert_help_to_syscharset (const gchar * charset, const gchar * error_message_str,
|
2012-03-16 11:06:17 +04:00
|
|
|
const gchar * help_str)
|
|
|
|
{
|
|
|
|
GString *buffer;
|
|
|
|
GIConv conv;
|
|
|
|
gchar *full_help_str;
|
|
|
|
|
|
|
|
buffer = g_string_new ("");
|
|
|
|
conv = g_iconv_open (charset, "UTF-8");
|
2014-07-15 16:53:06 +04:00
|
|
|
full_help_str = g_strdup_printf ("%s\n\n%s\n", error_message_str, help_str);
|
2012-03-16 11:06:17 +04:00
|
|
|
|
|
|
|
str_convert (conv, full_help_str, buffer);
|
|
|
|
|
|
|
|
g_free (full_help_str);
|
|
|
|
g_iconv_close (conv);
|
|
|
|
|
|
|
|
return g_string_free (buffer, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2012-03-04 17:53:38 +04:00
|
|
|
static gboolean
|
2014-07-15 16:53:06 +04:00
|
|
|
parse_mc_e_argument (const gchar * option_name, const gchar * value, gpointer data,
|
|
|
|
GError ** mcerror)
|
2012-03-16 11:06:17 +04:00
|
|
|
{
|
|
|
|
(void) option_name;
|
2012-01-07 14:35:01 +04:00
|
|
|
(void) value;
|
2012-03-16 11:06:17 +04:00
|
|
|
(void) data;
|
2014-07-15 16:53:06 +04:00
|
|
|
|
|
|
|
mc_return_val_if_error (mcerror, FALSE);
|
2012-03-16 11:06:17 +04:00
|
|
|
|
|
|
|
mc_global.mc_run_mode = MC_RUN_EDITOR;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static gboolean
|
2014-07-15 16:53:06 +04:00
|
|
|
parse_mc_v_argument (const gchar * option_name, const gchar * value, gpointer data,
|
|
|
|
GError ** mcerror)
|
2012-03-16 11:06:17 +04:00
|
|
|
{
|
|
|
|
(void) option_name;
|
2015-05-24 18:34:43 +03:00
|
|
|
(void) value;
|
2012-03-16 11:06:17 +04:00
|
|
|
(void) data;
|
2014-07-15 16:53:06 +04:00
|
|
|
|
|
|
|
mc_return_val_if_error (mcerror, FALSE);
|
2012-03-16 11:06:17 +04:00
|
|
|
|
|
|
|
mc_global.mc_run_mode = MC_RUN_VIEWER;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-01-17 19:09:56 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Create mcedit_arg_t object from vfs_path_t object and the line number.
|
|
|
|
*
|
|
|
|
* @param file_vpath file path object
|
|
|
|
* @param line_number line number. If value is 0, try to restore saved position.
|
|
|
|
* @return mcedit_arg_t object
|
|
|
|
*/
|
|
|
|
|
|
|
|
static mcedit_arg_t *
|
|
|
|
mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number)
|
|
|
|
{
|
|
|
|
mcedit_arg_t *arg;
|
|
|
|
|
|
|
|
arg = g_new (mcedit_arg_t, 1);
|
|
|
|
arg->file_vpath = file_vpath;
|
|
|
|
arg->line_number = line_number;
|
|
|
|
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Create mcedit_arg_t object from file name and the line number.
|
|
|
|
*
|
|
|
|
* @param file_name file name
|
|
|
|
* @param line_number line number. If value is 0, try to restore saved position.
|
|
|
|
* @return mcedit_arg_t object
|
|
|
|
*/
|
|
|
|
|
|
|
|
static mcedit_arg_t *
|
|
|
|
mcedit_arg_new (const char *file_name, long line_number)
|
|
|
|
{
|
|
|
|
return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number);
|
|
|
|
}
|
|
|
|
|
2012-01-07 14:35:01 +04:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Get list of filenames (and line numbers) from command line, when mc called as editor
|
|
|
|
*
|
|
|
|
* @param argc count of all arguments
|
|
|
|
* @param argv array of strings, contains arguments
|
|
|
|
* @return list of mcedit_arg_t objects
|
|
|
|
*/
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
parse_mcedit_arguments (int argc, char **argv)
|
|
|
|
{
|
|
|
|
GList *flist = NULL;
|
|
|
|
int i;
|
2012-08-08 14:12:02 +04:00
|
|
|
long first_line_number = -1;
|
2012-01-07 14:35:01 +04:00
|
|
|
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
char *end, *p;
|
|
|
|
mcedit_arg_t *arg;
|
|
|
|
|
|
|
|
tmp = argv[i];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First, try to get line number as +lineno.
|
|
|
|
*/
|
|
|
|
if (*tmp == '+')
|
|
|
|
{
|
|
|
|
long lineno;
|
|
|
|
char *error;
|
|
|
|
|
|
|
|
lineno = strtol (tmp + 1, &error, 10);
|
|
|
|
|
|
|
|
if (*error == '\0')
|
|
|
|
{
|
|
|
|
/* this is line number */
|
2012-08-08 14:12:02 +04:00
|
|
|
first_line_number = lineno;
|
2012-01-07 14:35:01 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* this is file name */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for filename:lineno, followed by an optional colon.
|
|
|
|
* This format is used by many programs (especially compilers)
|
|
|
|
* in error messages and warnings. It is supported so that
|
|
|
|
* users can quickly copy and paste file locations.
|
|
|
|
*/
|
|
|
|
end = tmp + strlen (tmp);
|
|
|
|
p = end;
|
|
|
|
|
|
|
|
if (p > tmp && p[-1] == ':')
|
|
|
|
p--;
|
|
|
|
while (p > tmp && g_ascii_isdigit ((gchar) p[-1]))
|
|
|
|
p--;
|
|
|
|
|
|
|
|
if (tmp < p && p < end && p[-1] == ':')
|
|
|
|
{
|
|
|
|
char *fname;
|
|
|
|
vfs_path_t *tmp_vpath, *fname_vpath;
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
fname = g_strndup (tmp, p - 1 - tmp);
|
|
|
|
tmp_vpath = vfs_path_from_str (tmp);
|
|
|
|
fname_vpath = vfs_path_from_str (fname);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check that the file before the colon actually exists.
|
|
|
|
* If it doesn't exist, create new file.
|
|
|
|
*/
|
|
|
|
if (mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1)
|
|
|
|
{
|
|
|
|
arg = mcedit_arg_vpath_new (fname_vpath, atoi (p));
|
2021-02-21 19:30:18 +03:00
|
|
|
vfs_path_free (tmp_vpath, TRUE);
|
2012-01-07 14:35:01 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-23 21:01:08 +04:00
|
|
|
arg = mcedit_arg_vpath_new (tmp_vpath, 0);
|
2021-02-21 19:30:18 +03:00
|
|
|
vfs_path_free (fname_vpath, TRUE);
|
2012-01-07 14:35:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (fname);
|
|
|
|
}
|
|
|
|
else
|
2012-07-23 21:01:08 +04:00
|
|
|
arg = mcedit_arg_new (tmp, 0);
|
2012-01-07 14:35:01 +04:00
|
|
|
|
|
|
|
flist = g_list_prepend (flist, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flist == NULL)
|
2012-07-23 21:01:08 +04:00
|
|
|
flist = g_list_prepend (flist, mcedit_arg_new (NULL, 0));
|
2012-01-07 14:35:01 +04:00
|
|
|
else if (first_line_number != -1)
|
|
|
|
{
|
|
|
|
/* overwrite line number for first file */
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
l = g_list_last (flist);
|
|
|
|
((mcedit_arg_t *) l->data)->line_number = first_line_number;
|
|
|
|
}
|
|
|
|
|
|
|
|
return flist;
|
|
|
|
}
|
|
|
|
|
2012-03-16 11:06:17 +04:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/*** public functions ****************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2017-04-13 20:27:46 +03:00
|
|
|
void
|
|
|
|
mc_setup_run_mode (char **argv)
|
|
|
|
{
|
|
|
|
const char *base;
|
|
|
|
|
|
|
|
base = x_basename (argv[0]);
|
|
|
|
|
|
|
|
if (strncmp (base, "mce", 3) == 0 || strcmp (base, "vi") == 0)
|
|
|
|
{
|
|
|
|
/* mce* or vi is link to mc */
|
|
|
|
mc_global.mc_run_mode = MC_RUN_EDITOR;
|
|
|
|
}
|
|
|
|
else if (strncmp (base, "mcv", 3) == 0 || strcmp (base, "view") == 0)
|
|
|
|
{
|
|
|
|
/* mcv* or view is link to mc */
|
|
|
|
mc_global.mc_run_mode = MC_RUN_VIEWER;
|
|
|
|
}
|
|
|
|
#ifdef USE_DIFF_VIEW
|
|
|
|
else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
|
|
|
|
{
|
|
|
|
/* mcd* or diff is link to mc */
|
|
|
|
mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
|
|
|
|
}
|
|
|
|
#endif /* USE_DIFF_VIEW */
|
|
|
|
}
|
|
|
|
|
2012-03-16 11:06:17 +04:00
|
|
|
gboolean
|
2014-07-15 16:53:06 +04:00
|
|
|
mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError ** mcerror)
|
2012-03-16 11:06:17 +04:00
|
|
|
{
|
|
|
|
const gchar *_system_codepage;
|
|
|
|
gboolean ok = TRUE;
|
|
|
|
|
2014-07-15 16:53:06 +04:00
|
|
|
mc_return_val_if_error (mcerror, FALSE);
|
|
|
|
|
2012-03-16 11:06:17 +04:00
|
|
|
_system_codepage = str_detect_termencoding ();
|
|
|
|
|
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
if (!str_isutf8 (_system_codepage))
|
|
|
|
bind_textdomain_codeset ("mc", "UTF-8");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
context = g_option_context_new (mc_args_add_usage_info ());
|
|
|
|
|
|
|
|
g_option_context_set_ignore_unknown_options (context, FALSE);
|
|
|
|
|
|
|
|
mc_args_add_extended_info_to_help ();
|
|
|
|
|
|
|
|
main_group = g_option_group_new ("main", _("Main options"), _("Main options"), NULL, NULL);
|
|
|
|
|
|
|
|
g_option_group_add_entries (main_group, argument_main_table);
|
|
|
|
g_option_context_set_main_group (context, main_group);
|
|
|
|
g_option_group_set_translation_domain (main_group, translation_domain);
|
|
|
|
|
|
|
|
terminal_group = g_option_group_new ("terminal", _("Terminal options"),
|
|
|
|
_("Terminal options"), NULL, NULL);
|
|
|
|
|
|
|
|
g_option_group_add_entries (terminal_group, argument_terminal_table);
|
|
|
|
g_option_context_add_group (context, terminal_group);
|
|
|
|
g_option_group_set_translation_domain (terminal_group, translation_domain);
|
|
|
|
|
|
|
|
color_group = mc_args_new_color_group ();
|
|
|
|
|
|
|
|
g_option_group_add_entries (color_group, argument_color_table);
|
|
|
|
g_option_context_add_group (context, color_group);
|
|
|
|
g_option_group_set_translation_domain (color_group, translation_domain);
|
|
|
|
|
2014-07-15 16:53:06 +04:00
|
|
|
if (!g_option_context_parse (context, argc, argv, mcerror))
|
2012-03-16 11:06:17 +04:00
|
|
|
{
|
2014-07-15 16:53:06 +04:00
|
|
|
if (*mcerror == NULL)
|
|
|
|
mc_propagate_error (mcerror, 0, "%s\n", _("Arguments parse error!"));
|
2012-03-16 11:06:17 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *help_str;
|
|
|
|
|
|
|
|
help_str = g_option_context_get_help (context, TRUE, NULL);
|
2015-02-24 17:11:41 +03:00
|
|
|
|
2012-03-16 11:06:17 +04:00
|
|
|
if (str_isutf8 (_system_codepage))
|
2014-07-15 16:53:06 +04:00
|
|
|
mc_replace_error (mcerror, (*mcerror)->code, "%s\n\n%s\n", (*mcerror)->message,
|
|
|
|
help_str);
|
2012-03-16 11:06:17 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *full_help_str;
|
|
|
|
|
|
|
|
full_help_str =
|
2014-07-15 16:53:06 +04:00
|
|
|
mc_args__convert_help_to_syscharset (_system_codepage, (*mcerror)->message,
|
2012-03-16 11:06:17 +04:00
|
|
|
help_str);
|
2014-07-15 16:53:06 +04:00
|
|
|
mc_replace_error (mcerror, (*mcerror)->code, "%s", full_help_str);
|
2012-03-16 11:06:17 +04:00
|
|
|
g_free (full_help_str);
|
|
|
|
}
|
|
|
|
g_free (help_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_option_context_free (context);
|
|
|
|
mc_args_clean_temp_help_strings ();
|
|
|
|
|
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
if (!str_isutf8 (_system_codepage))
|
|
|
|
bind_textdomain_codeset ("mc", _system_codepage);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
mc_args_show_info (void)
|
|
|
|
{
|
|
|
|
if (mc_args__show_version)
|
|
|
|
{
|
|
|
|
show_version ();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mc_args__show_datadirs)
|
|
|
|
{
|
|
|
|
printf ("%s (%s)\n", mc_global.sysconfig_dir, mc_global.share_data_dir);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mc_args__show_datadirs_extended)
|
|
|
|
{
|
|
|
|
show_datadirs_extended ();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-10 05:01:48 +03:00
|
|
|
#ifdef ENABLE_CONFIGURE_ARGS
|
2012-03-16 11:06:17 +04:00
|
|
|
if (mc_args__show_configure_opts)
|
|
|
|
{
|
|
|
|
show_configure_options ();
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-11-10 05:01:48 +03:00
|
|
|
#endif
|
2012-03-16 11:06:17 +04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
gboolean
|
2014-07-15 16:53:06 +04:00
|
|
|
mc_setup_by_args (int argc, char **argv, GError ** mcerror)
|
2010-05-12 10:29:57 +04:00
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
|
2014-07-15 16:53:06 +04:00
|
|
|
mc_return_val_if_error (mcerror, FALSE);
|
|
|
|
|
2012-03-16 11:06:17 +04:00
|
|
|
if (mc_args__force_colors)
|
|
|
|
mc_global.tty.disable_colors = FALSE;
|
|
|
|
|
2012-10-19 19:24:57 +04:00
|
|
|
#ifdef ENABLE_SUBSHELL
|
2012-03-16 11:06:17 +04:00
|
|
|
if (mc_args__nouse_subshell)
|
|
|
|
mc_global.tty.use_subshell = FALSE;
|
2012-10-19 19:24:57 +04:00
|
|
|
#endif /* ENABLE_SUBSHELL */
|
2012-03-16 11:06:17 +04:00
|
|
|
|
2022-02-25 22:11:42 +03:00
|
|
|
#ifdef ENABLE_VFS_FTP
|
2010-05-12 10:29:57 +04:00
|
|
|
if (mc_args__netfs_logfile != NULL)
|
|
|
|
{
|
2011-07-21 00:12:02 +04:00
|
|
|
vfs_path_t *vpath;
|
2022-02-25 22:11:42 +03:00
|
|
|
|
2011-07-21 00:12:02 +04:00
|
|
|
vpath = vfs_path_from_str ("ftp://");
|
|
|
|
mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
|
2021-02-21 19:30:18 +03:00
|
|
|
vfs_path_free (vpath, TRUE);
|
2010-05-12 10:29:57 +04:00
|
|
|
}
|
2022-02-25 22:11:42 +03:00
|
|
|
#endif /* ENABLE_VFS_FTP */
|
2010-05-12 10:29:57 +04:00
|
|
|
|
|
|
|
tmp = (argc > 0) ? argv[1] : NULL;
|
|
|
|
|
2015-05-09 16:33:27 +03:00
|
|
|
switch (mc_global.mc_run_mode)
|
|
|
|
{
|
|
|
|
case MC_RUN_EDITOR:
|
|
|
|
mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MC_RUN_VIEWER:
|
|
|
|
if (tmp == NULL)
|
|
|
|
{
|
|
|
|
mc_propagate_error (mcerror, 0, "%s\n", _("No arguments given to the viewer."));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-05-12 11:12:27 +04:00
|
|
|
|
2015-05-09 16:33:27 +03:00
|
|
|
mc_run_param0 = g_strdup (tmp);
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef USE_DIFF_VIEW
|
|
|
|
case MC_RUN_DIFFVIEWER:
|
2010-05-12 10:29:57 +04:00
|
|
|
if (argc < 3)
|
|
|
|
{
|
2014-07-15 16:53:06 +04:00
|
|
|
mc_propagate_error (mcerror, 0, "%s\n",
|
Fix various typos in the source code (closes MidnightCommander/mc#177).
Found via `codespell -S
po,doc,./misc/syntax,./src/vfs/extfs/helpers/README.it -L
parm,rouge,sav,ect,vie,te,dum,clen,wee,dynamc,childs,ths,fo,nin,unx,nd,iif,iterm,ser,makrs,wil`
Co-authored-by: Yury V. Zaytsev <yury@shurup.com>
Signed-off-by: Kian-Meng Ang <kianmeng@cpan.org>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2023-01-10 06:02:52 +03:00
|
|
|
_("Two files are required to invoke the diffviewer."));
|
2012-03-04 17:53:38 +04:00
|
|
|
return FALSE;
|
2010-05-12 10:29:57 +04:00
|
|
|
}
|
2017-12-16 20:52:39 +03:00
|
|
|
MC_FALLTHROUGH;
|
2015-05-09 16:33:27 +03:00
|
|
|
#endif /* USE_DIFF_VIEW */
|
2010-05-12 10:29:57 +04:00
|
|
|
|
2015-05-09 16:33:27 +03:00
|
|
|
case MC_RUN_FULL:
|
|
|
|
default:
|
|
|
|
/* set the current dir and the other dir for filemanager,
|
|
|
|
or two files for diff viewer */
|
2010-05-12 10:29:57 +04:00
|
|
|
if (tmp != NULL)
|
|
|
|
{
|
|
|
|
mc_run_param0 = g_strdup (tmp);
|
|
|
|
tmp = (argc > 1) ? argv[2] : NULL;
|
|
|
|
if (tmp != NULL)
|
|
|
|
mc_run_param1 = g_strdup (tmp);
|
|
|
|
}
|
2015-05-09 16:33:27 +03:00
|
|
|
break;
|
2010-05-12 10:29:57 +04:00
|
|
|
}
|
2012-03-04 17:53:38 +04:00
|
|
|
|
|
|
|
return TRUE;
|
2010-05-12 10:29:57 +04:00
|
|
|
}
|
|
|
|
|
2012-01-07 14:35:01 +04:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Free the mcedit_arg_t object.
|
|
|
|
*
|
|
|
|
* @param arg mcedit_arg_t object
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
mcedit_arg_free (mcedit_arg_t * arg)
|
|
|
|
{
|
2021-02-21 19:30:18 +03:00
|
|
|
vfs_path_free (arg->file_vpath, TRUE);
|
2012-01-07 14:35:01 +04:00
|
|
|
g_free (arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|