From e6ec447585ee4209689aaa315de033f8dba7fdb2 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Mon, 13 Jun 2011 14:44:25 +0300 Subject: [PATCH] Following prototypes of functions was changed in VFS-module API: * archive_check * archive_same * open_archive Signed-off-by: Slava Zanko --- lib/tests/vfs/vfs_s_get_path_mangle.c | 14 +++++-------- lib/vfs/direntry.c | 10 +++------ lib/vfs/xdirentry.h | 10 ++++----- src/vfs/cpio/cpio.c | 22 +++++++++----------- src/vfs/fish/fish.c | 21 ++++++++++--------- src/vfs/ftpfs/ftpfs.c | 19 +++++++++--------- src/vfs/tar/tar.c | 38 +++++++++++++++-------------------- 7 files changed, 60 insertions(+), 74 deletions(-) diff --git a/lib/tests/vfs/vfs_s_get_path_mangle.c b/lib/tests/vfs/vfs_s_get_path_mangle.c index 8521e7d35..246839b92 100644 --- a/lib/tests/vfs/vfs_s_get_path_mangle.c +++ b/lib/tests/vfs/vfs_s_get_path_mangle.c @@ -39,34 +39,30 @@ struct vfs_s_subclass test_subclass1, test_subclass2, test_subclass3; struct vfs_class vfs_test_ops1, vfs_test_ops2, vfs_test_ops3; static int -test1_mock_open_archive(struct vfs_class *me, struct vfs_s_super *super, - const vfs_path_t *vpath, char *op) +test1_mock_open_archive(struct vfs_s_super *super, const vfs_path_t *vpath, const vfs_path_element_t *vpath_element) { struct vfs_s_inode *root; char *spath = vfs_path_to_str (vpath); - (void) op; - fail_unless(strcmp("/" ETALON_VFS_NAME ARCH_NAME, spath) == 0, "etalon(%s) doesn't equal to actual(%s)", "/" ETALON_VFS_NAME ARCH_NAME, spath); super->name = g_strdup (spath); super->data = g_new (char *, 1); - root = vfs_s_new_inode (me, super, NULL); + root = vfs_s_new_inode (vpath_element->class, super, NULL); super->root = root; g_free(spath); return 0; } static int -test1_mock_archive_same (struct vfs_class *me, struct vfs_s_super *super, - const vfs_path_t *vpath, char *op, void *cookie) +test1_mock_archive_same (const vfs_path_element_t *vpath_element, struct vfs_s_super *super, + const vfs_path_t *vpath, void *cookie) { vfs_path_element_t *path_element = vfs_path_get_by_index(vpath, -1); - (void) me; + (void) vpath_element; (void) super; - (void) op; (void) cookie; if (strcmp(ARCH_NAME, path_element->path) != 0) diff --git a/lib/vfs/direntry.c b/lib/vfs/direntry.c index 630201dc7..1b99a12e8 100644 --- a/lib/vfs/direntry.c +++ b/lib/vfs/direntry.c @@ -1069,8 +1069,7 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i if (subclass->archive_check != NULL) { - cookie = - subclass->archive_check (path_element->class, vpath_archive, path_element->raw_url_str); + cookie = subclass->archive_check (vpath_archive); if (cookie == NULL) { vfs_path_free (vpath_archive); @@ -1085,8 +1084,7 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i super = (struct vfs_s_super *) iter->data; /* 0 == other, 1 == same, return it, 2 == other but stop scanning */ - i = subclass->archive_same (path_element->class, super, vpath_archive, - path_element->raw_url_str, cookie); + i = subclass->archive_same (path_element, super, vpath_archive, cookie); if (i != 0) { if (i == 1) @@ -1104,9 +1102,7 @@ vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, i super = vfs_s_new_super (path_element->class); if (subclass->open_archive != NULL) - result = - subclass->open_archive (path_element->class, super, vpath_archive, - path_element->raw_url_str); + result = subclass->open_archive (super, vpath_archive, path_element); if (result == -1) { vfs_s_free_super (path_element->class, super); diff --git a/lib/vfs/xdirentry.h b/lib/vfs/xdirentry.h index d58c83d94..c4bf56abf 100644 --- a/lib/vfs/xdirentry.h +++ b/lib/vfs/xdirentry.h @@ -124,11 +124,11 @@ struct vfs_s_subclass void (*free_inode) (struct vfs_class * me, struct vfs_s_inode * ino); /* optional */ int (*init_entry) (struct vfs_class * me, struct vfs_s_entry * entry); /* optional */ - void *(*archive_check) (struct vfs_class * me, const vfs_path_t * vpath, char *op); /* optional */ - int (*archive_same) (struct vfs_class * me, struct vfs_s_super * psup, - const vfs_path_t * vpath, char *op, void *cookie); - int (*open_archive) (struct vfs_class * me, struct vfs_s_super * psup, - const vfs_path_t * vpath, char *op); + void *(*archive_check) (const vfs_path_t * vpath); /* optional */ + int (*archive_same) (const vfs_path_element_t * vpath_element, struct vfs_s_super * psup, + const vfs_path_t * vpath, void *cookie); + int (*open_archive) (struct vfs_s_super * psup, + const vfs_path_t * vpath, const vfs_path_element_t * vpath_element); void (*free_archive) (struct vfs_class * me, struct vfs_s_super * psup); int (*fh_open) (struct vfs_class * me, vfs_file_handler_t * fh, int flags, mode_t mode); diff --git a/src/vfs/cpio/cpio.c b/src/vfs/cpio/cpio.c index 44077bcad..699010932 100644 --- a/src/vfs/cpio/cpio.c +++ b/src/vfs/cpio/cpio.c @@ -714,15 +714,15 @@ cpio_read_crc_head (struct vfs_class *me, struct vfs_s_super *super) /** Need to CPIO_SEEK_CUR to skip the file at the end of add entry!!!! */ static int -cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const vfs_path_t * vpath, - char *op) +cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath, + const vfs_path_element_t * vpath_element) { int status = STATUS_START; char *archive_name = vfs_path_to_str (vpath); - (void) op; + (void) vpath_element; - if (cpio_open_cpio_file (me, super, archive_name) == -1) + if (cpio_open_cpio_file (vpath_element->class, super, archive_name) == -1) { g_free (archive_name); return -1; @@ -730,7 +730,7 @@ cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const vfs_pa while (TRUE) { - status = cpio_read_head (me, super); + status = cpio_read_head (vpath_element->class, super); switch (status) { @@ -753,15 +753,12 @@ cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super, const vfs_pa /** Remaining functions are exactly same as for tarfs (and were in fact just copied) */ static void * -cpio_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op) +cpio_super_check (const vfs_path_t * vpath) { static struct stat sb; char *archive_name = vfs_path_to_str (vpath); int stat_result; - (void) me; - (void) op; - stat_result = mc_stat (archive_name, &sb); g_free (archive_name); return (stat_result == 0 ? &sb : NULL); @@ -770,14 +767,13 @@ cpio_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op) /* --------------------------------------------------------------------------------------------- */ static int -cpio_super_same (struct vfs_class *me, struct vfs_s_super *parc, - const vfs_path_t * vpath, char *op, void *cookie) +cpio_super_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *parc, + const vfs_path_t * vpath, void *cookie) { struct stat *archive_stat = cookie; /* stat of main archive */ char *archive_name = vfs_path_to_str (vpath); - (void) me; - (void) op; + (void) vpath_element; if (strcmp (parc->name, archive_name)) { diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c index 8c986c7b6..4e27c0ec1 100644 --- a/src/vfs/fish/fish.c +++ b/src/vfs/fish/fish.c @@ -581,15 +581,17 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super) /* --------------------------------------------------------------------------------------------- */ static int -fish_open_archive (struct vfs_class *me, struct vfs_s_super *super, - const vfs_path_t * vpath, char *op) +fish_open_archive (struct vfs_s_super *super, + const vfs_path_t * vpath, const vfs_path_element_t * vpath_element) { (void) vpath; super->data = g_new0 (fish_super_data_t, 1); - super->path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS); + super->path_element = + vfs_url_split (strchr (vpath_element->raw_url_str, ':') + 1, 0, + URL_NOSLASH | URL_USE_ANONYMOUS); - if (strncmp (op, "rsh:", 4) == 0) + if (strncmp (vpath_element->raw_url_str, "rsh:", 4) == 0) super->path_element->port = FISH_FLAG_RSH; SUP->scr_ls = @@ -631,23 +633,24 @@ fish_open_archive (struct vfs_class *me, struct vfs_s_super *super, fish_load_script_from_file (super->path_element->host, FISH_INFO_FILE, FISH_INFO_DEF_CONTENT); - return fish_open_archive_int (me, super); + return fish_open_archive_int (vpath_element->class, super); } /* --------------------------------------------------------------------------------------------- */ static int -fish_archive_same (struct vfs_class *me, struct vfs_s_super *super, - const vfs_path_t * vpath, char *op, void *cookie) +fish_archive_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *super, + const vfs_path_t * vpath, void *cookie) { vfs_path_element_t *path_element; int result; - (void) me; (void) vpath; (void) cookie; - path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS); + path_element = + vfs_url_split (strchr (vpath_element->raw_url_str, ':') + 1, 0, + URL_NOSLASH | URL_USE_ANONYMOUS); if (path_element->user == NULL) path_element->user = vfs_get_local_username (); diff --git a/src/vfs/ftpfs/ftpfs.c b/src/vfs/ftpfs/ftpfs.c index a5aad1d5f..2b55a18ed 100644 --- a/src/vfs/ftpfs/ftpfs.c +++ b/src/vfs/ftpfs/ftpfs.c @@ -959,14 +959,14 @@ ftpfs_open_archive_int (struct vfs_class *me, struct vfs_s_super *super) /* --------------------------------------------------------------------------------------------- */ static int -ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super, - const vfs_path_t * vpath, char *op) +ftpfs_open_archive (struct vfs_s_super *super, + const vfs_path_t * vpath, const vfs_path_element_t * vpath_element) { (void) vpath; super->data = g_new0 (ftp_super_data_t, 1); - super->path_element = ftpfs_split_url (strchr (op, ':') + 1); + super->path_element = ftpfs_split_url (strchr (vpath_element->raw_url_str, ':') + 1); SUP->proxy = NULL; if (ftpfs_check_proxy (super->path_element->host)) SUP->proxy = ftpfs_proxy_host; @@ -975,25 +975,26 @@ ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super, SUP->isbinary = TYPE_UNKNOWN; SUP->remote_is_amiga = 0; super->name = g_strdup ("/"); - super->root = vfs_s_new_inode (me, super, vfs_s_default_stat (me, S_IFDIR | 0755)); + super->root = + vfs_s_new_inode (vpath_element->class, super, + vfs_s_default_stat (vpath_element->class, S_IFDIR | 0755)); - return ftpfs_open_archive_int (me, super); + return ftpfs_open_archive_int (vpath_element->class, super); } /* --------------------------------------------------------------------------------------------- */ static int -ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super, - const vfs_path_t * vpath, char *op, void *cookie) +ftpfs_archive_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *super, + const vfs_path_t * vpath, void *cookie) { vfs_path_element_t *path_element; int result; - (void) me; (void) vpath; (void) cookie; - path_element = ftpfs_split_url (strchr (op, ':') + 1); + path_element = ftpfs_split_url (strchr (vpath_element->raw_url_str, ':') + 1); result = ((strcmp (path_element->host, super->path_element->host) == 0) && (strcmp (path_element->user, super->path_element->user) == 0) diff --git a/src/vfs/tar/tar.c b/src/vfs/tar/tar.c index 309fba574..8b7575440 100644 --- a/src/vfs/tar/tar.c +++ b/src/vfs/tar/tar.c @@ -287,7 +287,7 @@ tar_open_archive_int (struct vfs_class *me, const vfs_path_t * vpath, struct vfs if (result == -1) { message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), archive_name); - g_free(archive_name); + g_free (archive_name); ERRNOR (ENOENT, -1); } @@ -729,19 +729,17 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si * Returns 0 on success, -1 on error. */ static int -tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const vfs_path_t * vpath, - char *op) +tar_open_archive (struct vfs_s_super *archive, const vfs_path_t * vpath, + const vfs_path_element_t * vpath_element) { /* Initial status at start of archive */ ReadStatus status = STATUS_EOFMARK; ReadStatus prev_status; int tard; - (void) op; - current_tar_position = 0; /* Open for reading */ - tard = tar_open_archive_int (me, vpath, archive); + tard = tar_open_archive_int (vpath_element->class, vpath, archive); if (tard == -1) return -1; @@ -750,7 +748,7 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const vfs_p size_t h_size; prev_status = status; - status = tar_read_header (me, archive, tard, &h_size); + status = tar_read_header (vpath_element->class, archive, tard, &h_size); switch (status) { @@ -772,10 +770,10 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const vfs_p /* Error on first record */ case STATUS_EOFMARK: { - char *archive_name = vfs_path_to_str(vpath); + char *archive_name = vfs_path_to_str (vpath); message (D_ERROR, MSG_ERROR, _("%s\ndoesn't look like a tar archive."), archive_name); - g_free(archive_name); + g_free (archive_name); /* FALL THRU */ /* Error after header rec */ @@ -806,17 +804,14 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive, const vfs_p /* --------------------------------------------------------------------------------------------- */ static void * -tar_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op) +tar_super_check (const vfs_path_t * vpath) { static struct stat stat_buf; - char *archive_name = vfs_path_to_str(vpath); + char *archive_name = vfs_path_to_str (vpath); int stat_result; - (void) me; - (void) op; - stat_result = mc_stat (archive_name, &stat_buf); - g_free(archive_name); + g_free (archive_name); return (stat_result != 0) ? NULL : &stat_buf; } @@ -824,21 +819,20 @@ tar_super_check (struct vfs_class *me, const vfs_path_t * vpath, char *op) /* --------------------------------------------------------------------------------------------- */ static int -tar_super_same (struct vfs_class *me, struct vfs_s_super *parc, - const vfs_path_t * vpath, char *op, void *cookie) +tar_super_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *parc, + const vfs_path_t * vpath, void *cookie) { struct stat *archive_stat = cookie; /* stat of main archive */ - char *archive_name = vfs_path_to_str(vpath); + char *archive_name = vfs_path_to_str (vpath); - (void) me; - (void) op; + (void) vpath_element; if (strcmp (parc->name, archive_name) != 0) { - g_free(archive_name); + g_free (archive_name); return 0; } - g_free(archive_name); + g_free (archive_name); /* Has the cached archive been changed on the disk? */ if (((tar_super_data_t *) parc->data)->st.st_mtime < archive_stat->st_mtime) -- 2.11.4.GIT