(extfs_find_entry_int): fix comparisons.
[midnight-commander.git] / src / args.c
blob7efe461de44b896ceade954bf2015b0d4d6b3252
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, 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 int mc_args__debug_level = 0;
71 void *mc_run_param0 = NULL;
72 char *mc_run_param1 = NULL;
74 /*** file scope macro definitions ****************************************************************/
76 /*** file scope type declarations ****************************************************************/
78 /*** file scope variables ************************************************************************/
80 /* If true, show version info and exit */
81 static gboolean mc_args__show_version = FALSE;
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 */
176 /* handle arguments manually */
177 "view", 'v', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
178 parse_mc_v_argument,
179 N_("Launches the file viewer on a file"),
180 "<file>"
184 /* handle arguments manually */
185 "edit", 'e', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
186 parse_mc_e_argument,
187 N_("Edit files"),
188 "<file> ..." },
191 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
193 /* *INDENT-ON* */
196 static GOptionGroup *terminal_group;
197 #define ARGS_TERM_OPTIONS 0
198 static const GOptionEntry argument_terminal_table[] = {
199 /* *INDENT-OFF* */
200 /* terminal options */
202 "xterm", 'x', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
203 &mc_args__force_xterm,
204 N_("Forces xterm features"),
205 NULL
209 "no-x11", 'X', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
210 &mc_global.tty.disable_x11,
211 N_("Disable X11 support"),
212 NULL
216 "oldmouse", 'g', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
217 &mc_global.tty.old_mouse,
218 N_("Tries to use an old highlight mouse tracking"),
219 NULL
223 "nomouse", 'd', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
224 &mc_args__nomouse,
225 N_("Disable mouse support in text version"),
226 NULL
229 #ifdef HAVE_SLANG
231 "termcap", 't', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
232 &SLtt_Try_Termcap,
233 N_("Tries to use termcap instead of terminfo"),
234 NULL
236 #endif
239 "slow", 's', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
240 &mc_global.tty.slow_terminal,
241 N_("To run on slow terminals"),
242 NULL
246 "stickchars", 'a', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
247 &mc_global.tty.ugly_line_drawing,
248 N_("Use stickchars to draw"),
249 NULL
252 #ifdef HAVE_SLANG
254 "resetsoft", 'k', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
255 &reset_hp_softkeys,
256 N_("Resets soft keys on HP terminals"),
257 NULL
259 #endif
262 "keymap", 'K', ARGS_TERM_OPTIONS, G_OPTION_ARG_STRING,
263 &mc_args__keymap_file,
264 N_("Load definitions of key bindings from specified file"),
265 "<file>"
269 "nokeymap", '\0', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
270 &mc_args__nokeymap,
271 N_("Don't load definitions of key bindings from file, use defaults"),
272 NULL
276 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
278 /* *INDENT-ON* */
281 #undef ARGS_TERM_OPTIONS
283 static GOptionGroup *color_group;
284 #define ARGS_COLOR_OPTIONS 0
285 /* #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN */
286 static const GOptionEntry argument_color_table[] = {
287 /* *INDENT-OFF* */
288 /* color options */
290 "nocolor", 'b', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
291 &mc_global.tty.disable_colors,
292 N_("Requests to run in black and white"),
293 NULL
297 "color", 'c', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
298 &mc_args__force_colors,
299 N_("Request to run in color mode"),
300 NULL
304 "colors", 'C', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
305 &mc_global.tty.command_line_colors,
306 N_("Specifies a color configuration"),
307 "<string>"
311 "skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
312 &mc_global.tty.skin,
313 N_("Show mc with specified skin"),
314 "<string>"
318 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
320 /* *INDENT-ON* */
323 #undef ARGS_COLOR_OPTIONS
325 static gchar *mc_args__loc__colors_string = NULL;
326 static gchar *mc_args__loc__footer_string = NULL;
327 static gchar *mc_args__loc__header_string = NULL;
328 static gchar *mc_args__loc__usage_string = NULL;
330 /*** file scope functions ************************************************************************/
332 /* --------------------------------------------------------------------------------------------- */
333 static void
334 mc_args_clean_temp_help_strings (void)
336 MC_PTR_FREE (mc_args__loc__colors_string);
337 MC_PTR_FREE (mc_args__loc__footer_string);
338 MC_PTR_FREE (mc_args__loc__header_string);
339 MC_PTR_FREE (mc_args__loc__usage_string);
342 /* --------------------------------------------------------------------------------------------- */
344 static GOptionGroup *
345 mc_args_new_color_group (void)
347 /* *INDENT-OFF* */
348 /* FIXME: to preserve translations, lines should be split. */
349 mc_args__loc__colors_string = g_strdup_printf ("%s\n%s",
350 /* TRANSLATORS: don't translate keywords */
351 _("--colors KEYWORD={FORE},{BACK},{ATTR}:KEYWORD2=...\n\n"
352 "{FORE}, {BACK} and {ATTR} can be omitted, and the default will be used\n"
353 "\n Keywords:\n"
354 " Global: errors, disabled, reverse, gauge, header\n"
355 " input, inputmark, inputunchanged, commandlinemark\n"
356 " bbarhotkey, bbarbutton, statusbar\n"
357 " File display: normal, selected, marked, markselect\n"
358 " Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"
359 " errdhotfocus\n"
360 " Menus: menunormal, menuhot, menusel, menuhotsel, menuinactive\n"
361 " Popup menus: pmenunormal, pmenusel, pmenutitle\n"
362 " Editor: editnormal, editbold, editmarked, editwhitespace,\n"
363 " editlinestate, editbg, editframe, editframeactive\n"
364 " editframedrag\n"
365 " Viewer: viewnormal,viewbold, viewunderline, viewselected\n"
366 " Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n"),
367 /* TRANSLATORS: don't translate color names and attributes */
368 _("Standard Colors:\n"
369 " black, gray, red, brightred, green, brightgreen, brown,\n"
370 " yellow, blue, brightblue, magenta, brightmagenta, cyan,\n"
371 " brightcyan, lightgray and white\n\n"
372 "Extended colors, when 256 colors are available:\n"
373 " color16 to color255, or rgb000 to rgb555 and gray0 to gray23\n\n"
374 "Attributes:\n"
375 " bold, italic, underline, reverse, blink; append more with '+'\n")
377 /* *INDENT-ON* */
379 return g_option_group_new ("color", mc_args__loc__colors_string,
380 _("Color options"), NULL, NULL);
384 /* --------------------------------------------------------------------------------------------- */
386 static gchar *
387 mc_args_add_usage_info (void)
389 mc_args__loc__usage_string = g_strdup_printf ("[%s] %s\n %s - %s\n",
390 _("+number"),
391 _("[this_dir] [other_panel_dir]"),
392 _("+number"),
394 ("Set initial line number for the internal editor"));
395 return mc_args__loc__usage_string;
398 /* --------------------------------------------------------------------------------------------- */
400 static void
401 mc_args_add_extended_info_to_help (void)
403 mc_args__loc__footer_string = g_strdup_printf ("%s",
405 ("\n"
406 "Please send any bug reports (including the output of 'mc -V')\n"
407 "as tickets at www.midnight-commander.org\n"));
408 mc_args__loc__header_string = g_strdup_printf (_("GNU Midnight Commander %s\n"), VERSION);
410 g_option_context_set_description (context, mc_args__loc__footer_string);
411 g_option_context_set_summary (context, mc_args__loc__header_string);
414 /* --------------------------------------------------------------------------------------------- */
416 static gchar *
417 mc_args__convert_help_to_syscharset (const gchar * charset, const gchar * error_message_str,
418 const gchar * help_str)
420 GString *buffer;
421 GIConv conv;
422 gchar *full_help_str;
424 buffer = g_string_new ("");
425 conv = g_iconv_open (charset, "UTF-8");
426 full_help_str = g_strdup_printf ("%s\n\n%s\n", error_message_str, help_str);
428 str_convert (conv, full_help_str, buffer);
430 g_free (full_help_str);
431 g_iconv_close (conv);
433 return g_string_free (buffer, FALSE);
436 /* --------------------------------------------------------------------------------------------- */
438 static gboolean
439 parse_mc_e_argument (const gchar * option_name, const gchar * value, gpointer data,
440 GError ** mcerror)
442 (void) option_name;
443 (void) value;
444 (void) data;
446 mc_return_val_if_error (mcerror, FALSE);
448 mc_global.mc_run_mode = MC_RUN_EDITOR;
450 return TRUE;
453 /* --------------------------------------------------------------------------------------------- */
455 static gboolean
456 parse_mc_v_argument (const gchar * option_name, const gchar * value, gpointer data,
457 GError ** mcerror)
459 (void) option_name;
460 (void) value;
461 (void) data;
463 mc_return_val_if_error (mcerror, FALSE);
465 mc_global.mc_run_mode = MC_RUN_VIEWER;
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 ** mcerror)
581 const gchar *_system_codepage;
582 gboolean ok = TRUE;
584 mc_return_val_if_error (mcerror, FALSE);
586 _system_codepage = str_detect_termencoding ();
588 #ifdef ENABLE_NLS
589 if (!str_isutf8 (_system_codepage))
590 bind_textdomain_codeset ("mc", "UTF-8");
591 #endif
593 context = g_option_context_new (mc_args_add_usage_info ());
595 g_option_context_set_ignore_unknown_options (context, FALSE);
597 mc_args_add_extended_info_to_help ();
599 main_group = g_option_group_new ("main", _("Main options"), _("Main options"), NULL, NULL);
601 g_option_group_add_entries (main_group, argument_main_table);
602 g_option_context_set_main_group (context, main_group);
603 g_option_group_set_translation_domain (main_group, translation_domain);
605 terminal_group = g_option_group_new ("terminal", _("Terminal options"),
606 _("Terminal options"), NULL, NULL);
608 g_option_group_add_entries (terminal_group, argument_terminal_table);
609 g_option_context_add_group (context, terminal_group);
610 g_option_group_set_translation_domain (terminal_group, translation_domain);
612 color_group = mc_args_new_color_group ();
614 g_option_group_add_entries (color_group, argument_color_table);
615 g_option_context_add_group (context, color_group);
616 g_option_group_set_translation_domain (color_group, translation_domain);
618 if (!g_option_context_parse (context, argc, argv, mcerror))
620 if (*mcerror == NULL)
621 mc_propagate_error (mcerror, 0, "%s\n", _("Arguments parse error!"));
622 else
624 gchar *help_str;
626 help_str = g_option_context_get_help (context, TRUE, NULL);
628 if (str_isutf8 (_system_codepage))
629 mc_replace_error (mcerror, (*mcerror)->code, "%s\n\n%s\n", (*mcerror)->message,
630 help_str);
631 else
633 gchar *full_help_str;
635 full_help_str =
636 mc_args__convert_help_to_syscharset (_system_codepage, (*mcerror)->message,
637 help_str);
638 mc_replace_error (mcerror, (*mcerror)->code, "%s", full_help_str);
639 g_free (full_help_str);
641 g_free (help_str);
644 ok = FALSE;
647 g_option_context_free (context);
648 mc_args_clean_temp_help_strings ();
650 #ifdef ENABLE_NLS
651 if (!str_isutf8 (_system_codepage))
652 bind_textdomain_codeset ("mc", _system_codepage);
653 #endif
655 return ok;
658 /* --------------------------------------------------------------------------------------------- */
660 gboolean
661 mc_args_show_info (void)
663 if (mc_args__show_version)
665 show_version ();
666 return FALSE;
669 if (mc_args__show_datadirs)
671 printf ("%s (%s)\n", mc_global.sysconfig_dir, mc_global.share_data_dir);
672 return FALSE;
675 if (mc_args__show_datadirs_extended)
677 show_datadirs_extended ();
678 return FALSE;
681 if (mc_args__show_configure_opts)
683 show_configure_options ();
684 return FALSE;
687 return TRUE;
690 /* --------------------------------------------------------------------------------------------- */
692 gboolean
693 mc_setup_by_args (int argc, char **argv, GError ** mcerror)
695 const char *base;
696 char *tmp;
698 mc_return_val_if_error (mcerror, FALSE);
700 if (mc_args__force_colors)
701 mc_global.tty.disable_colors = FALSE;
703 #ifdef ENABLE_SUBSHELL
704 if (mc_args__nouse_subshell)
705 mc_global.tty.use_subshell = FALSE;
706 #endif /* ENABLE_SUBSHELL */
708 #ifdef ENABLE_VFS_SMB
709 if (mc_args__debug_level != 0)
710 smbfs_set_debug (mc_args__debug_level);
711 #endif /* ENABLE_VFS_SMB */
713 if (mc_args__netfs_logfile != NULL)
715 vfs_path_t *vpath;
716 #ifdef ENABLE_VFS_FTP
717 vpath = vfs_path_from_str ("ftp://");
718 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
719 vfs_path_free (vpath);
720 #endif /* ENABLE_VFS_FTP */
721 #ifdef ENABLE_VFS_SMB
722 vpath = vfs_path_from_str ("smb://");
723 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
724 vfs_path_free (vpath);
725 #endif /* ENABLE_VFS_SMB */
726 (void) vpath;
729 base = x_basename (argv[0]);
730 tmp = (argc > 0) ? argv[1] : NULL;
732 if (strncmp (base, "mce", 3) == 0 || strcmp (base, "vi") == 0)
734 /* mce* or vi is link to mc */
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 */
740 mc_global.mc_run_mode = MC_RUN_VIEWER;
742 #ifdef USE_DIFF_VIEW
743 else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
745 /* mcd* or diff is link to mc */
746 mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
748 #endif /* USE_DIFF_VIEW */
750 switch (mc_global.mc_run_mode)
752 case MC_RUN_EDITOR:
753 mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
754 break;
756 case MC_RUN_VIEWER:
757 if (tmp == NULL)
759 mc_propagate_error (mcerror, 0, "%s\n", _("No arguments given to the viewer."));
760 return FALSE;
763 mc_run_param0 = g_strdup (tmp);
764 break;
766 #ifdef USE_DIFF_VIEW
767 case MC_RUN_DIFFVIEWER:
768 if (argc < 3)
770 mc_propagate_error (mcerror, 0, "%s\n",
771 _("Two files are required to envoke the diffviewer."));
772 return FALSE;
774 /* fallthrough */
775 #endif /* USE_DIFF_VIEW */
777 case MC_RUN_FULL:
778 default:
779 /* set the current dir and the other dir for filemanager,
780 or two files for diff viewer */
781 if (tmp != NULL)
783 mc_run_param0 = g_strdup (tmp);
784 tmp = (argc > 1) ? argv[2] : NULL;
785 if (tmp != NULL)
786 mc_run_param1 = g_strdup (tmp);
788 break;
791 return TRUE;
794 /* --------------------------------------------------------------------------------------------- */
796 * Create mcedit_arg_t object from file name and the line number.
798 * @param file_name file name
799 * @param line_number line number. If value is 0, try to restore saved position.
800 * @return mcedit_arg_t object
803 mcedit_arg_t *
804 mcedit_arg_new (const char *file_name, long line_number)
806 return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number);
809 /* --------------------------------------------------------------------------------------------- */
811 * Create mcedit_arg_t object from vfs_path_t object and the line number.
813 * @param file_vpath file path object
814 * @param line_number line number. If value is 0, try to restore saved position.
815 * @return mcedit_arg_t object
818 mcedit_arg_t *
819 mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number)
821 mcedit_arg_t *arg;
823 arg = g_new (mcedit_arg_t, 1);
824 arg->file_vpath = file_vpath;
825 arg->line_number = line_number;
827 return arg;
830 /* --------------------------------------------------------------------------------------------- */
832 * Free the mcedit_arg_t object.
834 * @param arg mcedit_arg_t object
837 void
838 mcedit_arg_free (mcedit_arg_t * arg)
840 vfs_path_free (arg->file_vpath);
841 g_free (arg);
844 /* --------------------------------------------------------------------------------------------- */