71static void *
zstrm_malloc(
void *opaque,
unsigned int items,
unsigned int size)
106 double read_ratio = (zctx->
read.
z.total_in != 0) ?
107 (
double) zctx->
read.
z.total_out /
108 (double) zctx->
read.
z.total_in :
110 double write_ratio = (zctx->
write.
z.total_out != 0) ?
111 (
double) zctx->
write.
z.total_in /
112 (double) zctx->
write.
z.total_out :
115 zctx->
read.
z.total_in, zctx->
read.
z.total_out, read_ratio,
116 zctx->
write.
z.total_in, zctx->
write.
z.total_out, write_ratio);
126 inflateEnd(&zctx->
read.
z);
127 deflateEnd(&zctx->
write.
z);
165 zctx->
read.
z.avail_out = (uInt) len;
166 zctx->
read.
z.next_out = (Bytef *) buf;
168 zrc = inflate(&zctx->
read.
z, Z_SYNC_FLUSH);
171 len - zctx->
read.
z.avail_out, len);
183 zrc = len - zctx->
read.
z.avail_out;
194 zrc = len - zctx->
read.
z.avail_out;
226 "last read wrote full buffer" :
227 "falling back on next stream");
228 if ((zctx->
read.
z.avail_out == 0) || (zctx->
read.
pos > 0))
242 zctx->
write.
z.avail_in = (uInt) count;
243 zctx->
write.
z.next_in = (Bytef *) buf;
249 int zrc = deflate(&zctx->
write.
z, Z_PARTIAL_FLUSH);
256 count - zctx->
write.
z.avail_in, count);
271 if ((zctx->
write.
z.avail_out != 0) && (zctx->
write.
z.avail_in == 0))
286 return (rc <= 0) ? 1 : rc;
329 zctx->
read.
z.opaque = NULL;
331 (void) inflateInit2(&zctx->
read.
z, -15);
334 zctx->
write.
z.opaque = NULL;
336 (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.
#define FREE(x)
Free memory and set the pointer to NULL.
#define MUTT_MEM_CALLOC(n, type)
#define MUTT_MEM_MALLOC(n, type)
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.