]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
fix archive_filter_count to actually work; implementation of this aparently was never...
authorBrian Harring <ferringb@gmail.com>
Mon, 26 Apr 2010 01:44:24 +0000 (21:44 -0400)
committerBrian Harring <ferringb@gmail.com>
Mon, 26 Apr 2010 01:44:24 +0000 (21:44 -0400)
SVN-Revision: 2294

Makefile.am
libarchive/archive_read.c
libarchive/archive_write.c

index fd4e1f7a1935030181339eed8c2769e0ef2ee3ed..8c057191cd3b83e819094f8d5ef814929d9e9df5 100644 (file)
@@ -249,6 +249,7 @@ libarchive_test_SOURCES=                                    \
        libarchive/test/test_empty_write.c                      \
        libarchive/test/test_entry.c                            \
        libarchive/test/test_extattr_freebsd.c                  \
+       libarchive/test/test_filter_count.c             \
        libarchive/test/test_fuzz.c                             \
        libarchive/test/test_entry_strmode.c                    \
        libarchive/test/test_link_resolver.c                    \
index 39d9776090cc46822a8d16380ea2b6ea3587989b..b9b76748499f8c5f05797c1cf6d941ff260cf884 100644 (file)
@@ -63,6 +63,7 @@ static struct archive_vtable *archive_read_vtable(void);
 static int64_t _archive_filter_bytes(struct archive *, int);
 static int     _archive_filter_code(struct archive *, int);
 static const char *_archive_filter_name(struct archive *, int);
+static int  _archive_filter_count(struct archive *);
 static int     _archive_read_close(struct archive *);
 static int     _archive_read_free(struct archive *);
 static int64_t  advance_file_pointer(struct archive_read_filter *, int64_t);
@@ -77,6 +78,7 @@ archive_read_vtable(void)
                av.archive_filter_bytes = _archive_filter_bytes;
                av.archive_filter_code = _archive_filter_code;
                av.archive_filter_name = _archive_filter_name;
+               av.archive_filter_count = _archive_filter_count;
                av.archive_free = _archive_read_free;
                av.archive_close = _archive_read_close;
        }
@@ -763,6 +765,23 @@ free_filters(struct archive_read *a)
        }
 }
 
+/* 
+ * return the count of # of filters in use
+ */
+static int
+_archive_filter_count(struct archive *_a)
+{
+       struct archive_read *a = (struct archive_read *)_a;
+       struct archive_read_filter *p = a->filter;
+       int count = 0;
+       while(p) {
+               count++;
+               p = p->upstream;
+       }
+       return count;
+}
+               
+       
 /*
  * Close the file and all I/O.
  */
index 08d2b1ffa124235ab3bd3d67a6773a9690ec7865..b9ce507496a29c5546086bf6c8f081553bce063c 100644 (file)
@@ -65,6 +65,7 @@ static struct archive_vtable *archive_write_vtable(void);
 static int     _archive_filter_code(struct archive *, int);
 static const char *_archive_filter_name(struct archive *, int);
 static int64_t _archive_filter_bytes(struct archive *, int);
+static int  _archive_write_filter_count(struct archive *);
 static int     _archive_write_close(struct archive *);
 static int     _archive_write_free(struct archive *);
 static int     _archive_write_header(struct archive *, struct archive_entry *);
@@ -89,6 +90,7 @@ archive_write_vtable(void)
                av.archive_filter_bytes = _archive_filter_bytes;
                av.archive_filter_code = _archive_filter_code;
                av.archive_filter_name = _archive_filter_name;
+               av.archive_filter_count = _archive_write_filter_count;
                av.archive_free = _archive_write_free;
                av.archive_write_header = _archive_write_header;
                av.archive_write_finish_entry = _archive_write_finish_entry;
@@ -184,7 +186,6 @@ archive_write_get_bytes_in_last_block(struct archive *_a)
        return (a->bytes_in_last_block);
 }
 
-
 /*
  * dev/ino of a file to be rejected.  Used to prevent adding
  * an archive to itself recursively.
@@ -506,6 +507,19 @@ _archive_write_close(struct archive *_a)
        return (r);
 }
 
+static int
+_archive_write_filter_count(struct archive *_a)
+{
+       struct archive_write *a = (struct archive_write *)_a;
+       struct archive_write_filter *p = a->filter_first;
+       int count = 0;
+       while(p) {
+               count++;
+               p = p->next_filter;
+       }
+       return count;
+}
+
 void
 __archive_write_filters_free(struct archive *_a)
 {