]> granicus.if.org Git - php/commitdiff
- WS
authorPierre Joye <pajoye@php.net>
Mon, 18 May 2009 09:11:31 +0000 (09:11 +0000)
committerPierre Joye <pajoye@php.net>
Mon, 18 May 2009 09:11:31 +0000 (09:11 +0000)
ext/curl/interface.c

index 25727055c28ff8e9a91e519d0265446d6e2d34a2..351d15f43af760370c02f0591a5f05cd489b1371 100644 (file)
@@ -367,7 +367,7 @@ PHP_MINIT_FUNCTION(curl)
 {
        le_curl = zend_register_list_destructors_ex(_php_curl_close, NULL, "curl", module_number);
        le_curl_multi_handle = zend_register_list_destructors_ex(_php_curl_multi_close, NULL, "curl", module_number);
-       
+
        /* Constants for curl_setopt() */
        REGISTER_CURL_CONSTANT(CURLOPT_DNS_USE_GLOBAL_CACHE);
        REGISTER_CURL_CONSTANT(CURLOPT_DNS_CACHE_TIMEOUT);
@@ -435,7 +435,7 @@ PHP_MINIT_FUNCTION(curl)
        REGISTER_CURL_CONSTANT(CURLOPT_FILETIME);
        REGISTER_CURL_CONSTANT(CURLOPT_WRITEFUNCTION);
        REGISTER_CURL_CONSTANT(CURLOPT_READFUNCTION);
-#if CURLOPT_PASSWDFUNCTION != 0 
+#if CURLOPT_PASSWDFUNCTION != 0
        REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION);
 #endif
        REGISTER_CURL_CONSTANT(CURLOPT_HEADERFUNCTION);
@@ -534,7 +534,7 @@ PHP_MINIT_FUNCTION(curl)
        REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS4);
        REGISTER_CURL_CONSTANT(CURL_VERSION_SSL);
        REGISTER_CURL_CONSTANT(CURL_VERSION_LIBZ);
-       
+
        /* version constants */
        REGISTER_CURL_CONSTANT(CURLVERSION_NOW);
 
@@ -619,7 +619,7 @@ PHP_MINIT_FUNCTION(curl)
        REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_NONE);
        REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_0);
        REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_1);
-       
+
        REGISTER_CURL_CONSTANT(CURLM_CALL_MULTI_PERFORM);
        REGISTER_CURL_CONSTANT(CURLM_OK);
        REGISTER_CURL_CONSTANT(CURLM_BAD_HANDLE);
@@ -665,13 +665,13 @@ PHP_MINIT_FUNCTION(curl)
 #ifdef PHP_CURL_NEED_OPENSSL_TSL
        if (!CRYPTO_get_id_callback()) {
                int i, c = CRYPTO_num_locks();
-               
+
                php_curl_openssl_tsl = malloc(c * sizeof(MUTEX_T));
-               
+
                for (i = 0; i < c; ++i) {
                        php_curl_openssl_tsl[i] = tsrm_mutex_alloc();
                }
-               
+
                CRYPTO_set_id_callback(php_curl_ssl_id);
                CRYPTO_set_locking_callback(php_curl_ssl_lock);
        }
@@ -679,7 +679,7 @@ PHP_MINIT_FUNCTION(curl)
 #ifdef PHP_CURL_NEED_GNUTLS_TSL
        gcry_control(GCRYCTL_SET_THREAD_CBS, &php_curl_gnutls_tsl);
 #endif
-       
+
        if (curl_global_init(CURL_GLOBAL_SSL) != CURLE_OK) {
                return FAILURE;
        }
@@ -701,7 +701,7 @@ PHP_MINIT_FUNCTION(curl)
        php_register_url_stream_wrapper("ldap", &php_curl_wrapper TSRMLS_CC);
 # endif
 #endif
-       
+
        return SUCCESS;
 }
 /* }}} */
@@ -720,14 +720,14 @@ PHP_MSHUTDOWN_FUNCTION(curl)
 #ifdef PHP_CURL_NEED_OPENSSL_TSL
        if (php_curl_openssl_tsl) {
                int i, c = CRYPTO_num_locks();
-               
+
                CRYPTO_set_id_callback(NULL);
                CRYPTO_set_locking_callback(NULL);
-                       
+
                for (i = 0; i < c; ++i) {
                        tsrm_mutex_free(php_curl_openssl_tsl[i]);
                }
-                       
+
                free(php_curl_openssl_tsl);
                php_curl_openssl_tsl = NULL;
        }
@@ -749,7 +749,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
        fprintf(stderr, "curl_write() called\n");
        fprintf(stderr, "data = %s, size = %d, nmemb = %d, ctx = %x\n", data, size, nmemb, ctx);
 #endif
-       
+
        switch (t->method) {
                case PHP_CURL_STDOUT:
                        PHPWRITE(data, length);
@@ -773,7 +773,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
                        ZVAL_RESOURCE(handle, ch->id);
                        zend_list_addref(ch->id);
                        argv[0] = &handle;
-       
+
                        MAKE_STD_ZVAL(zdata);
                        ZVAL_STRINGL(zdata, data, length, 1);
                        argv[1] = &zdata;
@@ -864,7 +864,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
                        error = zend_call_function(&fci, &t->fci_cache TSRMLS_CC);
                        ch->in_callback = 0;
                        if (error == FAILURE) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_READFUNCTION"); 
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_READFUNCTION");
 #if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
                                length = CURL_READFUNC_ABORT;
 #endif
@@ -895,7 +895,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
        php_curl_write *t   = ch->handlers->write_header;
        size_t          length = size * nmemb;
        TSRMLS_FETCH_FROM_CTX(ch->thread_ctx);
-       
+
        switch (t->method) {
                case PHP_CURL_STDOUT:
                        /* Handle special case write when we're returning the entire transfer
@@ -971,7 +971,7 @@ static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, v
 
        if (type == CURLINFO_HEADER_OUT) {
                if (ch->header.str_len) {
-                       efree(ch->header.str);          
+                       efree(ch->header.str);
                }
                if (buf_len > 0) {
                        ch->header.str = estrndup(buf, buf_len);
@@ -1017,7 +1017,7 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
        } else {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "User handler '%s' did not return a string", Z_STRVAL_P(func));
        }
-       
+
        zval_ptr_dtor(&argv[0]);
        zval_ptr_dtor(&argv[1]);
        zval_ptr_dtor(&argv[2]);
@@ -1034,7 +1034,7 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
 static void curl_free_string(void **string)
 {
        efree(*string);
-}      
+}
 /* }}} */
 #endif
 
@@ -1108,9 +1108,9 @@ static void alloc_curl_handle(php_curl **ch)
 
        (*ch)->in_callback = 0;
        (*ch)->header.str_len = 0;
-               
+
        memset(&(*ch)->err, 0, sizeof((*ch)->err));
-       
+
 #if LIBCURL_VERSION_NUM < 0x071101
        zend_llist_init(&(*ch)->to_free.str,   sizeof(char *),            (llist_dtor_func_t) curl_free_string, 0);
 #endif
@@ -1146,7 +1146,7 @@ PHP_FUNCTION(curl_init)
        TSRMLS_SET_CTX(ch->thread_ctx);
 
        ch->cp = cp;
-       
+
        ch->handlers->write->method = PHP_CURL_STDOUT;
        ch->handlers->write->type   = PHP_CURL_ASCII;
        ch->handlers->read->method  = PHP_CURL_DIRECT;
@@ -1366,22 +1366,22 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
                case CURLOPT_COOKIE:
                case CURLOPT_REFERER:
                case CURLOPT_INTERFACE:
-               case CURLOPT_KRB4LEVEL: 
+               case CURLOPT_KRB4LEVEL:
                case CURLOPT_EGDSOCKET:
-               case CURLOPT_CAINFO: 
+               case CURLOPT_CAINFO:
                case CURLOPT_CAPATH:
-               case CURLOPT_SSL_CIPHER_LIST: 
+               case CURLOPT_SSL_CIPHER_LIST:
                case CURLOPT_SSLKEY:
-               case CURLOPT_SSLKEYTYPE: 
-               case CURLOPT_SSLKEYPASSWD: 
-               case CURLOPT_SSLENGINE: 
+               case CURLOPT_SSLKEYTYPE:
+               case CURLOPT_SSLKEYPASSWD:
+               case CURLOPT_SSLENGINE:
                case CURLOPT_SSLENGINE_DEFAULT:
                case CURLOPT_SSLCERTTYPE:
                case CURLOPT_ENCODING: {
 #if LIBCURL_VERSION_NUM < 0x071100
                        char *copystr = NULL;
 #endif
-       
+
                        convert_to_string_ex(zvalue);
 
                        if (option == CURLOPT_URL) {
@@ -1402,13 +1402,13 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
                        break;
                }
                case CURLOPT_FILE:
-               case CURLOPT_INFILE: 
+               case CURLOPT_INFILE:
                case CURLOPT_WRITEHEADER:
                case CURLOPT_STDERR: {
                        FILE *fp = NULL;
                        int type;
                        void * what;
-               
+
                        what = zend_fetch_resource(zvalue TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream());
                        if (!what) {
                                RETVAL_FALSE;
@@ -1457,7 +1457,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
                        }
                        break;
                case CURLOPT_BINARYTRANSFER:
-                       convert_to_long_ex(zvalue);     
+                       convert_to_long_ex(zvalue);
 
                        if (Z_LVAL_PP(zvalue)) {
                                ch->handlers->write->type = PHP_CURL_BINARY;
@@ -1516,7 +1516,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 
                                postfields = HASH_OF(*zvalue);
                                if (! postfields) {
-                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't get HashTable in CURLOPT_POSTFIELDS"); 
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't get HashTable in CURLOPT_POSTFIELDS");
                                        RETVAL_FALSE;
                                        return 1;
                                }
@@ -1530,7 +1530,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
                                        convert_to_string_ex(current);
 
                                        zend_hash_get_current_key_ex(postfields, &string_key, &string_key_len, &num_key, 0, NULL);
-                               
+
                                        postval = Z_STRVAL_PP(current);
 
                                        /* The arguments after _NAMELENGTH and _CONTENTSLENGTH
@@ -1552,7 +1552,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
                                                        return 1;
                                                }
                                                if (type) {
-                                                       error = curl_formadd(&first, &last, 
+                                                       error = curl_formadd(&first, &last,
                                                                                         CURLFORM_COPYNAME, string_key,
                                                                                         CURLFORM_NAMELENGTH, (long)string_key_len - 1,
                                                                                         CURLFORM_FILE, postval,
@@ -1560,7 +1560,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
                                                                                         CURLFORM_END);
                                                        *type = ';';
                                                } else {
-                                                       error = curl_formadd(&first, &last, 
+                                                       error = curl_formadd(&first, &last,
                                                                                         CURLFORM_COPYNAME, string_key,
                                                                                         CURLFORM_NAMELENGTH, (long)string_key_len - 1,
                                                                                         CURLFORM_FILE, postval,
@@ -1568,10 +1568,10 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 
                                                }
                                        } else {
-                                               error = curl_formadd(&first, &last, 
+                                               error = curl_formadd(&first, &last,
                                                                                         CURLFORM_COPYNAME, string_key,
                                                                                         CURLFORM_NAMELENGTH, (long)string_key_len - 1,
-                                                                                        CURLFORM_COPYCONTENTS, postval, 
+                                                                                        CURLFORM_COPYCONTENTS, postval,
                                                                                         CURLFORM_CONTENTSLENGTH, (long)Z_STRLEN_PP(current),
                                                                                         CURLFORM_END);
                                        }
@@ -1604,7 +1604,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 #endif
                        }
                        break;
-               case CURLOPT_HTTPHEADER: 
+               case CURLOPT_HTTPHEADER:
                case CURLOPT_QUOTE:
                case CURLOPT_HTTP200ALIASES:
                case CURLOPT_POSTQUOTE: {
@@ -1628,7 +1628,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 
                                slist = curl_slist_append(slist, Z_STRVAL_PP(current));
                                if (!slist) {
-                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not build curl_slist"); 
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not build curl_slist");
                                        RETVAL_FALSE;
                                        return 1;
                                }
@@ -1733,7 +1733,7 @@ PHP_FUNCTION(curl_setopt_array)
        zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos);
        while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **)&entry, &pos) == SUCCESS) {
                if (zend_hash_get_current_key_ex(Z_ARRVAL_P(arr), &string_key, &str_key_len, &option, 0, &pos) == HASH_KEY_IS_STRING) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array keys must be CURLOPT constants or equivalent integer values"); 
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array keys must be CURLOPT constants or equivalent integer values");
                        RETURN_FALSE;
                }
                if (_php_curl_setopt(ch, option, entry, return_value TSRMLS_CC)) {
@@ -1745,7 +1745,7 @@ PHP_FUNCTION(curl_setopt_array)
 }
 /* }}} */
 
-/* {{{ _php_curl_cleanup_handle(ch) 
+/* {{{ _php_curl_cleanup_handle(ch)
    Cleanup an execution phase */
 void _php_curl_cleanup_handle(php_curl *ch)
 {
@@ -1777,7 +1777,7 @@ PHP_FUNCTION(curl_exec)
        ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
 
        _php_curl_cleanup_handle(ch);
-       
+
        error = curl_easy_perform(ch->cp);
        SAVE_CURL_ERROR(ch, error);
        /* CURLE_PARTIAL_FILE is returned by HEAD requests */
@@ -1808,7 +1808,7 @@ PHP_FUNCTION(curl_exec)
    Get information regarding a specific transfer */
 PHP_FUNCTION(curl_getinfo)
 {
-       zval       **zid, 
+       zval       **zid,
                   **zoption;
        php_curl    *ch;
        int          option, argc = ZEND_NUM_ARGS();
@@ -1900,7 +1900,7 @@ PHP_FUNCTION(curl_getinfo)
                option = Z_LVAL_PP(zoption);
                switch (option) {
                        case CURLINFO_PRIVATE:
-                       case CURLINFO_EFFECTIVE_URL: 
+                       case CURLINFO_EFFECTIVE_URL:
                        case CURLINFO_CONTENT_TYPE: {
                                char *s_code = NULL;
 
@@ -1911,11 +1911,11 @@ PHP_FUNCTION(curl_getinfo)
                                }
                                break;
                        }
-                       case CURLINFO_HTTP_CODE: 
-                       case CURLINFO_HEADER_SIZE: 
-                       case CURLINFO_REQUEST_SIZE: 
-                       case CURLINFO_FILETIME: 
-                       case CURLINFO_SSL_VERIFYRESULT: 
+                       case CURLINFO_HTTP_CODE:
+                       case CURLINFO_HEADER_SIZE:
+                       case CURLINFO_REQUEST_SIZE:
+                       case CURLINFO_FILETIME:
+                       case CURLINFO_SSL_VERIFYRESULT:
                        case CURLINFO_REDIRECT_COUNT: {
                                long code = 0;
 
@@ -1926,16 +1926,16 @@ PHP_FUNCTION(curl_getinfo)
                                }
                                break;
                        }
-                       case CURLINFO_TOTAL_TIME: 
-                       case CURLINFO_NAMELOOKUP_TIME: 
+                       case CURLINFO_TOTAL_TIME:
+                       case CURLINFO_NAMELOOKUP_TIME:
                        case CURLINFO_CONNECT_TIME:
-                       case CURLINFO_PRETRANSFER_TIME: 
-                       case CURLINFO_SIZE_UPLOAD: 
+                       case CURLINFO_PRETRANSFER_TIME:
+                       case CURLINFO_SIZE_UPLOAD:
                        case CURLINFO_SIZE_DOWNLOAD:
-                       case CURLINFO_SPEED_DOWNLOAD: 
-                       case CURLINFO_SPEED_UPLOAD: 
+                       case CURLINFO_SPEED_DOWNLOAD:
+                       case CURLINFO_SPEED_UPLOAD:
                        case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
-                       case CURLINFO_CONTENT_LENGTH_UPLOAD: 
+                       case CURLINFO_CONTENT_LENGTH_UPLOAD:
                        case CURLINFO_STARTTRANSFER_TIME:
                        case CURLINFO_REDIRECT_TIME: {
                                double code = 0.0;
@@ -1964,7 +1964,7 @@ PHP_FUNCTION(curl_error)
 {
        zval      **zid;
        php_curl   *ch;
-       
+
        if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zid) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
@@ -2010,8 +2010,8 @@ PHP_FUNCTION(curl_close)
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close cURL handle from a callback");
                return;
        }
-       
-       if (ch->uses) { 
+
+       if (ch->uses) {
                ch->uses--;
        } else {
                zend_list_delete(Z_LVAL_PP(zid));
@@ -2026,7 +2026,7 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
 #if PHP_CURL_DEBUG
        fprintf(stderr, "DTOR CALLED, ch = %x\n", ch);
 #endif
-       
+
        curl_easy_cleanup(ch->cp);
 #if LIBCURL_VERSION_NUM < 0x071101
        zend_llist_clean(&ch->to_free.str);
@@ -2052,13 +2052,13 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
        if (ch->header.str_len > 0) {
                efree(ch->header.str);
        }
-       
+
        efree(ch->handlers->write);
        efree(ch->handlers->write_header);
        efree(ch->handlers->read);
        efree(ch->handlers);
        efree(ch);
-}      
+}
 /* }}} */
 
 /* {{{ _php_curl_close()
@@ -2067,7 +2067,7 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 {
        php_curl *ch = (php_curl *) rsrc->ptr;
        _php_curl_close_ex(ch TSRMLS_CC);
-}      
+}
 /* }}} */
 
 #endif /* HAVE_CURL */