autoconf-old compatibility
[m6w6/ext-http] / php_http_curl_client.c
index 640f3bbf5cdf5365aebb45d913eabcfc1116dbe3..174fa150d76f066e3b57938398ad228dd52d62a6 100644 (file)
@@ -14,7 +14,7 @@
 
 /* resource_factory ops */
 
-static void *php_http_curl_ctor(void *opaque TSRMLS_DC)
+static void *php_http_curl_ctor(void *opaque, void *init_arg TSRMLS_DC)
 {
        void *ch;
 
@@ -436,8 +436,8 @@ static STATUS php_http_curl_client_option_set_cookies(php_http_option_t *opt, zv
                        }
 
                        php_http_buffer_fix(&curl->options.cookies);
-                       if (PHP_HTTP_BUFFER_LEN(&curl->options.cookies)) {
-                               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIE, PHP_HTTP_BUFFER_VAL(&curl->options.cookies))) {
+                       if (curl->options.cookies.used) {
+                               if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIE, curl->options.cookies.data)) {
                                        return FAILURE;
                                }
                        }
@@ -506,7 +506,7 @@ static STATUS php_http_curl_client_option_set_etag(php_http_option_t *opt, zval
        php_http_buffer_init(&header);
        php_http_buffer_appendf(&header, is_quoted?"%s: %s":"%s: \"%s\"", curl->options.range_request?"If-Match":"If-None-Match", Z_STRVAL_P(val));
        php_http_buffer_fix(&header);
-       curl->options.headers = curl_slist_append(curl->options.headers, PHP_HTTP_BUFFER_VAL(&header));
+       curl->options.headers = curl_slist_append(curl->options.headers, header.data);
        php_http_buffer_dtor(&header);
        return SUCCESS;
 }
@@ -543,14 +543,14 @@ static STATUS php_http_curl_client_option_set_range(php_http_option_t *opt, zval
                        }
                }
 
-               if (PHP_HTTP_BUFFER_LEN(&curl->options.ranges)) {
+               if (curl->options.ranges.used) {
                        curl->options.range_request = 1;
                        /* ditch last comma */
-                       PHP_HTTP_BUFFER_VAL(&curl->options.ranges)[PHP_HTTP_BUFFER_LEN(&curl->options.ranges)-- -1] = '\0';
+                       curl->options.ranges.data[curl->options.ranges.used - 1] = '\0';
                }
        }
 
-       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_RANGE, PHP_HTTP_BUFFER_VAL(&curl->options.ranges))) {
+       if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_RANGE, curl->options.ranges.data)) {
                return FAILURE;
        }
        return SUCCESS;
@@ -642,6 +642,7 @@ static STATUS php_http_curl_client_option_set_portrange(php_http_option_t *opt,
        return SUCCESS;
 }
 
+#if PHP_HTTP_CURL_VERSION(7,21,3)
 static STATUS php_http_curl_client_option_set_resolve(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_t *h = userdata;
@@ -670,6 +671,7 @@ static STATUS php_http_curl_client_option_set_resolve(php_http_option_t *opt, zv
        }
        return SUCCESS;
 }
+#endif
 
 static void php_http_curl_client_options_init(php_http_options_t *registry TSRMLS_DC)
 {
@@ -1009,7 +1011,7 @@ static php_http_client_t *php_http_curl_client_init(php_http_client_t *h, void *
        php_http_curl_client_t *ctx;
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
-       if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) {
+       if (!handle && !(handle = php_resource_factory_handle_ctor(h->rf, NULL TSRMLS_CC))) {
                php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT, "could not initialize curl handle");
                return NULL;
        }
@@ -1049,7 +1051,7 @@ static php_http_client_t *php_http_curl_client_copy(php_http_client_t *from, php
        void *copy;
        TSRMLS_FETCH_FROM_CTX(from->ts);
 
-       if (!(copy = php_http_resource_factory_handle_copy(from->rf, ctx->handle TSRMLS_CC))) {
+       if (!(copy = php_resource_factory_handle_copy(from->rf, ctx->handle TSRMLS_CC))) {
                return NULL;
        }
 
@@ -1070,7 +1072,7 @@ static void php_http_curl_client_dtor(php_http_client_t *h)
        curl_easy_setopt(ctx->handle, CURLOPT_VERBOSE, 0L);
        curl_easy_setopt(ctx->handle, CURLOPT_DEBUGFUNCTION, NULL);
 
-       php_http_resource_factory_handle_dtor(h->rf, ctx->handle TSRMLS_CC);
+       php_resource_factory_handle_dtor(h->rf, ctx->handle TSRMLS_CC);
 
        php_http_buffer_dtor(&ctx->options.ranges);
        php_http_buffer_dtor(&ctx->options.cookies);
@@ -1198,7 +1200,7 @@ PHP_HTTP_API STATUS php_http_curl_client_prepare(php_http_client_t *h, php_http_
 
                                php_http_buffer_appendf(&header, "%s: %s", header_key.str, Z_STRVAL_P(header_cpy));
                                php_http_buffer_fix(&header);
-                               curl->options.headers = curl_slist_append(curl->options.headers, PHP_HTTP_BUFFER_VAL(&header));
+                               curl->options.headers = curl_slist_append(curl->options.headers, header.data);
                                php_http_buffer_reset(&header);
 
                                zval_ptr_dtor(&header_cpy);
@@ -1209,16 +1211,16 @@ PHP_HTTP_API STATUS php_http_curl_client_prepare(php_http_client_t *h, php_http_
        }
 
        /* attach request body */
-       if ((body_size = php_http_message_body_size(&msg->body))) {
+       if ((body_size = php_http_message_body_size(msg->body))) {
                /* RFC2616, section 4.3 (para. 4) states that »a message-body MUST NOT be included in a request if the
                 * specification of the request method (section 5.1.1) does not allow sending an entity-body in request.«
                 * Following the clause in section 5.1.1 (para. 2) that request methods »MUST be implemented with the
                 * same semantics as those specified in section 9« reveal that not any single defined HTTP/1.1 method
                 * does not allow a request body.
                 */
-               php_stream_rewind(php_http_message_body_stream(&msg->body));
-               curl_easy_setopt(curl->handle, CURLOPT_IOCTLDATA, &msg->body);
-               curl_easy_setopt(curl->handle, CURLOPT_READDATA, &msg->body);
+               php_stream_rewind(php_http_message_body_stream(msg->body));
+               curl_easy_setopt(curl->handle, CURLOPT_IOCTLDATA, msg->body);
+               curl_easy_setopt(curl->handle, CURLOPT_READDATA, msg->body);
                curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, body_size);
                curl_easy_setopt(curl->handle, CURLOPT_POSTFIELDSIZE, body_size);
        }
@@ -1351,7 +1353,7 @@ static STATUS php_http_curl_client_getopt(php_http_client_t *h, php_http_client_
        return SUCCESS;
 }
 
-static php_http_resource_factory_ops_t php_http_curl_client_resource_factory_ops = {
+static php_resource_factory_ops_t php_http_curl_client_resource_factory_ops = {
        php_http_curl_ctor,
        php_http_curl_copy,
        php_http_curl_dtor
@@ -1430,7 +1432,7 @@ PHP_MINIT_FUNCTION(http_curl_client)
 {
        php_http_options_t *options;
 
-       if (SUCCESS != php_http_persistent_handle_provide(ZEND_STRL("http_client.curl"), &php_http_curl_client_resource_factory_ops, NULL, NULL)) {
+       if (SUCCESS != php_persistent_handle_provide(ZEND_STRL("http_client.curl"), &php_http_curl_client_resource_factory_ops, NULL, NULL TSRMLS_CC)) {
                return FAILURE;
        }