Lines Matching refs:ctx
71 z_stream *ctx = zend_fetch_resource(res, NULL, le_deflate); in deflate_rsrc_dtor() local
72 deflateEnd(ctx); in deflate_rsrc_dtor()
73 efree(ctx); in deflate_rsrc_dtor()
78 z_stream *ctx = zend_fetch_resource(res, NULL, le_inflate); in inflate_rsrc_dtor() local
79 if (((php_zlib_context *) ctx)->inflateDict) { in inflate_rsrc_dtor()
80 efree(((php_zlib_context *) ctx)->inflateDict); in inflate_rsrc_dtor()
82 inflateEnd(ctx); in inflate_rsrc_dtor()
83 efree(ctx); in inflate_rsrc_dtor()
124 static int php_zlib_output_handler_ex(php_zlib_context *ctx, php_output_context *output_context) in php_zlib_output_handler_ex() argument
130 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
137 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
144 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
147 ctx->buffer.used = 0; in php_zlib_output_handler_ex()
152 if (ctx->buffer.free < output_context->in.used) { in php_zlib_output_handler_ex()
153 …if (!(ctx->buffer.aptr = erealloc_recoverable(ctx->buffer.data, ctx->buffer.used + ctx->buffer.fre… in php_zlib_output_handler_ex()
154 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
157 ctx->buffer.data = ctx->buffer.aptr; in php_zlib_output_handler_ex()
158 ctx->buffer.free += output_context->in.used; in php_zlib_output_handler_ex()
160 memcpy(ctx->buffer.data + ctx->buffer.used, output_context->in.data, output_context->in.used); in php_zlib_output_handler_ex()
161 ctx->buffer.free -= output_context->in.used; in php_zlib_output_handler_ex()
162 ctx->buffer.used += output_context->in.used; in php_zlib_output_handler_ex()
169 ctx->Z.avail_in = ctx->buffer.used; in php_zlib_output_handler_ex()
170 ctx->Z.next_in = (Bytef *) ctx->buffer.data; in php_zlib_output_handler_ex()
171 ctx->Z.avail_out = output_context->out.size; in php_zlib_output_handler_ex()
172 ctx->Z.next_out = (Bytef *) output_context->out.data; in php_zlib_output_handler_ex()
180 switch (deflate(&ctx->Z, flags)) { in php_zlib_output_handler_ex()
183 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
187 if (ctx->Z.avail_in) { in php_zlib_output_handler_ex()
188 … memmove(ctx->buffer.data, ctx->buffer.data + ctx->buffer.used - ctx->Z.avail_in, ctx->Z.avail_in); in php_zlib_output_handler_ex()
190 ctx->buffer.free += ctx->buffer.used - ctx->Z.avail_in; in php_zlib_output_handler_ex()
191 ctx->buffer.used = ctx->Z.avail_in; in php_zlib_output_handler_ex()
192 output_context->out.used = output_context->out.size - ctx->Z.avail_out; in php_zlib_output_handler_ex()
195 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
200 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
211 php_zlib_context *ctx = *(php_zlib_context **) handler_context; in php_zlib_output_handler() local
232 if (SUCCESS != php_zlib_output_handler_ex(ctx, output_context)) { in php_zlib_output_handler()
243 deflateEnd(&ctx->Z); in php_zlib_output_handler()
254 deflateEnd(&ctx->Z); in php_zlib_output_handler()
270 php_zlib_context *ctx = (php_zlib_context *) ecalloc(1, sizeof(php_zlib_context)); in php_zlib_output_handler_context_init() local
271 ctx->Z.zalloc = php_zlib_alloc; in php_zlib_output_handler_context_init()
272 ctx->Z.zfree = php_zlib_free; in php_zlib_output_handler_context_init()
273 return ctx; in php_zlib_output_handler_context_init()
280 php_zlib_context *ctx = (php_zlib_context *) opaq; in php_zlib_output_handler_context_dtor() local
282 if (ctx) { in php_zlib_output_handler_context_dtor()
283 if (ctx->buffer.data) { in php_zlib_output_handler_context_dtor()
284 efree(ctx->buffer.data); in php_zlib_output_handler_context_dtor()
286 efree(ctx); in php_zlib_output_handler_context_dtor()
483 php_output_context ctx = {0}; in PHP_FUNCTION() local
518 ctx.op = flags; in PHP_FUNCTION()
519 ctx.in.data = in_str; in PHP_FUNCTION()
520 ctx.in.used = in_len; in PHP_FUNCTION()
522 rv = php_zlib_output_handler_ex(ZLIBG(ob_gzhandler), &ctx); in PHP_FUNCTION()
525 if (ctx.out.data && ctx.out.free) { in PHP_FUNCTION()
526 efree(ctx.out.data); in PHP_FUNCTION()
532 if (ctx.out.data) { in PHP_FUNCTION()
533 RETVAL_STRINGL(ctx.out.data, ctx.out.used); in PHP_FUNCTION()
534 if (ctx.out.free) { in PHP_FUNCTION()
535 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()
878 if (Z_OK == inflateInit2(ctx, encoding)) { in PHP_FUNCTION()
880 php_zlib_context *php_ctx = (php_zlib_context *) ctx; in PHP_FUNCTION()
881 switch (inflateSetDictionary(ctx, (Bytef *) php_ctx->inflateDict, php_ctx->inflateDictlen)) { in PHP_FUNCTION()
894 RETURN_RES(zend_register_resource(ctx, le_inflate)); in PHP_FUNCTION()
896 efree(ctx); in PHP_FUNCTION()
911 z_stream *ctx; in PHP_FUNCTION() local
919 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_inflate))) { in PHP_FUNCTION()
944 ctx->next_in = (Bytef *) in_buf; in PHP_FUNCTION()
945 ctx->next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
946 ctx->avail_in = in_len; in PHP_FUNCTION()
947 ctx->avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
950 status = inflate(ctx, flush_type); in PHP_FUNCTION()
951 buffer_used = ZSTR_LEN(out) - ctx->avail_out; in PHP_FUNCTION()
955 if (ctx->avail_out == 0) { in PHP_FUNCTION()
958 ctx->avail_out = CHUNK_SIZE; in PHP_FUNCTION()
959 ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
965 inflateReset(ctx); in PHP_FUNCTION()
968 if (flush_type == Z_FINISH && ctx->avail_out == 0) { in PHP_FUNCTION()
971 ctx->avail_out = CHUNK_SIZE; in PHP_FUNCTION()
972 ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
979 if (((php_zlib_context *) ctx)->inflateDict) { in PHP_FUNCTION()
980 php_zlib_context *php_ctx = (php_zlib_context *) ctx; in PHP_FUNCTION()
981 switch (inflateSetDictionary(ctx, (Bytef *) php_ctx->inflateDict, php_ctx->inflateDictlen)) { in PHP_FUNCTION()
1018 z_stream *ctx; in PHP_FUNCTION() local
1083 ctx = ecalloc(1, sizeof(php_zlib_context)); in PHP_FUNCTION()
1084 ctx->zalloc = php_zlib_alloc; in PHP_FUNCTION()
1085 ctx->zfree = php_zlib_free; in PHP_FUNCTION()
1093 if (Z_OK == deflateInit2(ctx, level, Z_DEFLATED, encoding, memory, strategy)) { in PHP_FUNCTION()
1095 int success = deflateSetDictionary(ctx, (Bytef *) dict, dictlen); in PHP_FUNCTION()
1100 RETURN_RES(zend_register_resource(ctx, le_deflate)); in PHP_FUNCTION()
1102 efree(ctx); in PHP_FUNCTION()
1117 z_stream *ctx; in PHP_FUNCTION() local
1125 if (!(ctx = zend_fetch_resource_ex(res, NULL, le_deflate))) { in PHP_FUNCTION()
1158 ctx->next_in = (Bytef *) in_buf; in PHP_FUNCTION()
1159 ctx->next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
1160 ctx->avail_in = in_len; in PHP_FUNCTION()
1161 ctx->avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
1166 if (ctx->avail_out == 0) { in PHP_FUNCTION()
1170 ctx->avail_out = 64; in PHP_FUNCTION()
1171 ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1173 status = deflate(ctx, flush_type); in PHP_FUNCTION()
1174 buffer_used = ZSTR_LEN(out) - ctx->avail_out; in PHP_FUNCTION()
1175 } while (status == Z_OK && ctx->avail_out == 0); in PHP_FUNCTION()
1179 ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1184 ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1186 deflateReset(ctx); in PHP_FUNCTION()