Prevent implicit -std=* passing from NXCFLAGS to NXCXXFLAGS.
[dragonfly.git] / lib / libz / zopen.c
blob5cbb83d265d016852007ba698f6b792d3bab1780
1 /*
2 * Public domain stdio wrapper for libz, written by Johan Danielsson.
4 * $FreeBSD: src/lib/libz/zopen.c,v 1.2.2.2 2003/02/01 13:33:12 sobomax Exp $
5 */
7 #include <stdio.h>
8 #include <zlib.h>
10 FILE *zopen(const char *fname, const char *mode);
12 /* convert arguments */
13 static int
14 xgzread(void *cookie, char *data, int size)
16 return gzread(cookie, data, size);
19 static int
20 xgzwrite(void *cookie, const char *data, int size)
22 return gzwrite(cookie, (void*)data, size);
25 static int
26 xgzclose(void *cookie)
28 return gzclose((gzFile) cookie);
31 FILE *
32 zopen(const char *fname, const char *mode)
34 gzFile gz = gzopen(fname, mode);
35 if(gz == NULL)
36 return NULL;
38 if(*mode == 'r')
39 return (funopen(gz, xgzread, NULL, NULL, xgzclose));
40 else
41 return (funopen(gz, NULL, xgzwrite, NULL, xgzclose));