# define PHP_HTTP_API extern
#endif
-/* make functions that return SUCCESS|FAILURE more obvious */
-typedef int STATUS;
-
#if (defined(HAVE_ICONV) || defined(PHP_HTTP_HAVE_EXT_ICONV)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV))
# define PHP_HTTP_HAVE_ICONV
#endif
*/
static HashTable php_http_client_drivers;
-STATUS php_http_client_driver_add(php_http_client_driver_t *driver)
+ZEND_RESULT_CODE php_http_client_driver_add(php_http_client_driver_t *driver)
{
return zend_hash_add(&php_http_client_drivers, driver->name_str, driver->name_len + 1, (void *) driver, sizeof(php_http_client_driver_t), NULL);
}
-STATUS php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver)
+ZEND_RESULT_CODE php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver)
{
php_http_client_driver_t *tmp;
}
}
-STATUS php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
+ZEND_RESULT_CODE php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
{
TSRMLS_FETCH_FROM_CTX(h->ts);
return FAILURE;
}
-STATUS php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request)
+ZEND_RESULT_CODE php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request)
{
TSRMLS_FETCH_FROM_CTX(h->ts);
return el ? (php_http_client_enqueue_t *) el->data : NULL;
}
-STATUS php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout)
+ZEND_RESULT_CODE php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout)
{
if (h->ops->wait) {
return h->ops->wait(h, custom_timeout);
return FAILURE;
}
-STATUS php_http_client_exec(php_http_client_t *h)
+ZEND_RESULT_CODE php_http_client_exec(php_http_client_t *h)
{
if (h->ops->exec) {
return h->ops->exec(h);
zend_llist_clean(&h->responses);
}
-STATUS php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
+ZEND_RESULT_CODE php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
{
if (h->ops->setopt) {
return h->ops->setopt(h, opt, arg);
return FAILURE;
}
-STATUS php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr)
+ZEND_RESULT_CODE php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr)
{
if (h->ops->getopt) {
return h->ops->getopt(h, opt, arg, res_ptr);
zval_ptr_dtor(&new_hist);
}
-static STATUS handle_response(void *arg, php_http_client_t *client, php_http_client_enqueue_t *e, php_http_message_t **response)
+static ZEND_RESULT_CODE handle_response(void *arg, php_http_client_t *client, php_http_client_enqueue_t *e, php_http_message_t **response)
{
zend_bool dequeue = 0;
zval zclient;
typedef struct php_http_client *(*php_http_client_copy_func_t)(struct php_http_client *from, struct php_http_client *to);
typedef void (*php_http_client_dtor_func_t)(struct php_http_client *p);
typedef void (*php_http_client_reset_func_t)(struct php_http_client *p);
-typedef STATUS (*php_http_client_exec_func_t)(struct php_http_client *p);
+typedef ZEND_RESULT_CODE (*php_http_client_exec_func_t)(struct php_http_client *p);
typedef int (*php_http_client_once_func_t)(struct php_http_client *p);
-typedef STATUS (*php_http_client_wait_func_t)(struct php_http_client *p, struct timeval *custom_timeout);
-typedef STATUS (*php_http_client_enqueue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
-typedef STATUS (*php_http_client_dequeue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
-typedef STATUS (*php_http_client_setopt_func_t)(struct php_http_client *p, php_http_client_setopt_opt_t opt, void *arg);
-typedef STATUS (*php_http_client_getopt_func_t)(struct php_http_client *h, php_http_client_getopt_opt_t opt, void *arg, void **res);
+typedef ZEND_RESULT_CODE (*php_http_client_wait_func_t)(struct php_http_client *p, struct timeval *custom_timeout);
+typedef ZEND_RESULT_CODE (*php_http_client_enqueue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
+typedef ZEND_RESULT_CODE (*php_http_client_dequeue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
+typedef ZEND_RESULT_CODE (*php_http_client_setopt_func_t)(struct php_http_client *p, php_http_client_setopt_opt_t opt, void *arg);
+typedef ZEND_RESULT_CODE (*php_http_client_getopt_func_t)(struct php_http_client *h, php_http_client_getopt_opt_t opt, void *arg, void **res);
typedef struct php_http_client_ops {
php_resource_factory_ops_t *rsrc;
php_http_client_ops_t *client_ops;
} php_http_client_driver_t;
-PHP_HTTP_API STATUS php_http_client_driver_add(php_http_client_driver_t *driver);
-PHP_HTTP_API STATUS php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_driver_add(php_http_client_driver_t *driver);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver);
typedef struct php_http_client_progress_state {
struct {
unsigned finished:1;
} php_http_client_progress_state_t;
-typedef STATUS (*php_http_client_response_callback_t)(void *arg, struct php_http_client *client, php_http_client_enqueue_t *e, php_http_message_t **response);
+typedef ZEND_RESULT_CODE (*php_http_client_response_callback_t)(void *arg, struct php_http_client *client, php_http_client_enqueue_t *e, php_http_message_t **response);
typedef void (*php_http_client_progress_callback_t)(void *arg, struct php_http_client *client, php_http_client_enqueue_t *e, php_http_client_progress_state_t *state);
typedef struct php_http_client {
PHP_HTTP_API void php_http_client_dtor(php_http_client_t *h);
PHP_HTTP_API void php_http_client_free(php_http_client_t **h);
-PHP_HTTP_API STATUS php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue);
-PHP_HTTP_API STATUS php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request);
-PHP_HTTP_API STATUS php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout);
PHP_HTTP_API int php_http_client_once(php_http_client_t *h);
-PHP_HTTP_API STATUS php_http_client_exec(php_http_client_t *h);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_exec(php_http_client_t *h);
PHP_HTTP_API void php_http_client_reset(php_http_client_t *h);
-PHP_HTTP_API STATUS php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg);
-PHP_HTTP_API STATUS php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr);
typedef int (*php_http_client_enqueue_cmp_func_t)(php_http_client_enqueue_t *cmp, void *arg);
/* compare with request message pointer if compare_func is NULL */
return php_http_message_body_append(h->response.body, data, n*l);
}
-static STATUS php_http_curle_get_info(CURL *ch, HashTable *info)
+static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info)
{
char *c;
long l;
#define PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR 0x0002
#define PHP_HTTP_CURLE_OPTION_TRANSFORM_MS 0x0004
-static STATUS php_http_curle_option_set_ssl_verifyhost(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_ssl_verifyhost(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_cookiestore(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_cookiestore(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_cookies(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_cookies(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_encodecookies(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_encodecookies(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_lastmodified(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_lastmodified(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_compress(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_compress(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_etag(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_etag(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
php_http_buffer_t header;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_range(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_range(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_resume(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_resume(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_retrydelay(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_retrydelay(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_retrycount(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_retrycount(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_redirect(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_redirect(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
return SUCCESS;
}
-static STATUS php_http_curle_option_set_portrange(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_portrange(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
}
#if PHP_HTTP_CURL_VERSION(7,37,0)
-static STATUS php_http_curle_option_set_proxyheader(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_proxyheader(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
TSRMLS_FETCH_FROM_CTX(curl->client->ts);
#endif
#if PHP_HTTP_CURL_VERSION(7,21,3)
-static STATUS php_http_curle_option_set_resolve(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_resolve(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
#endif
#if PHP_HTTP_CURL_VERSION(7,21,4) && defined(PHP_HTTP_CURL_TLSAUTH_SRP)
-static STATUS php_http_curle_option_set_ssl_tlsauthtype(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_ssl_tlsauthtype(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
return option;
}
-static STATUS php_http_curle_set_option(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_set_option(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_curl_handler_t *curl = userdata;
CURL *ch = curl->handle;
zval tmp;
CURLcode rc = CURLE_OK;
- STATUS rv = SUCCESS;
+ ZEND_RESULT_CODE rv = SUCCESS;
TSRMLS_FETCH_FROM_CTX(curl->client->ts);
if (!val) {
}
#if PHP_HTTP_CURL_VERSION(7,30,0)
-static STATUS php_http_curlm_option_set_pipelining_bl(php_http_option_t *opt, zval *value, void *userdata)
+static ZEND_RESULT_CODE php_http_curlm_option_set_pipelining_bl(php_http_option_t *opt, zval *value, void *userdata)
{
php_http_client_t *client = userdata;
php_http_client_curl_t *curl = client->ctx;
#endif
#if PHP_HTTP_HAVE_EVENT
-static inline STATUS php_http_curlm_use_eventloop(php_http_client_t *h, zend_bool enable)
+static inline ZEND_RESULT_CODE php_http_curlm_use_eventloop(php_http_client_t *h, zend_bool enable)
{
php_http_client_curl_t *curl = h->ctx;
return SUCCESS;
}
-static STATUS php_http_curlm_option_set_use_eventloop(php_http_option_t *opt, zval *value, void *userdata)
+static ZEND_RESULT_CODE php_http_curlm_option_set_use_eventloop(php_http_option_t *opt, zval *value, void *userdata)
{
php_http_client_t *client = userdata;
#endif
}
-static STATUS php_http_curlm_set_option(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curlm_set_option(php_http_option_t *opt, zval *val, void *userdata)
{
php_http_client_t *client = userdata;
php_http_client_curl_t *curl = client->ctx;
CURLM *ch = curl->handle;
zval *orig = val;
CURLMcode rc = CURLM_UNKNOWN_OPTION;
- STATUS rv = SUCCESS;
+ ZEND_RESULT_CODE rv = SUCCESS;
TSRMLS_FETCH_FROM_CTX(client->ts);
if (!val) {
/* client ops */
-static STATUS php_http_client_curl_handler_reset(php_http_client_curl_handler_t *curl)
+static ZEND_RESULT_CODE php_http_client_curl_handler_reset(php_http_client_curl_handler_t *curl)
{
CURL *ch = curl->handle;
php_http_curle_storage_t *st;
}
-static STATUS php_http_client_curl_handler_prepare(php_http_client_curl_handler_t *curl, php_http_client_enqueue_t *enqueue)
+static ZEND_RESULT_CODE php_http_client_curl_handler_prepare(php_http_client_curl_handler_t *curl, php_http_client_enqueue_t *enqueue)
{
size_t body_size;
php_http_message_t *msg = enqueue->request;
return rf;
}
-static STATUS php_http_client_curl_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
+static ZEND_RESULT_CODE php_http_client_curl_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
{
CURLMcode rs;
php_http_client_curl_t *curl = h->ctx;
}
}
-static STATUS php_http_client_curl_dequeue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
+static ZEND_RESULT_CODE php_http_client_curl_dequeue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
{
CURLMcode rs;
php_http_client_curl_t *curl = h->ctx;
# define SELECT_ERROR -1
#endif
-static STATUS php_http_client_curl_wait(php_http_client_t *h, struct timeval *custom_timeout)
+static ZEND_RESULT_CODE php_http_client_curl_wait(php_http_client_t *h, struct timeval *custom_timeout)
{
int MAX;
fd_set R, W, E;
}
-static STATUS php_http_client_curl_exec(php_http_client_t *h)
+static ZEND_RESULT_CODE php_http_client_curl_exec(php_http_client_t *h)
{
#if PHP_HTTP_HAVE_EVENT
php_http_client_curl_t *curl = h->ctx;
return SUCCESS;
}
-static STATUS php_http_client_curl_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
+static ZEND_RESULT_CODE php_http_client_curl_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
{
php_http_client_curl_t *curl = h->ctx;
return ZEND_HASH_APPLY_KEEP;
}
-static STATUS php_http_client_curl_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void **res)
+static ZEND_RESULT_CODE php_http_client_curl_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void **res)
{
php_http_client_enqueue_t *enqueue;
TSRMLS_FETCH_FROM_CTX(h->ts);
return status;
}
-STATUS php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC)
+ZEND_RESULT_CODE 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;
return FAILURE;
}
-STATUS php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC)
+ZEND_RESULT_CODE 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;
return NULL;
}
-STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t **s)
+ZEND_RESULT_CODE php_http_encoding_stream_reset(php_http_encoding_stream_t **s)
{
php_http_encoding_stream_t *ss;
if ((*s)->ops->dtor) {
return FAILURE;
}
-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)
+ZEND_RESULT_CODE 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;
return s->ops->update(s, in_str, in_len, out_str, out_len);
}
-STATUS php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *out_len)
+ZEND_RESULT_CODE 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;
return s->ops->done(s);
}
-STATUS php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *out_len)
+ZEND_RESULT_CODE 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;
return NULL;
}
-static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len)
+static ZEND_RESULT_CODE deflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len)
{
int status;
z_streamp ctx = s->ctx;
return FAILURE;
}
-static STATUS inflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len)
+static ZEND_RESULT_CODE inflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len)
{
int status;
z_streamp ctx = s->ctx;
return FAILURE;
}
-static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len)
+static ZEND_RESULT_CODE dechunk_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len)
{
php_http_buffer_t tmp;
struct dechunk_ctx *ctx = s->ctx;
return SUCCESS;
}
-static STATUS deflate_flush(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len)
+static ZEND_RESULT_CODE deflate_flush(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len)
{
int status;
z_streamp ctx = s->ctx;
return FAILURE;
}
-static STATUS dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len)
+static ZEND_RESULT_CODE dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len)
{
struct dechunk_ctx *ctx = s->ctx;
return SUCCESS;
}
-static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len)
+static ZEND_RESULT_CODE deflate_finish(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len)
{
int status;
z_streamp ctx = s->ctx;
return FAILURE;
}
-static STATUS inflate_finish(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len)
+static ZEND_RESULT_CODE inflate_finish(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len)
{
int status;
z_streamp ctx = s->ctx;
typedef php_http_encoding_stream_t *(*php_http_encoding_stream_init_func_t)(php_http_encoding_stream_t *s);
typedef php_http_encoding_stream_t *(*php_http_encoding_stream_copy_func_t)(php_http_encoding_stream_t *from, php_http_encoding_stream_t *to);
-typedef STATUS (*php_http_encoding_stream_update_func_t)(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len);
-typedef STATUS (*php_http_encoding_stream_flush_func_t)(php_http_encoding_stream_t *s, char **out_str, size_t *out_len);
+typedef ZEND_RESULT_CODE (*php_http_encoding_stream_update_func_t)(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len);
+typedef ZEND_RESULT_CODE (*php_http_encoding_stream_flush_func_t)(php_http_encoding_stream_t *s, char **out_str, size_t *out_len);
typedef zend_bool (*php_http_encoding_stream_done_func_t)(php_http_encoding_stream_t *s);
-typedef STATUS (*php_http_encoding_stream_finish_func_t)(php_http_encoding_stream_t *s, char **out_str, size_t *out_len);
+typedef ZEND_RESULT_CODE (*php_http_encoding_stream_finish_func_t)(php_http_encoding_stream_t *s, char **out_str, size_t *out_len);
typedef void (*php_http_encoding_stream_dtor_func_t)(php_http_encoding_stream_t *s);
typedef struct php_http_encoding_stream_ops {
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_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_API STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t **s);
-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);
-PHP_HTTP_API STATUS php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *len);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_stream_reset(php_http_encoding_stream_t **s);
+PHP_HTTP_API ZEND_RESULT_CODE 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);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *len);
PHP_HTTP_API zend_bool php_http_encoding_stream_done(php_http_encoding_stream_t *s);
-PHP_HTTP_API STATUS php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *len);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *len);
PHP_HTTP_API void php_http_encoding_stream_dtor(php_http_encoding_stream_t *s);
PHP_HTTP_API void php_http_encoding_stream_free(php_http_encoding_stream_t **s);
PHP_HTTP_API const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC);
-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);
-PHP_HTTP_API STATUS php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC);
typedef struct php_http_encoding_stream_object {
zend_object zo;
php_http_buffer_appends(PHP_HTTP_BUFFER(arg), PHP_HTTP_CRLF);
}
-STATUS php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC)
{
- STATUS status;
+ ZEND_RESULT_CODE status;
php_http_buffer_t headers;
php_http_buffer_init(&headers);
return code ? code : 200;
}
-STATUS php_http_env_set_response_code(long http_code TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_code(long http_code TSRMLS_DC)
{
return sapi_header_op(SAPI_HEADER_SET_STATUS, (void *) http_code TSRMLS_CC);
}
-STATUS php_http_env_set_response_status_line(long code, php_http_version_t *v TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_status_line(long code, php_http_version_t *v TSRMLS_DC)
{
sapi_header_line h = {NULL, 0, 0};
- STATUS ret;
+ ZEND_RESULT_CODE ret;
h.line_len = spprintf(&h.line, 0, "HTTP/%u.%u %ld %s", v->major, v->minor, code, php_http_env_get_response_status_for_code(code));
ret = sapi_header_op(SAPI_HEADER_REPLACE, (void *) &h TSRMLS_CC);
return ret;
}
-STATUS php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC)
{
return php_http_env_set_response_status_line(php_http_env_get_response_code(TSRMLS_C), v TSRMLS_CC);
}
-STATUS php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace TSRMLS_DC)
{
sapi_header_line h = {estrndup(header_str, header_len), header_len, http_code};
- STATUS ret = sapi_header_op(replace ? SAPI_HEADER_REPLACE : SAPI_HEADER_ADD, (void *) &h TSRMLS_CC);
+ ZEND_RESULT_CODE ret = sapi_header_op(replace ? SAPI_HEADER_REPLACE : SAPI_HEADER_ADD, (void *) &h TSRMLS_CC);
efree(h.line);
return ret;
}
-STATUS php_http_env_set_response_header_va(long http_code, zend_bool replace, const char *fmt, va_list argv TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_header_va(long http_code, zend_bool replace, const char *fmt, va_list argv TSRMLS_DC)
{
- STATUS ret = FAILURE;
+ ZEND_RESULT_CODE ret = FAILURE;
sapi_header_line h = {NULL, 0, http_code};
h.line_len = vspprintf(&h.line, 0, fmt, argv);
return ret;
}
-STATUS php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...)
+ZEND_RESULT_CODE php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...)
{
- STATUS ret;
+ ZEND_RESULT_CODE ret;
va_list args;
va_start(args, fmt);
return ret;
}
-STATUS php_http_env_set_response_header_value(long http_code, const char *name_str, size_t name_len, zval *value, zend_bool replace TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_header_value(long http_code, const char *name_str, size_t name_len, zval *value, zend_bool replace TSRMLS_DC)
{
if (!value) {
sapi_header_line h = {(char *) name_str, name_len, http_code};
return php_http_env_set_response_header_value(http_code, name_str, name_len, NULL, replace TSRMLS_CC);
} else {
sapi_header_line h;
- STATUS ret;
+ ZEND_RESULT_CODE ret;
if (name_len > INT_MAX) {
name_len = INT_MAX;
PHP_HTTP_API long php_http_env_get_response_code(TSRMLS_D);
PHP_HTTP_API const char *php_http_env_get_response_status_for_code(unsigned code);
-PHP_HTTP_API STATUS php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC);
PHP_HTTP_API char *php_http_env_get_response_header(const char *name_str, size_t name_len TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_code(long http_code TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_header_value(long http_code, const char *name_str, size_t name_len, zval *value, zend_bool replace TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...);
-PHP_HTTP_API STATUS php_http_env_set_response_header_va(long http_code, zend_bool replace, const char *fmt, va_list argv TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_code(long http_code TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_header_value(long http_code, const char *name_str, size_t name_len, zval *value, zend_bool replace TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_header_va(long http_code, zend_bool replace, const char *fmt, va_list argv TSRMLS_DC);
PHP_HTTP_API zval *php_http_env_get_server_var(const char *key_str, size_t key_len, zend_bool check TSRMLS_DC);
#define php_http_env_got_server_var(v) (NULL != php_http_env_get_server_var((v), strlen(v), 1 TSRMLS_CC))
}
#define php_http_env_response_send_done(r) php_http_env_response_send_data((r), NULL, 0)
-static STATUS php_http_env_response_send_data(php_http_env_response_t *r, const char *buf, size_t len)
+static ZEND_RESULT_CODE php_http_env_response_send_data(php_http_env_response_t *r, const char *buf, size_t len)
{
size_t chunks_sent, chunk = r->throttle.chunk ? r->throttle.chunk : PHP_HTTP_SENDBUF_SIZE;
TSRMLS_FETCH_FROM_CTX(r->ts);
}
}
-static STATUS php_http_env_response_send_head(php_http_env_response_t *r, php_http_message_t *request)
+static ZEND_RESULT_CODE php_http_env_response_send_head(php_http_env_response_t *r, php_http_message_t *request)
{
- STATUS ret = SUCCESS;
+ ZEND_RESULT_CODE ret = SUCCESS;
zval *zoption, *options = r->options;
TSRMLS_FETCH_FROM_CTX(r->ts);
return ret;
}
-static STATUS php_http_env_response_send_body(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_send_body(php_http_env_response_t *r)
{
- STATUS ret = SUCCESS;
+ ZEND_RESULT_CODE ret = SUCCESS;
zval *zoption;
php_http_message_body_t *body;
TSRMLS_FETCH_FROM_CTX(r->ts);
return ret;
}
-STATUS php_http_env_response_send(php_http_env_response_t *r)
+ZEND_RESULT_CODE php_http_env_response_send(php_http_env_response_t *r)
{
php_http_message_t *request;
php_http_message_body_t *body;
return php_http_env_get_response_code(TSRMLS_C);
}
-static STATUS php_http_env_response_sapi_set_status(php_http_env_response_t *r, long http_code)
+static ZEND_RESULT_CODE php_http_env_response_sapi_set_status(php_http_env_response_t *r, long http_code)
{
TSRMLS_FETCH_FROM_CTX(r->ts);
return php_http_env_set_response_code(http_code TSRMLS_CC);
}
-static STATUS php_http_env_response_sapi_set_protocol_version(php_http_env_response_t *r, php_http_version_t *v)
+static ZEND_RESULT_CODE php_http_env_response_sapi_set_protocol_version(php_http_env_response_t *r, php_http_version_t *v)
{
TSRMLS_FETCH_FROM_CTX(r->ts);
return php_http_env_set_response_protocol_version(v TSRMLS_CC);
}
-static STATUS php_http_env_response_sapi_set_header(php_http_env_response_t *r, const char *fmt, ...)
+static ZEND_RESULT_CODE php_http_env_response_sapi_set_header(php_http_env_response_t *r, const char *fmt, ...)
{
- STATUS ret;
+ ZEND_RESULT_CODE ret;
va_list args;
TSRMLS_FETCH_FROM_CTX(r->ts);
return ret;
}
-static STATUS php_http_env_response_sapi_add_header(php_http_env_response_t *r, const char *fmt, ...)
+static ZEND_RESULT_CODE php_http_env_response_sapi_add_header(php_http_env_response_t *r, const char *fmt, ...)
{
- STATUS ret;
+ ZEND_RESULT_CODE ret;
va_list args;
TSRMLS_FETCH_FROM_CTX(r->ts);
return ret;
}
-static STATUS php_http_env_response_sapi_del_header(php_http_env_response_t *r, const char *header_str, size_t header_len)
+static ZEND_RESULT_CODE php_http_env_response_sapi_del_header(php_http_env_response_t *r, const char *header_str, size_t header_len)
{
TSRMLS_FETCH_FROM_CTX(r->ts);
return php_http_env_set_response_header_value(0, header_str, header_len, NULL, 1 TSRMLS_CC);
}
-static STATUS php_http_env_response_sapi_write(php_http_env_response_t *r, const char *data_str, size_t data_len)
+static ZEND_RESULT_CODE php_http_env_response_sapi_write(php_http_env_response_t *r, const char *data_str, size_t data_len)
{
TSRMLS_FETCH_FROM_CTX(r->ts);
}
return FAILURE;
}
-static STATUS php_http_env_response_sapi_flush(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_sapi_flush(php_http_env_response_t *r)
{
TSRMLS_FETCH_FROM_CTX(r->ts);
return SUCCESS;
}
-static STATUS php_http_env_response_sapi_finish(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_sapi_finish(php_http_env_response_t *r)
{
return SUCCESS;
}
unsigned chunked:1;
} php_http_env_response_stream_ctx_t;
-static STATUS php_http_env_response_stream_init(php_http_env_response_t *r, void *init_arg)
+static ZEND_RESULT_CODE php_http_env_response_stream_init(php_http_env_response_t *r, void *init_arg)
{
php_http_env_response_stream_ctx_t *ctx;
size_t buffer_size = 0x1000;
}
}
}
-static STATUS php_http_env_response_stream_start(php_http_env_response_stream_ctx_t *ctx TSRMLS_DC)
+static ZEND_RESULT_CODE php_http_env_response_stream_start(php_http_env_response_stream_ctx_t *ctx TSRMLS_DC)
{
php_http_buffer_t header_buf;
return ctx->status_code;
}
-static STATUS php_http_env_response_stream_set_status(php_http_env_response_t *r, long http_code)
+static ZEND_RESULT_CODE php_http_env_response_stream_set_status(php_http_env_response_t *r, long http_code)
{
php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
return SUCCESS;
}
-static STATUS php_http_env_response_stream_set_protocol_version(php_http_env_response_t *r, php_http_version_t *v)
+static ZEND_RESULT_CODE php_http_env_response_stream_set_protocol_version(php_http_env_response_t *r, php_http_version_t *v)
{
php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
return SUCCESS;
}
-static STATUS php_http_env_response_stream_set_header_ex(php_http_env_response_t *r, zend_bool replace, const char *fmt, va_list argv)
+static ZEND_RESULT_CODE php_http_env_response_stream_set_header_ex(php_http_env_response_t *r, zend_bool replace, const char *fmt, va_list argv)
{
php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
char *header_end, *header_str = NULL;
return SUCCESS;
}
}
-static STATUS php_http_env_response_stream_set_header(php_http_env_response_t *r, const char *fmt, ...)
+static ZEND_RESULT_CODE php_http_env_response_stream_set_header(php_http_env_response_t *r, const char *fmt, ...)
{
- STATUS ret;
+ ZEND_RESULT_CODE ret;
va_list argv;
va_start(argv, fmt);
return ret;
}
-static STATUS php_http_env_response_stream_add_header(php_http_env_response_t *r, const char *fmt, ...)
+static ZEND_RESULT_CODE php_http_env_response_stream_add_header(php_http_env_response_t *r, const char *fmt, ...)
{
- STATUS ret;
+ ZEND_RESULT_CODE ret;
va_list argv;
va_start(argv, fmt);
return ret;
}
-static STATUS php_http_env_response_stream_del_header(php_http_env_response_t *r, const char *header_str, size_t header_len)
+static ZEND_RESULT_CODE php_http_env_response_stream_del_header(php_http_env_response_t *r, const char *header_str, size_t header_len)
{
php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
zend_hash_del(&stream_ctx->header, header_str, header_len + 1);
return SUCCESS;
}
-static STATUS php_http_env_response_stream_write(php_http_env_response_t *r, const char *data_str, size_t data_len)
+static ZEND_RESULT_CODE php_http_env_response_stream_write(php_http_env_response_t *r, const char *data_str, size_t data_len)
{
php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
TSRMLS_FETCH_FROM_CTX(r->ts);
return SUCCESS;
}
-static STATUS php_http_env_response_stream_flush(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_stream_flush(php_http_env_response_t *r)
{
php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
TSRMLS_FETCH_FROM_CTX(r->ts);
return php_stream_flush(stream_ctx->stream);
}
-static STATUS php_http_env_response_stream_finish(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_stream_finish(php_http_env_response_t *r)
{
php_http_env_response_stream_ctx_t *ctx = r->ctx;
TSRMLS_FETCH_FROM_CTX(r->ts);
typedef struct php_http_env_response php_http_env_response_t;
typedef struct php_http_env_response_ops {
- STATUS (*init)(php_http_env_response_t *r, void *arg);
+ ZEND_RESULT_CODE (*init)(php_http_env_response_t *r, void *arg);
void (*dtor)(php_http_env_response_t *r);
long (*get_status)(php_http_env_response_t *r);
- STATUS (*set_status)(php_http_env_response_t *r, long http_code);
- STATUS (*set_protocol_version)(php_http_env_response_t *r, php_http_version_t *v);
- STATUS (*set_header)(php_http_env_response_t *r, const char *fmt, ...);
- STATUS (*add_header)(php_http_env_response_t *r, const char *fmt, ...);
- STATUS (*del_header)(php_http_env_response_t *r, const char *header_str, size_t header_len);
- STATUS (*write)(php_http_env_response_t *r, const char *data_str, size_t data_len);
- STATUS (*flush)(php_http_env_response_t *r);
- STATUS (*finish)(php_http_env_response_t *r);
+ ZEND_RESULT_CODE (*set_status)(php_http_env_response_t *r, long http_code);
+ ZEND_RESULT_CODE (*set_protocol_version)(php_http_env_response_t *r, php_http_version_t *v);
+ ZEND_RESULT_CODE (*set_header)(php_http_env_response_t *r, const char *fmt, ...);
+ ZEND_RESULT_CODE (*add_header)(php_http_env_response_t *r, const char *fmt, ...);
+ ZEND_RESULT_CODE (*del_header)(php_http_env_response_t *r, const char *header_str, size_t header_len);
+ ZEND_RESULT_CODE (*write)(php_http_env_response_t *r, const char *data_str, size_t data_len);
+ ZEND_RESULT_CODE (*flush)(php_http_env_response_t *r);
+ ZEND_RESULT_CODE (*finish)(php_http_env_response_t *r);
} php_http_env_response_ops_t;
PHP_HTTP_API php_http_env_response_ops_t *php_http_env_response_get_sapi_ops(void);
};
PHP_HTTP_API php_http_env_response_t *php_http_env_response_init(php_http_env_response_t *r, zval *options, php_http_env_response_ops_t *ops, void *ops_ctx TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_response_send(php_http_env_response_t *r);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_response_send(php_http_env_response_t *r);
PHP_HTTP_API void php_http_env_response_dtor(php_http_env_response_t *r);
PHP_HTTP_API void php_http_env_response_free(php_http_env_response_t **r);
#include "php_http_api.h"
-STATUS php_http_header_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data TSRMLS_DC)
+ZEND_RESULT_CODE php_http_header_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data TSRMLS_DC)
{
php_http_header_parser_t ctx;
php_http_buffer_t buf;
#include "php_http_info.h"
-PHP_HTTP_API STATUS php_http_header_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_header_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data TSRMLS_DC);
PHP_HTTP_API void php_http_header_to_callback(HashTable *headers, zend_bool crlf, php_http_pass_format_callback_t cb, void *cb_arg TSRMLS_DC);
PHP_HTTP_API void php_http_header_to_string(php_http_buffer_t *str, HashTable *headers TSRMLS_DC);
efree(escaped_str);
}
-STATUS php_http_header_parser_parse(php_http_header_parser_t *parser, php_http_buffer_t *buffer, unsigned flags, HashTable *headers, php_http_info_callback_t callback_func, void *callback_arg)
+php_http_header_parser_state_t php_http_header_parser_parse(php_http_header_parser_t *parser, php_http_buffer_t *buffer, unsigned flags, HashTable *headers, php_http_info_callback_t callback_func, void *callback_arg)
{
TSRMLS_FETCH_FROM_CTX(parser->ts);
php_http_message_object_prophandler_func_t write;
} php_http_message_object_prophandler_t;
-static STATUS php_http_message_object_add_prophandler(const char *prop_str, size_t prop_len, php_http_message_object_prophandler_func_t read, php_http_message_object_prophandler_func_t write) {
+static ZEND_RESULT_CODE php_http_message_object_add_prophandler(const char *prop_str, size_t prop_len, php_http_message_object_prophandler_func_t read, php_http_message_object_prophandler_func_t write) {
php_http_message_object_prophandler_t h = { read, write };
return zend_hash_add(&php_http_message_object_prophandlers, prop_str, prop_len + 1, (void *) &h, sizeof(h), NULL);
}
-static STATUS php_http_message_object_get_prophandler(const char *prop_str, size_t prop_len, php_http_message_object_prophandler_t **handler) {
+static ZEND_RESULT_CODE php_http_message_object_get_prophandler(const char *prop_str, size_t prop_len, php_http_message_object_prophandler_t **handler) {
return zend_hash_find(&php_http_message_object_prophandlers, prop_str, prop_len + 1, (void *) handler);
}
static void php_http_message_object_prophandler_get_type(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
}
}
-STATUS php_http_message_object_set_body(php_http_message_object_t *msg_obj, zval *zbody TSRMLS_DC)
+ZEND_RESULT_CODE php_http_message_object_set_body(php_http_message_object_t *msg_obj, zval *zbody TSRMLS_DC)
{
zval *tmp = NULL;
php_stream *s;
return SUCCESS;
}
-STATUS php_http_message_object_init_body_object(php_http_message_object_t *obj)
+ZEND_RESULT_CODE php_http_message_object_init_body_object(php_http_message_object_t *obj)
{
TSRMLS_FETCH_FROM_CTX(obj->message->ts);
void php_http_message_object_prepend(zval *this_ptr, zval *prepend, zend_bool top /* = 1 */ TSRMLS_DC);
void php_http_message_object_reverse(zval *this_ptr, zval *return_value TSRMLS_DC);
-STATUS php_http_message_object_set_body(php_http_message_object_t *obj, zval *zbody TSRMLS_DC);
-STATUS php_http_message_object_init_body_object(php_http_message_object_t *obj);
+ZEND_RESULT_CODE php_http_message_object_set_body(php_http_message_object_t *obj, zval *zbody TSRMLS_DC);
+ZEND_RESULT_CODE php_http_message_object_init_body_object(php_http_message_object_t *obj);
zend_object_value php_http_message_object_new(zend_class_entry *ce TSRMLS_DC);
zend_object_value php_http_message_object_new_ex(zend_class_entry *ce, php_http_message_t *msg, php_http_message_object_t **ptr TSRMLS_DC);
#define BOUNDARY_CLOSE(body) \
php_http_message_body_appendf(body, PHP_HTTP_CRLF "--%s--" PHP_HTTP_CRLF, php_http_message_body_boundary(body))
-static STATUS add_recursive_fields(php_http_message_body_t *body, const char *name, zval *value);
-static STATUS add_recursive_files(php_http_message_body_t *body, const char *name, zval *value);
+static ZEND_RESULT_CODE add_recursive_fields(php_http_message_body_t *body, const char *name, zval *value);
+static ZEND_RESULT_CODE add_recursive_files(php_http_message_body_t *body, const char *name, zval *value);
php_http_message_body_t *php_http_message_body_init(php_http_message_body_t **body_ptr, php_stream *stream TSRMLS_DC)
{
*len = php_stream_copy_to_mem(s, buf, forlen, 0);
}
-STATUS php_http_message_body_to_stream(php_http_message_body_t *body, php_stream *dst, off_t offset, size_t forlen)
+ZEND_RESULT_CODE php_http_message_body_to_stream(php_http_message_body_t *body, php_stream *dst, off_t offset, size_t forlen)
{
php_stream *s = php_http_message_body_stream(body);
TSRMLS_FETCH_FROM_CTX(body->ts);
return php_stream_copy_to_stream_ex(s, dst, forlen, NULL);
}
-STATUS php_http_message_body_to_callback(php_http_message_body_t *body, php_http_pass_callback_t cb, void *cb_arg, off_t offset, size_t forlen)
+ZEND_RESULT_CODE php_http_message_body_to_callback(php_http_message_body_t *body, php_http_pass_callback_t cb, void *cb_arg, off_t offset, size_t forlen)
{
php_stream *s = php_http_message_body_stream(body);
char *buf = emalloc(0x1000);
return print_len;
}
-STATUS php_http_message_body_add_form(php_http_message_body_t *body, HashTable *fields, HashTable *files)
+ZEND_RESULT_CODE php_http_message_body_add_form(php_http_message_body_t *body, HashTable *fields, HashTable *files)
{
zval tmp;
}
-STATUS php_http_message_body_add_form_field(php_http_message_body_t *body, const char *name, const char *value_str, size_t value_len)
+ZEND_RESULT_CODE php_http_message_body_add_form_field(php_http_message_body_t *body, const char *name, const char *value_str, size_t value_len)
{
char *safe_name;
TSRMLS_FETCH_FROM_CTX(body->ts);
return SUCCESS;
}
-STATUS php_http_message_body_add_form_file(php_http_message_body_t *body, const char *name, const char *ctype, const char *path, php_stream *in)
+ZEND_RESULT_CODE php_http_message_body_add_form_file(php_http_message_body_t *body, const char *name, const char *ctype, const char *path, php_stream *in)
{
char *safe_name, *path_dup = estrdup(path), *bname;
size_t bname_len;
return new_key;
}
-static STATUS add_recursive_fields(php_http_message_body_t *body, const char *name, zval *value)
+static ZEND_RESULT_CODE add_recursive_fields(php_http_message_body_t *body, const char *name, zval *value)
{
if (Z_TYPE_P(value) == IS_ARRAY || Z_TYPE_P(value) == IS_OBJECT) {
zval **val;
return SUCCESS;
}
-static STATUS add_recursive_files(php_http_message_body_t *body, const char *name, zval *value)
+static ZEND_RESULT_CODE add_recursive_files(php_http_message_body_t *body, const char *name, zval *value)
{
zval **zdata = NULL, **zfile, **zname, **ztype;
HashTable *ht;
} else {
zval *znc = php_http_ztyp(IS_STRING, *zname), *ztc = php_http_ztyp(IS_STRING, *ztype);
char *key = format_key(HASH_KEY_IS_STRING, Z_STRVAL_P(znc), 0, name);
- STATUS ret = php_http_message_body_add_form_file(body, key, Z_STRVAL_P(ztc), Z_STRVAL_P(zfc), stream);
+ ZEND_RESULT_CODE ret = php_http_message_body_add_form_file(body, key, Z_STRVAL_P(ztc), Z_STRVAL_P(zfc), stream);
efree(key);
zval_ptr_dtor(&znc);
PHP_HTTP_API php_http_message_body_t *php_http_message_body_init(php_http_message_body_t **body, php_stream *stream TSRMLS_DC);
PHP_HTTP_API unsigned php_http_message_body_addref(php_http_message_body_t *body);
PHP_HTTP_API php_http_message_body_t *php_http_message_body_copy(php_http_message_body_t *from, php_http_message_body_t *to);
-PHP_HTTP_API STATUS php_http_message_body_add_form(php_http_message_body_t *body, HashTable *fields, HashTable *files);
-PHP_HTTP_API STATUS php_http_message_body_add_form_field(php_http_message_body_t *body, const char *name, const char *value_str, size_t value_len);
-PHP_HTTP_API STATUS php_http_message_body_add_form_file(php_http_message_body_t *body, const char *name, const char *ctype, const char *file, php_stream *stream);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_message_body_add_form(php_http_message_body_t *body, HashTable *fields, HashTable *files);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_message_body_add_form_field(php_http_message_body_t *body, const char *name, const char *value_str, size_t value_len);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_message_body_add_form_file(php_http_message_body_t *body, const char *name, const char *ctype, const char *file, php_stream *stream);
PHP_HTTP_API void php_http_message_body_add_part(php_http_message_body_t *body, struct php_http_message *part);
PHP_HTTP_API size_t php_http_message_body_append(php_http_message_body_t *body, const char *buf, size_t len);
PHP_HTTP_API size_t php_http_message_body_appendf(php_http_message_body_t *body, const char *fmt, ...);
PHP_HTTP_API void php_http_message_body_to_string(php_http_message_body_t *body, char **buf, size_t *len, off_t offset, size_t forlen);
-PHP_HTTP_API STATUS php_http_message_body_to_stream(php_http_message_body_t *body, php_stream *s, off_t offset, size_t forlen);
-PHP_HTTP_API STATUS php_http_message_body_to_callback(php_http_message_body_t *body, php_http_pass_callback_t cb, void *cb_arg, off_t offset, size_t forlen);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_message_body_to_stream(php_http_message_body_t *body, php_stream *s, off_t offset, size_t forlen);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_message_body_to_callback(php_http_message_body_t *body, php_http_pass_callback_t cb, void *cb_arg, off_t offset, size_t forlen);
PHP_HTTP_API void php_http_message_body_free(php_http_message_body_t **body);
PHP_HTTP_API const php_stream_statbuf *php_http_message_body_stat(php_http_message_body_t *body);
#define php_http_message_body_size(b) (php_http_message_body_stat((b))->sb.st_size)
# define PHP_HTTP_ZEND_LITERAL_CCN , NULL
#endif
+#if PHP_VERSION_ID < 50500
+typedef enum {
+ SUCCESS = 0,
+ FAILURE = -1
+} ZEND_RESULT_CODE;
+#endif
+
#if PHP_VERSION_ID < 50700
# define z_is_true zend_is_true
#else
}
}
-static inline STATUS php_http_ini_entry(const char *name_str, size_t name_len, const char **value_str, size_t *value_len, zend_bool orig TSRMLS_DC)
+static inline ZEND_RESULT_CODE php_http_ini_entry(const char *name_str, size_t name_len, const char **value_str, size_t *value_len, zend_bool orig TSRMLS_DC)
{
zend_ini_entry *ini_entry;
return o->zv;
}
-STATUS php_http_new(zend_object_value *ovp, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr, void **obj_ptr TSRMLS_DC)
+ZEND_RESULT_CODE php_http_new(zend_object_value *ovp, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr, void **obj_ptr TSRMLS_DC)
{
zend_object_value ov;
}
}
-STATUS php_http_object_method_call(php_http_object_method_t *cb, zval *zobject, zval **retval_ptr, int argc, zval ***args TSRMLS_DC)
+ZEND_RESULT_CODE php_http_object_method_call(php_http_object_method_t *cb, zval *zobject, zval **retval_ptr, int argc, zval ***args TSRMLS_DC)
{
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zval *retval = NULL;
Z_ADDREF_P(zobject);
typedef zend_object_value (*php_http_new_t)(zend_class_entry *ce, void *, void ** TSRMLS_DC);
-STATUS php_http_new(zend_object_value *ov, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr, void **obj_ptr TSRMLS_DC);
+ZEND_RESULT_CODE php_http_new(zend_object_value *ov, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr, void **obj_ptr TSRMLS_DC);
typedef struct php_http_method {
zend_fcall_info fci;
} php_http_object_method_t;
php_http_object_method_t *php_http_object_method_init(php_http_object_method_t *cb, zval *zobject, const char *method_str, size_t method_len TSRMLS_DC);
-STATUS php_http_object_method_call(php_http_object_method_t *cb, zval *zobject, zval **retval, int argc, zval ***args TSRMLS_DC);
+ZEND_RESULT_CODE php_http_object_method_call(php_http_object_method_t *cb, zval *zobject, zval **retval, int argc, zval ***args TSRMLS_DC);
void php_http_object_method_dtor(php_http_object_method_t *cb);
void php_http_object_method_free(php_http_object_method_t **cb);
return registry;
}
-STATUS php_http_options_apply(php_http_options_t *registry, HashTable *options, void *userdata)
+ZEND_RESULT_CODE php_http_options_apply(php_http_options_t *registry, HashTable *options, void *userdata)
{
HashPosition pos;
zval *val;
typedef struct php_http_option php_http_option_t;
typedef struct php_http_options php_http_options_t;
-typedef STATUS (*php_http_option_set_callback_t)(php_http_option_t *opt, zval *val, void *userdata);
+typedef ZEND_RESULT_CODE (*php_http_option_set_callback_t)(php_http_option_t *opt, zval *val, void *userdata);
typedef zval *(*php_http_option_get_callback_t)(php_http_option_t *opt, HashTable *options, void *userdata);
struct php_http_options {
};
PHP_HTTP_API php_http_options_t *php_http_options_init(php_http_options_t *registry, zend_bool persistent);
-PHP_HTTP_API STATUS php_http_options_apply(php_http_options_t *registry, HashTable *options, void *userdata);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_options_apply(php_http_options_t *registry, HashTable *options, void *userdata);
PHP_HTTP_API void php_http_options_dtor(php_http_options_t *registry);
PHP_HTTP_API void php_http_options_free(php_http_options_t **registry);
}
#ifdef PHP_HTTP_HAVE_ICONV
-STATUS php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe TSRMLS_DC)
+ZEND_RESULT_CODE php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe TSRMLS_DC)
{
HashPosition pos;
zval **entry = NULL;
}
#endif /* HAVE_ICONV */
-STATUS php_http_querystring_ctor(zval *instance, zval *params TSRMLS_DC)
+ZEND_RESULT_CODE php_http_querystring_ctor(zval *instance, zval *params TSRMLS_DC)
{
php_http_querystring_set(instance, params, 0 TSRMLS_CC);
return SUCCESS;
return ZEND_HASH_APPLY_KEEP;
}
-STATUS php_http_querystring_parse(HashTable *ht, const char *str, size_t len TSRMLS_DC)
+ZEND_RESULT_CODE php_http_querystring_parse(HashTable *ht, const char *str, size_t len TSRMLS_DC)
{
- STATUS rv = FAILURE;
+ ZEND_RESULT_CODE rv = FAILURE;
php_http_params_opts_t opts;
php_http_params_token_t psep = { ZEND_STRL("&") }, *psepp[] = { &psep, NULL };
php_http_params_token_t vsep = { ZEND_STRL("=") }, *vsepp[] = { &vsep, NULL };
return rv;
}
-STATUS php_http_querystring_update(zval *qarray, zval *params, zval *outstring TSRMLS_DC)
+ZEND_RESULT_CODE php_http_querystring_update(zval *qarray, zval *params, zval *outstring TSRMLS_DC)
{
/* enforce proper type */
if (Z_TYPE_P(qarray) != IS_ARRAY) {
#define PHP_HTTP_QUERYSTRING_H
#ifdef PHP_HTTP_HAVE_ICONV
-PHP_HTTP_API STATUS php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe TSRMLS_DC);
#endif /* PHP_HTTP_HAVE_ICONV */
-PHP_HTTP_API STATUS php_http_querystring_update(zval *qarray, zval *params, zval *qstring TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_querystring_ctor(zval *instance, zval *params TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_querystring_update(zval *qarray, zval *params, zval *qstring TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_querystring_ctor(zval *instance, zval *params TSRMLS_DC);
typedef php_http_object_t php_http_querystring_object_t;
return Z_ARRVAL(arr);
}
-STATUS php_http_url_encode_hash(HashTable *hash, const char *pre_encoded_str, size_t pre_encoded_len, char **encoded_str, size_t *encoded_len TSRMLS_DC)
+ZEND_RESULT_CODE php_http_url_encode_hash(HashTable *hash, const char *pre_encoded_str, size_t pre_encoded_len, char **encoded_str, size_t *encoded_len TSRMLS_DC)
{
const char *arg_sep_str;
size_t arg_sep_len;
return SUCCESS;
}
-STATUS php_http_url_encode_hash_ex(HashTable *hash, php_http_buffer_t *qstr, const char *arg_sep_str, size_t arg_sep_len, const char *val_sep_str, size_t val_sep_len, const char *pre_encoded_str, size_t pre_encoded_len TSRMLS_DC)
+ZEND_RESULT_CODE php_http_url_encode_hash_ex(HashTable *hash, php_http_buffer_t *qstr, const char *arg_sep_str, size_t arg_sep_len, const char *val_sep_str, size_t val_sep_len, const char *pre_encoded_str, size_t pre_encoded_len TSRMLS_DC)
{
if (pre_encoded_len && pre_encoded_str) {
php_http_buffer_append(qstr, pre_encoded_str, pre_encoded_len);
return 0;
}
-static STATUS parse_userinfo(struct parse_state *state, const char *ptr)
+static ZEND_RESULT_CODE parse_userinfo(struct parse_state *state, const char *ptr)
{
size_t mb;
const char *password = NULL, *end = state->ptr, *tmp = ptr;
#if defined(PHP_WIN32) || defined(HAVE_UIDNA_IDNTOASCII)
typedef size_t (*parse_mb_func)(unsigned *wc, const char *ptr, const char *end);
-static STATUS to_utf16(parse_mb_func fn, const char *u8, uint16_t **u16, size_t *len)
+static ZEND_RESULT_CODE to_utf16(parse_mb_func fn, const char *u8, uint16_t **u16, size_t *len)
{
size_t offset = 0, u8_len = strlen(u8);
#endif
#ifdef PHP_HTTP_HAVE_IDN
-static STATUS parse_idn(struct parse_state *state, size_t prev_len)
+static ZEND_RESULT_CODE parse_idn(struct parse_state *state, size_t prev_len)
{
char *idn = NULL;
int rv = -1;
typedef enum { U_ZERO_ERROR = 0 } UErrorCode;
int32_t uidna_IDNToASCII(const UChar *src, int32_t srcLength, UChar *dest, int32_t destCapacity, int32_t options, void *parseError, UErrorCode *status);
# endif
-static STATUS parse_uidn(struct parse_state *state)
+static ZEND_RESULT_CODE parse_uidn(struct parse_state *state)
{
char *host_ptr;
uint16_t *uhost_str, ahost_str[MAXHOSTNAMELEN], *ahost_ptr;
#endif
#if 0 && defined(PHP_WIN32)
-static STATUS parse_widn(struct parse_state *state)
+static ZEND_RESULT_CODE parse_widn(struct parse_state *state)
{
char *host_ptr;
uint16_t *uhost_str, ahost_str[MAXHOSTNAMELEN], *ahost_ptr;
}
#endif
-static STATUS parse_hostinfo(struct parse_state *state, const char *ptr)
+static ZEND_RESULT_CODE parse_hostinfo(struct parse_state *state, const char *ptr)
{
size_t mb, len;
const char *end = state->ptr, *tmp = ptr, *port = NULL;
PHP_HTTP_API char *php_http_url_authority_to_string(const php_http_url_t *url, char **url_str, size_t *url_len);
PHP_HTTP_API void php_http_url_free(php_http_url_t **url);
-PHP_HTTP_API STATUS php_http_url_encode_hash(HashTable *hash, const char *pre_encoded_str, size_t pre_encoded_len, char **encoded_str, size_t *encoded_len TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_url_encode_hash_ex(HashTable *hash, php_http_buffer_t *qstr, const char *arg_sep_str, size_t arg_sep_len, const char *val_sep_str, size_t val_sep_len, const char *pre_encoded_str, size_t pre_encoded_len TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_url_encode_hash(HashTable *hash, const char *pre_encoded_str, size_t pre_encoded_len, char **encoded_str, size_t *encoded_len TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_url_encode_hash_ex(HashTable *hash, php_http_buffer_t *qstr, const char *arg_sep_str, size_t arg_sep_len, const char *val_sep_str, size_t val_sep_len, const char *pre_encoded_str, size_t pre_encoded_len TSRMLS_DC);
static inline void php_http_url_argsep(const char **str, size_t *len TSRMLS_DC)
{