71static void *
zstrm_malloc(
void *opaque,
unsigned int items,
unsigned int size)
107 zctx->
read.
z.total_in, zctx->
read.
z.total_out,
108 (
double) zctx->
read.
z.total_out / (
double) zctx->
read.
z.total_in,
110 (
double) zctx->
write.
z.total_in / (
double) zctx->
write.
z.total_out);
120 inflateEnd(&zctx->
read.
z);
121 deflateEnd(&zctx->
write.
z);
159 zctx->
read.
z.avail_out = (uInt) len;
160 zctx->
read.
z.next_out = (Bytef *) buf;
162 zrc = inflate(&zctx->
read.
z, Z_SYNC_FLUSH);
165 len - zctx->
read.
z.avail_out, len);
177 zrc = len - zctx->
read.
z.avail_out;
188 zrc = len - zctx->
read.
z.avail_out;
220 "last read wrote full buffer" :
221 "falling back on next stream");
222 if ((zctx->
read.
z.avail_out == 0) || (zctx->
read.
pos > 0))
236 zctx->
write.
z.avail_in = (uInt) count;
237 zctx->
write.
z.next_in = (Bytef *) buf;
243 int zrc = deflate(&zctx->
write.
z, Z_PARTIAL_FLUSH);
250 count - zctx->
write.
z.avail_in, count);
265 if ((zctx->
write.
z.avail_out != 0) && (zctx->
write.
z.avail_in == 0))
280 return (rc <= 0) ? 1 : rc;
323 zctx->
read.
z.opaque = NULL;
325 (void) inflateInit2(&zctx->
read.
z, -15);
328 zctx->
write.
z.opaque = NULL;
330 (void) deflateInit2(&zctx->
write.
z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 8,
An open network connection (socket)
static int zstrm_close(struct Connection *conn)
Close a socket - Implements Connection::close() -.
static int zstrm_open(struct Connection *conn)
Open a socket - Implements Connection::open() -.
static int zstrm_poll(struct Connection *conn, time_t wait_secs)
Check if any data is waiting on a socket - Implements Connection::poll() -.
static int zstrm_read(struct Connection *conn, char *buf, size_t len)
Read compressed data from a socket - Implements Connection::read() -.
static int zstrm_write(struct Connection *conn, const char *buf, size_t count)
Write compressed data to a socket - Implements Connection::write() -.
#define mutt_debug(LEVEL,...)
@ LL_DEBUG5
Log at debug level 5.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Convenience wrapper for the library headers.
void * sockdata
Backend-specific socket data.
int(* poll)(struct Connection *conn, time_t wait_secs)
int(* write)(struct Connection *conn, const char *buf, size_t count)
int(* close)(struct Connection *conn)
int(* open)(struct Connection *conn)
int fd
Socket file descriptor.
int(* read)(struct Connection *conn, char *buf, size_t count)
struct ZstrmDirection read
Data being read and de-compressed.
struct ZstrmDirection write
Data being compressed and written.
struct Connection next_conn
Underlying stream.
A stream of data being (de-)compressed.
unsigned int pos
Current position.
bool conn_eof
Connection end-of-file reached.
unsigned int len
Length of data.
z_stream z
zlib compression handle
char * buf
Buffer for data being (de-)compressed.
bool stream_eof
Stream end-of-file reached.
static void * zstrm_malloc(void *opaque, unsigned int items, unsigned int size)
Redirector function for zlib's malloc()
static void zstrm_free(void *opaque, void *address)
Redirector function for zlib's free()
void mutt_zstrm_wrap_conn(struct Connection *conn)
Wrap a compression layer around a Connection.
Zlib compression of network traffic.