Пример #1
0
void ext_cmd (void)
{
    char *buffer;
    char *extdir;
    int  dir;

    dir = 0;
    if (geteuid () == 0){
	dir = query_dialog (_("Extension file edit"),
			    _(" Which extension file you want to edit? "), 0, 2,
			    _("&User"), _("&System Wide"));
    }
    extdir = concat_dir_and_file (mc_home, MC_LIB_EXT);

    if (dir == 0){
	buffer = concat_dir_and_file (home_dir, MC_USER_EXT);
	check_for_default (extdir, buffer);
	do_edit (buffer);
	g_free (buffer);
    } else if (dir == 1)
	do_edit (extdir);

   g_free (extdir);
   flush_extension_file ();
}
Пример #2
0
/* edit syntax file for mcedit */
void
edit_syntax_cmd (void)
{
    char *buffer;
    char *extdir;
    int dir = 0;

    if (geteuid () == 0) {
	dir =
	    query_dialog (_("Syntax file edit"),
			  _(" Which syntax file you want to edit? "), 0, 2,
			  _("&User"), _("&System Wide"));
    }
    extdir = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax");

    if (dir == 0) {
	buffer = concat_dir_and_file (home_dir, SYNTAX_FILE);
	check_for_default (extdir, buffer);
	do_edit (buffer);
	g_free (buffer);
    } else if (dir == 1)
	do_edit (extdir);

    g_free (extdir);
}
Пример #3
0
void
ext_cmd (void)
{
    char *buffer;
    char *extdir;
    int dir;

    dir = 0;
    if (geteuid () == 0)
    {
        dir = query_dialog (_("Extension file edit"),
                            _("Which extension file you want to edit?"), D_NORMAL, 2,
                            _("&User"), _("&System Wide"));
    }
    extdir = concat_dir_and_file (mc_global.sysconfig_dir, MC_LIB_EXT);

    if (dir == 0)
    {
        buffer = mc_config_get_full_path (MC_FILEBIND_FILE);
        check_for_default (extdir, buffer);
        do_edit (buffer);
        g_free (buffer);
    }
    else if (dir == 1)
    {
        if (!exist_file (extdir))
        {
            g_free (extdir);
            extdir = concat_dir_and_file (mc_global.share_data_dir, MC_LIB_EXT);
        }
        do_edit (extdir);
    }
    g_free (extdir);
    flush_extension_file ();
}
Пример #4
0
int
edit_file (const char *_file, int line)
{
    static gboolean made_directory = FALSE;
    Dlg_head *edit_dlg;
    WEdit *wedit;
    WMenuBar *menubar;

    if (!made_directory)
    {
        char *dir = concat_dir_and_file (mc_config_get_cache_path (), EDIT_DIR);
        made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
        g_free (dir);

        dir = concat_dir_and_file (mc_config_get_path (), EDIT_DIR);
        made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
        g_free (dir);

        dir = concat_dir_and_file (mc_config_get_data_path (), EDIT_DIR);
        made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
        g_free (dir);
    }

    wedit = edit_init (NULL, 1, 0, LINES - 2, COLS, _file, line);

    if (wedit == NULL)
        return 0;

    /* Create a new dialog and add it widgets to it */
    edit_dlg =
        create_dlg (FALSE, 0, 0, LINES, COLS, NULL, edit_dialog_callback,
                    "[Internal File Editor]", NULL, DLG_WANT_TAB);

    edit_dlg->get_shortcut = edit_get_shortcut;
    edit_dlg->get_title = edit_get_title;

    menubar = menubar_new (0, 0, COLS, NULL);
    add_widget (edit_dlg, menubar);
    edit_init_menu (menubar);

    init_widget (&wedit->widget, wedit->widget.y, wedit->widget.x,
                 wedit->widget.lines, wedit->widget.cols, edit_callback, edit_event);
    widget_want_cursor (wedit->widget, TRUE);

    add_widget (edit_dlg, wedit);

    add_widget (edit_dlg, buttonbar_new (TRUE));

    run_dlg (edit_dlg);

    if (edit_dlg->state == DLG_CLOSED)
        destroy_dlg (edit_dlg);

    return 1;
}
Пример #5
0
void
edit_mc_menu_cmd (void)
{
    char *buffer;
    char *menufile;
    int dir = 0;

    dir = query_dialog (_("Menu edit"),
                        _("Which menu file do you want to edit?"),
                        D_NORMAL, geteuid ()? 2 : 3, _("&Local"), _("&User"), _("&System Wide"));

    menufile = concat_dir_and_file (mc_global.sysconfig_dir, MC_GLOBAL_MENU);

    if (!exist_file (menufile))
    {
        g_free (menufile);
        menufile = concat_dir_and_file (mc_global.share_data_dir, MC_GLOBAL_MENU);
    }

    switch (dir)
    {
    case 0:
        buffer = g_strdup (MC_LOCAL_MENU);
        check_for_default (menufile, buffer);
        chmod (buffer, 0600);
        break;

    case 1:
        buffer = mc_config_get_full_path (MC_USERMENU_FILE);
        check_for_default (menufile, buffer);
        break;

    case 2:
        buffer = concat_dir_and_file (mc_global.sysconfig_dir, MC_GLOBAL_MENU);
        if (!exist_file (buffer))
        {
            g_free (buffer);
            buffer = concat_dir_and_file (mc_global.share_data_dir, MC_GLOBAL_MENU);
        }
        break;

    default:
        g_free (menufile);
        return;
    }

    do_edit (buffer);

    g_free (buffer);
    g_free (menufile);
}
Пример #6
0
static void
do_link (link_type_t link_type, const char *fname)
{
    char *dest = NULL, *src = NULL;

    if (link_type == LINK_HARDLINK)
    {
        src = g_strdup_printf (_("Link %s to:"), str_trunc (fname, 46));
        dest = input_expand_dialog (_("Link"), src, MC_HISTORY_FM_LINK, "");
        if (!dest || !*dest)
            goto cleanup;
        save_cwds_stat ();
        if (-1 == mc_link (fname, dest))
            message (D_ERROR, MSG_ERROR, _("link: %s"), unix_error_string (errno));
    }
    else
    {
        char *s;
        char *d;

        /* suggest the full path for symlink, and either the full or
           relative path to the file it points to  */
        s = concat_dir_and_file (current_panel->cwd, fname);

        if (get_other_type () == view_listing)
            d = concat_dir_and_file (other_panel->cwd, fname);
        else
            d = g_strdup (fname);

        if (link_type == LINK_SYMLINK_RELATIVE)
            s = diff_two_paths (other_panel->cwd, s);

        symlink_dialog (s, d, &dest, &src);
        g_free (d);
        g_free (s);

        if (!dest || !*dest || !src || !*src)
            goto cleanup;
        save_cwds_stat ();
        if (-1 == mc_symlink (dest, src))
            message (D_ERROR, MSG_ERROR, _("symlink: %s"), unix_error_string (errno));
    }

    update_panels (UP_OPTIMIZE, UP_KEEPSEL);
    repaint_screen ();

  cleanup:
    g_free (src);
    g_free (dest);
}
Пример #7
0
void
mkdir_cmd (void)
{
    char *tempdir;
    char *dir;

    dir =
	input_expand_dialog (_("Create a new Directory"),
			     _(" Enter directory name:"), "");

    if (!dir || !*dir)
	return;

    if (dir[0] == '/' || dir[0] == '~')
	tempdir = g_strdup (dir);
    else
	tempdir = concat_dir_and_file (current_panel->cwd, dir);
    g_free (dir);

    save_cwds_stat ();
    if (my_mkdir (tempdir, 0777) == 0) {
	update_panels (UP_OPTIMIZE, tempdir);
	repaint_screen ();
	select_item (current_panel);
	g_free (tempdir);
	return;
    }
    g_free (tempdir);
    message (1, MSG_ERROR, "  %s  ", unix_error_string (errno));
}
Пример #8
0
static int
my_mkdir_rec (char *s, mode_t mode)
{
    char *p, *q;
    int result;

    if (!mc_mkdir (s, mode))
	return 0;
    else if (errno != ENOENT)
	return -1;

    /* FIXME: should check instead if s is at the root of that filesystem */
    if (!vfs_file_is_local (s))
	return -1;

    if (!strcmp (s, PATH_SEP_STR)) {
	errno = ENOTDIR;
	return -1;
    }

    p = concat_dir_and_file (s, "..");
    q = vfs_canon (p);
    g_free (p);

    if (!(result = my_mkdir_rec (q, mode)))
	result = mc_mkdir (s, mode);

    g_free (q);
    return result;
}
Пример #9
0
/* Save position for the given file */
void
save_file_position (char *filename, long line, long column)
{
    char *tmp, *fn;
    FILE *f, *t;
    char buf[MC_MAXPATHLEN + 20];
    int i = 1;
    int len;

    len = strlen (filename);

    tmp = concat_dir_and_file (home_dir, MC_FILEPOS_TMP);
    fn = concat_dir_and_file (home_dir, MC_FILEPOS);

    /* open temporary file */
    t = fopen (tmp, "w");
    if (!t) {
	g_free (tmp);
	g_free (fn);
	return;
    }

    /* put the new record */
    fprintf (t, "%s %ld;%ld\n", filename, line, column);

    /* copy records from the old file */
    f = fopen (fn, "r");
    if (f) {
	while (fgets (buf, sizeof (buf), f)) {
	    /* Skip entries for the current filename */
	    if (strncmp (buf, filename, len) == 0 && buf[len] == ' '
		&& !strchr (&buf[len + 1], ' '))
		continue;

	    fprintf (t, "%s", buf);
	    if (++i > MC_FILEPOS_ENTRIES)
		break;
	}
	fclose (f);
    }

    fclose (t);
    rename (tmp, fn);
    g_free (tmp);
    g_free (fn);
}
Пример #10
0
static void
do_link (int symbolic_link, const char *fname)
{
    char *dest = NULL, *src = NULL;

    if (!symbolic_link) {
	src = g_strdup_printf (_("Link %s to:"), name_trunc (fname, 46));
	dest = input_expand_dialog (_(" Link "), src, "");
	if (!dest || !*dest)
	    goto cleanup;
	save_cwds_stat ();
	if (-1 == mc_link (fname, dest))
	    message (1, MSG_ERROR, _(" link: %s "),
		     unix_error_string (errno));
    } else {
	char *s;
	char *d;

	/* suggest the full path for symlink */
	s = concat_dir_and_file (current_panel->cwd, fname);

	if (get_other_type () == view_listing) {
	    d = concat_dir_and_file (other_panel->cwd, fname);
	} else {
	    d = g_strdup (fname);
	}

	symlink_dialog (s, d, &dest, &src);
	g_free (d);
	g_free (s);

	if (!dest || !*dest || !src || !*src)
	    goto cleanup;
	save_cwds_stat ();
	if (-1 == mc_symlink (dest, src))
	    message (1, MSG_ERROR, _(" symlink: %s "),
		     unix_error_string (errno));
    }
    update_panels (UP_OPTIMIZE, UP_KEEPSEL);
    repaint_screen ();

cleanup:
    g_free (src);
    g_free (dest);
}
Пример #11
0
static char *
get_absolute_name (char *file)
{
    char dir[MC_MAXPATHLEN];

    if (file[0] == PATH_SEP)
	return g_strdup (file);
    mc_get_current_wd (dir, MC_MAXPATHLEN);
    return concat_dir_and_file (dir, file);
}
Пример #12
0
/* where  = 1 - do edit file menu for mcedit */
static void
menu_edit_cmd (int where)
{
    char *buffer;
    char *menufile;
    int dir = 0;
    
    dir = query_dialog (
	_(" Menu edit "),
	_(" Which menu file do you want to edit? "), 
	0, geteuid() ? 2 : 3,
	_("&Local"), _("&Home"), _("&System Wide")
    );

    menufile = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);

    switch (dir) {
	case 0:
	    buffer = g_strdup (where ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU);
	    check_for_default (menufile, buffer);
	    break;

	case 1:
	    buffer = concat_dir_and_file (home_dir, where ? CEDIT_HOME_MENU : MC_HOME_MENU);
	    check_for_default (menufile, buffer);
	    break;
	
	case 2:
	    buffer = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
	    break;

	default:
	   g_free (menufile);
	    return;
    }
    do_edit (buffer);
	if (dir == 0)
		chmod(buffer, 0600);
    g_free (buffer);
    g_free (menufile);
}
Пример #13
0
void
edit_fhl_cmd (void)
{
    char *buffer = NULL;
    char *fhlfile = NULL;

    int dir;

    dir = 0;
    if (geteuid () == 0)
    {
        dir = query_dialog (_("Highlighting groups file edit"),
                            _("Which highlighting file you want to edit?"), D_NORMAL, 2,
                            _("&User"), _("&System Wide"));
    }
    fhlfile = concat_dir_and_file (mc_global.sysconfig_dir, MC_FHL_INI_FILE);

    if (dir == 0)
    {
        buffer = mc_config_get_full_path (MC_FHL_INI_FILE);
        check_for_default (fhlfile, buffer);
        do_edit (buffer);
        g_free (buffer);
    }
    else if (dir == 1)
    {
        if (!exist_file (fhlfile))
        {
            g_free (fhlfile);
            fhlfile = concat_dir_and_file (mc_global.sysconfig_dir, MC_FHL_INI_FILE);
        }
        do_edit (fhlfile);
    }
    g_free (fhlfile);

    /* refresh highlighting rules */
    mc_fhl_free (&mc_filehighlight);
    mc_filehighlight = mc_fhl_new (TRUE);
}
Пример #14
0
void save_configure (void)
{
    char *profile;
    int  i;

    profile = concat_dir_and_file (home_dir, PROFILE_NAME);

    /* Save integer options */
    for (i = 0; options [i].opt_name; i++)
	set_int (profile, options [i].opt_name, *options [i].opt_addr);

    free (profile);
}
Пример #15
0
void load_key_defs (void)
{
    char *libfile = concat_dir_and_file (mc_home, "mc.lib");
    load_keys_from_section (getenv ("TERM"), profile_name);
    load_keys_from_section ("general", profile_name);

    load_keys_from_section (getenv ("TERM"), libfile);
    load_keys_from_section ("general", libfile);

    /* We don't want a huge database loaded in core */
    free_profile_name (libfile);
    free (libfile);
}
Пример #16
0
gint pan_is_link_loop(const gchar *s)
{
	gchar *sl;
	struct stat st;
	gint ret = FALSE;

	sl = path_from_utf8(s);

	if (lstat(sl, &st) == 0 && S_ISLNK(st.st_mode))
		{
		gchar *buf;
		gint l;

		buf = g_malloc(st.st_size + 1);
		l = readlink(sl, buf, st.st_size);
		if (l == st.st_size)
			{
			buf[l] = '\0';

			parse_out_relatives(buf);
			l = strlen(buf);

			parse_out_relatives(sl);

			if (buf[0] == '/')
				{
				if (strncmp(sl, buf, l) == 0 &&
				    (sl[l] == '\0' || sl[l] == '/' || l == 1)) ret = TRUE;
				}
			else
				{
				gchar *link_path;

				link_path = concat_dir_and_file(sl, buf);
				parse_out_relatives(link_path);

				if (strncmp(sl, link_path, l) == 0 &&
				    (sl[l] == '\0' || sl[l] == '/' || l == 1)) ret = TRUE;

				g_free(link_path);
				}
			}

		g_free(buf);
		}

	g_free(sl);

	return ret;
}
Пример #17
0
char *
setup_init (void)
{
    char *profile;
    char *inifile;

    if (profile_name != NULL)
        return profile_name;

    profile = g_build_filename (mc_config_get_path (), MC_CONFIG_FILE, NULL);
    if (!exist_file (profile))
    {
        inifile = concat_dir_and_file (mc_sysconfig_dir, "mc.ini");
        if (exist_file (inifile))
        {
            g_free (profile);
            profile = inifile;
        }
        else
        {
            g_free (inifile);
            inifile = concat_dir_and_file (mc_share_data_dir, "mc.ini");
            if (exist_file (inifile))
            {
                g_free (profile);
                profile = inifile;
            }
            else
                g_free (inifile);
        }
    }

    profile_name = profile;

    return profile;
}
Пример #18
0
static void
cb_file_util_move_multiple_ok (GenericDialog * gd, gpointer data)
{
    FileDataMult *fdm = data;

    fdm->confirmed = TRUE;

    if (fdm->rename_auto)
    {
	gchar  *buf;

	buf = unique_filename_simple (fdm->dest);
	if (buf)
	{
	    g_free (fdm->dest);
	    fdm->dest = buf;
	}
	else
	{
	    /*
	     * unique failed? well, return to the overwrite prompt :( 
	     */
	    fdm->confirmed = FALSE;
	}
    }
    else if (fdm->rename)
    {
	const gchar *name;

	name = gtk_entry_get_text (GTK_ENTRY (fdm->rename_entry));

	if (strlen (name) == 0 ||
	    strcmp (name, filename_from_path (fdm->source)) == 0)
	{
	    fdm->confirmed = FALSE;
	}
	else
	{
	    g_free (fdm->dest);
	    fdm->dest = concat_dir_and_file (fdm->dest_base, name);
	    fdm->confirmed = !isname (fdm->dest);
	}
    }

    gtk_widget_hide (gd->dialog);

    file_util_move_multiple (fdm);
}
Пример #19
0
void save_layout (void)
{
    char *profile;
    int  i;
    char buffer [6];

    profile = concat_dir_and_file (home_dir, PROFILE_NAME);

    /* Save integer options */
    for (i = 0; layout [i].opt_name; i++){
	sprintf (buffer, "%d", *layout [i].opt_addr);
	save_string ("Layout", layout [i].opt_name, buffer, profile);
    }

    free (profile);
}
Пример #20
0
/*
 * Read and restore position for the given filename.
 * If there is no stored data, return line 1 and col 0.
 */
void
load_file_position (const char *filename, long *line, long *column)
{
    char *fn;
    FILE *f;
    char buf[MC_MAXPATHLEN + 20];
    int len;

    /* defaults */
    *line = 1;
    *column = 0;

    /* open file with positions */
    fn = concat_dir_and_file (home_dir, MC_FILEPOS);
    f = fopen (fn, "r");
    g_free (fn);
    if (!f)
	return;

    len = strlen (filename);

    while (fgets (buf, sizeof (buf), f)) {
	const char *p;

	/* check if the filename matches the beginning of string */
	if (strncmp (buf, filename, len) != 0)
	    continue;

	/* followed by single space */
	if (buf[len] != ' ')
	    continue;

	/* and string without spaces */
	p = &buf[len + 1];
	if (strchr (p, ' '))
	    continue;

	*line = strtol(p, const_cast(char **, &p), 10);
	if (*p == ';') {
	    *column = strtol(p+1, const_cast(char **, &p), 10);
	    if (*p != '\n')
	        *column = 0;
	} else
Пример #21
0
char *
load_mc_home_file (const char *filename, char **allocated_filename)
{
    char *hintfile_base, *hintfile;
    char *lang;
    char *data;

    hintfile_base = concat_dir_and_file (mc_home, filename);
    lang = guess_message_value ();

    hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL);
    data = load_file (hintfile);

    if (!data) {
	g_free (hintfile);
	/* Fall back to the two-letter language code */
	if (lang[0] && lang[1])
	    lang[2] = 0;
	hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL);
	data = load_file (hintfile);

	if (!data) {
	    g_free (hintfile);
	    hintfile = hintfile_base;
	    data = load_file (hintfile_base);
	}
    }

    g_free (lang);

    if (hintfile != hintfile_base)
	g_free (hintfile_base);

    if (allocated_filename)
	*allocated_filename = hintfile;
    else
	g_free (hintfile);

    return data;
}
Пример #22
0
void
mkdir_cmd (void)
{
    char *dir, *absdir;
    const char *name = "";

    /* If 'on' then automatically fills name with current selected item name */
    if (auto_fill_mkdir_name && strcmp (selection (current_panel)->fname, "..") != 0)
        name = selection (current_panel)->fname;

    dir =
        input_expand_dialog (_("Create a new Directory"),
                             _("Enter directory name:"), MC_HISTORY_FM_MKDIR, name);

    if (!dir)
        return;

    if (*dir)
    {
        if (dir[0] == '/' || dir[0] == '~')
            absdir = g_strdup (dir);
        else
            absdir = concat_dir_and_file (current_panel->cwd, dir);

        save_cwds_stat ();
        if (my_mkdir (absdir, 0777) == 0)
        {
            update_panels (UP_OPTIMIZE, dir);
            repaint_screen ();
            select_item (current_panel);
        }
        else
        {
            message (D_ERROR, MSG_ERROR, "%s", unix_error_string (errno));
        }
        g_free (absdir);
    }
    g_free (dir);
}
Пример #23
0
void save_setup (void)
{
    char *profile;
#ifdef USE_VFS
#ifdef USE_NETCODE
    extern char *ftpfs_anonymous_passwd;
    extern char *ftpfs_proxy_host;
#endif
#endif
    saving_setup = 1;
    profile = concat_dir_and_file (home_dir, PROFILE_NAME);

    save_layout ();
    save_configure ();
    save_string ("Dirs", "other_dir",
			       get_other_type () == view_listing
			       ? opanel->cwd : ".", profile);
    WritePrivateProfileString ("Dirs", "current_is_left",
			       get_current_index () == 0 ? "1" : "0", profile);
    save_hotlist ();
    save_panelize ();
    save_panel_types ();
/*     directory_history_save (); */
    
#ifdef USE_VFS
#ifdef USE_NETCODE
    WritePrivateProfileString ("Misc", "ftpfs_password",
			       ftpfs_anonymous_passwd, profile);
    if (ftpfs_proxy_host)
	WritePrivateProfileString ("Misc", "ftp_proxy_host",
				   ftpfs_proxy_host, profile);
#endif
#endif
    free (profile);
    saving_setup = 0;
}
Пример #24
0
static int
save_file (GtkamSave *save, const char *filename, CameraFile *file, CameraFileType type, guint n)
{
	gchar *full_path, *full_filename, *dirname, *msg, *number_filename;
	const char *mime_type;
	const gchar *fsel_filename, *fsel_path, *prefix, *suffix;
	GtkWidget *dialog;
	int result;

	gp_file_get_mime_type (file, &mime_type);

	fsel_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER_DIALOG (save));

	if ((save->priv->toggle_filename_camera->active) ||
		(g_slist_length (save->priv->data) == 1)) {

		/* Use filename provided by the CameraFile */
		full_filename = create_full_filename (filename, type);

		if (g_slist_length (save->priv->data) == 1)
			full_path = g_strdup(fsel_path);
		else
			full_path = concat_dir_and_file (fsel_path, full_filename);

		g_free (full_filename);

	} else {
		/* Use filename in prefix */
		prefix = g_locale_from_utf8 (gtk_entry_get_text
					(GTK_ENTRY (save->priv->prefix_entry)), -1,
					NULL, NULL, NULL);

		suffix = strrchr (mime_type, '/');
		suffix++;
		number_filename = g_strdup_printf ("%s%04i.%s", prefix,
								n, suffix);
		full_filename = create_full_filename (number_filename,
								type);
		g_free (number_filename);
		
		full_path = concat_dir_and_file (fsel_path,
							full_filename);
		g_free (full_filename);
	}

	/* FIXME Check which is user, and prompt the user */
	if (!save->priv->quiet && file_exists (full_path)) {
		msg = g_strdup_printf (_("The file '%s' already exists."),
				       full_path);
		if (!save->priv->err_shown) {
			dialog = gtkam_error_new (GP_ERROR_FILE_EXISTS, NULL, GTK_WIDGET (save), msg);
			gtk_window_set_transient_for (GTK_WINDOW (dialog),
						      save->priv->main_window);
			gtk_widget_show (dialog);
			g_free (msg);
			g_free (full_path);
			save->priv->err_shown = TRUE;
		}
		return -1;
	}

	/* FIXME Check for sufficient disk space for this file, or
	   calculate total disk space required for all files before
	   save process starts */

	result = gp_file_save (file, full_path);
	if (result < 0) {
		if (!save->priv->err_shown) {
			dialog = gtkam_error_new (result, NULL, GTK_WIDGET (save),
					_("Could not save file to '%s'."), full_path);
			gtk_widget_show (dialog);
			save->priv->err_shown = TRUE;
		}
	} else {
		/* Add the file to the list of files to be opened with
		   the specified external program */
		if (!save->priv->filelist)
				save->priv->filelist = g_string_new ("");
		g_string_append_printf (save->priv->filelist, " %s", full_path);
	}

	g_free (full_path);
	
	return result;
}
Пример #25
0
/* The second argument is action, i.e. Open, View or Edit
 *
 * This function returns:
 *
 * -1 for a failure or user interrupt
 * 0 if no command was run
 * 1 if some command was run
 *
 * If action == "View" then a parameter is checked in the form of "View:%d",
 * if the value for %d exists, then the viewer is started up at that line number.
 */
int
regex_command (const char *filename, const char *action, int *move_dir)
{
    char *p, *q, *r, c;
    int file_len = strlen (filename);
    int found = 0;
    int error_flag = 0;
    int ret = 0;
    struct stat mystat;
    int view_at_line_number;
    char *include_target;
    int include_target_len;
    int have_type = 0;		/* Flag used by regex_check_type() */

    /* Check for the special View:%d parameter */
    if (strncmp (action, "View:", 5) == 0) {
	view_at_line_number = atoi (action + 5);
	action = "View";
    } else {
	view_at_line_number = 0;
    }

    if (data == NULL) {
	char *extension_file;
	int mc_user_ext = 1;
	int home_error = 0;

	extension_file = concat_dir_and_file (home_dir, MC_USER_EXT);
	if (!exist_file (extension_file)) {
	    g_free (extension_file);
	  check_stock_mc_ext:
	    extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT);
	    mc_user_ext = 0;
	}
	data = load_file (extension_file);
	g_free (extension_file);
	if (data == NULL)
	    return 0;

	if (!strstr (data, "default/")) {
	    if (!strstr (data, "regex/") && !strstr (data, "shell/")
		&& !strstr (data, "type/")) {
		g_free (data);
		data = NULL;
		if (mc_user_ext) {
		    home_error = 1;
		    goto check_stock_mc_ext;
		} else {
		    char *msg;
		    char *msg2;
		    msg =
			g_strconcat (" ", mc_home, MC_LIB_EXT,
				     _(" file error "), (char *) NULL);
		    msg2 =
			g_strconcat (_("Format of the "), mc_home,
				     _("mc.ext file has changed\n"
				       "with version 3.0. It seems that installation\n"
				       "failed. Please fetch a fresh new copy from the\n"
				       "Midnight Commander package."),
				     (char *) NULL);
		    message (1, msg, "%s", msg2);
		    g_free (msg);
		    g_free (msg2);
		    return 0;
		}
	    }
	}
	if (home_error) {
	    char *msg;
	    char *msg2;
	    msg =
		g_strconcat (" ~/", MC_USER_EXT, _(" file error "), (char *) NULL);
	    msg2 =
		g_strconcat (_("Format of the "), "~/", MC_USER_EXT,
			     _(" file has changed\n"
			       "with version 3.0. You may want either to\n"
			       "copy it from "), mc_home,
			     _("mc.ext or use that\n"
			       "file as an example of how to write it.\n"),
			     mc_home,
			     _("mc.ext will be used for this moment."),
			     (char *) NULL);
	    message (1, msg, "%s", msg2);
	    g_free (msg);
	    g_free (msg2);
	}
    }
    mc_stat (filename, &mystat);

    include_target = NULL;
    include_target_len = 0;
    for (p = data; *p; p++) {
	for (q = p; *q == ' ' || *q == '\t'; q++);
	if (*q == '\n' || !*q)
	    p = q;		/* empty line */
	if (*p == '#')		/* comment */
	    while (*p && *p != '\n')
		p++;
	if (*p == '\n')
	    continue;
	if (!*p)
	    break;
	if (p == q) {		/* i.e. starts in the first column, should be
				 * keyword/descNL
				 */
	    found = 0;
	    q = strchr (p, '\n');
	    if (q == NULL)
		q = strchr (p, 0);
	    c = *q;
	    *q = 0;
	    if (include_target) {
		if ((strncmp (p, "include/", 8) == 0)
		    && (strncmp (p + 8, include_target, include_target_len)
			== 0))
		    found = 1;
	    } else if (!strncmp (p, "regex/", 6)) {
		p += 6;
		/* Do not transform shell patterns, you can use shell/ for
		 * that
		 */
		if (regexp_match (p, filename, match_regex))
		    found = 1;
	    } else if (!strncmp (p, "directory/", 10)) {
		if (S_ISDIR (mystat.st_mode)
		    && regexp_match (p + 10, filename, match_regex))
		    found = 1;
	    } else if (!strncmp (p, "shell/", 6)) {
		p += 6;
		if (*p == '.' && file_len >= (q - p)) {
		    if (!strncmp (p, filename + file_len - (q - p), q - p))
			found = 1;
		} else {
		    if (q - p == file_len && !strncmp (p, filename, q - p))
			found = 1;
		}
	    } else if (!strncmp (p, "type/", 5)) {
		int res;
		p += 5;
		res = regex_check_type (filename, p, &have_type);
		if (res == 1)
		    found = 1;
		if (res == -1)
		    error_flag = 1;	/* leave it if file cannot be opened */
	    } else if (!strncmp (p, "default/", 8)) {
		found = 1;
	    }
	    *q = c;
	    p = q;
	    if (!*p)
		break;
	} else {		/* List of actions */
	    p = q;
	    q = strchr (p, '\n');
	    if (q == NULL)
		q = strchr (p, 0);
	    if (found && !error_flag) {
		r = strchr (p, '=');
		if (r != NULL) {
		    c = *r;
		    *r = 0;
		    if (strcmp (p, "Include") == 0) {
			char *t;

			include_target = p + 8;
			t = strchr (include_target, '\n');
			if (t)
			    *t = 0;
			include_target_len = strlen (include_target);
			if (t)
			    *t = '\n';

			*r = c;
			p = q;
			found = 0;

			if (!*p)
			    break;
			continue;
		    }
		    if (!strcmp (action, p)) {
			*r = c;
			for (p = r + 1; *p == ' ' || *p == '\t'; p++);

			/* Empty commands just stop searching
			 * through, they don't do anything
			 *
			 * We need to copy the filename because exec_extension
			 * may end up invoking update_panels thus making the
			 * filename parameter invalid (ie, most of the time,
			 * we get filename as a pointer from current_panel->dir).
			 */
			if (p < q) {
			    char *filename_copy = g_strdup (filename);

			    exec_extension (filename_copy, r + 1, move_dir,
					    view_at_line_number);
			    g_free (filename_copy);

			    ret = 1;
			}
			break;
		    } else
			*r = c;
		}
	    }
	    p = q;
	    if (!*p)
		break;
	}
    }
    if (error_flag)
	return -1;
    return ret;
}
Пример #26
0
static void
file_util_move_multiple (FileDataMult * fdm)
{
    while (fdm->dest || fdm->source_next)
    {
	if (!fdm->dest)
	{
	    GList  *work = fdm->source_next;
	    fdm->source = work->data;
	    fdm->dest =
		concat_dir_and_file (fdm->dest_base,
				     filename_from_path (fdm->source));
	    fdm->source_next = work->next;
	}

	if (fdm->dest && fdm->source && strcmp (fdm->dest, fdm->source) == 0)
	{
	    GenericDialog *gd;
	    const gchar *title;
	    gchar  *text;

	    if (fdm->progress)
	    {
		gtk_grab_remove (fdm->progress);
		gtk_widget_destroy (fdm->progress);
		fdm->progress = NULL;
		fdm->cancel = FALSE;
	    }

	    if (fdm->copy)
	    {
		title = _("Source to copy matches destination");
		text =
		    g_strdup_printf (_
				     ("Unable to copy file:\n%s\nto itself."),
				     fdm->dest);
	    }
	    else
	    {
		title = _("Source to move matches destination");
		text =
		    g_strdup_printf (_
				     ("Unable to move file:\n%s\nto itself."),
				     fdm->dest);
	    }

	    gd = file_util_gen_dlg (title, text, "PornView", "dlg_confirm",
				    TRUE, cb_file_util_move_multiple_cancel,
				    fdm);
	    g_free (text);
	    generic_dialog_add (gd, _("Continue"),
				cb_file_util_move_multiple_skip, TRUE);

	    gtk_widget_show (gd->dialog);
	    return;
	}
	else if (isfile (fdm->dest) && !fdm->confirmed && !fdm->confirm_all
		 && !fdm->skip)
	{
	    GenericDialog *gd;
	    gchar  *text;

	    GtkWidget *hbox;

	    if (fdm->progress)
	    {
		gtk_grab_remove (fdm->progress);
		gtk_widget_destroy (fdm->progress);
		fdm->progress = NULL;
		fdm->cancel = FALSE;
	    }

	    text =
		g_strdup_printf (_("Overwrite file:\n %s\n with:\n %s"),
				 fdm->dest, fdm->source);
	    gd = file_util_gen_dlg (_("Overwrite file"), text, "PornView",
				    "dlg_confirm", TRUE,
				    cb_file_util_move_multiple_cancel, fdm);
	    g_free (text);

	    generic_dialog_add (gd, _("Yes"), cb_file_util_move_multiple_ok,
				TRUE);
	    fdm->yes_all_button =
		generic_dialog_add (gd, _("Yes to all"),
				    cb_file_util_move_multiple_all, FALSE);
	    generic_dialog_add (gd, _("Skip"),
				cb_file_util_move_multiple_skip, FALSE);
	    generic_dialog_add (gd, _("Skip all"),
				cb_file_util_move_multiple_skip_all, FALSE);
	    generic_dialog_add_images (gd, fdm->dest, fdm->source);

	    /*
	     * rename option 
	     */

	    fdm->rename = FALSE;
	    fdm->rename_all = FALSE;
	    fdm->rename_auto = FALSE;

	    hbox = gtk_hbox_new (FALSE, 5);
	    gtk_box_pack_start (GTK_BOX (gd->vbox), hbox, FALSE, FALSE, 0);
	    gtk_widget_show (hbox);

	    fdm->rename_auto_box =
		gtk_check_button_new_with_label (_("Auto rename"));
	    gtk_signal_connect (GTK_OBJECT (fdm->rename_auto_box), "clicked",
				GTK_SIGNAL_FUNC
				(cb_file_util_move_multiple_rename_auto), gd);
	    gtk_box_pack_start (GTK_BOX (hbox), fdm->rename_auto_box, FALSE,
				FALSE, 0);
	    gtk_widget_show (fdm->rename_auto_box);

	    hbox = gtk_hbox_new (FALSE, 5);
	    gtk_box_pack_start (GTK_BOX (gd->vbox), hbox, FALSE, FALSE, 0);
	    gtk_widget_show (hbox);

	    fdm->rename_box = gtk_check_button_new_with_label (_("Rename"));
	    gtk_signal_connect (GTK_OBJECT (fdm->rename_box), "clicked",
				GTK_SIGNAL_FUNC
				(cb_file_util_move_multiple_rename), gd);
	    gtk_box_pack_start (GTK_BOX (hbox), fdm->rename_box, FALSE, FALSE,
				0);
	    gtk_widget_show (fdm->rename_box);

	    fdm->rename_entry = gtk_entry_new ();
	    gtk_entry_set_text (GTK_ENTRY (fdm->rename_entry),
				filename_from_path (fdm->dest));
	    gtk_widget_set_sensitive (fdm->rename_entry, FALSE);
	    gtk_box_pack_start (GTK_BOX (hbox), fdm->rename_entry, TRUE, TRUE,
				0);
	    gtk_widget_show (fdm->rename_entry);

	    gtk_widget_show (gd->dialog);
	    return;
	}
	else
	{
	    gint    success = FALSE;
	    if (fdm->skip)
	    {
		success = TRUE;
		if (!fdm->confirm_all)
		    fdm->skip = FALSE;
	    }
	    else
	    {
		gint    try = TRUE;

		if (fdm->confirm_all && fdm->rename_all && isfile (fdm->dest))
		{
		    gchar  *buf;
		    buf = unique_filename_simple (fdm->dest);
		    if (buf)
		    {
			g_free (fdm->dest);
			fdm->dest = buf;
		    }
		    else
		    {
			try = FALSE;
		    }
		}

		if (try)
		{
		    if (!fdm->progress)
			fdm->progress =
			    dialog_progress_create (_("Pornview - copy/move"),
						    _(" "), &fdm->cancel, 300,
						    -1);
		    gtk_grab_add (fdm->progress);


		    if (fdm->copy)
		    {
			gfloat  c;
			c = (gfloat) fdm->count / (gfloat) fdm->length;
			dialog_progress_update (fdm->progress,
						_("PornView - copy"),
						g_basename (fdm->source),
						_(" "), c);

			if (fdm->cancel)
			    break;
			success = copy_file (fdm->source, fdm->dest);
			fdm->count++;
		    }
		    else
		    {
			gfloat  c;

			c = (gfloat) fdm->count / (gfloat) fdm->length;
			dialog_progress_update (fdm->progress,
						_("PornView - move"),
						g_basename (fdm->source),
						_(" "), c);

			if (fdm->cancel)
			    break;

			while (gtk_events_pending ())
			    gtk_main_iteration ();

			fdm->count++;

			if (move_file (fdm->source, fdm->dest))
			{
			    success = TRUE;
			    file_maint_moved (fdm->source, fdm->dest,
					      fdm->source_list);

			}
		    }
		}
	    }
	    if (!success)
	    {
		GenericDialog *gd;
		const gchar *title;
		gchar  *text;

		if (fdm->progress)
		{
		    gtk_grab_remove (fdm->progress);
		    gtk_widget_destroy (fdm->progress);
		    fdm->progress = NULL;
		    fdm->cancel = FALSE;
		}

		if (fdm->copy)
		{
		    title = _("Error copying file");
		    text =
			g_strdup_printf (_
					 ("Unable to copy file:\n%sto:\n%s\n during multiple file copy."),
					 fdm->source, fdm->dest);
		}
		else
		{
		    title = _("Error moving file");
		    text =
			g_strdup_printf (_
					 ("Unable to move file:\n%sto:\n%s\n during multiple file move."),
					 fdm->source, fdm->dest);
		}
		gd = file_util_gen_dlg (title, text, "PornView",
					"dlg_confirm", TRUE,
					cb_file_util_move_multiple_cancel,
					fdm);
		g_free (text);

		generic_dialog_add (gd, _("Continue"),
				    cb_file_util_move_multiple_skip, TRUE);

		gtk_widget_show (gd->dialog);
		return;
	    }
	    fdm->confirmed = FALSE;
	    g_free (fdm->dest);
	    fdm->dest = NULL;
	}
    }
Пример #27
0
Файл: extfs.c Проект: dborca/mc
static FILE *
extfs_open_archive (int fstype, const char *name, struct archive **pparc)
{
    static dev_t archive_counter = 0;
    FILE *result;
    mode_t mode;
    char *cmd;
    char *mc_extfsdir;
    struct stat mystat;
    struct archive *current_archive;
    struct entry *root_entry;
    char *local_name = NULL, *tmp = 0;
    int uses_archive = extfs_need_archive[fstype];

    if (uses_archive) {
	if (mc_stat (name, &mystat) == -1)
	    return NULL;
	if (!vfs_file_is_local (name)) {
	    local_name = mc_getlocalcopy (name);
	    if (local_name == NULL)
		return NULL;
	}
	tmp = name_quote (name, 0);
    }

    mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
    cmd =
	g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ",
		     local_name ? local_name : tmp, (char *) NULL);
    g_free (tmp);
    g_free (mc_extfsdir);
    open_error_pipe ();
    result = popen (cmd, "r");
    g_free (cmd);
    if (result == NULL) {
	close_error_pipe (1, NULL);
	if (local_name) {
	    mc_ungetlocalcopy (name, local_name, 0);
	    g_free(local_name);
	}
	return NULL;
    } 
#ifdef ___QNXNTO__    
    setvbuf (result, NULL, _IONBF, 0);
#endif    

    current_archive = g_new (struct archive, 1);
    current_archive->fstype = fstype;
    current_archive->name = name ? g_strdup (name) : NULL;
    current_archive->local_name = local_name;

    if (local_name != NULL)
	mc_stat (local_name, &current_archive->local_stat);
    current_archive->inode_counter = 0;
    current_archive->fd_usage = 0;
    current_archive->rdev = archive_counter++;
    current_archive->next = first_archive;
    first_archive = current_archive;
    mode = mystat.st_mode & 07777;
    if (mode & 0400)
	mode |= 0100;
    if (mode & 0040)
	mode |= 0010;
    if (mode & 0004)
	mode |= 0001;
    mode |= S_IFDIR;
    root_entry = extfs_generate_entry (current_archive, "/", NULL, mode);
    root_entry->inode->uid = mystat.st_uid;
    root_entry->inode->gid = mystat.st_gid;
    root_entry->inode->atime = mystat.st_atime;
    root_entry->inode->ctime = mystat.st_ctime;
    root_entry->inode->mtime = mystat.st_mtime;
    current_archive->root_entry = root_entry;

    *pparc = current_archive;

    return result;
}
Пример #28
0
/*
 * This is the function to call when the word to complete is in a position
 * where a command word can be found. It looks around $PATH, looking for
 * commands that match. It also scans aliases, function names, and the
 * table of shell built-ins.
 */
static char *
command_completion_function (char *text, int state)
{
    static const char *path_end;
    static int isabsolute;
    static int phase;
    static int text_len;
    static const char *const *words;
    static char *path;
    static char *cur_path;
    static char *cur_word;
    static int init_state;
    static const char *const bash_reserved[] = {
	"if", "then", "else", "elif", "fi", "case", "esac", "for",
	    "select", "while", "until", "do", "done", "in", "function", 0
    };
    static const char *const bash_builtins[] = {
	"alias", "bg", "bind", "break", "builtin", "cd", "command",
	    "continue", "declare", "dirs", "echo", "enable", "eval",
	    "exec", "exit", "export", "fc", "fg", "getopts", "hash",
	    "help", "history", "jobs", "kill", "let", "local", "logout",
	    "popd", "pushd", "pwd", "read", "readonly", "return", "set",
	    "shift", "source", "suspend", "test", "times", "trap", "type",
	    "typeset", "ulimit", "umask", "unalias", "unset", "wait", 0
    };
    char *p, *found;

    if (!state) {		/* Initialize us a little bit */
	isabsolute = strchr (text, PATH_SEP) != 0;
	look_for_executables = isabsolute ? 1 : 2;
	if (!isabsolute) {
	    words = bash_reserved;
	    phase = 0;
	    text_len = strlen (text);
	    if (!path && (path = g_strdup (getenv ("PATH"))) != NULL) {
		p = path;
		path_end = strchr (p, 0);
		while ((p = strchr (p, PATH_ENV_SEP))) {
		    *p++ = 0;
		}
	    }
	}
    }

    if (isabsolute) {
	p = filename_completion_function (text, state);
	if (!p)
	    look_for_executables = 0;
	return p;
    }

    found = NULL;
    switch (phase) {
    case 0:			/* Reserved words */
	while (*words) {
	    if (!strncmp (*words, text, text_len))
		return g_strdup (*(words++));
	    words++;
	}
	phase++;
	words = bash_builtins;
    case 1:			/* Builtin commands */
	while (*words) {
	    if (!strncmp (*words, text, text_len))
		return g_strdup (*(words++));
	    words++;
	}
	phase++;
	if (!path)
	    break;
	cur_path = path;
	cur_word = NULL;
    case 2:			/* And looking through the $PATH */
	while (!found) {
	    if (!cur_word) {
		char *expanded;

		if (cur_path >= path_end)
		    break;
		expanded = tilde_expand (*cur_path ? cur_path : ".");
		cur_word = concat_dir_and_file (expanded, text);
		g_free (expanded);
		canonicalize_pathname (cur_word);
		cur_path = strchr (cur_path, 0) + 1;
		init_state = state;
	    }
	    found =
		filename_completion_function (cur_word,
					      state - init_state);
	    if (!found) {
		g_free (cur_word);
		cur_word = NULL;
	    }
	}
    }

    if (!found) {
	look_for_executables = 0;
	g_free (path);
	path = NULL;
	return NULL;
    }
    if ((p = strrchr (found, PATH_SEP)) != NULL) {
	p++;
	p = g_strdup (p);
	g_free (found);
	return p;
    }
    return found;

}
Пример #29
0
int
load_codepages_list (void)
{
    int result = -1;
    FILE *f;
    char *fname;
    char buf[256];
    extern char *mc_home;
    extern int display_codepage;
    char *default_codepage = NULL;

    fname = concat_dir_and_file (mc_home, CHARSETS_INDEX);
    if (!(f = fopen (fname, "r"))) {
	fprintf (stderr, _("Warning: file %s not found\n"), fname);
	g_free (fname);
	return -1;
    }
    g_free (fname);

    for (n_codepages = 0; fgets (buf, sizeof (buf), f);)
	if (buf[0] != '\n' && buf[0] != '\0' && buf[0] != '#')
	    ++n_codepages;
    rewind (f);

    codepages = g_new0 (struct codepage_desc, n_codepages + 1);

    for (n_codepages = 0; fgets (buf, sizeof buf, f);) {
	/* split string into id and cpname */
	char *p = buf;
	int buflen = strlen (buf);

	if (*p == '\n' || *p == '\0' || *p == '#')
	    continue;

	if (buflen > 0 && buf[buflen - 1] == '\n')
	    buf[buflen - 1] = '\0';
	while (*p != '\t' && *p != ' ' && *p != '\0')
	    ++p;
	if (*p == '\0')
	    goto fail;

	*p++ = 0;

	while (*p == '\t' || *p == ' ')
	    ++p;
	if (*p == '\0')
	    goto fail;

	if (strcmp (buf, "default") == 0) {
	    default_codepage = g_strdup (p);
	    continue;
	}

	codepages[n_codepages].id = g_strdup (buf);
	codepages[n_codepages].name = g_strdup (p);
	++n_codepages;
    }

    if (default_codepage) {
	display_codepage = get_codepage_index (default_codepage);
	g_free (default_codepage);
    }

    result = n_codepages;
  fail:
    fclose (f);
    return result;
}
Пример #30
0
void load_setup (void)
{
    static char *buffer;
    char   *profile;
    char   *inifile;
    int    i;
#ifdef USE_NETCODE
    extern char *ftpfs_proxy_host;
#endif
    buffer = concat_dir_and_file (home_dir, PROFILE_NAME);
    inifile = concat_dir_and_file (mc_home, "mc.ini");
    if (exist_file (buffer)){
	profile = buffer;
    } else if (exist_file (inifile)){
	profile = strdup (inifile);
	free (buffer);
    } else {
	profile = buffer;
    }
    free (inifile);
    
    profile_name = profile;

    /* Load integer boolean options */
    for (i = 0; options [i].opt_name; i++)
	*options [i].opt_addr =
	    get_int (profile, options [i].opt_name, *options [i].opt_addr);

    load_layout (profile);

    load_panelize ();

    startup_left_mode = load_mode ("New Left Panel");
    startup_right_mode = load_mode ("New Right Panel");

    /* At least one of the panels is a listing panel */
    if (startup_left_mode != view_listing && startup_right_mode!=view_listing)
	startup_left_mode = view_listing;
    
    if (!other_dir){
	buffer = (char*) malloc (MC_MAXPATHLEN);
	load_string ("Dirs", "other_dir", ".", buffer,
			     MC_MAXPATHLEN);
	if (vfs_file_is_local (buffer))
	    other_dir = buffer;
	else
	    free (buffer);
    }
#ifdef USE_NETCODE
    ftpfs_proxy_host = do_load_string ("Misc", "ftp_proxy_host", "gate");
#endif
    boot_current_is_left =
	GetPrivateProfileInt ("Dirs", "current_is_left", 1, profile);
    
    load_string ("Misc", "find_ignore_dirs", "", setup_color_string,
		 sizeof (setup_color_string));
    if (setup_color_string [0])
	find_ignore_dirs = copy_strings (":", setup_color_string, ":", 0);
    
    /* The default color and the terminal dependent color */
    load_string ("Colors", "base_color", "", setup_color_string,
			     sizeof (setup_color_string));
    load_string ("Colors", getenv ("TERM"), "",
			     term_color_string, sizeof (term_color_string));
    load_string ("Colors", "color_terminals", "",
			     color_terminal_string, sizeof (color_terminal_string));

    /* Load the directory history */
/*    directory_history_load (); */
    /* Remove the temporal entries */
    profile_clean_section ("Temporal:New Left Panel", profile_name);
    profile_clean_section ("Temporal:New Right Panel", profile_name);
#ifdef USE_VFS
#ifdef USE_NETCODE
    ftpfs_init_passwd ();
#endif
#endif
}