(test_glob_prepare_replace_str): remove unneeded type cast.
[midnight-commander.git] / src / args.c
blob3655f7d94eef0425dde9309ef3f0af5569376043
1 /*
2 Handle command line arguments.
4 Copyright (C) 2009-2023
5 Free Software Foundation, Inc.
7 Written by:
8 Slava Zanko <slavazanko@gmail.com>, 2009.
9 Andrew Borodin <aborodin@vmail.ru>, 2011, 2012.
11 This file is part of the Midnight Commander.
13 The Midnight Commander is free software: you can redistribute it
14 and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
18 The Midnight Commander is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include <config.h>
28 #include <stdlib.h>
29 #include <stdio.h>
31 #include "lib/global.h"
32 #include "lib/tty/tty.h"
33 #include "lib/strutil.h"
34 #include "lib/vfs/vfs.h"
35 #include "lib/util.h" /* x_basename() */
37 #include "src/textconf.h"
39 #include "src/args.h"
41 /*** external variables **************************************************************************/
43 /*** global variables ****************************************************************************/
45 /* If true, assume we are running on an xterm terminal */
46 gboolean mc_args__force_xterm = FALSE;
48 gboolean mc_args__nomouse = FALSE;
50 /* Force colors, only used by Slang */
51 gboolean mc_args__force_colors = FALSE;
53 /* Don't load keymap from file and use default one */
54 gboolean mc_args__nokeymap = FALSE;
56 char *mc_args__last_wd_file = NULL;
58 /* when enabled NETCODE, use following file as logfile */
59 char *mc_args__netfs_logfile = NULL;
61 /* keymap file */
62 char *mc_args__keymap_file = NULL;
64 void *mc_run_param0 = NULL;
65 char *mc_run_param1 = NULL;
67 /*** file scope macro definitions ****************************************************************/
69 /*** file scope type declarations ****************************************************************/
71 /*** forward declarations (file scope functions) *************************************************/
73 static gboolean parse_mc_e_argument (const gchar * option_name, const gchar * value,
74 gpointer data, GError ** mcerror);
75 static gboolean parse_mc_v_argument (const gchar * option_name, const gchar * value,
76 gpointer data, GError ** mcerror);
78 /*** file scope variables ************************************************************************/
80 /* If true, show version info and exit */
81 static gboolean mc_args__show_version = FALSE;
83 static GOptionContext *context;
85 #ifdef ENABLE_SUBSHELL
86 static gboolean mc_args__nouse_subshell = FALSE;
87 #endif /* ENABLE_SUBSHELL */
88 static gboolean mc_args__show_datadirs = FALSE;
89 static gboolean mc_args__show_datadirs_extended = FALSE;
90 #ifdef ENABLE_CONFIGURE_ARGS
91 static gboolean mc_args__show_configure_opts = FALSE;
92 #endif
94 static GOptionGroup *main_group;
96 static const GOptionEntry argument_main_table[] = {
97 /* *INDENT-OFF* */
98 /* generic options */
100 "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
101 &mc_args__show_version,
102 N_("Displays the current version"),
103 NULL
106 /* options for wrappers */
108 "datadir", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
109 &mc_args__show_datadirs,
110 N_("Print data directory"),
111 NULL
114 /* show extended information about used data directories */
116 "datadir-info", 'F', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
117 &mc_args__show_datadirs_extended,
118 N_("Print extended info about used data directories"),
119 NULL
122 #ifdef ENABLE_CONFIGURE_ARGS
123 /* show configure options */
125 "configure-options", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
126 &mc_args__show_configure_opts,
127 N_("Print configure options"),
128 NULL
130 #endif
133 "printwd", 'P', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
134 &mc_args__last_wd_file,
135 N_("Print last working directory to specified file"),
136 N_("<file>")
139 #ifdef ENABLE_SUBSHELL
141 "subshell", 'U', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
142 &mc_global.tty.use_subshell,
143 N_("Enables subshell support (default)"),
144 NULL
148 "nosubshell", 'u', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
149 &mc_args__nouse_subshell,
150 N_("Disables subshell support"),
151 NULL
153 #endif
155 /* debug options */
156 #ifdef ENABLE_VFS_FTP
158 "ftplog", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
159 &mc_args__netfs_logfile,
160 N_("Log ftp dialog to specified file"),
161 N_("<file>")
163 #endif /* ENABLE_VFS_FTP */
166 /* handle arguments manually */
167 "view", 'v', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
168 (gpointer) parse_mc_v_argument,
169 N_("Launches the file viewer on a file"),
170 N_("<file>")
174 /* handle arguments manually */
175 "edit", 'e', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
176 (gpointer) parse_mc_e_argument,
177 N_("Edit files"),
178 N_("<file> ...")
181 G_OPTION_ENTRY_NULL
182 /* *INDENT-ON* */
185 static GOptionGroup *terminal_group;
186 #define ARGS_TERM_OPTIONS 0
187 static const GOptionEntry argument_terminal_table[] = {
188 /* *INDENT-OFF* */
189 /* terminal options */
191 "xterm", 'x', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
192 &mc_args__force_xterm,
193 N_("Forces xterm features"),
194 NULL
198 "no-x11", 'X', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
199 &mc_global.tty.disable_x11,
200 N_("Disable X11 support"),
201 NULL
205 "oldmouse", 'g', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
206 &mc_global.tty.old_mouse,
207 N_("Tries to use an old highlight mouse tracking"),
208 NULL
212 "nomouse", 'd', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
213 &mc_args__nomouse,
214 N_("Disable mouse support in text version"),
215 NULL
218 #ifdef HAVE_SLANG
220 "termcap", 't', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
221 &SLtt_Try_Termcap,
222 N_("Tries to use termcap instead of terminfo"),
223 NULL
225 #endif
228 "slow", 's', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
229 &mc_global.tty.slow_terminal,
230 N_("To run on slow terminals"),
231 NULL
235 "stickchars", 'a', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
236 &mc_global.tty.ugly_line_drawing,
237 N_("Use stickchars to draw"),
238 NULL
241 #ifdef HAVE_SLANG
243 "resetsoft", 'k', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
244 &reset_hp_softkeys,
245 N_("Resets soft keys on HP terminals"),
246 NULL
248 #endif
251 "keymap", 'K', ARGS_TERM_OPTIONS, G_OPTION_ARG_STRING,
252 &mc_args__keymap_file,
253 N_("Load definitions of key bindings from specified file"),
254 N_("<file>")
258 "nokeymap", '\0', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
259 &mc_args__nokeymap,
260 N_("Don't load definitions of key bindings from file, use defaults"),
261 NULL
264 G_OPTION_ENTRY_NULL
265 /* *INDENT-ON* */
268 #undef ARGS_TERM_OPTIONS
270 static GOptionGroup *color_group;
271 #define ARGS_COLOR_OPTIONS 0
272 /* #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN */
273 static const GOptionEntry argument_color_table[] = {
274 /* *INDENT-OFF* */
275 /* color options */
277 "nocolor", 'b', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
278 &mc_global.tty.disable_colors,
279 N_("Requests to run in black and white"),
280 NULL
284 "color", 'c', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
285 &mc_args__force_colors,
286 N_("Request to run in color mode"),
287 NULL
291 "colors", 'C', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
292 &mc_global.tty.command_line_colors,
293 N_("Specifies a color configuration"),
294 N_("<string>")
298 "skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
299 &mc_global.tty.skin,
300 N_("Show mc with specified skin"),
301 N_("<string>")
304 G_OPTION_ENTRY_NULL
305 /* *INDENT-ON* */
308 #undef ARGS_COLOR_OPTIONS
310 static gchar *mc_args__loc__colors_string = NULL;
311 static gchar *mc_args__loc__footer_string = NULL;
312 static gchar *mc_args__loc__header_string = NULL;
313 static gchar *mc_args__loc__usage_string = NULL;
315 /* --------------------------------------------------------------------------------------------- */
316 /*** file scope functions ************************************************************************/
317 /* --------------------------------------------------------------------------------------------- */
319 static void
320 mc_args_clean_temp_help_strings (void)
322 MC_PTR_FREE (mc_args__loc__colors_string);
323 MC_PTR_FREE (mc_args__loc__footer_string);
324 MC_PTR_FREE (mc_args__loc__header_string);
325 MC_PTR_FREE (mc_args__loc__usage_string);
328 /* --------------------------------------------------------------------------------------------- */
330 static GOptionGroup *
331 mc_args_new_color_group (void)
333 /* *INDENT-OFF* */
334 /* FIXME: to preserve translations, lines should be split. */
335 mc_args__loc__colors_string = g_strdup_printf ("%s\n%s",
336 /* TRANSLATORS: don't translate keywords */
337 _("--colors KEYWORD={FORE},{BACK},{ATTR}:KEYWORD2=...\n\n"
338 "{FORE}, {BACK} and {ATTR} can be omitted, and the default will be used\n"
339 "\n Keywords:\n"
340 " Global: errors, disabled, reverse, gauge, header\n"
341 " input, inputmark, inputunchanged, commandlinemark\n"
342 " bbarhotkey, bbarbutton, statusbar\n"
343 " File display: normal, selected, marked, markselect\n"
344 " Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"
345 " errdhotfocus\n"
346 " Menus: menunormal, menuhot, menusel, menuhotsel, menuinactive\n"
347 " Popup menus: pmenunormal, pmenusel, pmenutitle\n"
348 " Editor: editnormal, editbold, editmarked, editwhitespace, editnonprintable,\n"
349 " editlinestate, editbg, editframe, editframeactive\n"
350 " editframedrag\n"
351 " Viewer: viewnormal,viewbold, viewunderline, viewselected\n"
352 " Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n"),
353 /* TRANSLATORS: don't translate color names and attributes */
354 _("Standard Colors:\n"
355 " black, gray, red, brightred, green, brightgreen, brown,\n"
356 " yellow, blue, brightblue, magenta, brightmagenta, cyan,\n"
357 " brightcyan, lightgray and white\n\n"
358 "Extended colors, when 256 colors are available:\n"
359 " color16 to color255, or rgb000 to rgb555 and gray0 to gray23\n\n"
360 "Attributes:\n"
361 " bold, italic, underline, reverse, blink; append more with '+'\n")
363 /* *INDENT-ON* */
365 return g_option_group_new ("color", mc_args__loc__colors_string,
366 _("Color options"), NULL, NULL);
370 /* --------------------------------------------------------------------------------------------- */
372 static gchar *
373 mc_args_add_usage_info (void)
375 gchar *s;
377 switch (mc_global.mc_run_mode)
379 case MC_RUN_EDITOR:
380 s = g_strdup_printf ("%s\n", _("[+lineno] file1[:lineno] [file2[:lineno]...]"));
381 break;
382 case MC_RUN_VIEWER:
383 s = g_strdup_printf ("%s\n", _("file"));
384 break;
385 #ifdef USE_DIFF_VIEW
386 case MC_RUN_DIFFVIEWER:
387 s = g_strdup_printf ("%s\n", _("file1 file2"));
388 break;
389 #endif /* USE_DIFF_VIEW */
390 case MC_RUN_FULL:
391 default:
392 s = g_strdup_printf ("%s\n", _("[this_dir] [other_panel_dir]"));
395 mc_args__loc__usage_string = s;
397 return mc_args__loc__usage_string;
400 /* --------------------------------------------------------------------------------------------- */
402 static void
403 mc_args_add_extended_info_to_help (void)
405 mc_args__loc__footer_string = g_strdup_printf ("%s",
407 ("\n"
408 "Please send any bug reports (including the output of 'mc -V')\n"
409 "as tickets at www.midnight-commander.org\n"));
410 mc_args__loc__header_string =
411 g_strdup_printf (_("GNU Midnight Commander %s\n"), mc_global.mc_version);
413 g_option_context_set_description (context, mc_args__loc__footer_string);
414 g_option_context_set_summary (context, mc_args__loc__header_string);
417 /* --------------------------------------------------------------------------------------------- */
419 static GString *
420 mc_args__convert_help_to_syscharset (const gchar * charset, const gchar * error_message_str,
421 const gchar * help_str)
423 GString *buffer;
424 GIConv conv;
425 gchar *full_help_str;
427 buffer = g_string_new ("");
428 conv = g_iconv_open (charset, "UTF-8");
429 full_help_str = g_strdup_printf ("%s\n\n%s\n", error_message_str, help_str);
431 str_convert (conv, full_help_str, buffer);
433 g_free (full_help_str);
434 g_iconv_close (conv);
436 return buffer;
439 /* --------------------------------------------------------------------------------------------- */
441 static gboolean
442 parse_mc_e_argument (const gchar * option_name, const gchar * value, gpointer data,
443 GError ** mcerror)
445 (void) option_name;
446 (void) value;
447 (void) data;
449 mc_return_val_if_error (mcerror, FALSE);
451 mc_global.mc_run_mode = MC_RUN_EDITOR;
453 return TRUE;
456 /* --------------------------------------------------------------------------------------------- */
458 static gboolean
459 parse_mc_v_argument (const gchar * option_name, const gchar * value, gpointer data,
460 GError ** mcerror)
462 (void) option_name;
463 (void) value;
464 (void) data;
466 mc_return_val_if_error (mcerror, FALSE);
468 mc_global.mc_run_mode = MC_RUN_VIEWER;
470 return TRUE;
473 /* --------------------------------------------------------------------------------------------- */
475 * Create mcedit_arg_t object from vfs_path_t object and the line number.
477 * @param file_vpath file path object
478 * @param line_number line number. If value is 0, try to restore saved position.
479 * @return mcedit_arg_t object
482 static mcedit_arg_t *
483 mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number)
485 mcedit_arg_t *arg;
487 arg = g_new (mcedit_arg_t, 1);
488 arg->file_vpath = file_vpath;
489 arg->line_number = line_number;
491 return arg;
494 /* --------------------------------------------------------------------------------------------- */
496 * Create mcedit_arg_t object from file name and the line number.
498 * @param file_name file name
499 * @param line_number line number. If value is 0, try to restore saved position.
500 * @return mcedit_arg_t object
503 static mcedit_arg_t *
504 mcedit_arg_new (const char *file_name, long line_number)
506 return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number);
509 /* --------------------------------------------------------------------------------------------- */
511 * Get list of filenames (and line numbers) from command line, when mc called as editor
513 * @param argc count of all arguments
514 * @param argv array of strings, contains arguments
515 * @return list of mcedit_arg_t objects
518 static GList *
519 parse_mcedit_arguments (int argc, char **argv)
521 GList *flist = NULL;
522 int i;
523 long first_line_number = -1;
525 for (i = 0; i < argc; i++)
527 char *tmp;
528 char *end, *p;
529 mcedit_arg_t *arg;
531 tmp = argv[i];
534 * First, try to get line number as +lineno.
536 if (*tmp == '+')
538 long lineno;
539 char *error;
541 lineno = strtol (tmp + 1, &error, 10);
543 if (*error == '\0')
545 /* this is line number */
546 first_line_number = lineno;
547 continue;
549 /* this is file name */
553 * Check for filename:lineno, followed by an optional colon.
554 * This format is used by many programs (especially compilers)
555 * in error messages and warnings. It is supported so that
556 * users can quickly copy and paste file locations.
558 end = tmp + strlen (tmp);
559 p = end;
561 if (p > tmp && p[-1] == ':')
562 p--;
563 while (p > tmp && g_ascii_isdigit ((gchar) p[-1]))
564 p--;
566 if (tmp < p && p < end && p[-1] == ':')
568 char *fname;
569 vfs_path_t *tmp_vpath, *fname_vpath;
570 struct stat st;
572 fname = g_strndup (tmp, p - 1 - tmp);
573 tmp_vpath = vfs_path_from_str (tmp);
574 fname_vpath = vfs_path_from_str (fname);
577 * Check that the file before the colon actually exists.
578 * If it doesn't exist, create new file.
580 if (mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1)
582 arg = mcedit_arg_vpath_new (fname_vpath, atoi (p));
583 vfs_path_free (tmp_vpath, TRUE);
585 else
587 arg = mcedit_arg_vpath_new (tmp_vpath, 0);
588 vfs_path_free (fname_vpath, TRUE);
591 g_free (fname);
593 else
594 arg = mcedit_arg_new (tmp, 0);
596 flist = g_list_prepend (flist, arg);
599 if (flist == NULL)
600 flist = g_list_prepend (flist, mcedit_arg_new (NULL, 0));
601 else if (first_line_number != -1)
603 /* overwrite line number for first file */
604 GList *l;
606 l = g_list_last (flist);
607 ((mcedit_arg_t *) l->data)->line_number = first_line_number;
610 return flist;
613 /* --------------------------------------------------------------------------------------------- */
614 /*** public functions ****************************************************************************/
615 /* --------------------------------------------------------------------------------------------- */
617 void
618 mc_setup_run_mode (char **argv)
620 const char *base;
622 base = x_basename (argv[0]);
624 if (strncmp (base, "mce", 3) == 0 || strcmp (base, "vi") == 0)
626 /* mce* or vi is link to mc */
627 mc_global.mc_run_mode = MC_RUN_EDITOR;
629 else if (strncmp (base, "mcv", 3) == 0 || strcmp (base, "view") == 0)
631 /* mcv* or view is link to mc */
632 mc_global.mc_run_mode = MC_RUN_VIEWER;
634 #ifdef USE_DIFF_VIEW
635 else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
637 /* mcd* or diff is link to mc */
638 mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
640 #endif /* USE_DIFF_VIEW */
643 gboolean
644 mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError ** mcerror)
646 const gchar *_system_codepage;
647 gboolean ok = TRUE;
649 mc_return_val_if_error (mcerror, FALSE);
651 _system_codepage = str_detect_termencoding ();
653 #ifdef ENABLE_NLS
654 if (!str_isutf8 (_system_codepage))
655 bind_textdomain_codeset ("mc", "UTF-8");
656 #endif
658 context = g_option_context_new (mc_args_add_usage_info ());
660 g_option_context_set_ignore_unknown_options (context, FALSE);
662 mc_args_add_extended_info_to_help ();
664 main_group = g_option_group_new ("main", _("Main options"), _("Main options"), NULL, NULL);
666 g_option_group_add_entries (main_group, argument_main_table);
667 g_option_context_set_main_group (context, main_group);
668 g_option_group_set_translation_domain (main_group, translation_domain);
670 terminal_group = g_option_group_new ("terminal", _("Terminal options"),
671 _("Terminal options"), NULL, NULL);
673 g_option_group_add_entries (terminal_group, argument_terminal_table);
674 g_option_context_add_group (context, terminal_group);
675 g_option_group_set_translation_domain (terminal_group, translation_domain);
677 color_group = mc_args_new_color_group ();
679 g_option_group_add_entries (color_group, argument_color_table);
680 g_option_context_add_group (context, color_group);
681 g_option_group_set_translation_domain (color_group, translation_domain);
683 if (!g_option_context_parse (context, argc, argv, mcerror))
685 if (*mcerror == NULL)
686 mc_propagate_error (mcerror, 0, "%s\n", _("Arguments parse error!"));
687 else
689 gchar *help_str;
691 help_str = g_option_context_get_help (context, TRUE, NULL);
693 if (str_isutf8 (_system_codepage))
694 mc_replace_error (mcerror, (*mcerror)->code, "%s\n\n%s\n", (*mcerror)->message,
695 help_str);
696 else
698 GString *full_help_str;
700 full_help_str =
701 mc_args__convert_help_to_syscharset (_system_codepage, (*mcerror)->message,
702 help_str);
703 mc_replace_error (mcerror, (*mcerror)->code, "%s", full_help_str->str);
704 g_string_free (full_help_str, TRUE);
706 g_free (help_str);
709 ok = FALSE;
712 g_option_context_free (context);
713 mc_args_clean_temp_help_strings ();
715 #ifdef ENABLE_NLS
716 if (!str_isutf8 (_system_codepage))
717 bind_textdomain_codeset ("mc", _system_codepage);
718 #endif
720 return ok;
723 /* --------------------------------------------------------------------------------------------- */
725 gboolean
726 mc_args_show_info (void)
728 if (mc_args__show_version)
730 show_version ();
731 return FALSE;
734 if (mc_args__show_datadirs)
736 printf ("%s (%s)\n", mc_global.sysconfig_dir, mc_global.share_data_dir);
737 return FALSE;
740 if (mc_args__show_datadirs_extended)
742 show_datadirs_extended ();
743 return FALSE;
746 #ifdef ENABLE_CONFIGURE_ARGS
747 if (mc_args__show_configure_opts)
749 show_configure_options ();
750 return FALSE;
752 #endif
754 return TRUE;
757 /* --------------------------------------------------------------------------------------------- */
759 gboolean
760 mc_setup_by_args (int argc, char **argv, GError ** mcerror)
762 char *tmp;
764 mc_return_val_if_error (mcerror, FALSE);
766 if (mc_args__force_colors)
767 mc_global.tty.disable_colors = FALSE;
769 #ifdef ENABLE_SUBSHELL
770 if (mc_args__nouse_subshell)
771 mc_global.tty.use_subshell = FALSE;
772 #endif /* ENABLE_SUBSHELL */
774 #ifdef ENABLE_VFS_FTP
775 if (mc_args__netfs_logfile != NULL)
777 vfs_path_t *vpath;
779 vpath = vfs_path_from_str ("ftp://");
780 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
781 vfs_path_free (vpath, TRUE);
783 #endif /* ENABLE_VFS_FTP */
785 tmp = (argc > 0) ? argv[1] : NULL;
787 switch (mc_global.mc_run_mode)
789 case MC_RUN_EDITOR:
790 mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
791 break;
793 case MC_RUN_VIEWER:
794 if (tmp == NULL)
796 mc_propagate_error (mcerror, 0, "%s\n", _("No arguments given to the viewer."));
797 return FALSE;
800 mc_run_param0 = g_strdup (tmp);
801 break;
803 #ifdef USE_DIFF_VIEW
804 case MC_RUN_DIFFVIEWER:
805 if (argc < 3)
807 mc_propagate_error (mcerror, 0, "%s\n",
808 _("Two files are required to invoke the diffviewer."));
809 return FALSE;
811 MC_FALLTHROUGH;
812 #endif /* USE_DIFF_VIEW */
814 case MC_RUN_FULL:
815 default:
816 /* set the current dir and the other dir for filemanager,
817 or two files for diff viewer */
818 if (tmp != NULL)
820 mc_run_param0 = g_strdup (tmp);
821 tmp = (argc > 1) ? argv[2] : NULL;
822 if (tmp != NULL)
823 mc_run_param1 = g_strdup (tmp);
825 break;
828 return TRUE;
831 /* --------------------------------------------------------------------------------------------- */
833 * Free the mcedit_arg_t object.
835 * @param arg mcedit_arg_t object
838 void
839 mcedit_arg_free (mcedit_arg_t * arg)
841 vfs_path_free (arg->file_vpath, TRUE);
842 g_free (arg);
845 /* --------------------------------------------------------------------------------------------- */