diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-12-30 19:22:46 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-12-30 19:22:46 (GMT) |
commit | 6d0f0e0acb95c23a476510726bf7c5fe6fb840bf (patch) | |
tree | 0bf1ae222c7564868e7115f5fa5285dec947c908 /Utilities/cmtar/libtar.c | |
parent | 01ac4158ed47f82b0d7ee7015d1cc38943d86eee (diff) | |
download | CMake-6d0f0e0acb95c23a476510726bf7c5fe6fb840bf.zip CMake-6d0f0e0acb95c23a476510726bf7c5fe6fb840bf.tar.gz CMake-6d0f0e0acb95c23a476510726bf7c5fe6fb840bf.tar.bz2 |
COMP: Fix support for gzip on non-32 bit platforms
Diffstat (limited to 'Utilities/cmtar/libtar.c')
-rw-r--r-- | Utilities/cmtar/libtar.c | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/Utilities/cmtar/libtar.c b/Utilities/cmtar/libtar.c index 91fed5c..58326b0 100644 --- a/Utilities/cmtar/libtar.c +++ b/Utilities/cmtar/libtar.c @@ -61,12 +61,17 @@ segv_handler(int sig) int use_zlib = 0; -int -gzopen_frontend(char *pathname, int oflags, int mode) +struct gzStruct +{ + gzFile* GZFile; +}; +struct gzStruct GZStruct; + +int libtar_gzopen(void* call_data, const char *pathname, int oflags, mode_t mode) { char *gzoflags; - gzFile gzf; int fd; + struct gzStruct* gzf = (struct gzStruct*)call_data; switch (oflags & O_ACCMODE) { @@ -84,25 +89,54 @@ gzopen_frontend(char *pathname, int oflags, int mode) fd = open(pathname, oflags, mode); if (fd == -1) + { return -1; + } #if !defined(_WIN32) || defined(__CYGWIN__) if ((oflags & O_CREAT) && fchmod(fd, mode)) + { return -1; + } #endif - gzf = gzdopen(fd, gzoflags); - if (!gzf) + gzf->GZFile = cm_zlib_gzdopen(fd, gzoflags); + if (!gzf->GZFile) { errno = ENOMEM; return -1; } - return (int)gzf; + return fd; +} + +int libtar_gzclose(void* call_data, int fd) +{ + struct gzStruct* gzf = (struct gzStruct*)call_data; + (void)fd; + return cm_zlib_gzclose(gzf->GZFile); +} + +ssize_t libtar_gzread(void* call_data, int fd, void* buf, size_t count) +{ + struct gzStruct* gzf = (struct gzStruct*)call_data; + (void)fd; + return cm_zlib_gzread(gzf->GZFile, buf, count); +} + +ssize_t libtar_gzwrite(void* call_data, int fd, const void* buf, size_t count) +{ + struct gzStruct* gzf = (struct gzStruct*)call_data; + (void)fd; + return cm_zlib_gzwrite(gzf->GZFile, (void*)buf, count); } -tartype_t gztype = { (openfunc_t) gzopen_frontend, (closefunc_t) gzclose, - (readfunc_t) gzread, (writefunc_t) gzwrite +tartype_t gztype = { + libtar_gzopen, + libtar_gzclose, + libtar_gzread, + libtar_gzwrite, + &GZStruct }; #endif /* HAVE_LIBZ */ |