Merge branch '3416_find_accents'
[midnight-commander.git] / src / args.c
blobfca9f50a41b494306bbd874d3550fffee56e0152
1 /*
2 Handle command line arguments.
4 Copyright (C) 2009-2015
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, show version info and exit */
50 gboolean mc_args__show_version = FALSE;
52 /* If true, assume we are running on an xterm terminal */
53 gboolean mc_args__force_xterm = FALSE;
55 gboolean mc_args__nomouse = FALSE;
57 /* Force colors, only used by Slang */
58 gboolean mc_args__force_colors = FALSE;
60 /* Don't load keymap form file and use default one */
61 gboolean mc_args__nokeymap = FALSE;
63 char *mc_args__last_wd_file = NULL;
65 /* when enabled NETCODE, use folowing file as logfile */
66 char *mc_args__netfs_logfile = NULL;
68 /* keymap file */
69 char *mc_args__keymap_file = NULL;
71 /* Debug level */
72 int mc_args__debug_level = 0;
74 void *mc_run_param0 = NULL;
75 char *mc_run_param1 = NULL;
77 /*** file scope macro definitions ****************************************************************/
79 /*** file scope type declarations ****************************************************************/
81 /*** file scope variables ************************************************************************/
83 /* forward declarations */
84 static gboolean parse_mc_e_argument (const gchar * option_name, const gchar * value,
85 gpointer data, GError ** mcerror);
86 static gboolean parse_mc_v_argument (const gchar * option_name, const gchar * value,
87 gpointer data, GError ** mcerror);
89 static GOptionContext *context;
91 #ifdef ENABLE_SUBSHELL
92 static gboolean mc_args__nouse_subshell = FALSE;
93 #endif /* ENABLE_SUBSHELL */
94 static gboolean mc_args__show_datadirs = FALSE;
95 static gboolean mc_args__show_datadirs_extended = FALSE;
96 static gboolean mc_args__show_configure_opts = FALSE;
98 static GOptionGroup *main_group;
100 static const GOptionEntry argument_main_table[] = {
101 /* *INDENT-OFF* */
102 /* generic options */
104 "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
105 &mc_args__show_version,
106 N_("Displays the current version"),
107 NULL
110 /* options for wrappers */
112 "datadir", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
113 &mc_args__show_datadirs,
114 N_("Print data directory"),
115 NULL
118 /* show extended information about used data directories */
120 "datadir-info", 'F', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
121 &mc_args__show_datadirs_extended,
122 N_("Print extended info about used data directories"),
123 NULL
126 /* show configure options */
128 "configure-options", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
129 &mc_args__show_configure_opts,
130 N_("Print configure options"),
131 NULL
135 "printwd", 'P', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
136 &mc_args__last_wd_file,
137 N_("Print last working directory to specified file"),
138 "<file>"
141 #ifdef ENABLE_SUBSHELL
143 "subshell", 'U', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
144 &mc_global.tty.use_subshell,
145 N_("Enables subshell support (default)"),
146 NULL
150 "nosubshell", 'u', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
151 &mc_args__nouse_subshell,
152 N_("Disables subshell support"),
153 NULL
155 #endif
157 /* debug options */
158 #ifdef ENABLE_VFS_FTP
160 "ftplog", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
161 &mc_args__netfs_logfile,
162 N_("Log ftp dialog to specified file"),
163 "<file>"
165 #endif /* ENABLE_VFS_FTP */
166 #ifdef ENABLE_VFS_SMB
168 "debuglevel", 'D', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT,
169 &mc_args__debug_level,
170 N_("Set debug level"),
171 "<integer>"
173 #endif /* ENABLE_VFS_SMB */
175 /* single file operations */
177 "view", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK,
178 parse_mc_v_argument,
179 N_("Launches the file viewer on a file"),
180 "<file>"
184 "edit", 'e', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
185 parse_mc_e_argument,
186 N_("Edit files"),
187 "<file> ..." },
190 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
192 /* *INDENT-ON* */
195 GOptionGroup *terminal_group;
196 #define ARGS_TERM_OPTIONS 0
197 static const GOptionEntry argument_terminal_table[] = {
198 /* *INDENT-OFF* */
199 /* terminal options */
201 "xterm", 'x', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
202 &mc_args__force_xterm,
203 N_("Forces xterm features"),
204 NULL
208 "no-x11", 'X', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
209 &mc_global.tty.disable_x11,
210 N_("Disable X11 support"),
211 NULL
215 "oldmouse", 'g', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
216 &mc_global.tty.old_mouse,
217 N_("Tries to use an old highlight mouse tracking"),
218 NULL
222 "nomouse", 'd', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
223 &mc_args__nomouse,
224 N_("Disable mouse support in text version"),
225 NULL
228 #ifdef HAVE_SLANG
230 "termcap", 't', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
231 &SLtt_Try_Termcap,
232 N_("Tries to use termcap instead of terminfo"),
233 NULL
235 #endif
238 "slow", 's', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
239 &mc_global.tty.slow_terminal,
240 N_("To run on slow terminals"),
241 NULL
245 "stickchars", 'a', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
246 &mc_global.tty.ugly_line_drawing,
247 N_("Use stickchars to draw"),
248 NULL
252 "resetsoft", 'k', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
253 &reset_hp_softkeys,
254 N_("Resets soft keys on HP terminals"),
255 NULL
259 "keymap", 'K', ARGS_TERM_OPTIONS, G_OPTION_ARG_STRING,
260 &mc_args__keymap_file,
261 N_("Load definitions of key bindings from specified file"),
262 "<file>"
266 "nokeymap", '\0', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
267 &mc_args__nokeymap,
268 N_("Don't load definitions of key bindings from file, use defaults"),
269 NULL
273 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
275 /* *INDENT-ON* */
278 #undef ARGS_TERM_OPTIONS
280 GOptionGroup *color_group;
281 #define ARGS_COLOR_OPTIONS 0
282 /* #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN */
283 static const GOptionEntry argument_color_table[] = {
284 /* *INDENT-OFF* */
285 /* color options */
287 "nocolor", 'b', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
288 &mc_global.tty.disable_colors,
289 N_("Requests to run in black and white"),
290 NULL
294 "color", 'c', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
295 &mc_args__force_colors,
296 N_("Request to run in color mode"),
297 NULL
301 "colors", 'C', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
302 &mc_global.tty.command_line_colors,
303 N_("Specifies a color configuration"),
304 "<string>"
308 "skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
309 &mc_global.tty.skin,
310 N_("Show mc with specified skin"),
311 "<string>"
315 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
317 /* *INDENT-ON* */
320 #undef ARGS_COLOR_OPTIONS
322 static gchar *mc_args__loc__colors_string = NULL;
323 static gchar *mc_args__loc__footer_string = NULL;
324 static gchar *mc_args__loc__header_string = NULL;
325 static gchar *mc_args__loc__usage_string = NULL;
327 /*** file scope functions ************************************************************************/
329 /* --------------------------------------------------------------------------------------------- */
330 static void
331 mc_args_clean_temp_help_strings (void)
333 MC_PTR_FREE (mc_args__loc__colors_string);
334 MC_PTR_FREE (mc_args__loc__footer_string);
335 MC_PTR_FREE (mc_args__loc__header_string);
336 MC_PTR_FREE (mc_args__loc__usage_string);
339 /* --------------------------------------------------------------------------------------------- */
341 static GOptionGroup *
342 mc_args_new_color_group (void)
344 /* *INDENT-OFF* */
345 /* FIXME: to preserve translations, lines should be split. */
346 mc_args__loc__colors_string = g_strdup_printf ("%s\n%s",
347 /* TRANSLATORS: don't translate keywords */
348 _("--colors KEYWORD={FORE},{BACK},{ATTR}:KEYWORD2=...\n\n"
349 "{FORE}, {BACK} and {ATTR} can be omitted, and the default will be used\n"
350 "\n Keywords:\n"
351 " Global: errors, disabled, reverse, gauge, header\n"
352 " input, inputmark, inputunchanged, commandlinemark\n"
353 " bbarhotkey, bbarbutton, statusbar\n"
354 " File display: normal, selected, marked, markselect\n"
355 " Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"
356 " errdhotfocus\n"
357 " Menus: menunormal, menuhot, menusel, menuhotsel, menuinactive\n"
358 " Popup menus: pmenunormal, pmenusel, pmenutitle\n"
359 " Editor: editnormal, editbold, editmarked, editwhitespace,\n"
360 " editlinestate, editbg, editframe, editframeactive\n"
361 " editframedrag\n"
362 " Viewer: viewnormal,viewbold, viewunderline, viewselected\n"
363 " Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n"),
364 /* TRANSLATORS: don't translate color names and attributes */
365 _("Standard Colors:\n"
366 " black, gray, red, brightred, green, brightgreen, brown,\n"
367 " yellow, blue, brightblue, magenta, brightmagenta, cyan,\n"
368 " brightcyan, lightgray and white\n\n"
369 "Extended colors, when 256 colors are available:\n"
370 " color16 to color255, or rgb000 to rgb555 and gray0 to gray23\n\n"
371 "Attributes:\n"
372 " bold, italic, underline, reverse, blink; append more with '+'\n")
374 /* *INDENT-ON* */
376 return g_option_group_new ("color", mc_args__loc__colors_string,
377 _("Color options"), NULL, NULL);
381 /* --------------------------------------------------------------------------------------------- */
383 static gchar *
384 mc_args_add_usage_info (void)
386 mc_args__loc__usage_string = g_strdup_printf ("[%s] %s\n %s - %s\n",
387 _("+number"),
388 _("[this_dir] [other_panel_dir]"),
389 _("+number"),
391 ("Set initial line number for the internal editor"));
392 return mc_args__loc__usage_string;
395 /* --------------------------------------------------------------------------------------------- */
397 static void
398 mc_args_add_extended_info_to_help (void)
400 mc_args__loc__footer_string = g_strdup_printf ("%s",
402 ("\n"
403 "Please send any bug reports (including the output of 'mc -V')\n"
404 "as tickets at www.midnight-commander.org\n"));
405 mc_args__loc__header_string = g_strdup_printf (_("GNU Midnight Commander %s\n"), VERSION);
407 g_option_context_set_description (context, mc_args__loc__footer_string);
408 g_option_context_set_summary (context, mc_args__loc__header_string);
411 /* --------------------------------------------------------------------------------------------- */
413 static gchar *
414 mc_args__convert_help_to_syscharset (const gchar * charset, const gchar * error_message_str,
415 const gchar * help_str)
417 GString *buffer;
418 GIConv conv;
419 gchar *full_help_str;
421 buffer = g_string_new ("");
422 conv = g_iconv_open (charset, "UTF-8");
423 full_help_str = g_strdup_printf ("%s\n\n%s\n", error_message_str, help_str);
425 str_convert (conv, full_help_str, buffer);
427 g_free (full_help_str);
428 g_iconv_close (conv);
430 return g_string_free (buffer, FALSE);
433 /* --------------------------------------------------------------------------------------------- */
435 static gboolean
436 parse_mc_e_argument (const gchar * option_name, const gchar * value, gpointer data,
437 GError ** mcerror)
439 (void) option_name;
440 (void) value;
441 (void) data;
443 mc_return_val_if_error (mcerror, FALSE);
445 mc_global.mc_run_mode = MC_RUN_EDITOR;
447 return TRUE;
450 /* --------------------------------------------------------------------------------------------- */
452 static gboolean
453 parse_mc_v_argument (const gchar * option_name, const gchar * value, gpointer data,
454 GError ** mcerror)
456 (void) option_name;
457 (void) data;
459 mc_return_val_if_error (mcerror, FALSE);
461 mc_global.mc_run_mode = MC_RUN_VIEWER;
462 mc_run_param0 = g_strdup (value);
464 return TRUE;
467 /* --------------------------------------------------------------------------------------------- */
469 * Get list of filenames (and line numbers) from command line, when mc called as editor
471 * @param argc count of all arguments
472 * @param argv array of strings, contains arguments
473 * @return list of mcedit_arg_t objects
476 static GList *
477 parse_mcedit_arguments (int argc, char **argv)
479 GList *flist = NULL;
480 int i;
481 long first_line_number = -1;
483 for (i = 0; i < argc; i++)
485 char *tmp;
486 char *end, *p;
487 mcedit_arg_t *arg;
489 tmp = argv[i];
492 * First, try to get line number as +lineno.
494 if (*tmp == '+')
496 long lineno;
497 char *error;
499 lineno = strtol (tmp + 1, &error, 10);
501 if (*error == '\0')
503 /* this is line number */
504 first_line_number = lineno;
505 continue;
507 /* this is file name */
511 * Check for filename:lineno, followed by an optional colon.
512 * This format is used by many programs (especially compilers)
513 * in error messages and warnings. It is supported so that
514 * users can quickly copy and paste file locations.
516 end = tmp + strlen (tmp);
517 p = end;
519 if (p > tmp && p[-1] == ':')
520 p--;
521 while (p > tmp && g_ascii_isdigit ((gchar) p[-1]))
522 p--;
524 if (tmp < p && p < end && p[-1] == ':')
526 char *fname;
527 vfs_path_t *tmp_vpath, *fname_vpath;
528 struct stat st;
530 fname = g_strndup (tmp, p - 1 - tmp);
531 tmp_vpath = vfs_path_from_str (tmp);
532 fname_vpath = vfs_path_from_str (fname);
535 * Check that the file before the colon actually exists.
536 * If it doesn't exist, create new file.
538 if (mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1)
540 arg = mcedit_arg_vpath_new (fname_vpath, atoi (p));
541 vfs_path_free (tmp_vpath);
543 else
545 arg = mcedit_arg_vpath_new (tmp_vpath, 0);
546 vfs_path_free (fname_vpath);
549 g_free (fname);
551 else
552 arg = mcedit_arg_new (tmp, 0);
554 flist = g_list_prepend (flist, arg);
557 if (flist == NULL)
558 flist = g_list_prepend (flist, mcedit_arg_new (NULL, 0));
559 else if (first_line_number != -1)
561 /* overwrite line number for first file */
562 GList *l;
564 l = g_list_last (flist);
565 ((mcedit_arg_t *) l->data)->line_number = first_line_number;
568 return flist;
571 /* --------------------------------------------------------------------------------------------- */
572 /*** public functions ****************************************************************************/
573 /* --------------------------------------------------------------------------------------------- */
575 gboolean
576 mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError ** mcerror)
578 const gchar *_system_codepage;
579 gboolean ok = TRUE;
581 mc_return_val_if_error (mcerror, FALSE);
583 _system_codepage = str_detect_termencoding ();
585 #ifdef ENABLE_NLS
586 if (!str_isutf8 (_system_codepage))
587 bind_textdomain_codeset ("mc", "UTF-8");
588 #endif
590 context = g_option_context_new (mc_args_add_usage_info ());
592 g_option_context_set_ignore_unknown_options (context, FALSE);
594 mc_args_add_extended_info_to_help ();
596 main_group = g_option_group_new ("main", _("Main options"), _("Main options"), NULL, NULL);
598 g_option_group_add_entries (main_group, argument_main_table);
599 g_option_context_set_main_group (context, main_group);
600 g_option_group_set_translation_domain (main_group, translation_domain);
602 terminal_group = g_option_group_new ("terminal", _("Terminal options"),
603 _("Terminal options"), NULL, NULL);
605 g_option_group_add_entries (terminal_group, argument_terminal_table);
606 g_option_context_add_group (context, terminal_group);
607 g_option_group_set_translation_domain (terminal_group, translation_domain);
609 color_group = mc_args_new_color_group ();
611 g_option_group_add_entries (color_group, argument_color_table);
612 g_option_context_add_group (context, color_group);
613 g_option_group_set_translation_domain (color_group, translation_domain);
615 if (!g_option_context_parse (context, argc, argv, mcerror))
618 if (*mcerror == NULL)
619 mc_propagate_error (mcerror, 0, "%s\n", _("Arguments parse error!"));
620 else
622 gchar *help_str;
624 help_str = g_option_context_get_help (context, TRUE, NULL);
626 if (str_isutf8 (_system_codepage))
627 mc_replace_error (mcerror, (*mcerror)->code, "%s\n\n%s\n", (*mcerror)->message,
628 help_str);
629 else
631 gchar *full_help_str;
633 full_help_str =
634 mc_args__convert_help_to_syscharset (_system_codepage, (*mcerror)->message,
635 help_str);
636 mc_replace_error (mcerror, (*mcerror)->code, "%s", full_help_str);
637 g_free (full_help_str);
639 g_free (help_str);
642 ok = FALSE;
645 g_option_context_free (context);
646 mc_args_clean_temp_help_strings ();
648 #ifdef ENABLE_NLS
649 if (!str_isutf8 (_system_codepage))
650 bind_textdomain_codeset ("mc", _system_codepage);
651 #endif
653 return ok;
656 /* --------------------------------------------------------------------------------------------- */
658 gboolean
659 mc_args_show_info (void)
661 if (mc_args__show_version)
663 show_version ();
664 return FALSE;
667 if (mc_args__show_datadirs)
669 printf ("%s (%s)\n", mc_global.sysconfig_dir, mc_global.share_data_dir);
670 return FALSE;
673 if (mc_args__show_datadirs_extended)
675 show_datadirs_extended ();
676 return FALSE;
679 if (mc_args__show_configure_opts)
681 show_configure_options ();
682 return FALSE;
685 return TRUE;
688 /* --------------------------------------------------------------------------------------------- */
690 gboolean
691 mc_setup_by_args (int argc, char **argv, GError ** mcerror)
693 const char *base;
694 char *tmp;
696 mc_return_val_if_error (mcerror, FALSE);
698 if (mc_args__force_colors)
699 mc_global.tty.disable_colors = FALSE;
701 #ifdef ENABLE_SUBSHELL
702 if (mc_args__nouse_subshell)
703 mc_global.tty.use_subshell = FALSE;
704 #endif /* ENABLE_SUBSHELL */
706 #ifdef ENABLE_VFS_SMB
707 if (mc_args__debug_level != 0)
708 smbfs_set_debug (mc_args__debug_level);
709 #endif /* ENABLE_VFS_SMB */
711 if (mc_args__netfs_logfile != NULL)
713 vfs_path_t *vpath;
714 #ifdef ENABLE_VFS_FTP
715 vpath = vfs_path_from_str ("ftp://");
716 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
717 vfs_path_free (vpath);
718 #endif /* ENABLE_VFS_FTP */
719 #ifdef ENABLE_VFS_SMB
720 vpath = vfs_path_from_str ("smb://");
721 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
722 vfs_path_free (vpath);
723 #endif /* ENABLE_VFS_SMB */
724 (void) vpath;
727 base = x_basename (argv[0]);
728 tmp = (argc > 0) ? argv[1] : NULL;
730 if (strncmp (base, "mce", 3) == 0 || strcmp (base, "vi") == 0)
732 /* mce* or vi is link to mc */
734 mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
735 mc_global.mc_run_mode = MC_RUN_EDITOR;
737 else if (strncmp (base, "mcv", 3) == 0 || strcmp (base, "view") == 0)
739 /* mcv* or view is link to mc */
741 if (tmp != NULL)
742 mc_run_param0 = g_strdup (tmp);
743 else
745 mc_propagate_error (mcerror, 0, "%s\n", _("No arguments given to the viewer."));
746 return FALSE;
748 mc_global.mc_run_mode = MC_RUN_VIEWER;
750 #ifdef USE_DIFF_VIEW
751 else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
753 /* mcd* or diff is link to mc */
755 if (argc < 3)
757 mc_propagate_error (mcerror, 0, "%s\n",
758 _("Two files are required to evoke the diffviewer."));
759 return FALSE;
762 if (tmp != NULL)
764 mc_run_param0 = g_strdup (tmp);
765 tmp = (argc > 1) ? argv[2] : NULL;
766 if (tmp != NULL)
767 mc_run_param1 = g_strdup (tmp);
768 mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
771 #endif /* USE_DIFF_VIEW */
772 else
774 /* MC is run as mc */
776 switch (mc_global.mc_run_mode)
778 case MC_RUN_EDITOR:
779 mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
780 break;
782 case MC_RUN_VIEWER:
783 /* mc_run_param0 is set up in parse_mc_v_argument() */
784 break;
786 case MC_RUN_DIFFVIEWER:
787 /* not implemented yet */
788 break;
790 case MC_RUN_FULL:
791 default:
792 /* sets the current dir and the other dir */
793 if (tmp != NULL)
795 mc_run_param0 = g_strdup (tmp);
796 tmp = (argc > 1) ? argv[2] : NULL;
797 if (tmp != NULL)
798 mc_run_param1 = g_strdup (tmp);
800 mc_global.mc_run_mode = MC_RUN_FULL;
801 break;
805 return TRUE;
808 /* --------------------------------------------------------------------------------------------- */
810 * Create mcedit_arg_t object from file name and the line number.
812 * @param file_name file name
813 * @param line_number line number. If value is 0, try to restore saved position.
814 * @return mcedit_arg_t object
817 mcedit_arg_t *
818 mcedit_arg_new (const char *file_name, long line_number)
820 return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number);
823 /* --------------------------------------------------------------------------------------------- */
825 * Create mcedit_arg_t object from vfs_path_t object and the line number.
827 * @param file_vpath file path object
828 * @param line_number line number. If value is 0, try to restore saved position.
829 * @return mcedit_arg_t object
832 mcedit_arg_t *
833 mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number)
835 mcedit_arg_t *arg;
837 arg = g_new (mcedit_arg_t, 1);
838 arg->file_vpath = file_vpath;
839 arg->line_number = line_number;
841 return arg;
844 /* --------------------------------------------------------------------------------------------- */
846 * Free the mcedit_arg_t object.
848 * @param arg mcedit_arg_t object
851 void
852 mcedit_arg_free (mcedit_arg_t * arg)
854 vfs_path_free (arg->file_vpath);
855 g_free (arg);
858 /* --------------------------------------------------------------------------------------------- */