Add zlib gzip functions

These will now be included in the cosmopolitan.a releases. It took a bit
of time because, these functions depend on heavyweight parts of the libc
that wouldn't be appropriate for the core zlib library to depend upon.

Fixes #345
This commit is contained in:
Justine Tunney 2022-05-12 12:16:25 -07:00
parent 4499f98e76
commit 4e62cefa6e
11 changed files with 1991 additions and 8 deletions

27
third_party/zlib/gz/gzclose.c vendored Normal file
View file

@ -0,0 +1,27 @@
#include "third_party/zlib/gz/gzguts.inc"
// clang-format off
/* gzclose.c -- zlib gzclose() function
* Copyright (C) 2004, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
asm(".ident\t\"\\n\\n\
zlib (zlib License)\\n\
Copyright 1995-2017 Jean-loup Gailly and Mark Adler\"");
asm(".include \"libc/disclaimer.inc\"");
/* gzclose() is in a separate file so that it is linked in only if it is used.
That way the other gzclose functions can be used instead to avoid linking in
unneeded compression or decompression routines. */
int gzclose(file)
gzFile file;
{
gz_statep state;
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_statep)file;
return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
}