got a lot of crypt32 stuff working
[reactos.git] / rosapps / mc / vfs / vfs.h
1 #ifndef __VFS_H
2 #define __VFS_H
3
4 #if !defined(_MSC_VER)
5 #if !defined(SCO_FLAVOR) || !defined(_SYS_SELECT_H)
6 # include <sys/time.h> /* alex: this redefines struct timeval */
7 #endif /* SCO_FLAVOR */
8 #else
9 #include <time.h>
10 #endif
11
12 #ifdef HAVE_UTIME_H
13 # include <utime.h>
14 #else
15 struct utimbuf {
16 time_t actime;
17 time_t modtime;
18 };
19 #endif
20
21 #ifdef USE_VFS
22
23 #ifdef HAVE_MMAP
24 #include <sys/mman.h>
25 #endif
26
27 /* Our virtual file system layer */
28
29 typedef void * vfsid;
30
31 struct vfs_stamping;
32
33 typedef struct {
34 void *(*open)(char *fname, int flags, int mode);
35 int (*close)(void *vfs_info);
36 int (*read)(void *vfs_info, char *buffer, int count);
37 int (*write)(void *vfs_info, char *buf, int count);
38
39 void *(*opendir)(char *dirname);
40 void *(*readdir)(void *vfs_info);
41 int (*closedir)(void *vfs_info);
42
43 int (*stat)(char *path, struct stat *buf);
44 int (*lstat)(char *path, struct stat *buf);
45 int (*fstat)(void *vfs_info, struct stat *buf);
46
47 int (*chmod)(char *path, int mode);
48 int (*chown)(char *path, int owner, int group);
49 int (*utime)(char *path, struct utimbuf *times);
50
51 int (*readlink)(char *path, char *buf, int size);
52 int (*symlink)(char *n1, char *n2);
53 int (*link)(char *p1, char *p2);
54 int (*unlink)(char *path);
55 int (*rename)(char *p1, char *p2);
56 int (*chdir)(char *path);
57 int (*ferrno)(void);
58 int (*lseek)(void *vfs_info, off_t offset, int whence);
59 int (*mknod)(char *path, int mode, int dev);
60
61 vfsid (*getid)(char *path, struct vfs_stamping **parent);
62 int (*nothingisopen)(vfsid id);
63 void (*free)(vfsid id);
64
65 char *(*getlocalcopy)(char *filename);
66 void (*ungetlocalcopy)(char *filename, char *local, int has_changed);
67
68 int (*mkdir)(char *path, mode_t mode);
69 int (*rmdir)(char *path);
70
71 int (*ctl)(void *vfs_info, int ctlop, int arg);
72 int (*setctl)(char *path, int ctlop, char *arg);
73 void (*forget_about)(char *path);
74 #ifdef HAVE_MMAP
75 caddr_t (*mmap)(caddr_t addr, size_t len, int prot, int flags, void *vfs_info, off_t offset);
76 int (*munmap)(caddr_t addr, size_t len, void *vfs_info);
77 #endif
78 } vfs;
79
80 /* Other file systems */
81 extern vfs local_vfs_ops;
82 extern vfs tarfs_vfs_ops;
83
84 extern vfs ftpfs_vfs_ops;
85 extern vfs mcfs_vfs_ops;
86
87 extern vfs extfs_vfs_ops;
88
89 extern vfs undelfs_vfs_ops;
90
91 struct vfs_stamping {
92 vfs *v;
93 vfsid id;
94 struct vfs_stamping *parent; /* At the moment applies to tarfs only */
95 struct vfs_stamping *next;
96 struct timeval time;
97 };
98
99 void vfs_init (void);
100 void vfs_shut (void);
101
102 extern int vfs_type_absolute;
103 vfs *vfs_type (char *path);
104 vfsid vfs_ncs_getid (vfs *nvfs, char *dir, struct vfs_stamping **par);
105 void vfs_rm_parents (struct vfs_stamping *stamp);
106 char *vfs_path (char *path);
107 char *vfs_canon (char *path);
108 char *mc_get_current_wd (char *buffer, int bufsize);
109 int vfs_current_is_local (void);
110 int vfs_current_is_extfs (void);
111 int vfs_current_is_tarfs (void);
112 int vfs_file_is_local (char *name);
113 int vfs_file_is_ftp (char *filename);
114 char *vfs_get_current_dir (void);
115
116 void vfs_stamp (vfs *, vfsid);
117 void vfs_rmstamp (vfs *, vfsid, int);
118 void vfs_addstamp (vfs *, vfsid, struct vfs_stamping *);
119 void vfs_add_noncurrent_stamps (vfs *, vfsid, struct vfs_stamping *);
120 void vfs_add_current_stamps (void);
121 void vfs_free_resources(char *path);
122 void vfs_timeout_handler ();
123 int vfs_timeouts ();
124 void vfs_force_expire (char *pathname);
125
126 void vfs_fill_names (void (*)(char *));
127
128 /* Required for the vfs_canon routine */
129 char *tarfs_analysis (char *inname, char **archive, int is_dir);
130
131 void ftpfs_init(void);
132 void ftpfs_done(void);
133 void ftpfs_set_debug (char *file);
134 #ifdef USE_NETCODE
135 void ftpfs_hint_reread(int reread);
136 void ftpfs_flushdir(void);
137 #else
138 # define ftpfs_flushdir()
139 # define ftpfs_hint_reread(x)
140 #endif
141 /* They fill the file system names */
142 void mcfs_fill_names (void (*)(char *));
143 void ftpfs_fill_names (void (*)(char *));
144 void tarfs_fill_names (void (*)(char *));
145
146 char *ftpfs_gethome (char *);
147 char *mcfs_gethome (char *);
148
149 char *ftpfs_getupdir (char *);
150 char *mcfs_getupdir (char *);
151
152 /* Only the routines outside of the VFS module need the emulation macros */
153
154 int mc_open (char *file, int flags, ...);
155 int mc_close (int handle);
156 int mc_read (int handle, char *buffer, int count);
157 int mc_write (int hanlde, char *buffer, int count);
158 off_t mc_lseek (int fd, off_t offset, int whence);
159 int mc_chdir (char *);
160
161 DIR *mc_opendir (char *dirname);
162 struct dirent *mc_readdir(DIR *dirp);
163 int mc_closedir (DIR *dir);
164
165 int mc_stat (char *path, struct stat *buf);
166 int mc_lstat (char *path, struct stat *buf);
167 int mc_fstat (int fd, struct stat *buf);
168
169 int mc_chmod (char *path, int mode);
170 int mc_chown (char *path, int owner, int group);
171 int mc_utime (char *path, struct utimbuf *times);
172 int mc_readlink(char *path, char *buf, int bufsiz);
173 int mc_unlink (char *path);
174 int mc_symlink (char *name1, char *name2);
175 int mc_link (char *name1, char *name2);
176 int mc_mknod (char *, int, int);
177 int mc_rename (char *original, char *target);
178 int mc_write (int fd, char *buf, int nbyte);
179 int mc_rmdir (char *path);
180 int mc_mkdir (char *path, mode_t mode);
181 char *mc_getlocalcopy (char *filename);
182 void mc_ungetlocalcopy (char *filename, char *local, int has_changed);
183 char *mc_def_getlocalcopy (char *filename);
184 void mc_def_ungetlocalcopy (char *filename, char *local, int has_changed);
185 int mc_ctl (int fd, int ctlop, int arg);
186 int mc_setctl (char *path, int ctlop, char *arg);
187 #ifdef HAVE_MMAP
188 caddr_t mc_mmap (caddr_t, size_t, int, int, int, off_t);
189 int mc_unmap (caddr_t, size_t);
190 int mc_munmap (caddr_t addr, size_t len);
191 #endif /* HAVE_MMAP */
192
193 #else
194
195 #ifdef USE_NETCODE
196 # undef USE_NETCODE
197 #endif
198
199 # define vfs_fill_names(x)
200 # define vfs_add_current_stamps()
201 # define vfs_current_is_local() 1
202 # define vfs_file_is_local(x) 1
203 # define vfs_file_is_ftp(x) 0
204 # define vfs_current_is_tarfs() 0
205 # define vfs_current_is_extfs() 0
206 # define vfs_path(x) x
207 # define mc_close close
208 # define mc_read read
209 # define mc_write write
210 # define mc_lseek lseek
211 # define mc_opendir opendir
212 # define mc_readdir readdir
213 # define mc_closedir closedir
214
215 # define mc_get_current_wd(x,size) get_current_wd (x, size)
216 # define mc_fstat fstat
217 # define mc_lstat lstat
218
219 # define mc_readlink readlink
220 # define mc_symlink symlink
221 # define mc_rename rename
222
223 #ifndef __os2__
224 # define mc_open open
225 # define mc_utime utime
226 # define mc_chmod chmod
227 # define mc_chown chown
228 # define mc_chdir chdir
229 # define mc_unlink unlink
230 #endif
231
232 # define mc_mmap mmap
233 # define mc_munmap munmap
234
235 # define mc_ctl(a,b,c) 0
236 # define mc_setctl(a,b,c)
237
238 # define mc_stat stat
239 # define mc_mknod mknod
240 # define mc_link link
241 # define mc_mkdir mkdir
242 # define mc_rmdir rmdir
243 # define is_special_prefix(x) 0
244 # define vfs_type(x) (vfs *)(NULL)
245 # define vfs_setup_wd()
246 # define vfs_init()
247 # define vfs_shut()
248 # define vfs_canon(p) strdup (canonicalize_pathname(p))
249 # define vfs_free_resources()
250 # define vfs_timeout_handler()
251 # define vfs_timeouts() 0
252 # define vfs_force_expire ()
253
254 typedef int vfs;
255
256 # define mc_getlocalcopy(x) NULL
257 # define mc_ungetlocalcopy(x,y,z)
258
259 # define ftpfs_hint_reread(x)
260 # define ftpfs_flushdir()
261
262 #ifdef _OS_NT
263 # undef mc_rmdir
264 #endif
265
266 #ifdef OS2_NT
267 # undef mc_ctl
268 # undef mc_unlink
269 # define mc_ctl(a,b,c) 0
270 # ifndef __EMX__
271 # undef mc_mkdir
272 # define mc_mkdir(a,b) mkdir(a)
273 # endif
274 #endif
275
276 #endif /* USE_VFS */
277
278 #define mc_errno errno
279
280 #ifdef WANT_PARSE_LS_LGA
281 int parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname);
282 #endif
283
284 #define MCCTL_SETREMOTECOPY 0
285 #define MCCTL_ISREMOTECOPY 1
286 #define MCCTL_REMOTECOPYCHUNK 2
287 #define MCCTL_FINISHREMOTE 3
288 #define MCCTL_FLUSHDIR 4
289
290 /* Return codes from the ${fs}_ctl routine */
291
292 #define MCERR_TARGETOPEN -1
293 /* Can't open target file */
294 #define MCERR_READ -2
295 /* Read error on source file */
296 #define MCERR_WRITE -3
297 /* Write error on target file */
298 #define MCERR_FINISH -4
299 /* Finished transfer */
300 #define MCERR_DATA_ON_STDIN -5
301 /* Data waiting on stdin to be processed */
302
303 #endif /* __VFS_H */
304