diff options
Diffstat (limited to 'src/lbx_zlib/lbx_zlib.c')
-rw-r--r-- | src/lbx_zlib/lbx_zlib.c | 94 |
1 files changed, 37 insertions, 57 deletions
diff --git a/src/lbx_zlib/lbx_zlib.c b/src/lbx_zlib/lbx_zlib.c index f2f17e0..95ae326 100644 --- a/src/lbx_zlib/lbx_zlib.c +++ b/src/lbx_zlib/lbx_zlib.c @@ -50,6 +50,7 @@ from The Open Group. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ +/* $XFree86: xc/lib/lbxutil/lbx_zlib/lbx_zlib.c,v 1.10 2001/12/14 19:56:59 dawes Exp $ */ #ifdef WIN32 #define _WILLWINSOCK_ @@ -58,18 +59,14 @@ from The Open Group. #include <X11/Xfuncs.h> #include <stdio.h> #include <errno.h> -#ifdef X_NOT_STDC_ENV -extern int errno; -#endif -#include "lbxzlib.h" #include <sys/types.h> -#ifndef WIN32 +#if !defined(WIN32) && !defined(Lynx) #include <sys/param.h> #endif #include "lbxbufstr.h" #include "lbx_zlib.h" - -void ZlibFree(); +#include "os.h" +#include "lbxzlib.h" unsigned long stream_out_compressed; unsigned long stream_out_uncompressed; @@ -94,9 +91,8 @@ struct ZlibInfo { }; static int -init_compress(priv, level) - struct compress_private *priv; /* local pointer to private data */ - int level; /* compression level */ +init_compress(struct compress_private *priv,/* local pointer to private data */ + int level) /* compression level */ { priv->cp_outputcount = 0; @@ -117,8 +113,7 @@ init_compress(priv, level) } static int -init_decompress(priv) - struct compress_private *priv; /* local pointer to private data */ +init_decompress(struct compress_private *priv)/* local pointer to private data */ { priv->cp_outputcount = 0; @@ -149,10 +144,8 @@ init_decompress(priv) static void -do_compress (priv, flush) - -struct compress_private *priv; -int flush; +do_compress (struct compress_private *priv, + int flush) { priv->stream.next_in = priv->cp_inputbuf; @@ -169,9 +162,7 @@ int flush; static void -do_decompress (priv) - -struct compress_private *priv; +do_decompress (struct compress_private *priv) { priv->stream.next_in = priv->cp_inputbuf; @@ -189,8 +180,7 @@ struct compress_private *priv; } static int -GetNewPacket(comp) - struct ZlibInfo *comp; +GetNewPacket(struct ZlibInfo *comp) { register struct compress_private *priv = &comp->decompress_state; int len; @@ -220,8 +210,7 @@ GetNewPacket(comp) } static int -NewPacketAvail(comp) - struct ZlibInfo *comp; +NewPacketAvail(struct ZlibInfo *comp) { register struct compress_private *priv = &comp->decompress_state; char *pkt; @@ -243,10 +232,9 @@ NewPacketAvail(comp) } static int -PlainWrite(comp, buffer, buflen) - struct ZlibInfo *comp; - unsigned char *buffer; - int buflen; +PlainWrite(struct ZlibInfo *comp, + unsigned char *buffer, + int buflen) { int retval; int lenleft = buflen; @@ -299,9 +287,8 @@ static struct ZlibInfo *per_fd[MAX_FDS]; * Initialize ZLIB compressor */ void * -ZlibInit(fd, level) - int fd; - int level; /* compression level */ +ZlibInit(int fd, + int level) /* compression level */ { struct ZlibInfo *comp; int ret1, ret2; @@ -335,8 +322,7 @@ ZlibInit(fd, level) } void -ZlibFree(comp) - struct ZlibInfo *comp; +ZlibFree(struct ZlibInfo *comp) { if (!comp) return; @@ -353,7 +339,7 @@ ZlibFree(comp) } int -ZlibFlush(fd) +ZlibFlush(int fd) { struct ZlibInfo *comp = per_fd[fd]; struct compress_private *priv = &comp->compress_state; @@ -373,10 +359,9 @@ ZlibFlush(fd) } int -ZlibStuffInput(fd,buffer,buflen) - int fd; - unsigned char *buffer; - int buflen; +ZlibStuffInput(int fd, + unsigned char *buffer, + int buflen) { struct ZlibInfo *comp = per_fd[fd]; @@ -386,24 +371,21 @@ ZlibStuffInput(fd,buffer,buflen) } void -ZlibCompressOn(fd) - int fd; +ZlibCompressOn(int fd) { per_fd[fd]->compress_off = FALSE; } void -ZlibCompressOff(fd) - int fd; +ZlibCompressOff(int fd) { per_fd[fd]->compress_off = TRUE; } int -ZlibWriteV(fd, iov, iovcnt) - int fd; - struct iovec *iov; - int iovcnt; +ZlibWriteV(int fd, + struct iovec *iov, + int iovcnt) { int i; int total = 0; @@ -411,7 +393,8 @@ ZlibWriteV(fd, iov, iovcnt) for (i = 0; i < iovcnt; i++) { - this_time = ZlibWrite(fd, iov[i].iov_base, iov[i].iov_len); + this_time = ZlibWrite(fd, (unsigned char *)iov[i].iov_base, + iov[i].iov_len); if (this_time > 0) total += this_time; if (this_time != iov[i].iov_len) @@ -425,10 +408,9 @@ ZlibWriteV(fd, iov, iovcnt) } int -ZlibWrite(fd, buffer, buflen) - int fd; - unsigned char *buffer; - int buflen; +ZlibWrite(int fd, + unsigned char *buffer, + int buflen) { struct ZlibInfo *comp = per_fd[fd]; struct compress_private *priv = &comp->compress_state; @@ -474,17 +456,16 @@ ZlibWrite(fd, buffer, buflen) } int -ZlibRead(fd, buffer, buflen) - int fd; - unsigned char *buffer; - int buflen; +ZlibRead(int fd, + unsigned char *buffer, + int buflen) { struct ZlibInfo *comp = per_fd[fd]; struct compress_private *priv = &comp->decompress_state; unsigned char *p = buffer; int lenleft = buflen; int len; - int retval; + int retval = -1; /* * First check if there is any data Zlib decompressed already but @@ -550,8 +531,7 @@ ZlibRead(fd, buffer, buflen) } int -ZlibInputAvail(fd) - int fd; +ZlibInputAvail(int fd) { struct ZlibInfo *comp = per_fd[fd]; struct compress_private *priv = &comp->decompress_state; |