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()
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()
947 php_zlib_context *ctx; in PHP_FUNCTION() local
955 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
972 if (ctx->status == Z_STREAM_END) in PHP_FUNCTION()
974 ctx->status = Z_OK; in PHP_FUNCTION()
975 inflateReset(&ctx->Z); in PHP_FUNCTION()
983 ctx->Z.next_in = (Bytef *) in_buf; in PHP_FUNCTION()
984 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
985 ctx->Z.avail_in = in_len; in PHP_FUNCTION()
986 ctx->Z.avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
989 status = inflate(&ctx->Z, flush_type); in PHP_FUNCTION()
990 buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; in PHP_FUNCTION()
992 ctx->status = status; /* Save status for exposing to userspace */ in PHP_FUNCTION()
996 if (ctx->Z.avail_out == 0) { in PHP_FUNCTION()
999 ctx->Z.avail_out = CHUNK_SIZE; in PHP_FUNCTION()
1000 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1008 if (flush_type == Z_FINISH && ctx->Z.avail_out == 0) { in PHP_FUNCTION()
1011 ctx->Z.avail_out = CHUNK_SIZE; in PHP_FUNCTION()
1012 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1019 if (ctx->inflateDict) { in PHP_FUNCTION()
1020 switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict, ctx->inflateDictlen)) { in PHP_FUNCTION()
1022 efree(ctx->inflateDict); in PHP_FUNCTION()
1023 ctx->inflateDict = NULL; in PHP_FUNCTION()
1026 efree(ctx->inflateDict); in PHP_FUNCTION()
1027 ctx->inflateDict = NULL; in PHP_FUNCTION()
1056 php_zlib_context *ctx; in PHP_FUNCTION() local
1062 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1064 RETURN_LONG(ctx->status); in PHP_FUNCTION()
1072 php_zlib_context *ctx; in PHP_FUNCTION() local
1078 ctx = Z_INFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1080 RETURN_LONG(ctx->Z.total_in); in PHP_FUNCTION()
1087 php_zlib_context *ctx; in PHP_FUNCTION() local
1152 ctx = Z_DEFLATE_CONTEXT_P(return_value); in PHP_FUNCTION()
1154 ctx->Z.zalloc = php_zlib_alloc; in PHP_FUNCTION()
1155 ctx->Z.zfree = php_zlib_free; in PHP_FUNCTION()
1163 if (deflateInit2(&ctx->Z, level, Z_DEFLATED, encoding, memory, strategy) != Z_OK) { in PHP_FUNCTION()
1170 int success = deflateSetDictionary(&ctx->Z, (Bytef *) dict, dictlen); in PHP_FUNCTION()
1184 php_zlib_context *ctx; in PHP_FUNCTION() local
1192 ctx = Z_DEFLATE_CONTEXT_P(res); in PHP_FUNCTION()
1220 ctx->Z.next_in = (Bytef *) in_buf; in PHP_FUNCTION()
1221 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out); in PHP_FUNCTION()
1222 ctx->Z.avail_in = in_len; in PHP_FUNCTION()
1223 ctx->Z.avail_out = ZSTR_LEN(out); in PHP_FUNCTION()
1228 if (ctx->Z.avail_out == 0) { in PHP_FUNCTION()
1232 ctx->Z.avail_out = 64; in PHP_FUNCTION()
1233 ctx->Z.next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; in PHP_FUNCTION()
1235 status = deflate(&ctx->Z, flush_type); in PHP_FUNCTION()
1236 buffer_used = ZSTR_LEN(out) - ctx->Z.avail_out; in PHP_FUNCTION()
1237 } while (status == Z_OK && ctx->Z.avail_out == 0); in PHP_FUNCTION()
1241 ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1246 ZSTR_LEN(out) = (char *) ctx->Z.next_out - ZSTR_VAL(out); in PHP_FUNCTION()
1248 deflateReset(&ctx->Z); in PHP_FUNCTION()