diff options
author | Aron Xu <aron@debian.org> | 2014-10-26 07:02:25 +0800 |
---|---|---|
committer | Aron Xu <aron@debian.org> | 2014-10-26 07:02:25 +0800 |
commit | 3871a83a5f0aebd8c00879eab14fe901c93dbfcf (patch) | |
tree | b022967f880b7fb1e56c8cc4c3f200d6ffbc9efd /xzlib.c | |
parent | 7042e17490515a990a45aa7237d11bc49ab0eaf0 (diff) | |
download | libxml2-3871a83a5f0aebd8c00879eab14fe901c93dbfcf.tar.gz |
Imported Upstream version 2.9.2+dfsg1
Diffstat (limited to 'xzlib.c')
-rw-r--r-- | xzlib.c | 51 |
1 files changed, 47 insertions, 4 deletions
@@ -182,12 +182,37 @@ xz_open(const char *path, int fd, const char *mode ATTRIBUTE_UNUSED) return (xzFile) state; } +static int +xz_compressed(xzFile f) { + xz_statep state; + + if (f == NULL) + return(-1); + state = (xz_statep) f; + if (state->init <= 0) + return(-1); + + switch (state->how) { + case COPY: + return(0); + case GZIP: + case LZMA: + return(1); + } + return(-1); +} + xzFile __libxml2_xzopen(const char *path, const char *mode) { return xz_open(path, -1, mode); } +int +__libxml2_xzcompressed(xzFile f) { + return xz_compressed(f); +} + xzFile __libxml2_xzdopen(int fd, const char *mode) { @@ -245,6 +270,20 @@ xz_avail(xz_statep state) return 0; } +#ifdef HAVE_ZLIB_H +static int +xz_avail_zstrm(xz_statep state) +{ + int ret; + state->strm.avail_in = state->zstrm.avail_in; + state->strm.next_in = state->zstrm.next_in; + ret = xz_avail(state); + state->zstrm.avail_in = (uInt) state->strm.avail_in; + state->zstrm.next_in = (Bytef *) state->strm.next_in; + return ret; +} +#endif + static int is_format_xz(xz_statep state) { @@ -314,6 +353,10 @@ is_format_lzma(xz_statep state) #define NEXT() ((strm->avail_in == 0 && xz_avail(state) == -1) ? -1 : \ (strm->avail_in == 0 ? -1 : \ (strm->avail_in--, *(strm->next_in)++))) +/* Same thing, but from zstrm */ +#define NEXTZ() ((strm->avail_in == 0 && xz_avail_zstrm(state) == -1) ? -1 : \ + (strm->avail_in == 0 ? -1 : \ + (strm->avail_in--, *(strm->next_in)++))) /* Get a four-byte little-endian integer and return 0 on success and the value in *ret. Otherwise -1 is returned and *ret is not modified. */ @@ -324,10 +367,10 @@ gz_next4(xz_statep state, unsigned long *ret) unsigned long val; z_streamp strm = &(state->zstrm); - val = NEXT(); - val += (unsigned) NEXT() << 8; - val += (unsigned long) NEXT() << 16; - ch = NEXT(); + val = NEXTZ(); + val += (unsigned) NEXTZ() << 8; + val += (unsigned long) NEXTZ() << 16; + ch = NEXTZ(); if (ch == -1) return -1; val += (unsigned long) ch << 24; |