Use long for line numbers and columns.
[midnight-commander.git] / src / args.c
blob811ddc7fa228b743569a43fc753a829cb6f85f44
1 /*
2 Handle command line arguments.
4 Copyright (C) 2009, 2010, 2011, 2012
5 The 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/main.h"
42 #include "src/textconf.h"
44 #include "src/args.h"
46 /*** external variables **************************************************************************/
48 /*** global variables ****************************************************************************/
50 /* If true, show version info and exit */
51 gboolean mc_args__show_version = FALSE;
53 /* If true, assume we are running on an xterm terminal */
54 gboolean mc_args__force_xterm = FALSE;
56 gboolean mc_args__nomouse = FALSE;
58 /* Force colors, only used by Slang */
59 gboolean mc_args__force_colors = FALSE;
61 /* Don't load keymap form file and use default one */
62 gboolean mc_args__nokeymap = FALSE;
64 char *mc_args__last_wd_file = NULL;
66 /* when enabled NETCODE, use folowing file as logfile */
67 char *mc_args__netfs_logfile = NULL;
69 /* keymap file */
70 char *mc_args__keymap_file = NULL;
72 /* Debug level */
73 int mc_args__debug_level = 0;
75 /*** file scope macro definitions ****************************************************************/
77 /*** file scope type declarations ****************************************************************/
79 /*** file scope variables ************************************************************************/
81 /* forward declarations */
82 static gboolean parse_mc_e_argument (const gchar * option_name, const gchar * value,
83 gpointer data, GError ** error);
84 static gboolean parse_mc_v_argument (const gchar * option_name, const gchar * value,
85 gpointer data, GError ** error);
87 static GOptionContext *context;
89 #ifdef HAVE_SUBSHELL_SUPPORT
90 static gboolean mc_args__nouse_subshell = FALSE;
91 #endif /* HAVE_SUBSHELL_SUPPORT */
92 static gboolean mc_args__show_datadirs = FALSE;
93 static gboolean mc_args__show_datadirs_extended = FALSE;
94 static gboolean mc_args__show_configure_opts = FALSE;
96 static GOptionGroup *main_group;
98 static const GOptionEntry argument_main_table[] = {
99 /* *INDENT-OFF* */
100 /* generic options */
102 "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
103 &mc_args__show_version,
104 N_("Displays the current version"),
105 NULL
108 /* options for wrappers */
110 "datadir", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
111 &mc_args__show_datadirs,
112 N_("Print data directory"),
113 NULL
116 /* show extended information about used data directories */
118 "datadir-info", 'F', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
119 &mc_args__show_datadirs_extended,
120 N_("Print extended info about used data directories"),
121 NULL
124 /* show configure options */
126 "configure-options", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
127 &mc_args__show_configure_opts,
128 N_("Print configure options"),
129 NULL
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 "<file>"
139 #ifdef HAVE_SUBSHELL_SUPPORT
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 "<file>"
163 #endif /* ENABLE_VFS_FTP */
164 #ifdef ENABLE_VFS_SMB
166 "debuglevel", 'D', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT,
167 &mc_args__debug_level,
168 N_("Set debug level"),
169 "<integer>"
171 #endif /* ENABLE_VFS_SMB */
173 /* single file operations */
175 "view", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK,
176 parse_mc_v_argument,
177 N_("Launches the file viewer on a file"),
178 "<file>"
182 "edit", 'e', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
183 parse_mc_e_argument,
184 N_("Edit files"),
185 "<file> ..." },
188 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
190 /* *INDENT-ON* */
193 GOptionGroup *terminal_group;
194 #define ARGS_TERM_OPTIONS 0
195 static const GOptionEntry argument_terminal_table[] = {
196 /* *INDENT-OFF* */
197 /* terminal options */
199 "xterm", 'x', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
200 &mc_args__force_xterm,
201 N_("Forces xterm features"),
202 NULL
206 "no-x11", 'X', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
207 &mc_global.tty.disable_x11,
208 N_("Disable X11 support"),
209 NULL
213 "oldmouse", 'g', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
214 &mc_global.tty.old_mouse,
215 N_("Tries to use an old highlight mouse tracking"),
216 NULL
220 "nomouse", 'd', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
221 &mc_args__nomouse,
222 N_("Disable mouse support in text version"),
223 NULL
226 #ifdef HAVE_SLANG
228 "termcap", 't', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
229 &SLtt_Try_Termcap,
230 N_("Tries to use termcap instead of terminfo"),
231 NULL
233 #endif
236 "slow", 's', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
237 &mc_global.tty.slow_terminal,
238 N_("To run on slow terminals"),
239 NULL
243 "stickchars", 'a', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
244 &mc_global.tty.ugly_line_drawing,
245 N_("Use stickchars to draw"),
246 NULL
250 "resetsoft", 'k', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
251 &reset_hp_softkeys,
252 N_("Resets soft keys on HP terminals"),
253 NULL
257 "keymap", 'K', ARGS_TERM_OPTIONS, G_OPTION_ARG_STRING,
258 &mc_args__keymap_file,
259 N_("Load definitions of key bindings from specified file"),
260 "<file>"
264 "nokeymap", '\0', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
265 &mc_args__nokeymap,
266 N_("Don't load definitions of key bindings from file, use defaults"),
267 NULL
271 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
273 /* *INDENT-ON* */
276 #undef ARGS_TERM_OPTIONS
278 GOptionGroup *color_group;
279 #define ARGS_COLOR_OPTIONS 0
280 /* #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN */
281 static const GOptionEntry argument_color_table[] = {
282 /* *INDENT-OFF* */
283 /* color options */
285 "nocolor", 'b', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
286 &mc_global.tty.disable_colors,
287 N_("Requests to run in black and white"),
288 NULL
292 "color", 'c', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
293 &mc_args__force_colors,
294 N_("Request to run in color mode"),
295 NULL
299 "colors", 'C', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
300 &mc_global.tty.command_line_colors,
301 N_("Specifies a color configuration"),
302 "<string>"
306 "skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
307 &mc_global.tty.skin,
308 N_("Show mc with specified skin"),
309 "<string>"
313 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
315 /* *INDENT-ON* */
318 #undef ARGS_COLOR_OPTIONS
320 static gchar *mc_args__loc__colors_string = NULL;
321 static gchar *mc_args__loc__footer_string = NULL;
322 static gchar *mc_args__loc__header_string = NULL;
323 static gchar *mc_args__loc__usage_string = NULL;
325 /*** file scope functions ************************************************************************/
327 /* --------------------------------------------------------------------------------------------- */
328 static void
329 mc_args_clean_temp_help_strings (void)
331 g_free (mc_args__loc__colors_string);
332 mc_args__loc__colors_string = NULL;
334 g_free (mc_args__loc__footer_string);
335 mc_args__loc__footer_string = NULL;
337 g_free (mc_args__loc__header_string);
338 mc_args__loc__header_string = NULL;
340 g_free (mc_args__loc__usage_string);
341 mc_args__loc__usage_string = NULL;
344 /* --------------------------------------------------------------------------------------------- */
346 static GOptionGroup *
347 mc_args_new_color_group (void)
349 /* *INDENT-OFF* */
350 /* FIXME: to preserve translations, lines should be split. */
351 mc_args__loc__colors_string = g_strdup_printf ("%s\n%s",
352 /* TRANSLATORS: don't translate keywords */
353 _("--colors KEYWORD={FORE},{BACK},{ATTR}:KEYWORD2=...\n\n"
354 "{FORE}, {BACK} and {ATTR} can be omitted, and the default will be used\n"
355 "\n Keywords:\n"
356 " Global: errors, disabled, reverse, gauge, header\n"
357 " input, inputmark, inputunchanged, commandlinemark\n"
358 " bbarhotkey, bbarbutton, statusbar\n"
359 " File display: normal, selected, marked, markselect\n"
360 " Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"
361 " errdhotfocus\n"
362 " Menus: menunormal, menuhot, menusel, menuhotsel, menuinactive\n"
363 " Popup menus: pmenunormal, pmenusel, pmenutitle\n"
364 " Editor: editnormal, editbold, editmarked, editwhitespace,\n"
365 " editlinestate, editbg, editframe, editframeactive\n"
366 " editframedrag\n"
367 " Viewer: viewbold, viewunderline, viewselected\n"
368 " Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n"),
369 /* TRANSLATORS: don't translate color names and attributes */
370 _("Standard Colors:\n"
371 " black, gray, red, brightred, green, brightgreen, brown,\n"
372 " yellow, blue, brightblue, magenta, brightmagenta, cyan,\n"
373 " brightcyan, lightgray and white\n\n"
374 "Extended colors, when 256 colors are available:\n"
375 " color16 to color255, or rgb000 to rgb555 and gray0 to gray23\n\n"
376 "Attributes:\n"
377 " bold, underline, reverse, blink; append more with '+'\n")
379 /* *INDENT-ON* */
381 return g_option_group_new ("color", mc_args__loc__colors_string,
382 _("Color options"), NULL, NULL);
386 /* --------------------------------------------------------------------------------------------- */
388 static gchar *
389 mc_args_add_usage_info (void)
391 mc_args__loc__usage_string = g_strdup_printf ("[%s] %s\n %s - %s\n",
392 _("+number"),
393 _("[this_dir] [other_panel_dir]"),
394 _("+number"),
396 ("Set initial line number for the internal editor"));
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 = g_strdup_printf (_("GNU Midnight Commander %s\n"), VERSION);
412 #if GLIB_CHECK_VERSION(2,12,0)
413 g_option_context_set_description (context, mc_args__loc__footer_string);
414 g_option_context_set_summary (context, mc_args__loc__header_string);
415 #endif
418 /* --------------------------------------------------------------------------------------------- */
420 static gchar *
421 mc_args__convert_help_to_syscharset (const gchar * charset, const gchar * error_message,
422 const gchar * help_str)
424 GString *buffer;
425 GIConv conv;
426 gchar *full_help_str;
428 buffer = g_string_new ("");
429 conv = g_iconv_open (charset, "UTF-8");
430 full_help_str = g_strdup_printf ("%s\n\n%s\n", error_message, help_str);
432 str_convert (conv, full_help_str, buffer);
434 g_free (full_help_str);
435 g_iconv_close (conv);
437 return g_string_free (buffer, FALSE);
440 /* --------------------------------------------------------------------------------------------- */
442 static gboolean
443 parse_mc_e_argument (const gchar * option_name, const gchar * value, gpointer data, GError ** error)
445 (void) option_name;
446 (void) value;
447 (void) data;
448 (void) error;
450 mc_global.mc_run_mode = MC_RUN_EDITOR;
452 return TRUE;
455 /* --------------------------------------------------------------------------------------------- */
457 static gboolean
458 parse_mc_v_argument (const gchar * option_name, const gchar * value, gpointer data, GError ** error)
460 (void) option_name;
461 (void) data;
462 (void) error;
464 mc_global.mc_run_mode = MC_RUN_VIEWER;
465 mc_run_param0 = g_strdup (value);
467 return TRUE;
470 /* --------------------------------------------------------------------------------------------- */
472 * Get list of filenames (and line numbers) from command line, when mc called as editor
474 * @param argc count of all arguments
475 * @param argv array of strings, contains arguments
476 * @return list of mcedit_arg_t objects
479 static GList *
480 parse_mcedit_arguments (int argc, char **argv)
482 GList *flist = NULL;
483 int i;
484 long first_line_number = -1;
486 for (i = 0; i < argc; i++)
488 char *tmp;
489 char *end, *p;
490 mcedit_arg_t *arg;
492 tmp = argv[i];
495 * First, try to get line number as +lineno.
497 if (*tmp == '+')
499 long lineno;
500 char *error;
502 lineno = strtol (tmp + 1, &error, 10);
504 if (*error == '\0')
506 /* this is line number */
507 first_line_number = lineno;
508 continue;
510 /* this is file name */
514 * Check for filename:lineno, followed by an optional colon.
515 * This format is used by many programs (especially compilers)
516 * in error messages and warnings. It is supported so that
517 * users can quickly copy and paste file locations.
519 end = tmp + strlen (tmp);
520 p = end;
522 if (p > tmp && p[-1] == ':')
523 p--;
524 while (p > tmp && g_ascii_isdigit ((gchar) p[-1]))
525 p--;
527 if (tmp < p && p < end && p[-1] == ':')
529 char *fname;
530 vfs_path_t *tmp_vpath, *fname_vpath;
531 struct stat st;
533 fname = g_strndup (tmp, p - 1 - tmp);
534 tmp_vpath = vfs_path_from_str (tmp);
535 fname_vpath = vfs_path_from_str (fname);
538 * Check that the file before the colon actually exists.
539 * If it doesn't exist, create new file.
541 if (mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1)
543 arg = mcedit_arg_vpath_new (fname_vpath, atoi (p));
544 vfs_path_free (tmp_vpath);
546 else
548 arg = mcedit_arg_vpath_new (tmp_vpath, 0);
549 vfs_path_free (fname_vpath);
552 g_free (fname);
554 else
555 arg = mcedit_arg_new (tmp, 0);
557 flist = g_list_prepend (flist, arg);
560 if (flist == NULL)
561 flist = g_list_prepend (flist, mcedit_arg_new (NULL, 0));
562 else if (first_line_number != -1)
564 /* overwrite line number for first file */
565 GList *l;
567 l = g_list_last (flist);
568 ((mcedit_arg_t *) l->data)->line_number = first_line_number;
571 return flist;
574 /* --------------------------------------------------------------------------------------------- */
575 /*** public functions ****************************************************************************/
576 /* --------------------------------------------------------------------------------------------- */
578 gboolean
579 mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError ** error)
581 const gchar *_system_codepage;
582 gboolean ok = TRUE;
584 _system_codepage = str_detect_termencoding ();
586 #ifdef ENABLE_NLS
587 if (!str_isutf8 (_system_codepage))
588 bind_textdomain_codeset ("mc", "UTF-8");
589 #endif
591 context = g_option_context_new (mc_args_add_usage_info ());
593 g_option_context_set_ignore_unknown_options (context, FALSE);
595 mc_args_add_extended_info_to_help ();
597 main_group = g_option_group_new ("main", _("Main options"), _("Main options"), NULL, NULL);
599 g_option_group_add_entries (main_group, argument_main_table);
600 g_option_context_set_main_group (context, main_group);
601 g_option_group_set_translation_domain (main_group, translation_domain);
603 terminal_group = g_option_group_new ("terminal", _("Terminal options"),
604 _("Terminal options"), NULL, NULL);
606 g_option_group_add_entries (terminal_group, argument_terminal_table);
607 g_option_context_add_group (context, terminal_group);
608 g_option_group_set_translation_domain (terminal_group, translation_domain);
610 color_group = mc_args_new_color_group ();
612 g_option_group_add_entries (color_group, argument_color_table);
613 g_option_context_add_group (context, color_group);
614 g_option_group_set_translation_domain (color_group, translation_domain);
616 if (!g_option_context_parse (context, argc, argv, error))
618 GError *error2 = NULL;
620 if (*error == NULL)
621 *error = g_error_new (MC_ERROR, 0, "%s\n", _("Arguments parse error!"));
622 else
624 gchar *help_str;
626 #if GLIB_CHECK_VERSION(2,14,0)
627 help_str = g_option_context_get_help (context, TRUE, NULL);
628 #else
629 help_str = g_strdup ("");
630 #endif
631 if (str_isutf8 (_system_codepage))
632 error2 = g_error_new ((*error)->domain, (*error)->code, "%s\n\n%s\n",
633 (*error)->message, help_str);
634 else
636 gchar *full_help_str;
638 full_help_str =
639 mc_args__convert_help_to_syscharset (_system_codepage, (*error)->message,
640 help_str);
641 error2 = g_error_new ((*error)->domain, (*error)->code, "%s", full_help_str);
642 g_free (full_help_str);
645 g_free (help_str);
646 g_error_free (*error);
647 *error = error2;
650 ok = FALSE;
653 g_option_context_free (context);
654 mc_args_clean_temp_help_strings ();
656 #ifdef ENABLE_NLS
657 if (!str_isutf8 (_system_codepage))
658 bind_textdomain_codeset ("mc", _system_codepage);
659 #endif
661 return ok;
664 /* --------------------------------------------------------------------------------------------- */
666 gboolean
667 mc_args_show_info (void)
669 if (mc_args__show_version)
671 show_version ();
672 return FALSE;
675 if (mc_args__show_datadirs)
677 printf ("%s (%s)\n", mc_global.sysconfig_dir, mc_global.share_data_dir);
678 return FALSE;
681 if (mc_args__show_datadirs_extended)
683 show_datadirs_extended ();
684 return FALSE;
687 if (mc_args__show_configure_opts)
689 show_configure_options ();
690 return FALSE;
693 return TRUE;
696 /* --------------------------------------------------------------------------------------------- */
698 gboolean
699 mc_setup_by_args (int argc, char **argv, GError ** error)
701 const char *base;
702 char *tmp;
704 if (mc_args__force_colors)
705 mc_global.tty.disable_colors = FALSE;
707 #ifdef HAVE_SUBSHELL_SUPPORT
708 if (mc_args__nouse_subshell)
709 mc_global.tty.use_subshell = FALSE;
710 #endif /* HAVE_SUBSHELL_SUPPORT */
712 #ifdef ENABLE_VFS_SMB
713 if (mc_args__debug_level != 0)
714 smbfs_set_debug (mc_args__debug_level);
715 #endif /* ENABLE_VFS_SMB */
717 if (mc_args__netfs_logfile != NULL)
719 vfs_path_t *vpath;
720 #ifdef ENABLE_VFS_FTP
721 vpath = vfs_path_from_str ("ftp://");
722 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
723 vfs_path_free (vpath);
724 #endif /* ENABLE_VFS_FTP */
725 #ifdef ENABLE_VFS_SMB
726 vpath = vfs_path_from_str ("smb://");
727 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
728 vfs_path_free (vpath);
729 #endif /* ENABLE_VFS_SMB */
730 (void) vpath;
733 base = x_basename (argv[0]);
734 tmp = (argc > 0) ? argv[1] : NULL;
736 if (strncmp (base, "mce", 3) == 0 || strcmp (base, "vi") == 0)
738 /* mce* or vi is link to mc */
740 mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
741 mc_global.mc_run_mode = MC_RUN_EDITOR;
743 else if (strncmp (base, "mcv", 3) == 0 || strcmp (base, "view") == 0)
745 /* mcv* or view is link to mc */
747 if (tmp != NULL)
748 mc_run_param0 = g_strdup (tmp);
749 else
751 *error = g_error_new (MC_ERROR, 0, "%s\n", _("No arguments given to the viewer."));
752 return FALSE;
754 mc_global.mc_run_mode = MC_RUN_VIEWER;
756 #ifdef USE_DIFF_VIEW
757 else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
759 /* mcd* or diff is link to mc */
761 if (argc < 3)
763 *error = g_error_new (MC_ERROR, 0, "%s\n",
764 _("Two files are required to evoke the diffviewer."));
765 return FALSE;
768 if (tmp != NULL)
770 mc_run_param0 = g_strdup (tmp);
771 tmp = (argc > 1) ? argv[2] : NULL;
772 if (tmp != NULL)
773 mc_run_param1 = g_strdup (tmp);
774 mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
777 #endif /* USE_DIFF_VIEW */
778 else
780 /* MC is run as mc */
782 switch (mc_global.mc_run_mode)
784 case MC_RUN_EDITOR:
785 mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
786 break;
788 case MC_RUN_VIEWER:
789 /* mc_run_param0 is set up in parse_mc_v_argument() */
790 break;
792 case MC_RUN_DIFFVIEWER:
793 /* not implemented yet */
794 break;
796 case MC_RUN_FULL:
797 default:
798 /* sets the current dir and the other dir */
799 if (tmp != NULL)
801 mc_run_param0 = g_strdup (tmp);
802 tmp = (argc > 1) ? argv[2] : NULL;
803 if (tmp != NULL)
804 mc_run_param1 = g_strdup (tmp);
806 mc_global.mc_run_mode = MC_RUN_FULL;
807 break;
811 return TRUE;
814 /* --------------------------------------------------------------------------------------------- */
816 * Create mcedit_arg_t object from file name and the line number.
818 * @param file_name file name
819 * @param line_number line number. If value is 0, try to restore saved position.
820 * @return mcedit_arg_t object
823 mcedit_arg_t *
824 mcedit_arg_new (const char *file_name, long line_number)
826 return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number);
829 /* --------------------------------------------------------------------------------------------- */
831 * Create mcedit_arg_t object from vfs_path_t object and the line number.
833 * @param file_vpath file path object
834 * @param line_number line number. If value is 0, try to restore saved position.
835 * @return mcedit_arg_t object
838 mcedit_arg_t *
839 mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number)
841 mcedit_arg_t *arg;
843 arg = g_new (mcedit_arg_t, 1);
844 arg->file_vpath = file_vpath;
845 arg->line_number = line_number;
847 return arg;
850 /* --------------------------------------------------------------------------------------------- */
852 * Free the mcedit_arg_t object.
854 * @param arg mcedit_arg_t object
857 void
858 mcedit_arg_free (mcedit_arg_t * arg)
860 vfs_path_free (arg->file_vpath);
861 g_free (arg);
864 /* --------------------------------------------------------------------------------------------- */