if (Z_OK == (status = deflateCopy(to_ctx, from_ctx))) {
if ((to_ctx->opaque = php_http_buffer_init_ex(NULL, PHP_HTTP_DEFLATE_BUFFER_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0))) {
if (Z_OK == (status = deflateCopy(to_ctx, from_ctx))) {
if ((to_ctx->opaque = php_http_buffer_init_ex(NULL, PHP_HTTP_DEFLATE_BUFFER_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0))) {
- php_http_buffer_append(to_ctx->opaque, PHP_HTTP_BUFFER_VAL(from_ctx->opaque), PHP_HTTP_BUFFER_LEN(from_ctx->opaque));
+ php_http_buffer_append(to_ctx->opaque, PHP_HTTP_BUFFER(from_ctx->opaque)->data, PHP_HTTP_BUFFER(from_ctx->opaque)->used);
if (Z_OK == (status = inflateCopy(to_ctx, from_ctx))) {
if ((to_ctx->opaque = php_http_buffer_init_ex(NULL, PHP_HTTP_DEFLATE_BUFFER_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0))) {
if (Z_OK == (status = inflateCopy(to_ctx, from_ctx))) {
if ((to_ctx->opaque = php_http_buffer_init_ex(NULL, PHP_HTTP_DEFLATE_BUFFER_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0))) {
- php_http_buffer_append(to_ctx->opaque, PHP_HTTP_BUFFER_VAL(from_ctx->opaque), PHP_HTTP_BUFFER_LEN(from_ctx->opaque));
+ php_http_buffer_append(to_ctx->opaque, PHP_HTTP_BUFFER(from_ctx->opaque)->data, PHP_HTTP_BUFFER(from_ctx->opaque)->used);
if (php_http_buffer_init_ex(&to_ctx->buffer, PHP_HTTP_BUFFER_DEFAULT_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0)) {
to_ctx->hexlen = from_ctx->hexlen;
to_ctx->zeroed = from_ctx->zeroed;
if (php_http_buffer_init_ex(&to_ctx->buffer, PHP_HTTP_BUFFER_DEFAULT_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0)) {
to_ctx->hexlen = from_ctx->hexlen;
to_ctx->zeroed = from_ctx->zeroed;
- php_http_buffer_append(&to_ctx->buffer, PHP_HTTP_BUFFER_VAL(&from_ctx->buffer), PHP_HTTP_BUFFER_LEN(&from_ctx->buffer));
+ php_http_buffer_append(&to_ctx->buffer, from_ctx->buffer.data, from_ctx->buffer.used);
/* append input to our buffer */
php_http_buffer_append(PHP_HTTP_BUFFER(ctx->opaque), data, data_len);
/* append input to our buffer */
php_http_buffer_append(PHP_HTTP_BUFFER(ctx->opaque), data, data_len);
- ctx->next_in = (Bytef *) PHP_HTTP_BUFFER_VAL(ctx->opaque);
- ctx->avail_in = PHP_HTTP_BUFFER_LEN(ctx->opaque);
+ ctx->next_in = (Bytef *) PHP_HTTP_BUFFER(ctx->opaque)->data;
+ ctx->avail_in = PHP_HTTP_BUFFER(ctx->opaque)->used;
- php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER_LEN(ctx->opaque) - ctx->avail_in);
+ php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER(ctx->opaque)->used - ctx->avail_in);
- ctx->next_in = (Bytef *) PHP_HTTP_BUFFER_VAL(ctx->opaque);
- ctx->avail_in = PHP_HTTP_BUFFER_LEN(ctx->opaque);
+ ctx->next_in = (Bytef *) PHP_HTTP_BUFFER(ctx->opaque)->data;
+ ctx->avail_in = PHP_HTTP_BUFFER(ctx->opaque)->used;
switch (status = php_http_inflate_rounds(ctx, PHP_HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags), decoded, decoded_len)) {
case Z_OK:
case Z_STREAM_END:
/* cut off */
if (ctx->avail_in) {
switch (status = php_http_inflate_rounds(ctx, PHP_HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags), decoded, decoded_len)) {
case Z_OK:
case Z_STREAM_END:
/* cut off */
if (ctx->avail_in) {
- php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER_LEN(ctx->opaque) - ctx->avail_in);
+ php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER(ctx->opaque)->used - ctx->avail_in);
/* flush anyway? */
if (s->flags & PHP_HTTP_ENCODING_STREAM_FLUSH_FULL) {
/* flush all data (should only be chunk data) */
/* flush anyway? */
if (s->flags & PHP_HTTP_ENCODING_STREAM_FLUSH_FULL) {
/* flush all data (should only be chunk data) */
- while (off < PHP_HTTP_BUFFER_LEN(&ctx->buffer) && (
- PHP_HTTP_BUFFER_VAL(&ctx->buffer)[off] == '\n' ||
- PHP_HTTP_BUFFER_VAL(&ctx->buffer)[off] == '\r')) {
+ while (off < ctx->buffer.used && (
+ ctx->buffer.data[off] == '\n' ||
+ ctx->buffer.data[off] == '\r')) {
int eollen;
const char *eolstr;
/* we need eol, so we can be sure we have all hex digits */
php_http_buffer_fix(&ctx->buffer);
int eollen;
const char *eolstr;
/* we need eol, so we can be sure we have all hex digits */
php_http_buffer_fix(&ctx->buffer);
- if ((eolstr = php_http_locate_bin_eol(PHP_HTTP_BUFFER_VAL(&ctx->buffer), PHP_HTTP_BUFFER_LEN(&ctx->buffer), &eollen))) {
+ if ((eolstr = php_http_locate_bin_eol(ctx->buffer.data, ctx->buffer.used, &eollen))) {
- there's domething oddly wrong, i.e. bad input */
- if (stop == PHP_HTTP_BUFFER_VAL(&ctx->buffer)) {
+ there's something oddly wrong, i.e. bad input */
+ if (stop == ctx->buffer.data) {
php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to parse chunk len from '%.*s'", MIN(16, ctx->buffer.used), ctx->buffer.data);
php_http_buffer_dtor(&tmp);
return FAILURE;
}
/* cut out <chunk size hex><chunk extension><eol> */
php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to parse chunk len from '%.*s'", MIN(16, ctx->buffer.used), ctx->buffer.data);
php_http_buffer_dtor(&tmp);
return FAILURE;
}
/* cut out <chunk size hex><chunk extension><eol> */
/* buffer->hexlen is 0 now or contains the size of the next chunk */
if (!ctx->hexlen) {
size_t off = 0;
/* ignore following CRLFs (too loose?) */
/* buffer->hexlen is 0 now or contains the size of the next chunk */
if (!ctx->hexlen) {
size_t off = 0;
/* ignore following CRLFs (too loose?) */
- while (off < PHP_HTTP_BUFFER_LEN(&ctx->buffer) && (
- PHP_HTTP_BUFFER_VAL(&ctx->buffer)[off] == '\n' ||
- PHP_HTTP_BUFFER_VAL(&ctx->buffer)[off] == '\r')) {
+ while (off < ctx->buffer.used && (
+ ctx->buffer.data[off] == '\n' ||
+ ctx->buffer.data[off] == '\r')) {
php_http_buffer_fix(&ctx->buffer);
php_http_buffer_data(&ctx->buffer, decoded, decoded_len);
/* waiting for less data now */
php_http_buffer_fix(&ctx->buffer);
php_http_buffer_data(&ctx->buffer, decoded, decoded_len);
/* waiting for less data now */
- ctx->next_in = (Bytef *) PHP_HTTP_BUFFER_VAL(ctx->opaque);
- ctx->avail_in = PHP_HTTP_BUFFER_LEN(ctx->opaque);
+ ctx->next_in = (Bytef *) PHP_HTTP_BUFFER(ctx->opaque)->data;
+ ctx->avail_in = PHP_HTTP_BUFFER(ctx->opaque)->used;
- /* cut processed intp off */
- php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER_LEN(ctx->opaque) - ctx->avail_in);
+ /* cut processed input off */
+ php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER(ctx->opaque)->used - ctx->avail_in);
- ctx->next_in = (Bytef *) PHP_HTTP_BUFFER_VAL(ctx->opaque);
- ctx->avail_in = PHP_HTTP_BUFFER_LEN(ctx->opaque);
+ ctx->next_in = (Bytef *) PHP_HTTP_BUFFER(ctx->opaque)->data;
+ ctx->avail_in = PHP_HTTP_BUFFER(ctx->opaque)->used;
ctx->avail_out = *decoded_len;
ctx->next_out = (Bytef *) *decoded;
if (Z_STREAM_END == (status = inflate(ctx, Z_FINISH))) {
/* cut processed input off */
ctx->avail_out = *decoded_len;
ctx->next_out = (Bytef *) *decoded;
if (Z_STREAM_END == (status = inflate(ctx, Z_FINISH))) {
/* cut processed input off */
- php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER_LEN(ctx->opaque) - ctx->avail_in);
+ php_http_buffer_cut(PHP_HTTP_BUFFER(ctx->opaque), 0, PHP_HTTP_BUFFER(ctx->opaque)->used - ctx->avail_in);