From 13ff3063f4223e8916e1d5e33d9a2351ff27e35e Mon Sep 17 00:00:00 2001 From: Sebastian Freundt Date: Tue, 10 Jun 2014 13:03:31 +0000 Subject: [PATCH] Set archive format, and archive format name. This changeset adheres to the previously imported read test. The archive format is hard-set to ARCHIVE_FORMAT_WARC, while the format name is the stringified WARC/x.y version designator, which for performance reasons will be cached between calls to the header reader _warc_rdhdr(). --- libarchive/archive_read_support_format_warc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libarchive/archive_read_support_format_warc.c b/libarchive/archive_read_support_format_warc.c index b4875a5f7..da7aa0666 100644 --- a/libarchive/archive_read_support_format_warc.c +++ b/libarchive/archive_read_support_format_warc.c @@ -95,6 +95,10 @@ struct warc_s { /* string pool */ warc_strbuf_t pool; + /* previous version */ + unsigned int pver; + /* stringified format name */ + char sver[16U]; }; static int _warc_bid(struct archive_read *a, int); @@ -256,6 +260,15 @@ start_over: return (ARCHIVE_FATAL); } + /* let the world know we're a WARC archive */ + a->archive.archive_format = ARCHIVE_FORMAT_WARC; + if (ver != w->pver) { + /* stringify this entry's version */ + snprintf(w->sver, sizeof(w->sver), + "WARC/%u.%u", ver / 10000, ver % 10000); + /* remember the version */ + w->pver = ver; + } /* start off with the type */ ftyp = _warc_rdtyp(buf, eoh - buf); /* and let future calls know about the content */ -- 2.47.2