From 3cf53917e163ab0c4503597861d37b9fe3ada04d Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Mon, 16 Aug 2004 22:40:31 +0000 Subject: [PATCH] Const-ified the mc_* functions. --- vfs/vfs.c | 37 +++++++++++++++++++------------------ vfs/vfs.h | 22 +++++++++++----------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/vfs/vfs.c b/vfs/vfs.c index 08748143e..4bf98dfc0 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -341,24 +341,24 @@ int mc_##name inarg \ { \ struct vfs_class *vfs; \ int result; \ - path = vfs_canon (path); \ - vfs = vfs_get_class (path); \ + char *mpath = vfs_canon (path); \ + vfs = vfs_get_class (mpath); \ result = vfs->name ? (*vfs->name)callarg : -1; \ - g_free (path); \ + g_free (mpath); \ if (result == -1) \ errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \ return result; \ } -MC_NAMEOP (chmod, (char *path, int mode), (vfs, path, mode)) -MC_NAMEOP (chown, (char *path, int owner, int group), (vfs, path, owner, group)) -MC_NAMEOP (utime, (char *path, struct utimbuf *times), (vfs, path, times)) -MC_NAMEOP (readlink, (char *path, char *buf, int bufsiz), (vfs, path, buf, bufsiz)) -MC_NAMEOP (unlink, (char *path), (vfs, path)) -MC_NAMEOP (symlink, (char *name1, char *path), (vfs, name1, path)) -MC_NAMEOP (mkdir, (char *path, mode_t mode), (vfs, path, mode)) -MC_NAMEOP (rmdir, (char *path), (vfs, path)) -MC_NAMEOP (mknod, (char *path, int mode, int dev), (vfs, path, mode, dev)) +MC_NAMEOP (chmod, (const char *path, int mode), (vfs, path, mode)) +MC_NAMEOP (chown, (const char *path, int owner, int group), (vfs, path, owner, group)) +MC_NAMEOP (utime, (const char *path, struct utimbuf *times), (vfs, path, times)) +MC_NAMEOP (readlink, (const char *path, char *buf, int bufsiz), (vfs, path, buf, bufsiz)) +MC_NAMEOP (unlink, (const char *path), (vfs, path)) +MC_NAMEOP (symlink, (const char *name1, const char *path), (vfs, name1, path)) +MC_NAMEOP (mkdir, (const char *path, mode_t mode), (vfs, path, mode)) +MC_NAMEOP (rmdir, (const char *path), (vfs, path)) +MC_NAMEOP (mknod, (const char *path, int mode, int dev), (vfs, path, mode, dev)) #define MC_HANDLEOP(name, inarg, callarg) \ @@ -376,7 +376,7 @@ int mc_##name inarg \ } MC_HANDLEOP(read, (int handle, char *buffer, int count), (vfs_info (handle), buffer, count) ) -MC_HANDLEOP (write, (int handle, char *buf, int nbyte), (vfs_info (handle), buf, nbyte)) +MC_HANDLEOP (write, (int handle, const char *buf, int nbyte), (vfs_info (handle), buf, nbyte)) #define MC_RENAMEOP(name) \ @@ -414,18 +414,19 @@ mc_ctl (int handle, int ctlop, void *arg) } int -mc_setctl (char *path, int ctlop, void *arg) +mc_setctl (const char *path, int ctlop, void *arg) { struct vfs_class *vfs; int result; + char *mpath; if (!path) vfs_die("You don't want to pass NULL to mc_setctl."); - path = vfs_canon (path); - vfs = vfs_get_class (path); - result = vfs->setctl ? (*vfs->setctl)(vfs, path, ctlop, arg) : 0; - g_free (path); + mpath = vfs_canon (path); + vfs = vfs_get_class (mpath); + result = vfs->setctl ? (*vfs->setctl)(vfs, mpath, ctlop, arg) : 0; + g_free (mpath); return result; } diff --git a/vfs/vfs.h b/vfs/vfs.h index fff072a3f..c33ffac30 100644 --- a/vfs/vfs.h +++ b/vfs/vfs.h @@ -137,7 +137,7 @@ extern int use_netrc; int mc_open (const char *filename, int flags, ...); int mc_close (int handle); int mc_read (int handle, char *buffer, int count); -int mc_write (int handle, char *buffer, int count); +int mc_write (int handle, const char *buffer, int count); off_t mc_lseek (int fd, off_t offset, int whence); int mc_chdir (const char *path); @@ -149,22 +149,22 @@ 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 (char *path, int mode); -int mc_chown (char *path, int owner, int group); -int mc_utime (char *path, struct utimbuf *times); -int mc_readlink (char *path, char *buf, int bufsiz); -int mc_unlink (char *path); -int mc_symlink (char *name1, char *name2); +int mc_chmod (const char *path, int mode); +int mc_chown (const char *path, int owner, int group); +int mc_utime (const char *path, struct utimbuf *times); +int mc_readlink (const char *path, char *buf, int bufsiz); +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 (char *, int, int); +int mc_mknod (const char *, int, int); int mc_rename (const char *original, const char *target); -int mc_rmdir (char *path); -int mc_mkdir (char *path, mode_t mode); +int mc_rmdir (const char *path); +int mc_mkdir (const char *path, mode_t mode); char *mc_getlocalcopy (const char *pathname); int mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed); int mc_ctl (int fd, int ctlop, void *arg); -int mc_setctl (char *path, int ctlop, void *arg); +int mc_setctl (const 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);