Lines Matching refs:ctx
172 static int php_zlib_output_handler_ex(php_zlib_context *ctx, php_output_context *output_context) in php_zlib_output_handler_ex() argument
178 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
185 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
192 …if (Z_OK != deflateInit2(&ctx->Z, ZLIBG(output_compression_level), Z_DEFLATED, ZLIBG(compression_c… in php_zlib_output_handler_ex()
195 ctx->buffer.used = 0; in php_zlib_output_handler_ex()
200 if (ctx->buffer.free < output_context->in.used) { in php_zlib_output_handler_ex()
201 …if (!(ctx->buffer.aptr = erealloc_recoverable(ctx->buffer.data, ctx->buffer.used + ctx->buffer.fre… in php_zlib_output_handler_ex()
202 deflateEnd(&ctx->Z); in php_zlib_output_handler_ex()
205 ctx->buffer.data = ctx->buffer.aptr; in php_zlib_output_handler_ex()
206 ctx->buffer.free += output_context->in.used; in php_zlib_output_handler_ex()
208 memcpy(ctx->buffer.data + ctx->buffer.used, output_context->in.data, output_context->in.used); in php_zlib_output_handler_ex()
209 ctx->buffer.free -= output_context->in.used; in php_zlib_output_handler_ex()
210 ctx->buffer.used += output_context->in.used; in php_zlib_output_handler_ex()
217 ctx->Z.avail_in = ctx->buffer.used; in php_zlib_output_handler_ex()
218 ctx->Z.next_in = (Bytef *) ctx->buffer.data; in php_zlib_output_handler_ex()
219 ctx->Z.avail_out = output_context->out.size; in php_zlib_output_handler_ex()
220 ctx->Z.next_out = (Bytef *) output_context->out.data; in php_zlib_output_handler_ex()
228 switch (deflate(&ctx->Z, flags)) { in php_zlib_output_handler_ex()
231 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()
869 php_zlib_context *ctx; in PHP_FUNCTION() local
903 ctx = Z_INFLATE_CONTEXT_P(return_value); in PHP_FUNCTION()
905 ctx->Z.zalloc = php_zlib_alloc; in PHP_FUNCTION()
906 ctx->Z.zfree = php_zlib_free; in PHP_FUNCTION()
907 ctx->inflateDict = dict; in PHP_FUNCTION()
908 ctx->inflateDictlen = dictlen; in PHP_FUNCTION()
909 ctx->status = Z_OK; in PHP_FUNCTION()
917 if (inflateInit2(&ctx->Z, encoding) != Z_OK) { in PHP_FUNCTION()
924 switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict, ctx->inflateDictlen)) { in PHP_FUNCTION()
926 efree(ctx->inflateDict); in PHP_FUNCTION()
927 ctx->inflateDict = NULL; in PHP_FUNCTION()
931 efree(ctx->inflateDict); in PHP_FUNCTION()
932 ctx->inflateDict = NULL; in PHP_FUNCTION()
946 php_zlib_context *ctx; in PHP_FUNCTION() local
954 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
971 if (ctx->status == Z_STREAM_END) in PHP_FUNCTION()
973 ctx->status = Z_OK; in PHP_FUNCTION()
974 inflateReset(&ctx->Z); in PHP_FUNCTION()
982 ctx->Z.next_in = (Bytef *) in_buf; in PHP_FUNCTION()
983 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
984 ctx->Z.avail_in = in_len; in PHP_FUNCTION()
985 ctx->Z.avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
988 status = inflate(&ctx->Z, flush_type); in PHP_FUNCTION()
989 buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; in PHP_FUNCTION()
991 ctx->status = status; /* Save status for exposing to userspace */ in PHP_FUNCTION()
995 if (ctx->Z.avail_out == 0) { in PHP_FUNCTION()
998 ctx->Z.avail_out = CHUNK_SIZE; in PHP_FUNCTION()
999 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1007 if (flush_type == Z_FINISH && ctx->Z.avail_out == 0) { in PHP_FUNCTION()
1010 ctx->Z.avail_out = CHUNK_SIZE; in PHP_FUNCTION()
1011 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1018 if (ctx->inflateDict) { in PHP_FUNCTION()
1019 switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict, ctx->inflateDictlen)) { in PHP_FUNCTION()
1021 efree(ctx->inflateDict); in PHP_FUNCTION()
1022 ctx->inflateDict = NULL; in PHP_FUNCTION()
1025 efree(ctx->inflateDict); in PHP_FUNCTION()
1026 ctx->inflateDict = NULL; in PHP_FUNCTION()
1055 php_zlib_context *ctx; in PHP_FUNCTION() local
1061 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1063 RETURN_LONG(ctx->status); in PHP_FUNCTION()
1071 php_zlib_context *ctx; in PHP_FUNCTION() local
1077 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1079 RETURN_LONG(ctx->Z.total_in); in PHP_FUNCTION()
1086 php_zlib_context *ctx; in PHP_FUNCTION() local
1151 ctx = Z_DEFLATE_CONTEXT_P(return_value); in PHP_FUNCTION()
1153 ctx->Z.zalloc = php_zlib_alloc; in PHP_FUNCTION()
1154 ctx->Z.zfree = php_zlib_free; in PHP_FUNCTION()
1162 if (deflateInit2(&ctx->Z, level, Z_DEFLATED, encoding, memory, strategy) != Z_OK) { in PHP_FUNCTION()
1169 int success = deflateSetDictionary(&ctx->Z, (Bytef *) dict, dictlen); in PHP_FUNCTION()
1183 php_zlib_context *ctx; in PHP_FUNCTION() local
1191 ctx = Z_DEFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1219 ctx->Z.next_in = (Bytef *) in_buf; in PHP_FUNCTION()
1220 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
1221 ctx->Z.avail_in = in_len; in PHP_FUNCTION()
1222 ctx->Z.avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
1227 if (ctx->Z.avail_out == 0) { in PHP_FUNCTION()
1231 ctx->Z.avail_out = 64; in PHP_FUNCTION()
1232 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1234 status = deflate(&ctx->Z, flush_type); in PHP_FUNCTION()
1235 buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; in PHP_FUNCTION()
1236 } while (status == Z_OK && ctx->Z.avail_out == 0); in PHP_FUNCTION()
1240 ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1245 ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1247 deflateReset(&ctx->Z); in PHP_FUNCTION()