No empty .Rs/.Re
[netbsd-mini2440.git] / sbin / savecore / zopen.c
blobea6e7f7cb6086a3653259a0218fd1f17edbec6b2
1 /* $NetBSD: zopen.c,v 1.1 2001/01/02 21:39:37 joda Exp $ */
3 /*
4 * Public domain stdio wrapper for libz, written by Johan Danielsson.
5 */
7 #include <sys/cdefs.h>
8 #ifndef lint
9 __RCSID("$NetBSD: zopen.c,v 1.1 2001/01/02 21:39:37 joda Exp $");
10 #endif
12 #include <stdio.h>
13 #include <zlib.h>
15 FILE *zopen(const char *fname, const char *mode);
17 /* convert arguments */
18 static int
19 xgzread(void *cookie, char *data, int size)
21 return gzread(cookie, data, size);
24 static int
25 xgzwrite(void *cookie, const char *data, int size)
27 return gzwrite(cookie, __UNCONST(data), size);
30 FILE *
31 zopen(const char *fname, const char *mode)
33 gzFile gz = gzopen(fname, mode);
34 if(gz == NULL)
35 return NULL;
37 if(*mode == 'r')
38 return (funopen(gz, xgzread, NULL, NULL, gzclose));
39 else
40 return (funopen(gz, NULL, xgzwrite, NULL, gzclose));