Lines Matching refs:ctx

69 	z_stream *ctx = zend_fetch_resource(res, NULL, le_deflate);  in deflate_rsrc_dtor()  local
70 deflateEnd(ctx); in deflate_rsrc_dtor()
71 efree(ctx); in deflate_rsrc_dtor()
76 z_stream *ctx = zend_fetch_resource(res, NULL, le_inflate); in inflate_rsrc_dtor() local
77 if (((php_zlib_context *) ctx)->inflateDict) { in inflate_rsrc_dtor()
78 efree(((php_zlib_context *) ctx)->inflateDict); in inflate_rsrc_dtor()
80 inflateEnd(ctx); in inflate_rsrc_dtor()
81 efree(ctx); in inflate_rsrc_dtor()
122 static int php_zlib_output_handler_ex(php_zlib_context *ctx, php_output_context *output_context) in php_zlib_output_handler_ex() argument
128 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
135 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
142 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
145 ctx->buffer.used = 0; in php_zlib_output_handler_ex()
150 if (ctx->buffer.free < output_context->in.used) { in php_zlib_output_handler_ex()
151 …if (!(ctx->buffer.aptr = erealloc_recoverable(ctx->buffer.data, ctx->buffer.used + ctx->buffer.fre… in php_zlib_output_handler_ex()
152 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
155 ctx->buffer.data = ctx->buffer.aptr; in php_zlib_output_handler_ex()
156 ctx->buffer.free += output_context->in.used; in php_zlib_output_handler_ex()
158 memcpy(ctx->buffer.data + ctx->buffer.used, output_context->in.data, output_context->in.used); in php_zlib_output_handler_ex()
159 ctx->buffer.free -= output_context->in.used; in php_zlib_output_handler_ex()
160 ctx->buffer.used += output_context->in.used; in php_zlib_output_handler_ex()
167 ctx->Z.avail_in = ctx->buffer.used; in php_zlib_output_handler_ex()
168 ctx->Z.next_in = (Bytef *) ctx->buffer.data; in php_zlib_output_handler_ex()
169 ctx->Z.avail_out = output_context->out.size; in php_zlib_output_handler_ex()
170 ctx->Z.next_out = (Bytef *) output_context->out.data; in php_zlib_output_handler_ex()
178 switch (deflate(&ctx->Z, flags)) { in php_zlib_output_handler_ex()
181 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
185 if (ctx->Z.avail_in) { in php_zlib_output_handler_ex()
186 … memmove(ctx->buffer.data, ctx->buffer.data + ctx->buffer.used - ctx->Z.avail_in, ctx->Z.avail_in); in php_zlib_output_handler_ex()
188 ctx->buffer.free += ctx->buffer.used - ctx->Z.avail_in; in php_zlib_output_handler_ex()
189 ctx->buffer.used = ctx->Z.avail_in; in php_zlib_output_handler_ex()
190 output_context->out.used = output_context->out.size - ctx->Z.avail_out; in php_zlib_output_handler_ex()
193 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
198 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
209 php_zlib_context *ctx = *(php_zlib_context **) handler_context; in php_zlib_output_handler() local
230 if (SUCCESS != php_zlib_output_handler_ex(ctx, output_context)) { in php_zlib_output_handler()
241 deflateEnd(&ctx->Z); in php_zlib_output_handler()
252 deflateEnd(&ctx->Z); in php_zlib_output_handler()
268 php_zlib_context *ctx = (php_zlib_context *) ecalloc(1, sizeof(php_zlib_context)); in php_zlib_output_handler_context_init() local
269 ctx->Z.zalloc = php_zlib_alloc; in php_zlib_output_handler_context_init()
270 ctx->Z.zfree = php_zlib_free; in php_zlib_output_handler_context_init()
271 return ctx; in php_zlib_output_handler_context_init()
278 php_zlib_context *ctx = (php_zlib_context *) opaq; in php_zlib_output_handler_context_dtor() local
280 if (ctx) { in php_zlib_output_handler_context_dtor()
281 if (ctx->buffer.data) { in php_zlib_output_handler_context_dtor()
282 efree(ctx->buffer.data); in php_zlib_output_handler_context_dtor()
284 efree(ctx); in php_zlib_output_handler_context_dtor()
481 php_output_context ctx = {0}; in PHP_FUNCTION() local
516 ctx.op = flags; in PHP_FUNCTION()
517 ctx.in.data = in_str; in PHP_FUNCTION()
518 ctx.in.used = in_len; in PHP_FUNCTION()
520 rv = php_zlib_output_handler_ex(ZLIBG(ob_gzhandler), &ctx); in PHP_FUNCTION()
523 if (ctx.out.data && ctx.out.free) { in PHP_FUNCTION()
524 efree(ctx.out.data); in PHP_FUNCTION()
530 if (ctx.out.data) { in PHP_FUNCTION()
531 RETVAL_STRINGL(ctx.out.data, ctx.out.used); in PHP_FUNCTION()
532 if (ctx.out.free) { in PHP_FUNCTION()
533 efree(ctx.out.data); in PHP_FUNCTION()
833 z_stream *ctx; in PHP_FUNCTION() local
866 ctx = ecalloc(1, sizeof(php_zlib_context)); in PHP_FUNCTION()
867 ctx->zalloc = php_zlib_alloc; in PHP_FUNCTION()
868 ctx->zfree = php_zlib_free; in PHP_FUNCTION()
869 ((php_zlib_context *) ctx)->inflateDict = dict; in PHP_FUNCTION()
870 ((php_zlib_context *) ctx)->inflateDictlen = dictlen; in PHP_FUNCTION()
871 ((php_zlib_context *) ctx)->status = Z_OK; in PHP_FUNCTION()
879 if (Z_OK == inflateInit2(ctx, encoding)) { in PHP_FUNCTION()
881 php_zlib_context *php_ctx = (php_zlib_context *) ctx; in PHP_FUNCTION()
882 switch (inflateSetDictionary(ctx, (Bytef *) php_ctx->inflateDict, php_ctx->inflateDictlen)) { in PHP_FUNCTION()
895 RETURN_RES(zend_register_resource(ctx, le_inflate)); in PHP_FUNCTION()
897 efree(ctx); in PHP_FUNCTION()
912 z_stream *ctx; in PHP_FUNCTION() local
920 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { in PHP_FUNCTION()
941 if (((php_zlib_context *) ctx)->status == Z_STREAM_END) in PHP_FUNCTION()
943 ((php_zlib_context *) ctx)->status = Z_OK; in PHP_FUNCTION()
944 inflateReset(ctx); in PHP_FUNCTION()
952 ctx->next_in = (Bytef *) in_buf; in PHP_FUNCTION()
953 ctx->next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
954 ctx->avail_in = in_len; in PHP_FUNCTION()
955 ctx->avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
958 status = inflate(ctx, flush_type); in PHP_FUNCTION()
959 buffer_used = ZSTR_LEN(out) - ctx->avail_out; in PHP_FUNCTION()
961 ((php_zlib_context *) ctx)->status = status; /* Save status for exposing to userspace */ in PHP_FUNCTION()
965 if (ctx->avail_out == 0) { in PHP_FUNCTION()
968 ctx->avail_out = CHUNK_SIZE; in PHP_FUNCTION()
969 ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
977 if (flush_type == Z_FINISH && ctx->avail_out == 0) { in PHP_FUNCTION()
980 ctx->avail_out = CHUNK_SIZE; in PHP_FUNCTION()
981 ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
988 if (((php_zlib_context *) ctx)->inflateDict) { in PHP_FUNCTION()
989 php_zlib_context *php_ctx = (php_zlib_context *) ctx; in PHP_FUNCTION()
990 switch (inflateSetDictionary(ctx, (Bytef *) php_ctx->inflateDict, php_ctx->inflateDictlen)) { in PHP_FUNCTION()
1028 z_stream *ctx; in PHP_FUNCTION() local
1035 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { in PHP_FUNCTION()
1040 RETURN_LONG(((php_zlib_context *) ctx)->status); in PHP_FUNCTION()
1049 z_stream *ctx; in PHP_FUNCTION() local
1056 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { in PHP_FUNCTION()
1061 RETURN_LONG(ctx->total_in); in PHP_FUNCTION()
1069 z_stream *ctx; in PHP_FUNCTION() local
1134 ctx = ecalloc(1, sizeof(php_zlib_context)); in PHP_FUNCTION()
1135 ctx->zalloc = php_zlib_alloc; in PHP_FUNCTION()
1136 ctx->zfree = php_zlib_free; in PHP_FUNCTION()
1144 if (Z_OK == deflateInit2(ctx, level, Z_DEFLATED, encoding, memory, strategy)) { in PHP_FUNCTION()
1146 int success = deflateSetDictionary(ctx, (Bytef *) dict, dictlen); in PHP_FUNCTION()
1151 RETURN_RES(zend_register_resource(ctx, le_deflate)); in PHP_FUNCTION()
1153 efree(ctx); in PHP_FUNCTION()
1168 z_stream *ctx; in PHP_FUNCTION() local
1176 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_deflate))) { in PHP_FUNCTION()
1209 ctx->next_in = (Bytef *) in_buf; in PHP_FUNCTION()
1210 ctx->next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
1211 ctx->avail_in = in_len; in PHP_FUNCTION()
1212 ctx->avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
1217 if (ctx->avail_out == 0) { in PHP_FUNCTION()
1221 ctx->avail_out = 64; in PHP_FUNCTION()
1222 ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1224 status = deflate(ctx, flush_type); in PHP_FUNCTION()
1225 buffer_used = ZSTR_LEN(out) - ctx->avail_out; in PHP_FUNCTION()
1226 } while (status == Z_OK && ctx->avail_out == 0); in PHP_FUNCTION()
1230 ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1235 ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1237 deflateReset(ctx); in PHP_FUNCTION()