68static void *
zstrm_malloc(
void *opaque,
unsigned int items,
unsigned int size)
104 zctx->
read.
z.total_in, zctx->
read.
z.total_out,
105 (
float) zctx->
read.
z.total_out / (
float) zctx->
read.
z.total_in,
107 (
float) zctx->
write.
z.total_in / (
float) zctx->
write.
z.total_out);
117 inflateEnd(&zctx->
read.
z);
118 deflateEnd(&zctx->
write.
z);
156 zctx->
read.
z.avail_out = (uInt) len;
157 zctx->
read.
z.next_out = (Bytef *) buf;
159 zrc = inflate(&zctx->
read.
z, Z_SYNC_FLUSH);
162 len - zctx->
read.
z.avail_out, len);
174 zrc = len - zctx->
read.
z.avail_out;
185 zrc = len - zctx->
read.
z.avail_out;
217 "last read wrote full buffer" :
218 "falling back on next stream");
219 if ((zctx->
read.
z.avail_out == 0) || (zctx->
read.
pos > 0))
233 zctx->
write.
z.avail_in = (uInt) count;
234 zctx->
write.
z.next_in = (Bytef *) buf;
240 int zrc = deflate(&zctx->
write.
z, Z_PARTIAL_FLUSH);
247 count - zctx->
write.
z.avail_in, count);
262 if ((zctx->
write.
z.avail_out != 0) && (zctx->
write.
z.avail_in == 0))
277 return (rc <= 0) ? 1 : rc;
320 zctx->
read.
z.opaque = NULL;
322 (void) inflateInit2(&zctx->
read.
z, -15);
325 zctx->
write.
z.opaque = NULL;
327 (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.