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()
831 z_stream *ctx; in PHP_FUNCTION() local
864 ctx = ecalloc(1, sizeof(php_zlib_context)); in PHP_FUNCTION()
865 ctx->zalloc = php_zlib_alloc; in PHP_FUNCTION()
866 ctx->zfree = php_zlib_free; in PHP_FUNCTION()
867 ((php_zlib_context *) ctx)->inflateDict = dict; in PHP_FUNCTION()
868 ((php_zlib_context *) ctx)->inflateDictlen = dictlen; in PHP_FUNCTION()
869 ((php_zlib_context *) ctx)->status = Z_OK; in PHP_FUNCTION()
877 if (Z_OK == inflateInit2(ctx, encoding)) { in PHP_FUNCTION()
879 php_zlib_context *php_ctx = (php_zlib_context *) ctx; in PHP_FUNCTION()
880 switch (inflateSetDictionary(ctx, (Bytef *) php_ctx->inflateDict, php_ctx->inflateDictlen)) { in PHP_FUNCTION()
893 RETURN_RES(zend_register_resource(ctx, le_inflate)); in PHP_FUNCTION()
895 efree(ctx); in PHP_FUNCTION()
910 z_stream *ctx; in PHP_FUNCTION() local
918 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { in PHP_FUNCTION()
939 if (((php_zlib_context *) ctx)->status == Z_STREAM_END) in PHP_FUNCTION()
941 ((php_zlib_context *) ctx)->status = Z_OK; in PHP_FUNCTION()
942 inflateReset(ctx); in PHP_FUNCTION()
950 ctx->next_in = (Bytef *) in_buf; in PHP_FUNCTION()
951 ctx->next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
952 ctx->avail_in = in_len; in PHP_FUNCTION()
953 ctx->avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
956 status = inflate(ctx, flush_type); in PHP_FUNCTION()
957 buffer_used = ZSTR_LEN(out) - ctx->avail_out; in PHP_FUNCTION()
959 ((php_zlib_context *) ctx)->status = status; /* Save status for exposing to userspace */ in PHP_FUNCTION()
963 if (ctx->avail_out == 0) { in PHP_FUNCTION()
966 ctx->avail_out = CHUNK_SIZE; in PHP_FUNCTION()
967 ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
975 if (flush_type == Z_FINISH && ctx->avail_out == 0) { in PHP_FUNCTION()
978 ctx->avail_out = CHUNK_SIZE; in PHP_FUNCTION()
979 ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
986 if (((php_zlib_context *) ctx)->inflateDict) { in PHP_FUNCTION()
987 php_zlib_context *php_ctx = (php_zlib_context *) ctx; in PHP_FUNCTION()
988 switch (inflateSetDictionary(ctx, (Bytef *) php_ctx->inflateDict, php_ctx->inflateDictlen)) { in PHP_FUNCTION()
1026 z_stream *ctx; in PHP_FUNCTION() local
1033 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { in PHP_FUNCTION()
1038 RETURN_LONG(((php_zlib_context *) ctx)->status); in PHP_FUNCTION()
1047 z_stream *ctx; in PHP_FUNCTION() local
1054 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { in PHP_FUNCTION()
1059 RETURN_LONG(ctx->total_in); in PHP_FUNCTION()
1067 z_stream *ctx; in PHP_FUNCTION() local
1132 ctx = ecalloc(1, sizeof(php_zlib_context)); in PHP_FUNCTION()
1133 ctx->zalloc = php_zlib_alloc; in PHP_FUNCTION()
1134 ctx->zfree = php_zlib_free; in PHP_FUNCTION()
1142 if (Z_OK == deflateInit2(ctx, level, Z_DEFLATED, encoding, memory, strategy)) { in PHP_FUNCTION()
1144 int success = deflateSetDictionary(ctx, (Bytef *) dict, dictlen); in PHP_FUNCTION()
1149 RETURN_RES(zend_register_resource(ctx, le_deflate)); in PHP_FUNCTION()
1151 efree(ctx); in PHP_FUNCTION()
1166 z_stream *ctx; in PHP_FUNCTION() local
1174 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_deflate))) { in PHP_FUNCTION()
1207 ctx->next_in = (Bytef *) in_buf; in PHP_FUNCTION()
1208 ctx->next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
1209 ctx->avail_in = in_len; in PHP_FUNCTION()
1210 ctx->avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
1215 if (ctx->avail_out == 0) { in PHP_FUNCTION()
1219 ctx->avail_out = 64; in PHP_FUNCTION()
1220 ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1222 status = deflate(ctx, flush_type); in PHP_FUNCTION()
1223 buffer_used = ZSTR_LEN(out) - ctx->avail_out; in PHP_FUNCTION()
1224 } while (status == Z_OK && ctx->avail_out == 0); in PHP_FUNCTION()
1228 ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1233 ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1235 deflateReset(ctx); in PHP_FUNCTION()