From 1274f3c1fa8862b0818a1cd4bb13330c54de6b6c Mon Sep 17 00:00:00 2001 From: Mystery Man Date: Fri, 14 Mar 2003 01:10:03 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'V9_1_23mdk'. --- mdk-stage1/insmod-modutils/util/gzfiles.c | 74 ------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 mdk-stage1/insmod-modutils/util/gzfiles.c (limited to 'mdk-stage1/insmod-modutils/util/gzfiles.c') diff --git a/mdk-stage1/insmod-modutils/util/gzfiles.c b/mdk-stage1/insmod-modutils/util/gzfiles.c deleted file mode 100644 index 8d02253bb..000000000 --- a/mdk-stage1/insmod-modutils/util/gzfiles.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This simple library intends to make it transparent to read gzipped and/or - * standard files. This is simple enough to fit modutils' needs, but may be - * easily adapted to anyone's needs. It's completely free, do what you want - * with it . - Willy Tarreau - 2000/05/05 - - */ - -#ifdef CONFIG_USE_ZLIB - -#include -#include -#include -#include -#include - -/* redefinition of gz_stream which isn't exported by zlib */ -typedef struct gz_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - FILE *file; /* .gz file */ - Byte *inbuf; /* input buffer */ - Byte *outbuf; /* output buffer */ - uLong crc; /* crc32 of uncompressed data */ - char *msg; /* error message */ - char *path; /* path name for debugging only */ - int transparent; /* 1 if input file is not a .gz file */ - char mode; /* 'w' or 'r' */ - long startpos; /* start of compressed data in file (header skipped) */ -} gz_stream; - -/* maximum number of simultaneous open files, also greater file descriptor number */ -#define MAXFD 64 - -/* this static list is assumed to be filled with NULLs at runtime */ -static gzFile gzf_fds[MAXFD]; - -/* returns the filedesc of the opened file. */ -int gzf_open(const char *name, int mode) { - int fd; - gzFile g; - - if ((g=gzopen(name, "rb")) != NULL) { - fd=fileno(((gz_stream*)g)->file); - gzf_fds[fd]=g; - } - else if ((fd=open(name, mode)) != -1) { - gzf_fds[fd]=NULL; /* NULL means not GZ mode */ - } - return fd; -} - -off_t gzf_lseek(int fd, off_t offset, int whence) { - if (fd<0 || fd>=MAXFD || gzf_fds[fd]==NULL) - return lseek(fd, offset, whence); - else - return gzseek(gzf_fds[fd], offset, whence); -} - -int gzf_read(int fd, void *buf, size_t count) { - if (fd<0 || fd>=MAXFD || gzf_fds[fd]==NULL) - return read(fd, buf, count); - else - return gzread(gzf_fds[fd], buf, count); -} - -void gzf_close(int fd) { - if (fd<0 || fd>=MAXFD || gzf_fds[fd]==NULL) - close(fd); - else - gzclose(gzf_fds[fd]); -} -#endif - -- cgit v1.2.1