summaryrefslogtreecommitdiffstats
path: root/lib/libarchive
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2009-04-17 00:47:16 +0000
committerkientzle <kientzle@FreeBSD.org>2009-04-17 00:47:16 +0000
commit5387456c70c14b686b55a811d0f071abd3a49fd8 (patch)
tree683295462da6bdbc257690dffa6676b2873f8552 /lib/libarchive
parenta3b67d58021c18b3fd5bf3a549b64b0297f482f5 (diff)
downloadFreeBSD-src-5387456c70c14b686b55a811d0f071abd3a49fd8.zip
FreeBSD-src-5387456c70c14b686b55a811d0f071abd3a49fd8.tar.gz
Accept empty options, add a new read_next_header2() which is more
efficient for some uses.
Diffstat (limited to 'lib/libarchive')
-rw-r--r--lib/libarchive/archive_read.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c
index ddaf686..5781fe0 100644
--- a/lib/libarchive/archive_read.c
+++ b/lib/libarchive/archive_read.c
@@ -120,7 +120,11 @@ archive_read_set_format_options(struct archive *_a, const char *s)
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 archive *_a, const char *s)
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 *_a, struct archive_entry **entryp)
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);
OpenPOWER on IntegriCloud