]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Set archive format, and archive format name.
authorSebastian Freundt <freundt@ga-group.nl>
Tue, 10 Jun 2014 13:03:31 +0000 (13:03 +0000)
committerSebastian Freundt <freundt@ga-group.nl>
Tue, 10 Jun 2014 13:03:31 +0000 (13:03 +0000)
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

index b4875a5f79033daacd8b30e4d93edea9bf4e22d5..da7aa06664d8cbe388e3dc317564543bcecce8e1 100644 (file)
@@ -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 */