X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_encoding.c;h=b7050f6d769e737984bcddee1fd45996c0c3d179;hp=4a71c80074d24f1ea902a641df09810c13653312;hb=refs%2Fheads%2Fv2.2.x;hpb=bd80b17b026a00a254ee8693cd7bacf1ebdec4cf diff --git a/php_http_encoding.c b/php_http_encoding.c index 4a71c80..b7050f6 100644 --- a/php_http_encoding.c +++ b/php_http_encoding.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2011, Michael Wallner | + | Copyright (c) 2004-2014, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -28,7 +28,7 @@ static inline int eol_match(char **line, int *eol_len) } } -PHP_HTTP_API const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC) +const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC) { int eol_len = 0; char *n_ptr = NULL; @@ -50,14 +50,13 @@ PHP_HTTP_API const char *php_http_encoding_dechunk(const char *encoded, size_t e * not encoded data and return a copy */ if (e_ptr == encoded) { - php_http_error(HE_NOTICE, PHP_HTTP_E_ENCODING, "Data does not seem to be chunked encoded"); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Data does not seem to be chunked encoded"); memcpy(*decoded, encoded, encoded_len); *decoded_len = encoded_len; - decoded[*decoded_len] = '\0'; return encoded + encoded_len; } else { efree(*decoded); - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Expected chunk size at pos %tu of %zu but got trash", n_ptr - encoded, encoded_len); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected chunk size at pos %tu of %zu but got trash", n_ptr - encoded, encoded_len); return NULL; } } @@ -80,16 +79,16 @@ PHP_HTTP_API const char *php_http_encoding_dechunk(const char *encoded, size_t e /* there should be CRLF after the chunk size, but we'll ignore SP+ too */ if (*n_ptr && !eol_match(&n_ptr, &eol_len)) { if (eol_len == 2) { - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Expected CRLF at pos %tu of %zu but got 0x%02X 0x%02X", n_ptr - encoded, encoded_len, *n_ptr, *(n_ptr + 1)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected CRLF at pos %tu of %zu but got 0x%02X 0x%02X", n_ptr - encoded, encoded_len, *n_ptr, *(n_ptr + 1)); } else { - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Expected LF at pos %tu of %zu but got 0x%02X", n_ptr - encoded, encoded_len, *n_ptr); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected LF at pos %tu of %zu but got 0x%02X", n_ptr - encoded, encoded_len, *n_ptr); } } n_ptr += eol_len; /* chunk size pretends more data than we actually got, so it's probably a truncated message */ if (chunk_len > (rest = encoded + encoded_len - n_ptr)) { - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Truncated message: chunk size %lu exceeds remaining data size %lu at pos %tu of %zu", chunk_len, rest, n_ptr - encoded, encoded_len); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Truncated message: chunk size %lu exceeds remaining data size %lu at pos %tu of %zu", chunk_len, rest, n_ptr - encoded, encoded_len); chunk_len = rest; } @@ -149,7 +148,7 @@ static inline int php_http_inflate_rounds(z_stream *Z, int flush, char **buf, si return status; } -PHP_HTTP_API STATUS php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC) +STATUS php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC) { int status, level, wbits, strategy; z_stream Z; @@ -181,16 +180,16 @@ PHP_HTTP_API STATUS php_http_encoding_deflate(int flags, const char *data, size_ (*encoded)[*encoded_len = Z.total_out] = '\0'; return SUCCESS; } else { - STR_SET(*encoded, NULL); + PTR_SET(*encoded, NULL); *encoded_len = 0; } } - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Could not deflate data: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not deflate data: %s", zError(status)); return FAILURE; } -PHP_HTTP_API STATUS php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC) +STATUS php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC) { z_stream Z; int status, wbits = PHP_HTTP_WINDOW_BITS_ANY; @@ -228,11 +227,11 @@ retry_raw_inflate: } } - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Could not inflate data: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not inflate data: %s", zError(status)); return FAILURE; } -PHP_HTTP_API php_http_encoding_stream_t *php_http_encoding_stream_init(php_http_encoding_stream_t *s, php_http_encoding_stream_ops_t *ops, unsigned flags TSRMLS_DC) +php_http_encoding_stream_t *php_http_encoding_stream_init(php_http_encoding_stream_t *s, php_http_encoding_stream_ops_t *ops, unsigned flags TSRMLS_DC) { int freeme; @@ -260,7 +259,7 @@ PHP_HTTP_API php_http_encoding_stream_t *php_http_encoding_stream_init(php_http_ return NULL; } -PHP_HTTP_API php_http_encoding_stream_t *php_http_encoding_stream_copy(php_http_encoding_stream_t *from, php_http_encoding_stream_t *to) +php_http_encoding_stream_t *php_http_encoding_stream_copy(php_http_encoding_stream_t *from, php_http_encoding_stream_t *to) { TSRMLS_FETCH_FROM_CTX(from->ts); @@ -291,7 +290,7 @@ PHP_HTTP_API php_http_encoding_stream_t *php_http_encoding_stream_copy(php_http_ return NULL; } -PHP_HTTP_API STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t **s) +STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t **s) { php_http_encoding_stream_t *ss; if ((*s)->ops->dtor) { @@ -304,7 +303,7 @@ PHP_HTTP_API STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t ** return FAILURE; } -PHP_HTTP_API STATUS php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len) +STATUS php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len) { if (!s->ops->update) { return FAILURE; @@ -312,7 +311,7 @@ PHP_HTTP_API STATUS php_http_encoding_stream_update(php_http_encoding_stream_t * return s->ops->update(s, in_str, in_len, out_str, out_len); } -PHP_HTTP_API STATUS php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *out_len) +STATUS php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *out_len) { if (!s->ops->flush) { *out_str = NULL; @@ -322,7 +321,7 @@ PHP_HTTP_API STATUS php_http_encoding_stream_flush(php_http_encoding_stream_t *s return s->ops->flush(s, out_str, out_len); } -PHP_HTTP_API zend_bool php_http_encoding_stream_done(php_http_encoding_stream_t *s) +zend_bool php_http_encoding_stream_done(php_http_encoding_stream_t *s) { if (!s->ops->done) { return 0; @@ -330,7 +329,7 @@ PHP_HTTP_API zend_bool php_http_encoding_stream_done(php_http_encoding_stream_t return s->ops->done(s); } -PHP_HTTP_API STATUS php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *out_len) +STATUS php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *out_len) { if (!s->ops->finish) { *out_str = NULL; @@ -340,14 +339,14 @@ PHP_HTTP_API STATUS php_http_encoding_stream_finish(php_http_encoding_stream_t * return s->ops->finish(s, out_str, out_len); } -PHP_HTTP_API void php_http_encoding_stream_dtor(php_http_encoding_stream_t *s) +void php_http_encoding_stream_dtor(php_http_encoding_stream_t *s) { if (s->ops->dtor) { s->ops->dtor(s); } } -PHP_HTTP_API void php_http_encoding_stream_free(php_http_encoding_stream_t **s) +void php_http_encoding_stream_free(php_http_encoding_stream_t **s) { if (*s) { if ((*s)->ops->dtor) { @@ -383,7 +382,7 @@ static php_http_encoding_stream_t *deflate_init(php_http_encoding_stream_t *s) status = Z_MEM_ERROR; } pefree(ctx, p); - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to initialize deflate encoding stream: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to initialize deflate encoding stream: %s", zError(status)); return NULL; } @@ -404,7 +403,7 @@ static php_http_encoding_stream_t *inflate_init(php_http_encoding_stream_t *s) status = Z_MEM_ERROR; } pefree(ctx, p); - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to initialize inflate stream: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to initialize inflate stream: %s", zError(status)); return NULL; } @@ -431,14 +430,14 @@ static php_http_encoding_stream_t *deflate_copy(php_http_encoding_stream_t *from 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); to->ctx = to_ctx; return to; } deflateEnd(to_ctx); status = Z_MEM_ERROR; } - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to copy deflate encoding stream: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to copy deflate encoding stream: %s", zError(status)); return NULL; } @@ -450,14 +449,14 @@ static php_http_encoding_stream_t *inflate_copy(php_http_encoding_stream_t *from 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); to->ctx = to_ctx; return to; } inflateEnd(to_ctx); status = Z_MEM_ERROR; } - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to copy inflate encoding stream: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to copy inflate encoding stream: %s", zError(status)); return NULL; } @@ -470,12 +469,12 @@ static php_http_encoding_stream_t *dechunk_copy(php_http_encoding_stream_t *from 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); to->ctx = to_ctx; return to; } pefree(to_ctx, p); - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to copy inflate encoding stream: out of memory"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to copy inflate encoding stream: out of memory"); return NULL; } @@ -488,8 +487,8 @@ static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, si /* 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; /* deflate */ *encoded_len = PHP_HTTP_DEFLATE_BUFFER_SIZE_GUESS(data_len); @@ -502,7 +501,7 @@ static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, si case Z_STREAM_END: /* cut processed chunk off the buffer */ 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); } else { php_http_buffer_reset(PHP_HTTP_BUFFER(ctx->opaque)); } @@ -514,9 +513,9 @@ static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, si return SUCCESS; } - STR_SET(*encoded, NULL); + PTR_SET(*encoded, NULL); *encoded_len = 0; - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to update deflate stream: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to update deflate stream: %s", zError(status)); return FAILURE; } @@ -530,15 +529,15 @@ static STATUS inflate_update(php_http_encoding_stream_t *s, const char *data, si php_http_buffer_append(PHP_HTTP_BUFFER(ctx->opaque), data, data_len); retry_raw_inflate: - 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) { - 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); } else { php_http_buffer_reset(PHP_HTTP_BUFFER(ctx->opaque)); } @@ -555,7 +554,7 @@ retry_raw_inflate: break; } - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to update inflate stream: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to update inflate stream: %s", zError(status)); return FAILURE; } @@ -566,7 +565,7 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si TSRMLS_FETCH_FROM_CTX(s->ts); if (ctx->zeroed) { - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Dechunk encoding stream has already reached the end of chunked input"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Dechunk encoding stream has already reached the end of chunked input"); return FAILURE; } if ((PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(&ctx->buffer, data, data_len)) || !php_http_buffer_fix(&ctx->buffer)) { @@ -580,20 +579,20 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si php_http_buffer_init(&tmp); /* we have data in our buffer */ - while (PHP_HTTP_BUFFER_LEN(&ctx->buffer)) { + while (ctx->buffer.used) { /* we already know the size of the chunk and are waiting for data */ if (ctx->hexlen) { /* not enough data buffered */ - if (PHP_HTTP_BUFFER_LEN(&ctx->buffer) < ctx->hexlen) { + if (ctx->buffer.used < ctx->hexlen) { /* flush anyway? */ if (s->flags & PHP_HTTP_ENCODING_STREAM_FLUSH_FULL) { /* flush all data (should only be chunk data) */ - php_http_buffer_append(&tmp, PHP_HTTP_BUFFER_VAL(&ctx->buffer), PHP_HTTP_BUFFER_LEN(&ctx->buffer)); + php_http_buffer_append(&tmp, ctx->buffer.data, ctx->buffer.used); /* waiting for less data now */ - ctx->hexlen -= PHP_HTTP_BUFFER_LEN(&ctx->buffer); + ctx->hexlen -= ctx->buffer.used; /* no more buffered data */ php_http_buffer_reset(&ctx->buffer); /* break */ @@ -607,9 +606,9 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si /* we seem to have all data of the chunk */ else { - php_http_buffer_append(&tmp, PHP_HTTP_BUFFER_VAL(&ctx->buffer), ctx->hexlen); + php_http_buffer_append(&tmp, ctx->buffer.data, ctx->hexlen); /* remove outgoing data from the buffer */ - php_http_buffer_cut(PHP_HTTP_BUFFER(&ctx->buffer), 0, ctx->hexlen); + php_http_buffer_cut(&ctx->buffer, 0, ctx->hexlen); /* reset hexlen */ ctx->hexlen = 0; /* continue */ @@ -621,50 +620,50 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si size_t off = 0; /* ignore preceeding 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')) { ++off; } if (off) { - php_http_buffer_cut(PHP_HTTP_BUFFER(&ctx->buffer), 0, off); + php_http_buffer_cut(&ctx->buffer, 0, off); } /* still data there? */ - if (PHP_HTTP_BUFFER_LEN(&ctx->buffer)) { + if (ctx->buffer.used) { 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))) { char *stop = NULL; /* read in chunk size */ - ctx->hexlen = strtoul(PHP_HTTP_BUFFER_VAL(&ctx->buffer), &stop, 16); + ctx->hexlen = strtoul(ctx->buffer.data, &stop, 16); /* if strtoul() stops at the beginning of the buffered data - there's domething oddly wrong, i.e. bad input */ - if (stop == PHP_HTTP_BUFFER_VAL(&ctx->buffer)) { - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to parse chunk len from '%.*s'", MIN(16, ctx->buffer.used), ctx->buffer.data); + there's something oddly wrong, i.e. bad input */ + if (stop == ctx->buffer.data) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse chunk len from '%.*s'", (int) MIN(16, ctx->buffer.used), ctx->buffer.data); php_http_buffer_dtor(&tmp); return FAILURE; } /* cut out */ - php_http_buffer_cut(PHP_HTTP_BUFFER(&ctx->buffer), 0, eolstr + eollen - PHP_HTTP_BUFFER_VAL(&ctx->buffer)); + php_http_buffer_cut(&ctx->buffer, 0, eolstr + eollen - ctx->buffer.data); /* 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')) { ++off; } if (off) { - php_http_buffer_cut(PHP_HTTP_BUFFER(&ctx->buffer), 0, off); + php_http_buffer_cut(&ctx->buffer, 0, off); } ctx->zeroed = 1; @@ -681,8 +680,8 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si } php_http_buffer_fix(&tmp); - *decoded = PHP_HTTP_BUFFER_VAL(&tmp); - *decoded_len = PHP_HTTP_BUFFER_LEN(&tmp); + *decoded = tmp.data; + *decoded_len = tmp.used; return SUCCESS; } @@ -710,9 +709,9 @@ static STATUS deflate_flush(php_http_encoding_stream_t *s, char **encoded, size_ return SUCCESS; } - STR_SET(*encoded, NULL); + PTR_SET(*encoded, NULL); *encoded_len = 0; - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to flush deflate stream: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to flush deflate stream: %s", zError(status)); return FAILURE; } @@ -725,7 +724,7 @@ static STATUS dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_ php_http_buffer_fix(&ctx->buffer); php_http_buffer_data(&ctx->buffer, decoded, decoded_len); /* waiting for less data now */ - ctx->hexlen -= PHP_HTTP_BUFFER_LEN(&ctx->buffer); + ctx->hexlen -= ctx->buffer.used; /* no more buffered data */ php_http_buffer_reset(&ctx->buffer); } else { @@ -746,8 +745,8 @@ static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size *encoded = emalloc(*encoded_len); /* deflate remaining input */ - 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 = *encoded_len; ctx->next_out = (Bytef *) *encoded; @@ -757,8 +756,8 @@ static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size } while (Z_OK == status); if (Z_STREAM_END == status) { - /* 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); /* size down */ *encoded_len -= ctx->avail_out; @@ -767,9 +766,9 @@ static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size return SUCCESS; } - STR_SET(*encoded, NULL); + PTR_SET(*encoded, NULL); *encoded_len = 0; - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to finish deflate stream: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to finish deflate stream: %s", zError(status)); return FAILURE; } @@ -779,25 +778,25 @@ static STATUS inflate_finish(php_http_encoding_stream_t *s, char **decoded, size z_streamp ctx = s->ctx; TSRMLS_FETCH_FROM_CTX(s->ts); - if (!PHP_HTTP_BUFFER_LEN(ctx->opaque)) { + if (!PHP_HTTP_BUFFER(ctx->opaque)->used) { *decoded = NULL; *decoded_len = 0; return SUCCESS; } - *decoded_len = (PHP_HTTP_BUFFER_LEN(ctx->opaque) + 1) * PHP_HTTP_INFLATE_ROUNDS; + *decoded_len = (PHP_HTTP_BUFFER(ctx->opaque)->used + 1) * PHP_HTTP_INFLATE_ROUNDS; *decoded = emalloc(*decoded_len); /* inflate remaining input */ - 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 */ - 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); /* size down */ *decoded_len -= ctx->avail_out; @@ -806,22 +805,22 @@ static STATUS inflate_finish(php_http_encoding_stream_t *s, char **decoded, size return SUCCESS; } - STR_SET(*decoded, NULL); + PTR_SET(*decoded, NULL); *decoded_len = 0; - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to finish inflate stream: %s", zError(status)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to finish inflate stream: %s", zError(status)); return FAILURE; } static zend_bool deflate_done(php_http_encoding_stream_t *s) { z_streamp ctx = s->ctx; - return !ctx->avail_in && !PHP_HTTP_BUFFER_LEN(ctx->opaque); + return !ctx->avail_in && !PHP_HTTP_BUFFER(ctx->opaque)->used; } static zend_bool inflate_done(php_http_encoding_stream_t *s) { z_streamp ctx = s->ctx; - return !ctx->avail_in && !PHP_HTTP_BUFFER_LEN(ctx->opaque); + return !ctx->avail_in && !PHP_HTTP_BUFFER(ctx->opaque)->used; } static zend_bool dechunk_done(php_http_encoding_stream_t *s) @@ -878,7 +877,7 @@ static php_http_encoding_stream_ops_t php_http_encoding_deflate_ops = { deflate_dtor }; -PHP_HTTP_API php_http_encoding_stream_ops_t *php_http_encoding_stream_get_deflate_ops(void) +php_http_encoding_stream_ops_t *php_http_encoding_stream_get_deflate_ops(void) { return &php_http_encoding_deflate_ops; } @@ -893,7 +892,7 @@ static php_http_encoding_stream_ops_t php_http_encoding_inflate_ops = { inflate_dtor }; -PHP_HTTP_API php_http_encoding_stream_ops_t *php_http_encoding_stream_get_inflate_ops(void) +php_http_encoding_stream_ops_t *php_http_encoding_stream_get_inflate_ops(void) { return &php_http_encoding_inflate_ops; } @@ -908,43 +907,11 @@ static php_http_encoding_stream_ops_t php_http_encoding_dechunk_ops = { dechunk_dtor }; -PHP_HTTP_API php_http_encoding_stream_ops_t *php_http_encoding_stream_get_dechunk_ops(void) +php_http_encoding_stream_ops_t *php_http_encoding_stream_get_dechunk_ops(void) { return &php_http_encoding_dechunk_ops; } -#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpEncodingStream, method, 0, req_args) -#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpEncodingStream, method, 0) -#define PHP_HTTP_ENCSTREAM_ME(method, visibility) PHP_ME(HttpEncodingStream, method, PHP_HTTP_ARGS(HttpEncodingStream, method), visibility) - -PHP_HTTP_BEGIN_ARGS(__construct, 0) - PHP_HTTP_ARG_VAL(flags, 0) -PHP_HTTP_END_ARGS; - -PHP_HTTP_BEGIN_ARGS(update, 1) - PHP_HTTP_ARG_VAL(data, 0) -PHP_HTTP_END_ARGS; - -PHP_HTTP_EMPTY_ARGS(flush); -PHP_HTTP_EMPTY_ARGS(done); -PHP_HTTP_EMPTY_ARGS(finish); - -static zend_class_entry *php_http_encoding_stream_class_entry; - -zend_class_entry *php_http_encoding_stream_get_class_entry(void) -{ - return php_http_encoding_stream_class_entry; -} - -static zend_function_entry php_http_encoding_stream_method_entry[] = { - PHP_HTTP_ENCSTREAM_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) - PHP_HTTP_ENCSTREAM_ME(update, ZEND_ACC_PUBLIC) - PHP_HTTP_ENCSTREAM_ME(flush, ZEND_ACC_PUBLIC) - PHP_HTTP_ENCSTREAM_ME(done, ZEND_ACC_PUBLIC) - PHP_HTTP_ENCSTREAM_ME(finish, ZEND_ACC_PUBLIC) - - EMPTY_FUNCTION_ENTRY -}; static zend_object_handlers php_http_encoding_stream_object_handlers; zend_object_value php_http_encoding_stream_object_new(zend_class_entry *ce TSRMLS_DC) @@ -954,7 +921,6 @@ zend_object_value php_http_encoding_stream_object_new(zend_class_entry *ce TSRML zend_object_value php_http_encoding_stream_object_new_ex(zend_class_entry *ce, php_http_encoding_stream_t *s, php_http_encoding_stream_object_t **ptr TSRMLS_DC) { - zend_object_value ov; php_http_encoding_stream_object_t *o; o = ecalloc(1, sizeof(*o)); @@ -969,10 +935,10 @@ zend_object_value php_http_encoding_stream_object_new_ex(zend_class_entry *ce, p o->stream = s; } - ov.handle = zend_objects_store_put((zend_object *) o, NULL, php_http_encoding_stream_object_free, NULL TSRMLS_CC); - ov.handlers = &php_http_encoding_stream_object_handlers; + o->zv.handle = zend_objects_store_put((zend_object *) o, NULL, php_http_encoding_stream_object_free, NULL TSRMLS_CC); + o->zv.handlers = &php_http_encoding_stream_object_handlers; - return ov; + return o->zv; } zend_object_value php_http_encoding_stream_object_clone(zval *this_ptr TSRMLS_DC) @@ -997,41 +963,42 @@ void php_http_encoding_stream_object_free(void *object TSRMLS_DC) efree(o); } -PHP_METHOD(HttpEncodingStream, __construct) +ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream___construct, 0, 0, 0) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO(); +static PHP_METHOD(HttpEncodingStream, __construct) { - with_error_handling(EH_THROW, php_http_exception_get_class_entry()) { - long flags = 0; - - if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags)) { - with_error_handling(EH_THROW, php_http_exception_get_class_entry()) { - php_http_encoding_stream_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); - - if (!obj->stream) { - php_http_encoding_stream_ops_t *ops = NULL; - - if (instanceof_function(obj->zo.ce, php_http_deflate_stream_get_class_entry() TSRMLS_CC)) { - ops = &php_http_encoding_deflate_ops; - } else if (instanceof_function(obj->zo.ce, php_http_inflate_stream_get_class_entry() TSRMLS_CC)) { - ops = &php_http_encoding_inflate_ops; - } else if (instanceof_function(obj->zo.ce, php_http_dechunk_stream_get_class_entry() TSRMLS_CC)) { - ops = &php_http_encoding_dechunk_ops; - } + long flags = 0; + php_http_encoding_stream_object_t *obj; + php_http_encoding_stream_ops_t *ops; - if (ops) { - obj->stream = php_http_encoding_stream_init(obj->stream, ops, flags TSRMLS_CC); - } else { - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Unknown HttpEncodingStream class %s", obj->zo.ce->name); - } + php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags), invalid_arg, return); - } else { - php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "HttpEncodingStream cannot be initialized twice"); - } - } end_error_handling(); - } - } end_error_handling(); + obj = zend_object_store_get_object(getThis() TSRMLS_CC); + + if (obj->stream) { + php_http_throw(bad_method_call, "http\\Encoding\\Stream cannot be initialized twice", NULL); + return; + } + + if (instanceof_function(obj->zo.ce, php_http_deflate_stream_class_entry TSRMLS_CC)) { + ops = &php_http_encoding_deflate_ops; + } else if (instanceof_function(obj->zo.ce, php_http_inflate_stream_class_entry TSRMLS_CC)) { + ops = &php_http_encoding_inflate_ops; + } else if (instanceof_function(obj->zo.ce, php_http_dechunk_stream_class_entry TSRMLS_CC)) { + ops = &php_http_encoding_dechunk_ops; + } else { + php_http_throw(runtime, "Unknown http\\Encoding\\Stream class '%s'", obj->zo.ce->name); + return; + } + + php_http_expect(obj->stream = php_http_encoding_stream_init(obj->stream, ops, flags TSRMLS_CC), runtime, return); } -PHP_METHOD(HttpEncodingStream, update) +ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_update, 0, 0, 1) + ZEND_ARG_INFO(0, data) +ZEND_END_ARG_INFO(); +static PHP_METHOD(HttpEncodingStream, update) { int data_len; char *data_str; @@ -1048,10 +1015,11 @@ PHP_METHOD(HttpEncodingStream, update) } } } - RETURN_FALSE; } -PHP_METHOD(HttpEncodingStream, flush) +ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_flush, 0, 0, 0) +ZEND_END_ARG_INFO(); +static PHP_METHOD(HttpEncodingStream, flush) { if (SUCCESS == zend_parse_parameters_none()) { php_http_encoding_stream_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1061,14 +1029,19 @@ PHP_METHOD(HttpEncodingStream, flush) size_t encoded_len; if (SUCCESS == php_http_encoding_stream_flush(obj->stream, &encoded_str, &encoded_len)) { - RETURN_STRINGL(encoded_str, encoded_len, 0); + if (encoded_str) { + RETURN_STRINGL(encoded_str, encoded_len, 0); + } else { + RETURN_EMPTY_STRING(); + } } } } - RETURN_FALSE; } -PHP_METHOD(HttpEncodingStream, done) +ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_done, 0, 0, 0) +ZEND_END_ARG_INFO(); +static PHP_METHOD(HttpEncodingStream, done) { if (SUCCESS == zend_parse_parameters_none()) { php_http_encoding_stream_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1077,10 +1050,11 @@ PHP_METHOD(HttpEncodingStream, done) RETURN_BOOL(php_http_encoding_stream_done(obj->stream)); } } - RETURN_FALSE; } -PHP_METHOD(HttpEncodingStream, finish) +ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_finish, 0, 0, 0) +ZEND_END_ARG_INFO(); +static PHP_METHOD(HttpEncodingStream, finish) { if (SUCCESS == zend_parse_parameters_none()) { php_http_encoding_stream_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1097,39 +1071,27 @@ PHP_METHOD(HttpEncodingStream, finish) RETURN_EMPTY_STRING(); } } else { - STR_FREE(encoded_str); + PTR_FREE(encoded_str); } } } } - RETURN_FALSE; -} - -#undef PHP_HTTP_BEGIN_ARGS -#undef PHP_HTTP_EMPTY_ARGS -#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpDeflateStream, method, 0, req_args) -#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpDeflateStream, method, 0) -#define PHP_HTTP_DEFLATE_ME(method, visibility) PHP_ME(HttpDeflateStream, method, PHP_HTTP_ARGS(HttpDeflateStream, method), visibility) - -PHP_HTTP_BEGIN_ARGS(encode, 1) - PHP_HTTP_ARG_VAL(data, 0) - PHP_HTTP_ARG_VAL(flags, 0) -PHP_HTTP_END_ARGS; - -static zend_class_entry *php_http_deflate_stream_class_entry; - -zend_class_entry *php_http_deflate_stream_get_class_entry(void) -{ - return php_http_deflate_stream_class_entry; } -static zend_function_entry php_http_deflate_stream_method_entry[] = { - PHP_HTTP_DEFLATE_ME(encode, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - +static zend_function_entry php_http_encoding_stream_methods[] = { + PHP_ME(HttpEncodingStream, __construct, ai_HttpEncodingStream___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_ME(HttpEncodingStream, update, ai_HttpEncodingStream_update, ZEND_ACC_PUBLIC) + PHP_ME(HttpEncodingStream, flush, ai_HttpEncodingStream_flush, ZEND_ACC_PUBLIC) + PHP_ME(HttpEncodingStream, done, ai_HttpEncodingStream_done, ZEND_ACC_PUBLIC) + PHP_ME(HttpEncodingStream, finish, ai_HttpEncodingStream_finish, ZEND_ACC_PUBLIC) EMPTY_FUNCTION_ENTRY }; -PHP_METHOD(HttpDeflateStream, encode) +ZEND_BEGIN_ARG_INFO_EX(ai_HttpDeflateStream_encode, 0, 0, 1) + ZEND_ARG_INFO(0, data) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO(); +static PHP_METHOD(HttpDeflateStream, encode) { char *str; int len; @@ -1146,30 +1108,15 @@ PHP_METHOD(HttpDeflateStream, encode) RETURN_FALSE; } -#undef PHP_HTTP_BEGIN_ARGS -#undef PHP_HTTP_EMPTY_ARGS -#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpInflateStream, method, 0, req_args) -#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpInflateStream, method, 0) -#define PHP_HTTP_INFLATE_ME(method, visibility) PHP_ME(HttpInflateStream, method, PHP_HTTP_ARGS(HttpInflateStream, method), visibility) - -PHP_HTTP_BEGIN_ARGS(decode, 1) - PHP_HTTP_ARG_VAL(data, 0) -PHP_HTTP_END_ARGS; - -static zend_class_entry *php_http_inflate_stream_class_entry; - -zend_class_entry *php_http_inflate_stream_get_class_entry(void) -{ - return php_http_inflate_stream_class_entry; -} - -static zend_function_entry php_http_inflate_stream_method_entry[] = { - PHP_HTTP_INFLATE_ME(decode, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - +static zend_function_entry php_http_deflate_stream_methods[] = { + PHP_ME(HttpDeflateStream, encode, ai_HttpDeflateStream_encode, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) EMPTY_FUNCTION_ENTRY }; -PHP_METHOD(HttpInflateStream, decode) +ZEND_BEGIN_ARG_INFO_EX(ai_HttpInflateStream_decode, 0, 0, 1) + ZEND_ARG_INFO(0, data) +ZEND_END_ARG_INFO(); +static PHP_METHOD(HttpInflateStream, decode) { char *str; int len; @@ -1185,31 +1132,16 @@ PHP_METHOD(HttpInflateStream, decode) RETURN_FALSE; } -#undef PHP_HTTP_BEGIN_ARGS -#undef PHP_HTTP_EMPTY_ARGS -#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpDechunkStream, method, 0, req_args) -#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpDechunkStream, method, 0) -#define PHP_HTTP_DECHUNK_ME(method, visibility) PHP_ME(HttpDechunkStream, method, PHP_HTTP_ARGS(HttpDechunkStream, method), visibility) - -PHP_HTTP_BEGIN_ARGS(decode, 1) - PHP_HTTP_ARG_VAL(data, 0) - PHP_HTTP_ARG_VAL(decoded_len, 1) -PHP_HTTP_END_ARGS; - -static zend_class_entry *php_http_dechunk_stream_class_entry; - -zend_class_entry *php_http_dechunk_stream_get_class_entry(void) -{ - return php_http_dechunk_stream_class_entry; -} - -static zend_function_entry php_http_dechunk_stream_method_entry[] = { - PHP_HTTP_DECHUNK_ME(decode, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - +static zend_function_entry php_http_inflate_stream_methods[] = { + PHP_ME(HttpInflateStream, decode, ai_HttpInflateStream_decode, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) EMPTY_FUNCTION_ENTRY }; -PHP_METHOD(HttpDechunkStream, decode) +ZEND_BEGIN_ARG_INFO_EX(ai_HttpDechunkStream_decode, 0, 0, 1) + ZEND_ARG_INFO(0, data) + ZEND_ARG_INFO(1, decoded_len) +ZEND_END_ARG_INFO(); +static PHP_METHOD(HttpDechunkStream, decode) { char *str; int len; @@ -1231,9 +1163,23 @@ PHP_METHOD(HttpDechunkStream, decode) RETURN_FALSE; } +static zend_function_entry php_http_dechunk_stream_methods[] = { + PHP_ME(HttpDechunkStream, decode, ai_HttpDechunkStream_decode, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + EMPTY_FUNCTION_ENTRY +}; + +zend_class_entry *php_http_encoding_stream_class_entry; +zend_class_entry *php_http_deflate_stream_class_entry; +zend_class_entry *php_http_inflate_stream_class_entry; +zend_class_entry *php_http_dechunk_stream_class_entry; + PHP_MINIT_FUNCTION(http_encoding) { - PHP_HTTP_REGISTER_CLASS(http\\Encoding, Stream, http_encoding_stream, php_http_object_get_class_entry(), ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_class_entry ce = {0}; + + INIT_NS_CLASS_ENTRY(ce, "http\\Encoding", "Stream", php_http_encoding_stream_methods); + php_http_encoding_stream_class_entry = zend_register_internal_class(&ce TSRMLS_CC); + php_http_encoding_stream_class_entry->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; php_http_encoding_stream_class_entry->create_object = php_http_encoding_stream_object_new; memcpy(&php_http_encoding_stream_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_http_encoding_stream_object_handlers.clone_obj = php_http_encoding_stream_object_clone; @@ -1242,7 +1188,9 @@ PHP_MINIT_FUNCTION(http_encoding) zend_declare_class_constant_long(php_http_encoding_stream_class_entry, ZEND_STRL("FLUSH_SYNC"), PHP_HTTP_ENCODING_STREAM_FLUSH_SYNC TSRMLS_CC); zend_declare_class_constant_long(php_http_encoding_stream_class_entry, ZEND_STRL("FLUSH_FULL"), PHP_HTTP_ENCODING_STREAM_FLUSH_FULL TSRMLS_CC); - PHP_HTTP_REGISTER_CLASS(http\\Encoding\\Stream, Deflate, http_deflate_stream, php_http_encoding_stream_class_entry, 0); + memset(&ce, 0, sizeof(ce)); + INIT_NS_CLASS_ENTRY(ce, "http\\Encoding\\Stream", "Deflate", php_http_deflate_stream_methods); + php_http_deflate_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_encoding_stream_class_entry, NULL TSRMLS_CC); zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("TYPE_GZIP"), PHP_HTTP_DEFLATE_TYPE_GZIP TSRMLS_CC); zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("TYPE_ZLIB"), PHP_HTTP_DEFLATE_TYPE_ZLIB TSRMLS_CC); @@ -1256,8 +1204,13 @@ PHP_MINIT_FUNCTION(http_encoding) zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_RLE"), PHP_HTTP_DEFLATE_STRATEGY_RLE TSRMLS_CC); zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_FIXED"), PHP_HTTP_DEFLATE_STRATEGY_FIXED TSRMLS_CC); - PHP_HTTP_REGISTER_CLASS(http\\Encoding\\Stream, Inflate, http_inflate_stream, php_http_encoding_stream_class_entry, 0); - PHP_HTTP_REGISTER_CLASS(http\\Encoding\\Stream, Dechunk, http_dechunk_stream, php_http_encoding_stream_class_entry, 0); + memset(&ce, 0, sizeof(ce)); + INIT_NS_CLASS_ENTRY(ce, "http\\Encoding\\Stream", "Inflate", php_http_inflate_stream_methods); + php_http_inflate_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_encoding_stream_class_entry, NULL TSRMLS_CC); + + memset(&ce, 0, sizeof(ce)); + INIT_NS_CLASS_ENTRY(ce, "http\\Encoding\\Stream", "Dechunk", php_http_dechunk_stream_methods); + php_http_dechunk_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_encoding_stream_class_entry, NULL TSRMLS_CC); return SUCCESS; }