mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
ce086c793b
Unexpand the tag, remove the fbsd:nokeywords property and add the svn:keywords property. This should eliminate the gratuituous diffs that appear on these files in projects branches. Sponsored by: The FreeBSD Foundation
50 lines
906 B
C
50 lines
906 B
C
/*
|
|
* Public domain stdio wrapper for libz, written by Johan Danielsson.
|
|
*/
|
|
|
|
#include <sys/cdefs.h>
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
#include <stdio.h>
|
|
#include <zlib.h>
|
|
|
|
FILE *zopen(const char *fname, const char *mode);
|
|
|
|
/* convert arguments */
|
|
static int
|
|
xgzread(void *cookie, char *data, int size)
|
|
{
|
|
return gzread(cookie, data, size);
|
|
}
|
|
|
|
static int
|
|
xgzwrite(void *cookie, const char *data, int size)
|
|
{
|
|
return gzwrite(cookie, (void*)data, size);
|
|
}
|
|
|
|
static int
|
|
xgzclose(void *cookie)
|
|
{
|
|
return gzclose(cookie);
|
|
}
|
|
|
|
static fpos_t
|
|
xgzseek(void *cookie, fpos_t offset, int whence)
|
|
{
|
|
return gzseek(cookie, (z_off_t)offset, whence);
|
|
}
|
|
|
|
FILE *
|
|
zopen(const char *fname, const char *mode)
|
|
{
|
|
gzFile gz = gzopen(fname, mode);
|
|
if(gz == NULL)
|
|
return NULL;
|
|
|
|
if(*mode == 'r')
|
|
return (funopen(gz, xgzread, NULL, xgzseek, xgzclose));
|
|
else
|
|
return (funopen(gz, NULL, xgzwrite, xgzseek, xgzclose));
|
|
}
|