VFS: moved functions from src/vfsdummy.h to vfs/vfs.h

This commit is contained in:
Enrico Weigelt, metux IT service 2009-12-31 03:17:48 +01:00 committed by Andrew Borodin
parent 491b88eae9
commit cb56023b4d
3 changed files with 89 additions and 92 deletions

View File

@ -9,62 +9,10 @@
#include "global.h" /* glib.h*/
#include "util.h"
/* Flags of VFS classes */
#define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */
#define VFSF_NOLINKS 2 /* Hard links not supported */
#define mc_close close
#define mc_lseek lseek
#define mc_opendir opendir
#define mc_readdir readdir
#define mc_closedir closedir
#define mc_stat stat
#define mc_mknod mknod
#define mc_link link
#define mc_mkdir mkdir
#define mc_rmdir rmdir
#define mc_fstat fstat
#define mc_lstat lstat
#define mc_symlink symlink
#define mc_rename rename
#define mc_open open
#define mc_chmod chmod
#define mc_chown chown
#define mc_chdir chdir
#define mc_unlink unlink
static inline int
return_zero (void)
{
return 0;
}
#define mc_ctl(a,b,c) return_zero()
#define mc_setctl(a,b,c) return_zero()
#define mc_get_current_wd(x,size) get_current_wd (x, size)
#define mc_getlocalcopy(x) vfs_canon(x)
#define vfs_strip_suffix_from_filename(x) g_strdup(x)
#define vfs_file_class_flags(x) (VFSF_LOCAL)
#define vfs_get_class(x) (struct vfs_class *)(NULL)
#define vfs_translate_url(s) g_strdup(s)
#define vfs_release_path(x)
#define vfs_add_current_stamps() do { } while (0)
#define vfs_timeout_handler() do { } while (0)
#define vfs_timeouts() 0
static inline char *
vfs_canon (const char *path)
{
char *p = g_strdup (path);
canonicalize_pathname(p);
return p;
}
#endif /* MC_VFSDUMMY_H */

View File

@ -19,10 +19,6 @@
typedef void *vfsid;
struct vfs_stamping;
/* Flags of VFS classes */
#define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */
#define VFSF_NOLINKS 2 /* Hard links not supported */
/**
* 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.

125
vfs/vfs.h
View File

@ -12,6 +12,10 @@
#include <utime.h>
#include <stdio.h>
/* Flags of VFS classes */
#define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */
#define VFSF_NOLINKS 2 /* Hard links not supported */
#ifdef ENABLE_VFS
void vfs_init (void);
@ -24,6 +28,32 @@ ssize_t mc_write (int handle, const void *buffer, int count);
int mc_utime (const char *path, struct utimbuf *times);
int mc_readlink (const char *path, char *buf, int bufsiz);
int mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed);
int mc_close (int handle);
off_t mc_lseek (int fd, off_t offset, int whence);
DIR *mc_opendir (const char *dirname);
struct dirent *mc_readdir (DIR * dirp);
int mc_closedir (DIR * dir);
int mc_stat (const char *path, struct stat *buf);
int mc_mknod (const char *, mode_t, dev_t);
int mc_link (const char *name1, const char *name2);
int mc_mkdir (const char *path, mode_t mode);
int mc_rmdir (const char *path);
int mc_fstat (int fd, struct stat *buf);
int mc_lstat (const char *path, struct stat *buf);
int mc_symlink (const char *name1, const char *name2);
int mc_rename (const char *original, const char *target);
int mc_chmod (const char *path, mode_t mode);
int mc_chown (const char *path, uid_t owner, gid_t group);
int mc_chdir (const char *path);
int mc_unlink (const char *path);
int mc_ctl (int fd, int ctlop, void *arg);
int mc_setctl (const char *path, int ctlop, void *arg);
int mc_open (const char *filename, int flags, ...);
char *mc_get_current_wd (char *buffer, int bufsize);
char *vfs_canon (const char *path);
char *mc_getlocalcopy (const char *pathname);
char *vfs_strip_suffix_from_filename (const char *filename);
char *vfs_translate_url (const char *url);
/* return encoding after last #enc: or NULL, if part does not contain #enc:
* return static buffer */
@ -32,17 +62,68 @@ const char *vfs_get_encoding (const char *path);
/* return new string */
char *vfs_translate_path_n (const char *path);
/* canonize and translate path, return new string */
char *vfs_canon_and_translate (const char *path);
#else /* ENABLE_VFS */
/* Only the routines outside of the VFS module need the emulation macros */
#define vfs_init() do { } while (0)
#define vfs_shut() do { } while (0)
#define vfs_current_is_local() (1)
#define vfs_file_is_local(x) (1)
#define vfs_strip_suffix_from_filename(x) g_strdup(x)
#define vfs_get_class(x) (struct vfs_class *)(NULL)
#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
#define mc_getlocalcopy(x) vfs_canon(x)
#define mc_read read
#define mc_write write
#define mc_utime utime
#define mc_readlink readlink
#define mc_ungetlocalcopy(x,y,z) do { } while (0)
#define mc_close close
#define mc_lseek lseek
#define mc_opendir opendir
#define mc_readdir readdir
#define mc_closedir closedir
#define mc_stat stat
#define mc_mknod mknod
#define mc_link link
#define mc_mkdir mkdir
#define mc_rmdir rmdir
#define mc_fstat fstat
#define mc_lstat lstat
#define mc_symlink symlink
#define mc_rename rename
#define mc_chmod chmod
#define mc_chown chown
#define mc_chdir chdir
#define mc_unlink unlink
#define mc_open open
#define mc_get_current_wd(x,size) get_current_wd (x, size)
static inline int mc_setctl (const char *path, int ctlop, void *arg)
{
(void) path;
(void) ctlop;
(void) arg;
return 0;
}
static inline int mc_ctl (int fd, int ctlop, void *arg)
{
(void) fd;
(void) ctlop;
(void) arg;
return 0;
}
static inline const char *vfs_get_encoding (const char *path)
{
@ -76,49 +157,21 @@ static inline char* vfs_canon_and_translate(const char* path)
return ret_str;
}
static inline char *
vfs_canon (const char *path)
{
char *p = g_strdup (path);
canonicalize_pathname(p);
return p;
}
#endif /* ENABLE_VFS */
char *vfs_strip_suffix_from_filename (const char *filename);
char *vfs_canon (const char *path);
char *mc_get_current_wd (char *buffer, int bufsize);
char *vfs_get_current_dir (void);
/* translate path back to terminal encoding, remove all #enc:
* every invalid character is replaced with question mark
* return static buffer */
char *vfs_translate_path (const char *path);
/* canonize and translate path, return new string */
char *vfs_canon_and_translate (const char *path);
char *vfs_translate_url (const char *url);
/* Only the routines outside of the VFS module need the emulation macros */
int mc_open (const char *filename, int flags, ...);
int mc_close (int handle);
off_t mc_lseek (int fd, off_t offset, int whence);
int mc_chdir (const char *path);
DIR *mc_opendir (const char *dirname);
struct dirent *mc_readdir (DIR * dirp);
int mc_closedir (DIR * dir);
int mc_stat (const char *path, struct stat *buf);
int mc_lstat (const char *path, struct stat *buf);
int mc_fstat (int fd, struct stat *buf);
int mc_chmod (const char *path, mode_t mode);
int mc_chown (const char *path, uid_t owner, gid_t group);
int mc_unlink (const char *path);
int mc_symlink (const char *name1, const char *name2);
int mc_link (const char *name1, const char *name2);
int mc_mknod (const char *, mode_t, dev_t);
int mc_rename (const char *original, const char *target);
int mc_rmdir (const char *path);
int mc_mkdir (const char *path, mode_t mode);
char *mc_getlocalcopy (const char *pathname);
int mc_ctl (int fd, int ctlop, void *arg);
int mc_setctl (const char *path, int ctlop, void *arg);
/* Operations for mc_ctl - on open file */
enum {