gzfile.c

fopenz() and fgunzip() functions allow to read gzipped files with standard fread() function from stdio.h. Write or seek is not supported. This extension requires ability to virtualize FILE* files. Only Linux (GNU libc) and BSD are supported. Not tested under BSD. It doesn't depend on zlib.

#include <stdio.h>

FILE *fopenz(const char *name, const char *mode);
FILE *fgunzip(FILE *f);

The file should be fclose()'d before exit (due to risk of a race condition).

Note: It is possible that fgunzip() will cause unstability within stdio library (due to use FILE inside a callback).

Download

Source: gzfile.c