priv: Narrow down privileges
[dragonfly.git] / lib / libz / zopen.c
blob9eadb52a69f1d7147319cfda31731613b5eaef37
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 * $DragonFly: src/lib/libz/zopen.c,v 1.2 2003/06/17 04:26:52 dillon Exp $
6 */
8 #include <stdio.h>
9 #include <zlib.h>
11 FILE *zopen(const char *fname, const char *mode);
13 /* convert arguments */
14 static int
15 xgzread(void *cookie, char *data, int size)
17 return gzread(cookie, data, size);
20 static int
21 xgzwrite(void *cookie, const char *data, int size)
23 return gzwrite(cookie, (void*)data, size);
26 FILE *
27 zopen(const char *fname, const char *mode)
29 gzFile gz = gzopen(fname, mode);
30 if(gz == NULL)
31 return NULL;
33 if(*mode == 'r')
34 return (funopen(gz, xgzread, NULL, NULL, gzclose));
35 else
36 return (funopen(gz, NULL, xgzwrite, NULL, gzclose));