Ticket #???? (clock support)
[midnight-commander.git] / src / args.c
blob54dcb918c5a39ece249491d2dedc2234fdb5d5dd
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 static gboolean mc_args__nouse_subshell = FALSE;
90 static gboolean mc_args__show_datadirs = FALSE;
91 static gboolean mc_args__show_datadirs_extended = FALSE;
92 static gboolean mc_args__show_configure_opts = FALSE;
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 /* show configure options */
124 "configure-options", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
125 &mc_args__show_configure_opts,
126 N_("Print configure options"),
127 NULL
131 "printwd", 'P', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
132 &mc_args__last_wd_file,
133 N_("Print last working directory to specified file"),
134 "<file>"
137 #ifdef HAVE_SUBSHELL_SUPPORT
139 "subshell", 'U', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
140 &mc_global.tty.use_subshell,
141 N_("Enables subshell support (default)"),
142 NULL
146 "nosubshell", 'u', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
147 &mc_args__nouse_subshell,
148 N_("Disables subshell support"),
149 NULL
151 #endif
153 /* debug options */
154 #ifdef ENABLE_VFS_FTP
156 "ftplog", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
157 &mc_args__netfs_logfile,
158 N_("Log ftp dialog to specified file"),
159 "<file>"
161 #endif /* ENABLE_VFS_FTP */
162 #ifdef ENABLE_VFS_SMB
164 "debuglevel", 'D', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT,
165 &mc_args__debug_level,
166 N_("Set debug level"),
167 "<integer>"
169 #endif /* ENABLE_VFS_SMB */
171 /* single file operations */
173 "view", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK,
174 parse_mc_v_argument,
175 N_("Launches the file viewer on a file"),
176 "<file>"
180 "edit", 'e', G_OPTION_FLAG_IN_MAIN | G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
181 parse_mc_e_argument,
182 N_("Edit files"),
183 "<file> ..." },
186 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
188 /* *INDENT-ON* */
191 GOptionGroup *terminal_group;
192 #define ARGS_TERM_OPTIONS 0
193 static const GOptionEntry argument_terminal_table[] = {
194 /* *INDENT-OFF* */
195 /* terminal options */
197 "xterm", 'x', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
198 &mc_args__force_xterm,
199 N_("Forces xterm features"),
200 NULL
204 "no-x11", 'X', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
205 &mc_global.tty.disable_x11,
206 N_("Disable X11 support"),
207 NULL
211 "oldmouse", 'g', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
212 &mc_global.tty.old_mouse,
213 N_("Tries to use an old highlight mouse tracking"),
214 NULL
218 "nomouse", 'd', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
219 &mc_args__nomouse,
220 N_("Disable mouse support in text version"),
221 NULL
224 #ifdef HAVE_SLANG
226 "termcap", 't', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
227 &SLtt_Try_Termcap,
228 N_("Tries to use termcap instead of terminfo"),
229 NULL
231 #endif
234 "slow", 's', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
235 &mc_global.tty.slow_terminal,
236 N_("To run on slow terminals"),
237 NULL
241 "stickchars", 'a', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
242 &mc_global.tty.ugly_line_drawing,
243 N_("Use stickchars to draw"),
244 NULL
248 "resetsoft", 'k', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
249 &reset_hp_softkeys,
250 N_("Resets soft keys on HP terminals"),
251 NULL
255 "keymap", 'K', ARGS_TERM_OPTIONS, G_OPTION_ARG_STRING,
256 &mc_args__keymap_file,
257 N_("Load definitions of key bindings from specified file"),
258 "<file>"
262 "nokeymap", '\0', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
263 &mc_args__nokeymap,
264 N_("Don't load definitions of key bindings from file, use defaults"),
265 NULL
269 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
271 /* *INDENT-ON* */
274 #undef ARGS_TERM_OPTIONS
276 GOptionGroup *color_group;
277 #define ARGS_COLOR_OPTIONS 0
278 /* #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN */
279 static const GOptionEntry argument_color_table[] = {
280 /* *INDENT-OFF* */
281 /* color options */
283 "nocolor", 'b', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
284 &mc_global.tty.disable_colors,
285 N_("Requests to run in black and white"),
286 NULL
290 "color", 'c', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
291 &mc_args__force_colors,
292 N_("Request to run in color mode"),
293 NULL
297 "colors", 'C', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
298 &mc_global.tty.command_line_colors,
299 N_("Specifies a color configuration"),
300 "<string>"
304 "skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
305 &mc_global.tty.skin,
306 N_("Show mc with specified skin"),
307 "<string>"
311 NULL, '\0', 0, 0, NULL, NULL, NULL /* Complete struct initialization */
313 /* *INDENT-ON* */
316 #undef ARGS_COLOR_OPTIONS
318 static gchar *mc_args__loc__colors_string = NULL;
319 static gchar *mc_args__loc__footer_string = NULL;
320 static gchar *mc_args__loc__header_string = NULL;
321 static gchar *mc_args__loc__usage_string = NULL;
323 /*** file scope functions ************************************************************************/
325 /* --------------------------------------------------------------------------------------------- */
326 static void
327 mc_args_clean_temp_help_strings (void)
329 g_free (mc_args__loc__colors_string);
330 mc_args__loc__colors_string = NULL;
332 g_free (mc_args__loc__footer_string);
333 mc_args__loc__footer_string = NULL;
335 g_free (mc_args__loc__header_string);
336 mc_args__loc__header_string = NULL;
338 g_free (mc_args__loc__usage_string);
339 mc_args__loc__usage_string = NULL;
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: 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, 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 #if GLIB_CHECK_VERSION(2,12,0)
411 g_option_context_set_description (context, mc_args__loc__footer_string);
412 g_option_context_set_summary (context, mc_args__loc__header_string);
413 #endif
416 /* --------------------------------------------------------------------------------------------- */
418 static gchar *
419 mc_args__convert_help_to_syscharset (const gchar * charset, const gchar * error_message,
420 const gchar * help_str)
422 GString *buffer;
423 GIConv conv;
424 gchar *full_help_str;
426 buffer = g_string_new ("");
427 conv = g_iconv_open (charset, "UTF-8");
428 full_help_str = g_strdup_printf ("%s\n\n%s\n", error_message, help_str);
430 str_convert (conv, full_help_str, buffer);
432 g_free (full_help_str);
433 g_iconv_close (conv);
435 return g_string_free (buffer, FALSE);
438 /* --------------------------------------------------------------------------------------------- */
440 static gboolean
441 parse_mc_e_argument (const gchar * option_name, const gchar * value, gpointer data, GError ** error)
443 (void) option_name;
444 (void) value;
445 (void) data;
446 (void) error;
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, GError ** error)
458 (void) option_name;
459 (void) data;
460 (void) error;
462 mc_global.mc_run_mode = MC_RUN_VIEWER;
463 mc_run_param0 = g_strdup (value);
465 return TRUE;
468 /* --------------------------------------------------------------------------------------------- */
470 * Get list of filenames (and line numbers) from command line, when mc called as editor
472 * @param argc count of all arguments
473 * @param argv array of strings, contains arguments
474 * @return list of mcedit_arg_t objects
477 static GList *
478 parse_mcedit_arguments (int argc, char **argv)
480 GList *flist = NULL;
481 int i;
482 int first_line_number = -1;
484 for (i = 0; i < argc; i++)
486 char *tmp;
487 char *end, *p;
488 mcedit_arg_t *arg;
490 tmp = argv[i];
493 * First, try to get line number as +lineno.
495 if (*tmp == '+')
497 long lineno;
498 char *error;
500 lineno = strtol (tmp + 1, &error, 10);
502 if (*error == '\0')
504 /* this is line number */
505 first_line_number = (int) lineno;
506 continue;
508 /* this is file name */
512 * Check for filename:lineno, followed by an optional colon.
513 * This format is used by many programs (especially compilers)
514 * in error messages and warnings. It is supported so that
515 * users can quickly copy and paste file locations.
517 end = tmp + strlen (tmp);
518 p = end;
520 if (p > tmp && p[-1] == ':')
521 p--;
522 while (p > tmp && g_ascii_isdigit ((gchar) p[-1]))
523 p--;
525 if (tmp < p && p < end && p[-1] == ':')
527 char *fname;
528 vfs_path_t *tmp_vpath, *fname_vpath;
529 struct stat st;
531 fname = g_strndup (tmp, p - 1 - tmp);
532 tmp_vpath = vfs_path_from_str (tmp);
533 fname_vpath = vfs_path_from_str (fname);
536 * Check that the file before the colon actually exists.
537 * If it doesn't exist, create new file.
539 if (mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1)
541 arg = mcedit_arg_vpath_new (fname_vpath, atoi (p));
542 vfs_path_free (tmp_vpath);
544 else
546 arg = mcedit_arg_vpath_new (tmp_vpath, 1);
547 vfs_path_free (fname_vpath);
550 g_free (fname);
552 else
553 arg = mcedit_arg_new (tmp, 1);
555 flist = g_list_prepend (flist, arg);
558 if (flist == NULL)
559 flist = g_list_prepend (flist, mcedit_arg_new (NULL, 1));
560 else if (first_line_number != -1)
562 /* overwrite line number for first file */
563 GList *l;
565 if (first_line_number == 0)
566 first_line_number = 1;
568 l = g_list_last (flist);
569 ((mcedit_arg_t *) l->data)->line_number = first_line_number;
572 return flist;
575 /* --------------------------------------------------------------------------------------------- */
576 /*** public functions ****************************************************************************/
577 /* --------------------------------------------------------------------------------------------- */
579 gboolean
580 mc_args_parse (int *argc, char ***argv, const char *translation_domain, GError ** error)
582 const gchar *_system_codepage;
583 gboolean ok = TRUE;
585 _system_codepage = str_detect_termencoding ();
587 #ifdef ENABLE_NLS
588 if (!str_isutf8 (_system_codepage))
589 bind_textdomain_codeset ("mc", "UTF-8");
590 #endif
592 context = g_option_context_new (mc_args_add_usage_info ());
594 g_option_context_set_ignore_unknown_options (context, FALSE);
596 mc_args_add_extended_info_to_help ();
598 main_group = g_option_group_new ("main", _("Main options"), _("Main options"), NULL, NULL);
600 g_option_group_add_entries (main_group, argument_main_table);
601 g_option_context_set_main_group (context, main_group);
602 g_option_group_set_translation_domain (main_group, translation_domain);
604 terminal_group = g_option_group_new ("terminal", _("Terminal options"),
605 _("Terminal options"), NULL, NULL);
607 g_option_group_add_entries (terminal_group, argument_terminal_table);
608 g_option_context_add_group (context, terminal_group);
609 g_option_group_set_translation_domain (terminal_group, translation_domain);
611 color_group = mc_args_new_color_group ();
613 g_option_group_add_entries (color_group, argument_color_table);
614 g_option_context_add_group (context, color_group);
615 g_option_group_set_translation_domain (color_group, translation_domain);
617 if (!g_option_context_parse (context, argc, argv, error))
619 GError *error2 = NULL;
621 if (*error == NULL)
622 *error = g_error_new (MC_ERROR, 0, "%s\n", _("Arguments parse error!"));
623 else
625 gchar *help_str;
627 #if GLIB_CHECK_VERSION(2,14,0)
628 help_str = g_option_context_get_help (context, TRUE, NULL);
629 #else
630 help_str = g_strdup ("");
631 #endif
632 if (str_isutf8 (_system_codepage))
633 error2 = g_error_new ((*error)->domain, (*error)->code, "%s\n\n%s\n",
634 (*error)->message, help_str);
635 else
637 gchar *full_help_str;
639 full_help_str =
640 mc_args__convert_help_to_syscharset (_system_codepage, (*error)->message,
641 help_str);
642 error2 = g_error_new ((*error)->domain, (*error)->code, "%s", full_help_str);
643 g_free (full_help_str);
646 g_free (help_str);
647 g_error_free (*error);
648 *error = error2;
651 ok = FALSE;
654 g_option_context_free (context);
655 mc_args_clean_temp_help_strings ();
657 #ifdef ENABLE_NLS
658 if (!str_isutf8 (_system_codepage))
659 bind_textdomain_codeset ("mc", _system_codepage);
660 #endif
662 return ok;
665 /* --------------------------------------------------------------------------------------------- */
667 gboolean
668 mc_args_show_info (void)
670 if (mc_args__show_version)
672 show_version ();
673 return FALSE;
676 if (mc_args__show_datadirs)
678 printf ("%s (%s)\n", mc_global.sysconfig_dir, mc_global.share_data_dir);
679 return FALSE;
682 if (mc_args__show_datadirs_extended)
684 show_datadirs_extended ();
685 return FALSE;
688 if (mc_args__show_configure_opts)
690 show_configure_options ();
691 return FALSE;
694 return TRUE;
697 /* --------------------------------------------------------------------------------------------- */
699 gboolean
700 mc_setup_by_args (int argc, char **argv, GError ** error)
702 const char *base;
703 char *tmp;
705 if (mc_args__force_colors)
706 mc_global.tty.disable_colors = FALSE;
708 #ifdef HAVE_SUBSHELL_SUPPORT
709 if (mc_args__nouse_subshell)
710 mc_global.tty.use_subshell = FALSE;
711 #endif /* HAVE_SUBSHELL_SUPPORT */
713 #ifdef ENABLE_VFS_SMB
714 if (mc_args__debug_level != 0)
715 smbfs_set_debug (mc_args__debug_level);
716 #endif /* ENABLE_VFS_SMB */
718 if (mc_args__netfs_logfile != NULL)
720 vfs_path_t *vpath;
721 #ifdef ENABLE_VFS_FTP
722 vpath = vfs_path_from_str ("ftp://");
723 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
724 vfs_path_free (vpath);
725 #endif /* ENABLE_VFS_FTP */
726 #ifdef ENABLE_VFS_SMB
727 vpath = vfs_path_from_str ("smb://");
728 mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
729 vfs_path_free (vpath);
730 #endif /* ENABLE_VFS_SMB */
731 (void) vpath;
734 base = x_basename (argv[0]);
735 tmp = (argc > 0) ? argv[1] : NULL;
737 if (strncmp (base, "mce", 3) == 0 || strcmp (base, "vi") == 0)
739 /* mce* or vi is link to mc */
741 mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
742 mc_global.mc_run_mode = MC_RUN_EDITOR;
744 else if (strncmp (base, "mcv", 3) == 0 || strcmp (base, "view") == 0)
746 /* mcv* or view is link to mc */
748 if (tmp != NULL)
749 mc_run_param0 = g_strdup (tmp);
750 else
752 *error = g_error_new (MC_ERROR, 0, "%s\n", _("No arguments given to the viewer."));
753 return FALSE;
755 mc_global.mc_run_mode = MC_RUN_VIEWER;
757 #ifdef USE_DIFF_VIEW
758 else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
760 /* mcd* or diff is link to mc */
762 if (argc < 3)
764 *error = g_error_new (MC_ERROR, 0, "%s\n",
765 _("Two files are required to evoke the diffviewer."));
766 return FALSE;
769 if (tmp != NULL)
771 mc_run_param0 = g_strdup (tmp);
772 tmp = (argc > 1) ? argv[2] : NULL;
773 if (tmp != NULL)
774 mc_run_param1 = g_strdup (tmp);
775 mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
778 #endif /* USE_DIFF_VIEW */
779 else
781 /* MC is run as mc */
783 switch (mc_global.mc_run_mode)
785 case MC_RUN_EDITOR:
786 mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
787 break;
789 case MC_RUN_VIEWER:
790 /* mc_run_param0 is set up in parse_mc_v_argument() */
791 break;
793 case MC_RUN_DIFFVIEWER:
794 /* not implemented yet */
795 break;
797 case MC_RUN_FULL:
798 default:
799 /* sets the current dir and the other dir */
800 if (tmp != NULL)
802 mc_run_param0 = g_strdup (tmp);
803 tmp = (argc > 1) ? argv[2] : NULL;
804 if (tmp != NULL)
805 mc_run_param1 = g_strdup (tmp);
807 mc_global.mc_run_mode = MC_RUN_FULL;
808 break;
812 return TRUE;
815 /* --------------------------------------------------------------------------------------------- */
817 * Create mcedit_arg_t object from file name and the line number.
819 * @param file_name file name
820 * @param line_number line number
821 * @return mcedit_arg_t object
824 mcedit_arg_t *
825 mcedit_arg_new (const char *file_name, int line_number)
827 return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number);
830 /* --------------------------------------------------------------------------------------------- */
832 * Create mcedit_arg_t object from vfs_path_t object and the line number.
834 * @param file_vpath file path object
835 * @param line_number line number
836 * @return mcedit_arg_t object
839 mcedit_arg_t *
840 mcedit_arg_vpath_new (vfs_path_t * file_vpath, int line_number)
842 mcedit_arg_t *arg;
844 arg = g_new (mcedit_arg_t, 1);
845 arg->file_vpath = file_vpath;
846 if (line_number == 0)
847 line_number = 1;
848 arg->line_number = line_number;
850 return arg;
853 /* --------------------------------------------------------------------------------------------- */
855 * Free the mcedit_arg_t object.
857 * @param arg mcedit_arg_t object
860 void
861 mcedit_arg_free (mcedit_arg_t * arg)
863 vfs_path_free (arg->file_vpath);
864 g_free (arg);
867 /* --------------------------------------------------------------------------------------------- */