Lines Matching refs:ctx
171 static int php_zlib_output_handler_ex(php_zlib_context *ctx, php_output_context *output_context) in php_zlib_output_handler_ex() argument
177 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
184 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
191 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
194 ctx->buffer.used = 0; in php_zlib_output_handler_ex()
199 if (ctx->buffer.free < output_context->in.used) { in php_zlib_output_handler_ex()
200 …if (!(ctx->buffer.aptr = erealloc_recoverable(ctx->buffer.data, ctx->buffer.used + ctx->buffer.fre… in php_zlib_output_handler_ex()
201 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
204 ctx->buffer.data = ctx->buffer.aptr; in php_zlib_output_handler_ex()
205 ctx->buffer.free += output_context->in.used; in php_zlib_output_handler_ex()
207 memcpy(ctx->buffer.data + ctx->buffer.used, output_context->in.data, output_context->in.used); in php_zlib_output_handler_ex()
208 ctx->buffer.free -= output_context->in.used; in php_zlib_output_handler_ex()
209 ctx->buffer.used += output_context->in.used; in php_zlib_output_handler_ex()
216 ctx->Z.avail_in = ctx->buffer.used; in php_zlib_output_handler_ex()
217 ctx->Z.next_in = (Bytef *) ctx->buffer.data; in php_zlib_output_handler_ex()
218 ctx->Z.avail_out = output_context->out.size; in php_zlib_output_handler_ex()
219 ctx->Z.next_out = (Bytef *) output_context->out.data; in php_zlib_output_handler_ex()
227 switch (deflate(&ctx->Z, flags)) { in php_zlib_output_handler_ex()
230 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
235 if (ctx->Z.avail_in) { in php_zlib_output_handler_ex()
236 … memmove(ctx->buffer.data, ctx->buffer.data + ctx->buffer.used - ctx->Z.avail_in, ctx->Z.avail_in); in php_zlib_output_handler_ex()
238 ctx->buffer.free += ctx->buffer.used - ctx->Z.avail_in; in php_zlib_output_handler_ex()
239 ctx->buffer.used = ctx->Z.avail_in; in php_zlib_output_handler_ex()
240 output_context->out.used = output_context->out.size - ctx->Z.avail_out; in php_zlib_output_handler_ex()
243 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
248 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
259 php_zlib_context *ctx = *(php_zlib_context **) handler_context; in php_zlib_output_handler() local
280 if (SUCCESS != php_zlib_output_handler_ex(ctx, output_context)) { in php_zlib_output_handler()
291 deflateEnd(&ctx->Z); in php_zlib_output_handler()
302 deflateEnd(&ctx->Z); in php_zlib_output_handler()
318 php_zlib_context *ctx = (php_zlib_context *) ecalloc(1, sizeof(php_zlib_context)); in php_zlib_output_handler_context_init() local
319 ctx->Z.zalloc = php_zlib_alloc; in php_zlib_output_handler_context_init()
320 ctx->Z.zfree = php_zlib_free; in php_zlib_output_handler_context_init()
321 return ctx; in php_zlib_output_handler_context_init()
328 php_zlib_context *ctx = (php_zlib_context *) opaq; in php_zlib_output_handler_context_dtor() local
330 if (ctx) { in php_zlib_output_handler_context_dtor()
331 if (ctx->buffer.data) { in php_zlib_output_handler_context_dtor()
332 efree(ctx->buffer.data); in php_zlib_output_handler_context_dtor()
334 efree(ctx); in php_zlib_output_handler_context_dtor()
530 php_output_context ctx = {0}; in PHP_FUNCTION() local
565 ctx.op = flags; in PHP_FUNCTION()
566 ctx.in.data = in_str; in PHP_FUNCTION()
567 ctx.in.used = in_len; in PHP_FUNCTION()
569 rv = php_zlib_output_handler_ex(ZLIBG(ob_gzhandler), &ctx); in PHP_FUNCTION()
572 if (ctx.out.data && ctx.out.free) { in PHP_FUNCTION()
573 efree(ctx.out.data); in PHP_FUNCTION()
579 if (ctx.out.data) { in PHP_FUNCTION()
580 RETVAL_STRINGL(ctx.out.data, ctx.out.used); in PHP_FUNCTION()
581 if (ctx.out.free) { in PHP_FUNCTION()
582 efree(ctx.out.data); in PHP_FUNCTION()
863 php_zlib_context *ctx; in PHP_FUNCTION() local
897 ctx = Z_INFLATE_CONTEXT_P(return_value); in PHP_FUNCTION()
899 ctx->Z.zalloc = php_zlib_alloc; in PHP_FUNCTION()
900 ctx->Z.zfree = php_zlib_free; in PHP_FUNCTION()
901 ctx->inflateDict = dict; in PHP_FUNCTION()
902 ctx->inflateDictlen = dictlen; in PHP_FUNCTION()
903 ctx->status = Z_OK; in PHP_FUNCTION()
911 if (inflateInit2(&ctx->Z, encoding) != Z_OK) { in PHP_FUNCTION()
918 switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict, ctx->inflateDictlen)) { in PHP_FUNCTION()
920 efree(ctx->inflateDict); in PHP_FUNCTION()
921 ctx->inflateDict = NULL; in PHP_FUNCTION()
925 efree(ctx->inflateDict); in PHP_FUNCTION()
926 ctx->inflateDict = NULL; in PHP_FUNCTION()
941 php_zlib_context *ctx; in PHP_FUNCTION() local
949 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
966 if (ctx->status == Z_STREAM_END) in PHP_FUNCTION()
968 ctx->status = Z_OK; in PHP_FUNCTION()
969 inflateReset(&ctx->Z); in PHP_FUNCTION()
977 ctx->Z.next_in = (Bytef *) in_buf; in PHP_FUNCTION()
978 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
979 ctx->Z.avail_in = in_len; in PHP_FUNCTION()
980 ctx->Z.avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
983 status = inflate(&ctx->Z, flush_type); in PHP_FUNCTION()
984 buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; in PHP_FUNCTION()
986 ctx->status = status; /* Save status for exposing to userspace */ in PHP_FUNCTION()
990 if (ctx->Z.avail_out == 0) { in PHP_FUNCTION()
993 ctx->Z.avail_out = CHUNK_SIZE; in PHP_FUNCTION()
994 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1002 if (flush_type == Z_FINISH && ctx->Z.avail_out == 0) { in PHP_FUNCTION()
1005 ctx->Z.avail_out = CHUNK_SIZE; in PHP_FUNCTION()
1006 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1013 if (ctx->inflateDict) { in PHP_FUNCTION()
1014 switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict, ctx->inflateDictlen)) { in PHP_FUNCTION()
1016 efree(ctx->inflateDict); in PHP_FUNCTION()
1017 ctx->inflateDict = NULL; in PHP_FUNCTION()
1020 efree(ctx->inflateDict); in PHP_FUNCTION()
1021 ctx->inflateDict = NULL; in PHP_FUNCTION()
1050 php_zlib_context *ctx; in PHP_FUNCTION() local
1056 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1058 RETURN_LONG(ctx->status); in PHP_FUNCTION()
1066 php_zlib_context *ctx; in PHP_FUNCTION() local
1072 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1074 RETURN_LONG(ctx->Z.total_in); in PHP_FUNCTION()
1081 php_zlib_context *ctx; in PHP_FUNCTION() local
1146 ctx = Z_DEFLATE_CONTEXT_P(return_value); in PHP_FUNCTION()
1148 ctx->Z.zalloc = php_zlib_alloc; in PHP_FUNCTION()
1149 ctx->Z.zfree = php_zlib_free; in PHP_FUNCTION()
1157 if (deflateInit2(&ctx->Z, level, Z_DEFLATED, encoding, memory, strategy) != Z_OK) { in PHP_FUNCTION()
1164 int success = deflateSetDictionary(&ctx->Z, (Bytef *) dict, dictlen); in PHP_FUNCTION()
1178 php_zlib_context *ctx; in PHP_FUNCTION() local
1186 ctx = Z_DEFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1214 ctx->Z.next_in = (Bytef *) in_buf; in PHP_FUNCTION()
1215 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
1216 ctx->Z.avail_in = in_len; in PHP_FUNCTION()
1217 ctx->Z.avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
1222 if (ctx->Z.avail_out == 0) { in PHP_FUNCTION()
1226 ctx->Z.avail_out = 64; in PHP_FUNCTION()
1227 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1229 status = deflate(&ctx->Z, flush_type); in PHP_FUNCTION()
1230 buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; in PHP_FUNCTION()
1231 } while (status == Z_OK && ctx->Z.avail_out == 0); in PHP_FUNCTION()
1235 ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1240 ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1242 deflateReset(&ctx->Z); in PHP_FUNCTION()