Lines Matching refs:ctx

169 static int php_zlib_output_handler_ex(php_zlib_context *ctx, php_output_context *output_context)  in php_zlib_output_handler_ex()  argument
175 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
182 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
189 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
192 ctx->buffer.used = 0; in php_zlib_output_handler_ex()
197 if (ctx->buffer.free < output_context->in.used) { in php_zlib_output_handler_ex()
198 …if (!(ctx->buffer.aptr = erealloc_recoverable(ctx->buffer.data, ctx->buffer.used + ctx->buffer.fre… in php_zlib_output_handler_ex()
199 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
202 ctx->buffer.data = ctx->buffer.aptr; in php_zlib_output_handler_ex()
203 ctx->buffer.free += output_context->in.used; in php_zlib_output_handler_ex()
205 memcpy(ctx->buffer.data + ctx->buffer.used, output_context->in.data, output_context->in.used); in php_zlib_output_handler_ex()
206 ctx->buffer.free -= output_context->in.used; in php_zlib_output_handler_ex()
207 ctx->buffer.used += output_context->in.used; in php_zlib_output_handler_ex()
214 ctx->Z.avail_in = ctx->buffer.used; in php_zlib_output_handler_ex()
215 ctx->Z.next_in = (Bytef *) ctx->buffer.data; in php_zlib_output_handler_ex()
216 ctx->Z.avail_out = output_context->out.size; in php_zlib_output_handler_ex()
217 ctx->Z.next_out = (Bytef *) output_context->out.data; in php_zlib_output_handler_ex()
225 switch (deflate(&ctx->Z, flags)) { in php_zlib_output_handler_ex()
228 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
233 if (ctx->Z.avail_in) { in php_zlib_output_handler_ex()
234 … memmove(ctx->buffer.data, ctx->buffer.data + ctx->buffer.used - ctx->Z.avail_in, ctx->Z.avail_in); in php_zlib_output_handler_ex()
236 ctx->buffer.free += ctx->buffer.used - ctx->Z.avail_in; in php_zlib_output_handler_ex()
237 ctx->buffer.used = ctx->Z.avail_in; in php_zlib_output_handler_ex()
238 output_context->out.used = output_context->out.size - ctx->Z.avail_out; in php_zlib_output_handler_ex()
241 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
246 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
257 php_zlib_context *ctx = *(php_zlib_context **) handler_context; in php_zlib_output_handler() local
278 if (SUCCESS != php_zlib_output_handler_ex(ctx, output_context)) { in php_zlib_output_handler()
289 deflateEnd(&ctx->Z); in php_zlib_output_handler()
300 deflateEnd(&ctx->Z); in php_zlib_output_handler()
316 php_zlib_context *ctx = (php_zlib_context *) ecalloc(1, sizeof(php_zlib_context)); in php_zlib_output_handler_context_init() local
317 ctx->Z.zalloc = php_zlib_alloc; in php_zlib_output_handler_context_init()
318 ctx->Z.zfree = php_zlib_free; in php_zlib_output_handler_context_init()
319 return ctx; in php_zlib_output_handler_context_init()
326 php_zlib_context *ctx = (php_zlib_context *) opaq; in php_zlib_output_handler_context_dtor() local
328 if (ctx) { in php_zlib_output_handler_context_dtor()
329 if (ctx->buffer.data) { in php_zlib_output_handler_context_dtor()
330 efree(ctx->buffer.data); in php_zlib_output_handler_context_dtor()
332 efree(ctx); in php_zlib_output_handler_context_dtor()
528 php_output_context ctx = {0}; in PHP_FUNCTION() local
563 ctx.op = flags; in PHP_FUNCTION()
564 ctx.in.data = in_str; in PHP_FUNCTION()
565 ctx.in.used = in_len; in PHP_FUNCTION()
567 rv = php_zlib_output_handler_ex(ZLIBG(ob_gzhandler), &ctx); in PHP_FUNCTION()
570 if (ctx.out.data && ctx.out.free) { in PHP_FUNCTION()
571 efree(ctx.out.data); in PHP_FUNCTION()
577 if (ctx.out.data) { in PHP_FUNCTION()
578 RETVAL_STRINGL(ctx.out.data, ctx.out.used); in PHP_FUNCTION()
579 if (ctx.out.free) { in PHP_FUNCTION()
580 efree(ctx.out.data); in PHP_FUNCTION()
867 php_zlib_context *ctx; in PHP_FUNCTION() local
901 ctx = Z_INFLATE_CONTEXT_P(return_value); in PHP_FUNCTION()
903 ctx->Z.zalloc = php_zlib_alloc; in PHP_FUNCTION()
904 ctx->Z.zfree = php_zlib_free; in PHP_FUNCTION()
905 ctx->inflateDict = dict; in PHP_FUNCTION()
906 ctx->inflateDictlen = dictlen; in PHP_FUNCTION()
907 ctx->status = Z_OK; in PHP_FUNCTION()
915 if (inflateInit2(&ctx->Z, encoding) != Z_OK) { in PHP_FUNCTION()
922 switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict, ctx->inflateDictlen)) { in PHP_FUNCTION()
924 efree(ctx->inflateDict); in PHP_FUNCTION()
925 ctx->inflateDict = NULL; in PHP_FUNCTION()
929 efree(ctx->inflateDict); in PHP_FUNCTION()
930 ctx->inflateDict = NULL; in PHP_FUNCTION()
945 php_zlib_context *ctx; in PHP_FUNCTION() local
953 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
970 if (ctx->status == Z_STREAM_END) in PHP_FUNCTION()
972 ctx->status = Z_OK; in PHP_FUNCTION()
973 inflateReset(&ctx->Z); in PHP_FUNCTION()
981 ctx->Z.next_in = (Bytef *) in_buf; in PHP_FUNCTION()
982 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
983 ctx->Z.avail_in = in_len; in PHP_FUNCTION()
984 ctx->Z.avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
987 status = inflate(&ctx->Z, flush_type); in PHP_FUNCTION()
988 buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; in PHP_FUNCTION()
990 ctx->status = status; /* Save status for exposing to userspace */ in PHP_FUNCTION()
994 if (ctx->Z.avail_out == 0) { in PHP_FUNCTION()
997 ctx->Z.avail_out = CHUNK_SIZE; in PHP_FUNCTION()
998 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1006 if (flush_type == Z_FINISH && ctx->Z.avail_out == 0) { in PHP_FUNCTION()
1009 ctx->Z.avail_out = CHUNK_SIZE; in PHP_FUNCTION()
1010 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1017 if (ctx->inflateDict) { in PHP_FUNCTION()
1018 switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict, ctx->inflateDictlen)) { in PHP_FUNCTION()
1020 efree(ctx->inflateDict); in PHP_FUNCTION()
1021 ctx->inflateDict = NULL; in PHP_FUNCTION()
1024 efree(ctx->inflateDict); in PHP_FUNCTION()
1025 ctx->inflateDict = NULL; in PHP_FUNCTION()
1054 php_zlib_context *ctx; in PHP_FUNCTION() local
1060 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1062 RETURN_LONG(ctx->status); in PHP_FUNCTION()
1070 php_zlib_context *ctx; in PHP_FUNCTION() local
1076 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1078 RETURN_LONG(ctx->Z.total_in); in PHP_FUNCTION()
1085 php_zlib_context *ctx; in PHP_FUNCTION() local
1150 ctx = Z_DEFLATE_CONTEXT_P(return_value); in PHP_FUNCTION()
1152 ctx->Z.zalloc = php_zlib_alloc; in PHP_FUNCTION()
1153 ctx->Z.zfree = php_zlib_free; in PHP_FUNCTION()
1161 if (deflateInit2(&ctx->Z, level, Z_DEFLATED, encoding, memory, strategy) != Z_OK) { in PHP_FUNCTION()
1168 int success = deflateSetDictionary(&ctx->Z, (Bytef *) dict, dictlen); in PHP_FUNCTION()
1182 php_zlib_context *ctx; in PHP_FUNCTION() local
1190 ctx = Z_DEFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1218 ctx->Z.next_in = (Bytef *) in_buf; in PHP_FUNCTION()
1219 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
1220 ctx->Z.avail_in = in_len; in PHP_FUNCTION()
1221 ctx->Z.avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
1226 if (ctx->Z.avail_out == 0) { in PHP_FUNCTION()
1230 ctx->Z.avail_out = 64; in PHP_FUNCTION()
1231 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1233 status = deflate(&ctx->Z, flush_type); in PHP_FUNCTION()
1234 buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; in PHP_FUNCTION()
1235 } while (status == Z_OK && ctx->Z.avail_out == 0); in PHP_FUNCTION()
1239 ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1244 ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1246 deflateReset(&ctx->Z); in PHP_FUNCTION()