* vfs.c: Constify arguments of many functions.

This commit is contained in:
Pavel Roskin 2003-10-11 07:38:05 +00:00
parent 091023c37a
commit 60bab59379
3 changed files with 35 additions and 36 deletions

View File

@ -1,5 +1,7 @@
2003-10-11 Pavel Roskin <proski@gnu.org>
* vfs.c: Constify arguments of many functions.
* undelfs.c (undelfs_get_path): Constify first argument.
* vfs.h (struct vfs_class): Constify path. Fix all dependencies.

View File

@ -180,7 +180,7 @@ path_magic (const char *path)
* want to free neither *inpath nor *op
*/
vfs *
vfs_split (char *path, char **inpath, char **op)
vfs_split (const char *path, char **inpath, char **op)
{
char *semi;
char *slash;
@ -222,7 +222,7 @@ vfs_split (char *path, char **inpath, char **op)
}
static vfs *
_vfs_get_class (char *path)
_vfs_get_class (const char *path)
{
char *semi;
char *slash;
@ -251,7 +251,7 @@ _vfs_get_class (char *path)
}
vfs *
vfs_get_class (char *path)
vfs_get_class (const char *path)
{
vfs *vfs;
@ -746,15 +746,14 @@ vfs_canon (const char *path)
}
static vfsid
vfs_ncs_getid (vfs *nvfs, char *dir, struct vfs_stamping **par)
vfs_ncs_getid (vfs *nvfs, const char *dir, struct vfs_stamping **par)
{
vfsid nvfsid;
char *dir1;
dir = concat_dir_and_file (dir, "");
nvfsid = (*nvfs->getid)(nvfs, dir, par);
g_free (dir);
dir1 = concat_dir_and_file (dir, "");
nvfsid = (*nvfs->getid) (nvfs, dir1, par);
g_free (dir1);
return nvfsid;
}
@ -951,14 +950,13 @@ vfs_file_is_local (const char *file)
}
int
vfs_file_is_ftp (char *filename)
vfs_file_is_ftp (const char *filename)
{
#ifdef USE_NETCODE
vfs *vfs;
filename = vfs_canon (filename);
vfs = vfs_get_class (filename);
g_free (filename);
char *fname = vfs_canon (filename);
vfs = vfs_get_class (fname);
g_free (fname);
return vfs == &vfs_ftpfs_ops;
#else
return 0;
@ -966,15 +964,14 @@ vfs_file_is_ftp (char *filename)
}
int
vfs_file_is_smb (char *filename)
vfs_file_is_smb (const char *filename)
{
#ifdef WITH_SMBFS
#ifdef USE_NETCODE
vfs *vfs;
filename = vfs_canon (filename);
vfs = vfs_get_class (filename);
g_free (filename);
char *fname = vfs_canon (filename);
vfs = vfs_get_class (fname);
g_free (fname);
return vfs == &vfs_smbfs_ops;
#endif /* USE_NETCODE */
#endif /* WITH_SMBFS */
@ -1863,7 +1860,7 @@ vfs_get_password (char *msg)
* not recognized as url, g_strdup(url) is returned.
*/
char *
vfs_translate_url (char *url)
vfs_translate_url (const char *url)
{
if (strncmp (url, "ftp://", 6) == 0)
return g_strconcat ("/#ftp:", url + 6, NULL);
@ -1875,7 +1872,7 @@ vfs_translate_url (char *url)
void
vfs_release_path (char *dir)
vfs_release_path (const char *dir)
{
struct vfs_class *oldvfs;
vfsid oldvfsid;

View File

@ -79,23 +79,23 @@ struct vfs_class {
int (*ctl) (void *vfs_info, int ctlop, int arg);
int (*setctl) (vfs *me, char *path, int ctlop, char *arg);
#ifdef HAVE_MMAP
caddr_t (*mmap) (vfs *me, caddr_t addr, size_t len, int prot,
int flags, void *vfs_info, off_t offset);
caddr_t (*mmap) (vfs *me, caddr_t addr, size_t len, int prot,
int flags, void *vfs_info, off_t offset);
int (*munmap) (vfs *me, caddr_t addr, size_t len, void *vfs_info);
#endif
};
/*
* This union is used to ensure that there is enough space for the
* filename (d_name) when the dirent structure is created.
*/
/*
* This union is used to ensure that there is enough space for the
* filename (d_name) when the dirent structure is created.
*/
union vfs_dirent {
struct dirent dent;
char _extra_buffer[((int) &((struct dirent *) 0)->d_name) +
MC_MAXPATHLEN + 1];
};
/* Register a file system class */
/* Register a file system class */
int vfs_register_class (struct vfs_class *vfs);
void init_cpiofs (void);
void init_fish (void);
@ -120,17 +120,17 @@ struct vfs_stamping {
void vfs_init (void);
void vfs_shut (void);
struct vfs_class *vfs_get_class (char *path);
vfs *vfs_split (char *path, char **inpath, char **op);
struct vfs_class *vfs_get_class (const char *path);
vfs *vfs_split (const char *path, char **inpath, char **op);
void vfs_rm_parents (struct vfs_stamping *stamp);
char *vfs_path (char *path);
char *vfs_path (const char *path);
char *vfs_strip_suffix_from_filename (const char *filename);
char *vfs_canon (const char *path);
char *mc_get_current_wd (char *buffer, int bufsize);
int vfs_current_is_local (void);
int vfs_file_is_local (const char *name);
int vfs_file_is_ftp (char *filename);
int vfs_file_is_smb (char *filename);
int vfs_file_is_ftp (const char *filename);
int vfs_file_is_smb (const char *filename);
char *vfs_get_current_dir (void);
extern int vfs_timeout;
@ -142,10 +142,10 @@ void vfs_add_current_stamps (void);
void vfs_timeout_handler (void);
void vfs_expire (int);
int vfs_timeouts (void);
void vfs_release_path (char *dir);
void vfs_release_path (const char *dir);
void vfs_fill_names (void (*)(char *));
char *vfs_translate_url (char *);
char *vfs_translate_url (const char *);
void ftpfs_set_debug (const char *file);
#ifdef USE_NETCODE
@ -157,7 +157,7 @@ extern int use_netrc;
# define ftpfs_hint_reread(x)
#endif
/* Only the routines outside of the VFS module need the emulation macros */
/* 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);