From 52844a3092ca7a77adc3f7234df896cdacbafed7 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Thu, 16 Oct 2003 16:12:19 +0000 Subject: [PATCH] * vfs.h: Rename commands for mc_ctl() and mc_setctl() to make it clear which function they are used with. * vfs.c (mc_ctl): Change last argument to (void*). (mc_set): Likewise. Adjust all dependencies. --- src/file.c | 14 +++++++------- src/screen.c | 2 +- vfs/ChangeLog | 6 ++++++ vfs/direntry.c | 26 ++++++++++---------------- vfs/extfs.c | 7 ++++--- vfs/fish.c | 4 ++-- vfs/ftpfs.c | 4 ++-- vfs/mcfs.c | 4 ++-- vfs/smbfs.c | 12 ++++++------ vfs/vfs.c | 4 ++-- vfs/vfs.h | 32 +++++++++++++++++++------------- 11 files changed, 61 insertions(+), 54 deletions(-) diff --git a/src/file.c b/src/file.c index dea9ddc96..8f00aae0f 100644 --- a/src/file.c +++ b/src/file.c @@ -688,7 +688,7 @@ copy_file_file (FileOpContext *ctx, char *src_path, char *dst_path, for (;;) { /* src_read */ - if (mc_ctl (src_desc, MCCTL_IS_NOTREADY, 0)) + if (mc_ctl (src_desc, VFS_CTL_IS_NOTREADY, 0)) n_read = -1; else while ((n_read = mc_read (src_desc, buf, buf_size)) < 0) { @@ -1896,8 +1896,8 @@ panel_operate (void *source_panel, FileOperation operation, /* If we are the parent */ if (v == 1) { - mc_setctl (panel->cwd, MCCTL_FORGET_ABOUT, NULL); - mc_setctl (dest, MCCTL_FORGET_ABOUT, NULL); + mc_setctl (panel->cwd, VFS_SETCTL_FORGET, NULL); + mc_setctl (dest, VFS_SETCTL_FORGET, NULL); /* file_op_context_destroy (ctx); */ return 0; } @@ -1909,11 +1909,11 @@ panel_operate (void *source_panel, FileOperation operation, created/touched. However, this will make our cache contain invalid data. */ if (dest) { - if (mc_setctl (dest, MCCTL_WANT_STALE_DATA, NULL)) + if (mc_setctl (dest, VFS_SETCTL_STALE_DATA, (void *) 1)) save_dest = g_strdup (dest); } if (panel->cwd) { - if (mc_setctl (panel->cwd, MCCTL_WANT_STALE_DATA, NULL)) + if (mc_setctl (panel->cwd, VFS_SETCTL_STALE_DATA, (void *) 1)) save_cwd = g_strdup (panel->cwd); } @@ -2112,11 +2112,11 @@ panel_operate (void *source_panel, FileOperation operation, /* Clean up */ if (save_cwd) { - mc_setctl (save_cwd, MCCTL_NO_STALE_DATA, NULL); + mc_setctl (save_cwd, VFS_SETCTL_STALE_DATA, NULL); g_free (save_cwd); } if (save_dest) { - mc_setctl (save_dest, MCCTL_NO_STALE_DATA, NULL); + mc_setctl (save_dest, VFS_SETCTL_STALE_DATA, NULL); g_free (save_dest); } diff --git a/src/screen.c b/src/screen.c index d6621288c..be206e86f 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1959,7 +1959,7 @@ do_enter_on_file_entry (file_entry *fe) int ret; tmp = concat_dir_and_file (vfs_get_current_dir (), fe->fname); - ret = mc_setctl (tmp, MCCTL_EXTFS_RUN, NULL); + ret = mc_setctl (tmp, VFS_SETCTL_RUN, NULL); g_free (tmp); /* We took action only if the dialog was shown or the execution * was successful */ diff --git a/vfs/ChangeLog b/vfs/ChangeLog index be93c4deb..eac98f180 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,5 +1,11 @@ 2003-10-16 Pavel Roskin + * vfs.h: Rename commands for mc_ctl() and mc_setctl() to make it + clear which function they are used with. + * vfs.c (mc_ctl): Change last argument to (void*). + (mc_set): Likewise. + Adjust all dependencies. + * xdirentry.h: Move system includes to the files that need them. * xdirentry.h: Fix typos in field names. diff --git a/vfs/direntry.c b/vfs/direntry.c index 6e33d3493..4d8879860 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -992,27 +992,21 @@ vfs_s_getlocalcopy (struct vfs_class *me, char *path) return g_strdup (ino->localname); } -static int -vfs_s_setctl (struct vfs_class *me, char *path, int ctlop, char *arg) +static int +vfs_s_setctl (struct vfs_class *me, char *path, int ctlop, void *arg) { struct vfs_s_inode *ino = vfs_s_inode_from_path (me, path, 0); if (!ino) return 0; - switch (ctlop){ - case MCCTL_WANT_STALE_DATA: - ino->super->want_stale = 1; + switch (ctlop) { + case VFS_SETCTL_STALE_DATA: + if (arg) + ino->super->want_stale = 1; + else { + ino->super->want_stale = 0; + vfs_s_invalidate (me, ino->super); + } return 1; - case MCCTL_NO_STALE_DATA: - ino->super->want_stale = 0; - vfs_s_invalidate(me, ino->super); - return 1; -#if 0 /* FIXME: We should implement these */ - case MCCTL_REMOVELOCALCOPY: - return remove_temp_file (path); - case MCCTL_FORGET_ABOUT: - my_forget(path); - return 0; -#endif } return 0; } diff --git a/vfs/extfs.c b/vfs/extfs.c index a90fb6efa..afcd7282d 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -1345,10 +1345,11 @@ static void extfs_done (struct vfs_class *me) extfs_no = 0; } -static int extfs_setctl (struct vfs_class *me, char *path, int ctlop, char *arg) +static int +extfs_setctl (struct vfs_class *me, char *path, int ctlop, void *arg) { - if (ctlop == MCCTL_EXTFS_RUN) { - extfs_run (path); + if (ctlop == VFS_SETCTL_RUN) { + extfs_run (path); return 1; } return 0; diff --git a/vfs/fish.c b/vfs/fish.c index 6b2d3f596..56a202685 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -645,11 +645,11 @@ linear_close (struct vfs_class *me, struct vfs_s_fh *fh) } static int -fish_ctl (void *fh, int ctlop, int arg) +fish_ctl (void *fh, int ctlop, void *arg) { return 0; switch (ctlop) { - case MCCTL_IS_NOTREADY: + case VFS_CTL_IS_NOTREADY: { int v; diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 980969ced..a0b39e750 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -1506,10 +1506,10 @@ linear_close (struct vfs_class *me, struct vfs_s_fh *fh) linear_abort(me, fh); } -static int ftpfs_ctl (void *fh, int ctlop, int arg) +static int ftpfs_ctl (void *fh, int ctlop, void *arg) { switch (ctlop) { - case MCCTL_IS_NOTREADY: + case VFS_CTL_IS_NOTREADY: { int v; diff --git a/vfs/mcfs.c b/vfs/mcfs.c index 872799d67..5ef52b7c2 100644 --- a/vfs/mcfs.c +++ b/vfs/mcfs.c @@ -1141,10 +1141,10 @@ my_forget (char *path) } static int -mcfs_setctl (struct vfs_class *me, char *path, int ctlop, char *arg) +mcfs_setctl (struct vfs_class *me, char *path, int ctlop, void *arg) { switch (ctlop) { - case MCCTL_FORGET_ABOUT: + case VFS_SETCTL_FORGET: my_forget (path); return 0; } diff --git a/vfs/smbfs.c b/vfs/smbfs.c index 316fefb06..2f4e8dbf3 100644 --- a/vfs/smbfs.c +++ b/vfs/smbfs.c @@ -1727,14 +1727,14 @@ my_forget (char *path) g_free (user); } -static int -smbfs_setctl (struct vfs_class *me, char *path, int ctlop, char *arg) +static int +smbfs_setctl (struct vfs_class *me, char *path, int ctlop, void *arg) { - DEBUG(3, ("smbfs_setctl(path:%s, ctlop:%d)\n", path, ctlop)); + DEBUG (3, ("smbfs_setctl(path:%s, ctlop:%d)\n", path, ctlop)); switch (ctlop) { - case MCCTL_FORGET_ABOUT: - my_forget(path); - return 0; + case VFS_SETCTL_FORGET: + my_forget (path); + return 0; } return 0; } diff --git a/vfs/vfs.c b/vfs/vfs.c index a87a7e6ca..7ccb0dcf6 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -434,7 +434,7 @@ mc_open (const char *filename, int flags, ...) MC_HANDLEOP(read, (int handle, char *buffer, int count), (vfs_info (handle), buffer, count) ) int -mc_ctl (int handle, int ctlop, int arg) +mc_ctl (int handle, int ctlop, void *arg) { struct vfs_class *vfs = vfs_op (handle); @@ -442,7 +442,7 @@ mc_ctl (int handle, int ctlop, int arg) } int -mc_setctl (char *path, int ctlop, char *arg) +mc_setctl (char *path, int ctlop, void *arg) { struct vfs_class *vfs; int result; diff --git a/vfs/vfs.h b/vfs/vfs.h index 3d34d1c18..3d821ba2d 100644 --- a/vfs/vfs.h +++ b/vfs/vfs.h @@ -74,8 +74,8 @@ struct vfs_class { int (*mkdir) (struct vfs_class *me, char *path, mode_t mode); int (*rmdir) (struct vfs_class *me, char *path); - int (*ctl) (void *vfs_info, int ctlop, int arg); - int (*setctl) (struct vfs_class *me, char *path, int ctlop, char *arg); + int (*ctl) (void *vfs_info, int ctlop, void *arg); + int (*setctl) (struct vfs_class *me, char *path, int ctlop, void *arg); #ifdef HAVE_MMAP caddr_t (*mmap) (struct vfs_class *me, caddr_t addr, size_t len, int prot, int flags, void *vfs_info, off_t offset); @@ -183,8 +183,8 @@ int mc_ungetlocalcopy (const char *pathname, char *local, int has_changed); char *mc_def_getlocalcopy (struct vfs_class *vfs, char *filename); int mc_def_ungetlocalcopy (struct vfs_class *vfs, char *filename, char *local, int has_changed); -int mc_ctl (int fd, int ctlop, int arg); -int mc_setctl (char *path, int ctlop, char *arg); +int mc_ctl (int fd, int ctlop, void *arg); +int mc_setctl (char *path, int ctlop, void *arg); #ifdef HAVE_MMAP caddr_t mc_mmap (caddr_t, size_t, int, int, int, off_t); int mc_munmap (caddr_t addr, size_t len); @@ -227,15 +227,21 @@ struct smb_authinfo *vfs_smb_get_authinfo (const char *host, void vfs_print_stats (const char *fs_name, const char *action, const char *file_name, off_t have, off_t need); -/* Don't use values 0..4 for a while -- 10/98, pavel@ucw.cz */ -#define MCCTL_REMOVELOCALCOPY 5 -#define MCCTL_IS_NOTREADY 6 -#define MCCTL_FORGET_ABOUT 7 -#define MCCTL_EXTFS_RUN 8 -/* These two make vfs layer give out potentially incorrect data, but - they also make some operation 100 times faster. Use with caution. */ -#define MCCTL_WANT_STALE_DATA 9 -#define MCCTL_NO_STALE_DATA 10 +/* Operations for mc_ctl - on open file */ +enum { + VFS_CTL_IS_NOTREADY +}; + +/* Operations for mc_setctl - on path */ +enum { + VFS_SETCTL_FORGET, + VFS_SETCTL_RUN, + VFS_SETCTL_LOGFILE, + + /* Setting this makes vfs layer give out potentially incorrect data, + but it also makes some operations much faster. Use with caution. */ + VFS_SETCTL_STALE_DATA +}; #define O_ALL (O_CREAT | O_EXCL | O_NOCTTY | O_NDELAY | O_SYNC | O_WRONLY | O_RDWR | O_RDONLY) /* Midnight commander code should _not_ use other flags than those