Ticket #1627: glib macros fix.
[midnight-commander.git] / vfs / vfs-impl.h
blobe6156472346cc6eb6349af53d10b92219930aab1
2 /**
3 * \file
4 * \brief Header: VFS implemntation (?)
5 */
7 #ifndef MC_VFS_IMPL_H
8 #define MC_VFS_IMPL_H
10 #ifdef USE_VFS
12 #include <sys/types.h>
13 #include <dirent.h>
15 #include "../src/fs.h" /* MC_MAXPATHLEN */
17 typedef void *vfsid;
18 struct vfs_stamping;
20 /* Flags of VFS classes */
21 #define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */
22 #define VFSF_NOLINKS 2 /* Hard links not supported */
24 /**
25 * This is the type of callback function passed to vfs_fill_names.
26 * It gets the name of the virtual file system as its first argument.
27 * See also:
28 * vfs_fill_names().
30 typedef void (*fill_names_f) (const char *);
32 struct vfs_class {
33 struct vfs_class *next;
34 const char *name; /* "FIles over SHell" */
35 int flags;
36 const char *prefix; /* "fish:" */
37 void *data; /* this is for filesystem's own use */
38 int verrno; /* can't use errno because glibc2 might define errno as function */
40 int (*init) (struct vfs_class *me);
41 void (*done) (struct vfs_class *me);
43 /**
44 * The fill_names method shall call the callback function for every
45 * filesystem name that this vfs module supports.
47 void (*fill_names) (struct vfs_class *me, fill_names_f);
49 /**
50 * The which() method shall return the index of the vfs subsystem
51 * or -1 if this vfs cannot handle the given pathname.
53 int (*which) (struct vfs_class *me, const char *path);
55 void *(*open) (struct vfs_class *me, const char *fname, int flags,
56 int mode);
57 int (*close) (void *vfs_info);
58 ssize_t (*read) (void *vfs_info, char *buffer, int count);
59 ssize_t (*write) (void *vfs_info, const char *buf, int count);
61 void *(*opendir) (struct vfs_class *me, const char *dirname);
62 void *(*readdir) (void *vfs_info);
63 int (*closedir) (void *vfs_info);
65 int (*stat) (struct vfs_class *me, const char *path, struct stat * buf);
66 int (*lstat) (struct vfs_class *me, const char *path, struct stat * buf);
67 int (*fstat) (void *vfs_info, struct stat * buf);
69 int (*chmod) (struct vfs_class *me, const char *path, int mode);
70 int (*chown) (struct vfs_class *me, const char *path, int owner, int group);
71 int (*utime) (struct vfs_class *me, const char *path,
72 struct utimbuf * times);
74 int (*readlink) (struct vfs_class *me, const char *path, char *buf,
75 size_t size);
76 int (*symlink) (struct vfs_class *me, const char *n1, const char *n2);
77 int (*link) (struct vfs_class *me, const char *p1, const char *p2);
78 int (*unlink) (struct vfs_class *me, const char *path);
79 int (*rename) (struct vfs_class *me, const char *p1, const char *p2);
80 int (*chdir) (struct vfs_class *me, const char *path);
81 int (*ferrno) (struct vfs_class *me);
82 off_t (*lseek) (void *vfs_info, off_t offset, int whence);
83 int (*mknod) (struct vfs_class *me, const char *path, int mode, int dev);
85 vfsid (*getid) (struct vfs_class *me, const char *path);
87 int (*nothingisopen) (vfsid id);
88 void (*free) (vfsid id);
90 char *(*getlocalcopy) (struct vfs_class *me, const char *filename);
91 int (*ungetlocalcopy) (struct vfs_class *me, const char *filename,
92 const char *local, int has_changed);
94 int (*mkdir) (struct vfs_class *me, const char *path, mode_t mode);
95 int (*rmdir) (struct vfs_class *me, const char *path);
97 int (*ctl) (void *vfs_info, int ctlop, void *arg);
98 int (*setctl) (struct vfs_class *me, const char *path, int ctlop,
99 void *arg);
103 * This union is used to ensure that there is enough space for the
104 * filename (d_name) when the dirent structure is created.
106 union vfs_dirent {
107 struct dirent dent;
108 char _extra_buffer[offsetof(struct dirent, d_name) + MC_MAXPATHLEN + 1];
111 /* Register a file system class */
112 int vfs_register_class (struct vfs_class *vfs);
114 #ifdef WITH_SMBFS
115 /* Interface for requesting SMB credentials. */
116 struct smb_authinfo {
117 char *host;
118 char *share;
119 char *domain;
120 char *user;
121 char *password;
124 struct smb_authinfo *vfs_smb_get_authinfo (const char *host,
125 const char *share,
126 const char *domain,
127 const char *user);
128 #endif /* WITH_SMBFS */
130 struct vfs_class *vfs_get_class (const char *path);
131 struct vfs_class *vfs_split (char *path, char **inpath, char **op);
132 char *vfs_path (const char *path);
133 int vfs_file_class_flags (const char *filename);
135 void vfs_fill_names (fill_names_f);
137 /* vfs/direntry.c: */
138 void *vfs_s_open (struct vfs_class *, const char *, int, int);
140 #ifdef USE_NETCODE
141 extern int use_netrc;
142 #endif
144 void init_cpiofs (void);
145 void init_extfs (void);
146 void init_fish (void);
147 void init_sfs (void);
148 void init_tarfs (void);
149 void init_undelfs (void);
151 #endif /* USE_VFS */
153 #endif /* MC_VFS_IMPL_H */