1
1

Some reorginizing of VFS private and public APIs.

Clean up of remained mcfs support.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2010-07-08 11:32:37 +04:00
родитель 57281c6e0b
Коммит 9df2f96e75
13 изменённых файлов: 105 добавлений и 139 удалений

Просмотреть файл

@ -489,8 +489,6 @@ strip_password (char *p, int has_prefix)
/* *INDENT-OFF* */
{ "/#ftp:", 6 },
{ "ftp://", 6 },
{ "/#mc:", 5 },
{ "mc://", 5 },
{ "/#smb:", 6 },
{ "smb://", 6 },
{ "/#sh:", 5 },

Просмотреть файл

@ -44,22 +44,18 @@
#include "lib/global.h"
#include "src/wtools.h" /* message() */
#include "src/main.h" /* print_vfs_message */
#include "src/panel.h" /* get_current_panel() */
#include "src/layout.h" /* get_current_type() */
#include "src/panel.h" /* current_panel */
#include "src/layout.h" /* get_current_type(), get_other_type() */
#include "utilvfs.h"
#include "vfs-impl.h"
#include "vfs.h"
#include "gc.h"
#include "utilvfs.h"
int vfs_timeout = 60; /* VFS timeout in seconds */
static struct vfs_stamping *stamps;
static void
vfs_addstamp (struct vfs_class *v, vfsid id)
{
@ -142,8 +138,8 @@ vfs_getid (struct vfs_class *vclass, const char *dir)
}
static void
vfs_stamp_path (char *path)
void
vfs_stamp_path (const char *path)
{
struct vfs_class *vfs;
vfsid id;
@ -205,24 +201,6 @@ vfs_stamp_create (struct vfs_class *oldvfs, vfsid oldvfsid)
vfs_addstamp (oldvfs, oldvfsid);
}
void
vfs_add_current_stamps (void)
{
vfs_stamp_path (vfs_get_current_dir ());
if (current_panel) {
if (get_current_type () == view_listing)
vfs_stamp_path (current_panel->cwd);
}
if (other_panel) {
if (get_other_type () == view_listing)
vfs_stamp_path (other_panel->cwd);
}
}
/* Compare two timeval structures. Return 0 is t1 is less than t2. */
static inline int
timeoutcmp (struct timeval *t1, struct timeval *t2)

Просмотреть файл

@ -20,11 +20,8 @@ struct vfs_stamping
void vfs_stamp (struct vfs_class *vclass, vfsid id);
void vfs_rmstamp (struct vfs_class *vclass, vfsid id);
void vfs_stamp_create (struct vfs_class *vclass, vfsid id);
void vfs_add_current_stamps (void);
void vfs_timeout_handler (void);
void vfs_expire (int now);
int vfs_timeouts (void);
void vfs_release_path (const char *dir);
vfsid vfs_getid (struct vfs_class *vclass, const char *dir);
void vfs_gc_done (void);

Просмотреть файл

@ -36,15 +36,15 @@
#include <sys/types.h>
#undef USE_NCURSES /* Don't include *curses.h */
#undef USE_NCURSESW
#undef USE_NCURSESW
#include <string.h>
#include "lib/global.h"
#include "src/wtools.h" /* message() */
#include "src/main.h" /* print_vfs_message */
#include "utilvfs.h"
#undef PACKAGE_BUGREPORT
#undef PACKAGE_NAME
#undef PACKAGE_STRING
@ -60,12 +60,10 @@
#include "samba/include/includes.h"
#include <string.h>
#include "vfs.h"
#include "vfs-impl.h"
#include "smbfs.h"
#include "netutil.h"
#include "utilvfs.h"
#include "smbfs.h"
#define SMBFS_MAX_CONNECTIONS 16
static const char * const IPC = "IPC$";
@ -183,20 +181,14 @@ smbfs_auth_cmp_host (gconstpointer _a, gconstpointer _b)
static void
smbfs_auth_add (const char *host, const char *share, const char *domain,
const char *user, const char *param_password)
const char *user, const char *pass)
{
struct smb_authinfo *auth = g_try_new (struct smb_authinfo, 1);
struct smb_authinfo *auth;
if (auth == NULL)
return;
auth = vfs_smb_authinfo_new (host, share, domain, user, pass);
/* Don't check for NULL, g_strdup already does. */
auth->host = g_strdup (host);
auth->share = g_strdup (share);
auth->domain = g_strdup (domain);
auth->user = g_strdup (user);
auth->password = g_strdup (param_password);
auth_list = g_slist_prepend (auth_list, auth);
if (auth != NULL)
auth_list = g_slist_prepend (auth_list, auth);
}
static void
@ -1967,6 +1959,26 @@ smbfs_fstat (void *data, struct stat *buf)
return 0;
}
smb_authinfo *
vfs_smb_authinfo_new (const char *host, const char *share, const char *domain,
const char *user, const char *pass)
{
smb_authinfo *auth;
auth = g_try_new (struct smb_authinfo, 1);
if (auth != NULL)
{
auth->host = g_strdup (host);
auth->share = g_strdup (share);
auth->domain = g_strdup (domain);
auth->user = g_strdup (user);
auth->password = g_strdup (password);
}
return auth;
}
void
init_smbfs (void)
{

Просмотреть файл

@ -8,7 +8,28 @@
#define MC_VFS_SMBFS_H
void init_smbfs (void);
extern void smbfs_set_debug (int arg);
extern void smbfs_set_debugf (const char *filename);
void smbfs_set_debug (int arg);
void smbfs_set_debugf (const char *filename);
#endif
typedef struct smb_authinfo
{
char *host;
char *share;
char *domain;
char *user;
char *password;
} smb_authinfo;
smb_authinfo *vfs_smb_authinfo_new (const char *host,
const char *share,
const char *domain,
const char *user,
const char *pass);
/* src/boxes.c */
smb_authinfo *vfs_smb_get_authinfo (const char *host,
const char *share,
const char *domain,
const char *user);
#endif /* MC_VFS_SMBFS_H */

Просмотреть файл

@ -17,19 +17,12 @@
#include <stddef.h>
#include <utime.h>
#include "vfs.h"
#include "lib/fs.h" /* MC_MAXPATHLEN */
typedef void *vfsid;
struct vfs_stamping;
/**
* This is the type of callback function passed to vfs_fill_names.
* It gets the name of the virtual file system as its first argument.
* See also:
* vfs_fill_names().
*/
typedef void (*fill_names_f) (const char *);
struct vfs_class {
struct vfs_class *next;
const char *name; /* "FIles over SHell" */
@ -40,7 +33,7 @@ struct vfs_class {
int (*init) (struct vfs_class *me);
void (*done) (struct vfs_class *me);
/**
* The fill_names method shall call the callback function for every
* filesystem name that this vfs module supports.
@ -112,28 +105,8 @@ union vfs_dirent {
/* Register a file system class */
int vfs_register_class (struct vfs_class *vfs);
#ifdef ENABLE_VFS_SMB
/* Interface for requesting SMB credentials. */
struct smb_authinfo {
char *host;
char *share;
char *domain;
char *user;
char *password;
};
struct smb_authinfo *vfs_smb_get_authinfo (const char *host,
const char *share,
const char *domain,
const char *user);
#endif /* ENABLE_VFS_SMB */
struct vfs_class *vfs_get_class (const char *path);
struct vfs_class *vfs_split (char *path, char **inpath, char **op);
char *vfs_path (const char *path);
int vfs_file_class_flags (const char *filename);
void vfs_fill_names (fill_names_f);
/* vfs/direntry.c: */
void *vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode);

Просмотреть файл

@ -1399,7 +1399,6 @@ static const struct
{
/* *INDENT-OFF* */
{ "ftp://", 6, "/#ftp:" },
{ "mc://", 5, "/#mc:" },
{ "smb://", 6, "/#smb:" },
{ "sh://", 5, "/#sh:" },
{ "ssh://", 6, "/#sh:" },

Просмотреть файл

@ -14,6 +14,8 @@
#include "lib/global.h"
struct vfs_class;
/* Flags of VFS classes */
typedef enum
{
@ -24,6 +26,14 @@ typedef enum
#ifdef ENABLE_VFS
/**
* This is the type of callback function passed to vfs_fill_names.
* It gets the name of the virtual file system as its first argument.
* See also:
* vfs_fill_names().
*/
typedef void (*fill_names_f) (const char *);
extern int vfs_timeout;
#ifdef USE_NETCODE
@ -32,6 +42,7 @@ extern int use_netrc;
void vfs_init (void);
void vfs_shut (void);
void vfs_expire (int now);
gboolean vfs_current_is_local (void);
gboolean vfs_file_is_local (const char *filename);
@ -80,6 +91,12 @@ char *vfs_translate_path_n (const char *path);
/* canonize and translate path, return new string */
char *vfs_canon_and_translate (const char *path);
void vfs_stamp_path (const char *path);
void vfs_release_path (const char *dir);
void vfs_fill_names (fill_names_f);
#else /* ENABLE_VFS */
/* Only the routines outside of the VFS module need the emulation macros */
@ -93,7 +110,6 @@ char *vfs_canon_and_translate (const char *path);
#define vfs_translate_url(s) g_strdup(s)
#define vfs_file_class_flags(x) (VFSF_LOCAL)
#define vfs_release_path(x)
#define vfs_add_current_stamps() do { } while (0)
#define vfs_timeout_handler() do { } while (0)
#define vfs_timeouts() 0
@ -261,4 +277,4 @@ enum {
#define E_PROTO EIO
#endif
#endif
#endif /* MC_VFS_VFS_H */

Просмотреть файл

@ -37,18 +37,15 @@
#include "lib/global.h"
#include "lib/tty/tty.h"
#include "lib/skin.h" /* INPUT_COLOR */
#include "lib/tty/key.h" /* XCTRL and ALT macros */
#include "lib/skin.h" /* INPUT_COLOR */
#include "lib/mcconfig.h" /* Load/save user formats */
#include "lib/strutil.h"
#ifdef ENABLE_VFS
#include "lib/vfs/mc-vfs/vfs.h" /* vfs_timeout */
#include "lib/vfs/mc-vfs/vfs-impl.h"
#endif
#include "lib/vfs/mc-vfs/vfs.h"
#ifdef USE_NETCODE
# include "lib/vfs/mc-vfs/ftpfs.h"
# include "lib/vfs/mc-vfs/smbfs.h"
#endif
#include "dialog.h" /* The nice dialog manager */
@ -58,7 +55,6 @@
#include "command.h" /* For cmdline */
#include "dir.h"
#include "panel.h" /* LIST_TYPES */
#include "boxes.h"
#include "main.h" /* For the confirm_* variables */
#include "tree.h"
#include "layout.h" /* for get_nth_panel_name proto */
@ -69,6 +65,7 @@
#include "selcodepage.h"
#endif
#include "boxes.h"
static WRadio *display_radio;
static WInput *display_user_format;
@ -1068,9 +1065,7 @@ struct smb_authinfo *
vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, const char *user)
{
static int dialog_x = 44;
enum
{ b0 = 3, dialog_y = 12 };
struct smb_authinfo *return_value;
int b0 = 3, dialog_y = 12;
static const char *lc_labs[] = { N_("Domain:"), N_("Username:"), N_("Password:") };
static const char *buts[] = { N_("&OK"), N_("&Cancel") };
static int ilen = 30, istart = 14;
@ -1080,6 +1075,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, c
WInput *in_user;
WInput *in_domain;
Dlg_head *auth_dlg;
struct smb_authinfo *return_value = NULL;
const int input_colors[3] =
{
@ -1155,24 +1151,9 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, c
add_widget (auth_dlg, label_new (5, 3, lc_labs[1]));
add_widget (auth_dlg, label_new (3, 3, lc_labs[0]));
run_dlg (auth_dlg);
switch (auth_dlg->ret_value)
{
case B_CANCEL:
return_value = 0;
break;
default:
return_value = g_try_new (struct smb_authinfo, 1);
if (return_value)
{
return_value->host = g_strdup (host);
return_value->share = g_strdup (share);
return_value->domain = g_strdup (in_domain->buffer);
return_value->user = g_strdup (in_user->buffer);
return_value->password = g_strdup (in_password->buffer);
}
}
if (run_dlg (auth_dlg) != B_CANCEL)
return_value = vfs_smb_authinfo_new (host, share, in_domain->buffer, in_user->buffer,
in_password->buffer);
destroy_dlg (auth_dlg);

Просмотреть файл

@ -59,10 +59,9 @@
#include "lib/tty/tty.h"
#include "lib/tty/key.h"
#include "lib/search.h"
#include "lib/vfs/mc-vfs/vfs-impl.h"
#include "lib/vfs/mc-vfs/vfs.h"
#include "lib/strescape.h"
#include "lib/strutil.h"
#include "lib/vfs/mc-vfs/vfs.h"
#include "setup.h"
#include "dialog.h"
@ -193,17 +192,11 @@ is_in_linklist (struct link *lp, const char *path, struct stat *sb)
{
ino_t ino = sb->st_ino;
dev_t dev = sb->st_dev;
#ifdef ENABLE_VFS
struct vfs_class *vfs = vfs_get_class (path);
#endif /* ENABLE_VFS */
(void) path;
while (lp)
while (lp != NULL)
{
#ifdef ENABLE_VFS
if (lp->vfs == vfs)
#endif /* ENABLE_VFS */
if (lp->ino == ino && lp->dev == dev)
return 1;
lp = lp->next;

Просмотреть файл

@ -48,6 +48,7 @@
#include "lib/mcconfig.h" /* Load/save directories hotlist */
#include "lib/fileloc.h"
#include "lib/strutil.h"
#include "lib/vfs/mc-vfs/vfs.h"
#include "dialog.h"
#include "widget.h"
@ -78,7 +79,6 @@
#define B_MOVE (B_USER + 7)
#ifdef ENABLE_VFS
#include "lib/vfs/mc-vfs/gc.h"
#define B_FREE_ALL_VFS (B_USER + 8)
#define B_REFRESH_VFS (B_USER + 9)
#endif

Просмотреть файл

@ -45,27 +45,18 @@
#include "lib/tty/mouse.h"
#include "lib/tty/key.h" /* For init_key() */
#include "lib/tty/win.h" /* xterm_flag */
#include "lib/skin.h"
#include "lib/mcconfig.h"
#include "lib/filehighlight.h"
#include "lib/fileloc.h" /* MC_USERCONF_DIR */
#include "lib/strutil.h"
#include "lib/vfs/mc-vfs/vfs.h" /* vfs_translate_url() */
#ifdef ENABLE_VFS_SMB
#include "lib/vfs/mc-vfs/smbfs.h" /* smbfs_set_debug() */
#endif /* ENABLE_VFS_SMB */
#ifdef ENABLE_VFS
#include "lib/vfs/mc-vfs/gc.h"
#endif
#include "lib/strutil.h"
#include "src/args.h"
#include "args.h"
#include "dir.h"
#include "dialog.h"
#include "menu.h"
@ -1578,7 +1569,18 @@ done_mc (void)
save_panel_types ();
}
done_screen ();
vfs_add_current_stamps ();
#ifdef ENABLE_VFS
vfs_stamp_path (vfs_get_current_dir ());
if ((current_panel != NULL)
&& (get_current_type () == view_listing))
vfs_stamp_path (current_panel->cwd);
if ((other_panel != NULL)
&& (get_other_type () == view_listing))
vfs_stamp_path (other_panel->cwd);
#endif
}
static cb_ret_t

Просмотреть файл

@ -38,10 +38,6 @@
#include "lib/vfs/mc-vfs/vfs.h"
#ifdef ENABLE_VFS
#include "lib/vfs/mc-vfs/gc.h"
#endif
#ifdef USE_NETCODE
#include "lib/vfs/mc-vfs/ftpfs.h"
#include "lib/vfs/mc-vfs/fish.h"