Update hints translations from Transifex
[midnight-commander.git] / src / args.c
blobf8dc24020a131472c17a756c5fc62061d1b54913
1 /*
2 Handle command line arguments.
4 Copyright (C) 2009-2019
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 #ifdef ENABLE_VFS_SMB
38 #include "src/vfs/smbfs/smbfs.h" /* smbfs_set_debugf() */
39 #endif
41 #include "src/textconf.h"
43 #include "src/args.h"
45 /*** external variables **************************************************************************/
47 /*** global variables ****************************************************************************/
49 /* If true, assume we are running on an xterm terminal */
50 gboolean mc_args__force_xterm = FALSE;
52 gboolean mc_args__nomouse = FALSE;
54 /* Force colors, only used by Slang */
55 gboolean mc_args__force_colors = FALSE;
57 /* Don't load keymap from file and use default one */
58 gboolean mc_args__nokeymap = FALSE;
60 char *mc_args__last_wd_file = NULL;
62 /* when enabled NETCODE, use folowing file as logfile */
63 char *mc_args__netfs_logfile = NULL;
65 /* keymap file */
66 char *mc_args__keymap_file = NULL;
68 /* Debug level */
69 #ifdef ENABLE_VFS_SMB
70 int mc_args__debug_level = 0;
71 #endif
73 void *mc_run_param0 = NULL;
74 char *mc_run_param1 = NULL;
76 /*** file scope macro definitions ****************************************************************/
78 /*** file scope type declarations ****************************************************************/
80 /*** file scope variables ************************************************************************/
82 /* If true, show version info and exit */
83 static gboolean mc_args__show_version = FALSE;
85 /* forward declarations */
86 static gboolean parse_mc_e_argument (const gchar * option_name, const gchar * value,
87 gpointer data, GError ** mcerror);
88 static gboolean parse_mc_v_argument (const gchar * option_name, const gchar * value,
89 gpointer data, GError ** mcerror);
91 static GOptionContext *context;
93 #ifdef ENABLE_SUBSHELL
94 static gboolean mc_args__nouse_subshell = FALSE;
95 #endif /* ENABLE_SUBSHELL */
96 static gboolean mc_args__show_datadirs = FALSE;
97 static gboolean mc_args__show_datadirs_extended = FALSE;
98 #ifdef ENABLE_CONFIGURE_ARGS
99 static gboolean mc_args__show_configure_opts = FALSE;
100 #endif
102 static GOptionGroup *main_group;
104 static const GOptionEntry argument_main_table[] = {
105 /* *INDENT-OFF* */
106 /* generic options */
108 "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
109 &mc_args__show_version,
110 N_("Displays the current version"),
111 NULL
114 /* options for wrappers */
116 "datadir", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
117 &mc_args__show_datadirs,
118 N_("Print data directory"),
119 NULL
122 /* show extended information about used data directories */
124 "datadir-info", 'F', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
125 &mc_args__show_datadirs_extended,
126 N_("Print extended info about used data directories"),
127 NULL
130 #ifdef ENABLE_CONFIGURE_ARGS
131 /* show configure options */
133 "configure-options", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
134 &mc_args__show_configure_opts,
135 N_("Print configure options"),
136 NULL
138 #endif
141 "printwd", 'P', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
142 &mc_args__last_wd_file,
143 N_("Print last working directory to specified file"),
144 N_("<file>")
147 #ifdef ENABLE_SUBSHELL
149 "subshell", 'U', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
150 &mc_global.tty.use_subshell,
151 N_("Enables subshell support (default)"),
152 NULL
156 "nosubshell", 'u', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
157 &mc_args__nouse_subshell,
158 N_("Disables subshell support"),
159 NULL
161 #endif
163 /* debug options */
164 #ifdef ENABLE_VFS_FTP
166 "ftplog", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
167 &mc_args__netfs_logfile,
168 N_("Log ftp dialog to specified file"),
169 N_("<file>")
171 #endif /* ENABLE_VFS_FTP */
172 #ifdef ENABLE_VFS_SMB
174 "debuglevel", 'D', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT,
175 &mc_args__debug_level,
176 N_("Set debug level"),
177 N_("<integer>")
179 #endif /* ENABLE_VFS_SMB */
182 /* handle arguments manually */
183 "view", 'v', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
184 (gpointer) parse_mc_v_argument,
185 N_("Launches the file viewer on a file"),
186 N_("<file>")
190 /* handle arguments manually */
191 "edit", 'e', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
192 (gpointer) parse_mc_e_argument,
193 N_("Edit files"),
194 N_("<file> ...") },
197 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
199 /* *INDENT-ON* */
202 static GOptionGroup *terminal_group;
203 #define ARGS_TERM_OPTIONS 0
204 static const GOptionEntry argument_terminal_table[] = {
205 /* *INDENT-OFF* */
206 /* terminal options */
208 "xterm", 'x', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
209 &mc_args__force_xterm,
210 N_("Forces xterm features"),
211 NULL
215 "no-x11", 'X', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
216 &mc_global.tty.disable_x11,
217 N_("Disable X11 support"),
218 NULL
222 "oldmouse", 'g', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
223 &mc_global.tty.old_mouse,
224 N_("Tries to use an old highlight mouse tracking"),
225 NULL
229 "nomouse", 'd', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
230 &mc_args__nomouse,
231 N_("Disable mouse support in text version"),
232 NULL
235 #ifdef HAVE_SLANG
237 "termcap", 't', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
238 &SLtt_Try_Termcap,
239 N_("Tries to use termcap instead of terminfo"),
240 NULL
242 #endif
245 "slow", 's', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
246 &mc_global.tty.slow_terminal,
247 N_("To run on slow terminals"),
248 NULL
252 "stickchars", 'a', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
253 &mc_global.tty.ugly_line_drawing,
254 N_("Use stickchars to draw"),
255 NULL
258 #ifdef HAVE_SLANG
260 "resetsoft", 'k', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
261 &reset_hp_softkeys,
262 N_("Resets soft keys on HP terminals"),
263 NULL
265 #endif
268 "keymap", 'K', ARGS_TERM_OPTIONS, G_OPTION_ARG_STRING,
269 &mc_args__keymap_file,
270 N_("Load definitions of key bindings from specified file"),
271 N_("<file>")
275 "nokeymap", '\0', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
276 &mc_args__nokeymap,
277 N_("Don't load definitions of key bindings from file, use defaults"),
278 NULL
282 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
284 /* *INDENT-ON* */
287 #undef ARGS_TERM_OPTIONS
289 static GOptionGroup *color_group;
290 #define ARGS_COLOR_OPTIONS 0
291 /* #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN */
292 static const GOptionEntry argument_color_table[] = {
293 /* *INDENT-OFF* */
294 /* color options */
296 "nocolor", 'b', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
297 &mc_global.tty.disable_colors,
298 N_("Requests to run in black and white"),
299 NULL
303 "color", 'c', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
304 &mc_args__force_colors,
305 N_("Request to run in color mode"),
306 NULL
310 "colors", 'C', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
311 &mc_global.tty.command_line_colors,
312 N_("Specifies a color configuration"),
313 N_("<string>")
317 "skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
318 &mc_global.tty.skin,
319 N_("Show mc with specified skin"),
320 N_("<string>")
324 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
326 /* *INDENT-ON* */
329 #undef ARGS_COLOR_OPTIONS
331 static gchar *mc_args__loc__colors_string = NULL;
332 static gchar *mc_args__loc__footer_string = NULL;
333 static gchar *mc_args__loc__header_string = NULL;
334 static gchar *mc_args__loc__usage_string = NULL;
336 /*** file scope functions ************************************************************************/
338 /* --------------------------------------------------------------------------------------------- */
339 static void
340 mc_args_clean_temp_help_strings (void)
342 MC_PTR_FREE (mc_args__loc__colors_string);
343 MC_PTR_FREE (mc_args__loc__footer_string);
344 MC_PTR_FREE (mc_args__loc__header_string);
345 MC_PTR_FREE (mc_args__loc__usage_string);
348 /* --------------------------------------------------------------------------------------------- */
350 static GOptionGroup *
351 mc_args_new_color_group (void)
353 /* *INDENT-OFF* */
354 /* FIXME: to preserve translations, lines should be split. */
355 mc_args__loc__colors_string = g_strdup_printf ("%s\n%s",
356 /* TRANSLATORS: don't translate keywords */
357 _("--colors KEYWORD={FORE},{BACK},{ATTR}:KEYWORD2=...\n\n"
358 "{FORE}, {BACK} and {ATTR} can be omitted, and the default will be used\n"
359 "\n Keywords:\n"
360 " Global: errors, disabled, reverse, gauge, header\n"
361 " input, inputmark, inputunchanged, commandlinemark\n"
362 " bbarhotkey, bbarbutton, statusbar\n"
363 " File display: normal, selected, marked, markselect\n"
364 " Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"
365 " errdhotfocus\n"
366 " Menus: menunormal, menuhot, menusel, menuhotsel, menuinactive\n"
367 " Popup menus: pmenunormal, pmenusel, pmenutitle\n"
368 " Editor: editnormal, editbold, editmarked, editwhitespace,\n"
369 " editlinestate, editbg, editframe, editframeactive\n"
370 " editframedrag\n"
371 " Viewer: viewnormal,viewbold, viewunderline, viewselected\n"
372 " Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n"),
373 /* TRANSLATORS: don't translate color names and attributes */
374 _("Standard Colors:\n"
375 " black, gray, red, brightred, green, brightgreen, brown,\n"
376 " yellow, blue, brightblue, magenta, brightmagenta, cyan,\n"
377 " brightcyan, lightgray and white\n\n"
378 "Extended colors, when 256 colors are available:\n"
379 " color16 to color255, or rgb000 to rgb555 and gray0 to gray23\n\n"
380 "Attributes:\n"
381 " bold, italic, underline, reverse, blink; append more with '+'\n")
383 /* *INDENT-ON* */
385 return g_option_group_new ("color", mc_args__loc__colors_string,
386 _("Color options"), NULL, NULL);
390 /* --------------------------------------------------------------------------------------------- */
392 static gchar *
393 mc_args_add_usage_info (void)
395 gchar *s;
397 switch (mc_global.mc_run_mode)
399 case MC_RUN_EDITOR:
400 s = g_strdup_printf ("%s\n", _("[+lineno] file1[:lineno] [file2[:lineno]...]"));
401 break;
402 case MC_RUN_VIEWER:
403 s = g_strdup_printf ("%s\n", _("file"));
404 break;
405 #ifdef USE_DIFF_VIEW
406 case MC_RUN_DIFFVIEWER:
407 s = g_strdup_printf ("%s\n", _("file1 file2"));
408 break;
409 #endif /* USE_DIFF_VIEW */
410 case MC_RUN_FULL:
411 default:
412 s = g_strdup_printf ("%s\n", _("[this_dir] [other_panel_dir]"));
415 mc_args__loc__usage_string = s;
417 return mc_args__loc__usage_string;
420 /* --------------------------------------------------------------------------------------------- */
422 static void
423 mc_args_add_extended_info_to_help (void)
425 mc_args__loc__footer_string = g_strdup_printf ("%s",
427 ("\n"
428 "Please send any bug reports (including the output of 'mc -V')\n"
429 "as tickets at www.midnight-commander.org\n"));
430 mc_args__loc__header_string = g_strdup_printf (_("GNU Midnight Commander %s\n"), VERSION);
432 g_option_context_set_description (context, mc_args__loc__footer_string);
433 g_option_context_set_summary (context, mc_args__loc__header_string);
436 /* --------------------------------------------------------------------------------------------- */
438 static gchar *
439 mc_args__convert_help_to_syscharset (const gchar * charset, const gchar * error_message_str,
440 const gchar * help_str)
442 GString *buffer;
443 GIConv conv;
444 gchar *full_help_str;
446 buffer = g_string_new ("");
447 conv = g_iconv_open (charset, "UTF-8");
448 full_help_str = g_strdup_printf ("%s\n\n%s\n", error_message_str, help_str);
450 str_convert (conv, full_help_str, buffer);
452 g_free (full_help_str);
453 g_iconv_close (conv);
455 return g_string_free (buffer, FALSE);
458 /* --------------------------------------------------------------------------------------------- */
460 static gboolean
461 parse_mc_e_argument (const gchar * option_name, const gchar * value, gpointer data,
462 GError ** mcerror)
464 (void) option_name;
465 (void) value;
466 (void) data;
468 mc_return_val_if_error (mcerror, FALSE);
470 mc_global.mc_run_mode = MC_RUN_EDITOR;
472 return TRUE;
475 /* --------------------------------------------------------------------------------------------- */
477 static gboolean
478 parse_mc_v_argument (const gchar * option_name, const gchar * value, gpointer data,
479 GError ** mcerror)
481 (void) option_name;
482 (void) value;
483 (void) data;
485 mc_return_val_if_error (mcerror, FALSE);
487 mc_global.mc_run_mode = MC_RUN_VIEWER;
489 return TRUE;
492 /* --------------------------------------------------------------------------------------------- */
494 * Create mcedit_arg_t object from vfs_path_t object and the line number.
496 * @param file_vpath file path object
497 * @param line_number line number. If value is 0, try to restore saved position.
498 * @return mcedit_arg_t object
501 static mcedit_arg_t *
502 mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number)
504 mcedit_arg_t *arg;
506 arg = g_new (mcedit_arg_t, 1);
507 arg->file_vpath = file_vpath;
508 arg->line_number = line_number;
510 return arg;
513 /* --------------------------------------------------------------------------------------------- */
515 * Create mcedit_arg_t object from file name and the line number.
517 * @param file_name file name
518 * @param line_number line number. If value is 0, try to restore saved position.
519 * @return mcedit_arg_t object
522 static mcedit_arg_t *
523 mcedit_arg_new (const char *file_name, long line_number)
525 return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number);
528 /* --------------------------------------------------------------------------------------------- */
530 * Get list of filenames (and line numbers) from command line, when mc called as editor
532 * @param argc count of all arguments
533 * @param argv array of strings, contains arguments
534 * @return list of mcedit_arg_t objects
537 static GList *
538 parse_mcedit_arguments (int argc, char **argv)
540 GList *flist = NULL;
541 int i;
542 long first_line_number = -1;
544 for (i = 0; i < argc; i++)
546 char *tmp;
547 char *end, *p;
548 mcedit_arg_t *arg;
550 tmp = argv[i];
553 * First, try to get line number as +lineno.
555 if (*tmp == '+')
557 long lineno;
558 char *error;
560 lineno = strtol (tmp + 1, &error, 10);
562 if (*error == '\0')
564 /* this is line number */
565 first_line_number = lineno;
566 continue;
568 /* this is file name */
572 * Check for filename:lineno, followed by an optional colon.
573 * This format is used by many programs (especially compilers)
574 * in error messages and warnings. It is supported so that
575 * users can quickly copy and paste file locations.
577 end = tmp + strlen (tmp);
578 p = end;
580 if (p > tmp && p[-1] == ':')
581 p--;
582 while (p > tmp && g_ascii_isdigit ((gchar) p[-1]))
583 p--;
585 if (tmp < p && p < end && p[-1] == ':')
587 char *fname;
588 vfs_path_t *tmp_vpath, *fname_vpath;
589 struct stat st;
591 fname = g_strndup (tmp, p - 1 - tmp);
592 tmp_vpath = vfs_path_from_str (tmp);
593 fname_vpath = vfs_path_from_str (fname);
596 * Check that the file before the colon actually exists.
597 * If it doesn't exist, create new file.
599 if (mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1)
601 arg = mcedit_arg_vpath_new (fname_vpath, atoi (p));
602 vfs_path_free (tmp_vpath);
604 else
606 arg = mcedit_arg_vpath_new (tmp_vpath, 0);
607 vfs_path_free (fname_vpath);
610 g_free (fname);
612 else
613 arg = mcedit_arg_new (tmp, 0);
615 flist = g_list_prepend (flist, arg);
618 if (flist == NULL)
619 flist = g_list_prepend (flist, mcedit_arg_new (NULL, 0));
620 else if (first_line_number != -1)
622 /* overwrite line number for first file */
623 GList *l;
625 l = g_list_last (flist);
626 ((mcedit_arg_t *) l->data)->line_number = first_line_number;
629 return flist;
632 /* --------------------------------------------------------------------------------------------- */
633 /*** public functions ****************************************************************************/
634 /* --------------------------------------------------------------------------------------------- */
636 void
637 mc_setup_run_mode (char **argv)
639 const char *base;
641 base = x_basename (argv[0]);
643 if (strncmp (base, "mce", 3) == 0 || strcmp (base, "vi") == 0)
645 /* mce* or vi is link to mc */
646 mc_global.mc_run_mode = MC_RUN_EDITOR;
648 else if (strncmp (base, "mcv", 3) == 0 || strcmp (base, "view") == 0)
650 /* mcv* or view is link to mc */
651 mc_global.mc_run_mode = MC_RUN_VIEWER;
653 #ifdef USE_DIFF_VIEW
654 else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
656 /* mcd* or diff is link to mc */
657 mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
659 #endif /* USE_DIFF_VIEW */
662 gboolean
663 mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError ** mcerror)
665 const gchar *_system_codepage;
666 gboolean ok = TRUE;
668 mc_return_val_if_error (mcerror, FALSE);
670 _system_codepage = str_detect_termencoding ();
672 #ifdef ENABLE_NLS
673 if (!str_isutf8 (_system_codepage))
674 bind_textdomain_codeset ("mc", "UTF-8");
675 #endif
677 context = g_option_context_new (mc_args_add_usage_info ());
679 g_option_context_set_ignore_unknown_options (context, FALSE);
681 mc_args_add_extended_info_to_help ();
683 main_group = g_option_group_new ("main", _("Main options"), _("Main options"), NULL, NULL);
685 g_option_group_add_entries (main_group, argument_main_table);
686 g_option_context_set_main_group (context, main_group);
687 g_option_group_set_translation_domain (main_group, translation_domain);
689 terminal_group = g_option_group_new ("terminal", _("Terminal options"),
690 _("Terminal options"), NULL, NULL);
692 g_option_group_add_entries (terminal_group, argument_terminal_table);
693 g_option_context_add_group (context, terminal_group);
694 g_option_group_set_translation_domain (terminal_group, translation_domain);
696 color_group = mc_args_new_color_group ();
698 g_option_group_add_entries (color_group, argument_color_table);
699 g_option_context_add_group (context, color_group);
700 g_option_group_set_translation_domain (color_group, translation_domain);
702 if (!g_option_context_parse (context, argc, argv, mcerror))
704 if (*mcerror == NULL)
705 mc_propagate_error (mcerror, 0, "%s\n", _("Arguments parse error!"));
706 else
708 gchar *help_str;
710 help_str = g_option_context_get_help (context, TRUE, NULL);
712 if (str_isutf8 (_system_codepage))
713 mc_replace_error (mcerror, (*mcerror)->code, "%s\n\n%s\n", (*mcerror)->message,
714 help_str);
715 else
717 gchar *full_help_str;
719 full_help_str =
720 mc_args__convert_help_to_syscharset (_system_codepage, (*mcerror)->message,
721 help_str);
722 mc_replace_error (mcerror, (*mcerror)->code, "%s", full_help_str);
723 g_free (full_help_str);
725 g_free (help_str);
728 ok = FALSE;
731 g_option_context_free (context);
732 mc_args_clean_temp_help_strings ();
734 #ifdef ENABLE_NLS
735 if (!str_isutf8 (_system_codepage))
736 bind_textdomain_codeset ("mc", _system_codepage);
737 #endif
739 return ok;
742 /* --------------------------------------------------------------------------------------------- */
744 gboolean
745 mc_args_show_info (void)
747 if (mc_args__show_version)
749 show_version ();
750 return FALSE;
753 if (mc_args__show_datadirs)
755 printf ("%s (%s)\n", mc_global.sysconfig_dir, mc_global.share_data_dir);
756 return FALSE;
759 if (mc_args__show_datadirs_extended)
761 show_datadirs_extended ();
762 return FALSE;
765 #ifdef ENABLE_CONFIGURE_ARGS
766 if (mc_args__show_configure_opts)
768 show_configure_options ();
769 return FALSE;
771 #endif
773 return TRUE;
776 /* --------------------------------------------------------------------------------------------- */
778 gboolean
779 mc_setup_by_args (int argc, char **argv, GError ** mcerror)
781 char *tmp;
783 mc_return_val_if_error (mcerror, FALSE);
785 if (mc_args__force_colors)
786 mc_global.tty.disable_colors = FALSE;
788 #ifdef ENABLE_SUBSHELL
789 if (mc_args__nouse_subshell)
790 mc_global.tty.use_subshell = FALSE;
791 #endif /* ENABLE_SUBSHELL */
793 #ifdef ENABLE_VFS_SMB
794 if (mc_args__debug_level != 0)
795 smbfs_set_debug (mc_args__debug_level);
796 #endif /* ENABLE_VFS_SMB */
798 if (mc_args__netfs_logfile != NULL)
800 vfs_path_t *vpath;
801 #ifdef ENABLE_VFS_FTP
802 vpath = vfs_path_from_str ("ftp://");
803 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
804 vfs_path_free (vpath);
805 #endif /* ENABLE_VFS_FTP */
806 #ifdef ENABLE_VFS_SMB
807 vpath = vfs_path_from_str ("smb://");
808 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
809 vfs_path_free (vpath);
810 #endif /* ENABLE_VFS_SMB */
811 (void) vpath;
814 tmp = (argc > 0) ? argv[1] : NULL;
816 switch (mc_global.mc_run_mode)
818 case MC_RUN_EDITOR:
819 mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
820 break;
822 case MC_RUN_VIEWER:
823 if (tmp == NULL)
825 mc_propagate_error (mcerror, 0, "%s\n", _("No arguments given to the viewer."));
826 return FALSE;
829 mc_run_param0 = g_strdup (tmp);
830 break;
832 #ifdef USE_DIFF_VIEW
833 case MC_RUN_DIFFVIEWER:
834 if (argc < 3)
836 mc_propagate_error (mcerror, 0, "%s\n",
837 _("Two files are required to envoke the diffviewer."));
838 return FALSE;
840 MC_FALLTHROUGH;
841 #endif /* USE_DIFF_VIEW */
843 case MC_RUN_FULL:
844 default:
845 /* set the current dir and the other dir for filemanager,
846 or two files for diff viewer */
847 if (tmp != NULL)
849 mc_run_param0 = g_strdup (tmp);
850 tmp = (argc > 1) ? argv[2] : NULL;
851 if (tmp != NULL)
852 mc_run_param1 = g_strdup (tmp);
854 break;
857 return TRUE;
860 /* --------------------------------------------------------------------------------------------- */
862 * Free the mcedit_arg_t object.
864 * @param arg mcedit_arg_t object
867 void
868 mcedit_arg_free (mcedit_arg_t * arg)
870 vfs_path_free (arg->file_vpath);
871 g_free (arg);
874 /* --------------------------------------------------------------------------------------------- */