Author: kientzle
Date: Fri Apr 17 00:47:16 2009
New Revision: 191170
URL: http://svn.freebsd.org/changeset/base/191170

Log:
  Accept empty options, add a new read_next_header2() which is more
  efficient for some uses.

Modified:
  head/lib/libarchive/archive_read.c

Modified: head/lib/libarchive/archive_read.c
==============================================================================
--- head/lib/libarchive/archive_read.c  Fri Apr 17 00:45:47 2009        
(r191169)
+++ head/lib/libarchive/archive_read.c  Fri Apr 17 00:47:16 2009        
(r191170)
@@ -120,7 +120,11 @@ archive_read_set_format_options(struct a
        size_t i;
        int len, r;
 
+       if (s == NULL || *s == '\0')
+               return (ARCHIVE_OK);
        a = (struct archive_read *)_a;
+       __archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
+           ARCHIVE_STATE_NEW, "archive_read_set_format_options");
        len = 0;
        for (i = 0; i < sizeof(a->formats)/sizeof(a->formats[0]); i++) {
                format = &a->formats[i];
@@ -160,7 +164,11 @@ archive_read_set_filter_options(struct a
        char key[64], val[64];
        int len, r;
 
+       if (s == NULL || *s == '\0')
+               return (ARCHIVE_OK);
        a = (struct archive_read *)_a;
+       __archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
+           ARCHIVE_STATE_NEW, "archive_read_set_filter_options");
        filter = a->filter;
        len = 0;
        for (filter = a->filter; filter != NULL; filter = filter->upstream) {
@@ -368,18 +376,15 @@ build_stream(struct archive_read *a)
  * Read header of next entry.
  */
 int
-archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
+archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
 {
        struct archive_read *a = (struct archive_read *)_a;
-       struct archive_entry *entry;
        int slot, ret;
 
        __archive_check_magic(_a, ARCHIVE_READ_MAGIC,
            ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
            "archive_read_next_header");
 
-       *entryp = NULL;
-       entry = a->entry;
        archive_entry_clear(entry);
        archive_clear_error(&a->archive);
 
@@ -437,12 +442,22 @@ archive_read_next_header(struct archive 
                break;
        }
 
-       *entryp = entry;
        a->read_data_output_offset = 0;
        a->read_data_remaining = 0;
        return (ret);
 }
 
+int
+archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
+{
+       int ret;
+       struct archive_read *a = (struct archive_read *)_a;
+       *entryp = NULL;
+       ret = archive_read_next_header2(_a, a->entry);
+       *entryp = a->entry;
+       return ret;
+}
+
 /*
  * Allow each registered format to bid on whether it wants to handle
  * the next entry.  Return index of winning bidder.
@@ -680,8 +695,10 @@ _archive_read_close(struct archive *_a)
 
        __archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
            ARCHIVE_STATE_ANY, "archive_read_close");
+       archive_clear_error(&a->archive);
        a->archive.state = ARCHIVE_STATE_CLOSED;
 
+
        /* Call cleanup functions registered by optional components. */
        if (a->cleanup_archive_extract != NULL)
                r = (a->cleanup_archive_extract)(a);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to