]> granicus.if.org Git - php/commitdiff
1. Move from experimental -> production
authorSterling Hughes <sterling@php.net>
Mon, 24 Jul 2000 20:00:00 +0000 (20:00 +0000)
committerSterling Hughes <sterling@php.net>
Mon, 24 Jul 2000 20:00:00 +0000 (20:00 +0000)
2.  Thread safety
3.  Set some initial options
4.  Redo the placement of some functions and options.

ext/curl/config.m4
ext/curl/curl.c
ext/curl/php_curl.h

index f6a7ed9d94b73052844c72ccde841f40d7e3b547..1f804c7b90c7d7e6d7ee39b7b4ff5b5f0d074b07 100644 (file)
@@ -2,7 +2,7 @@ dnl $Id$
 dnl config.m4 for extension CURL
 
 PHP_ARG_WITH(curl, for CURL support,
-[  --with-curl[=DIR]        Include CURL support !!CURRENTLY EXPERIMENTAL!!])
+[  --with-curl[=DIR]        Include CURL support])
 
 if test "$PHP_CURL" != "no"; then
   if test -r $PHP_CURL/include/curl/easy.h; then
index d3e1faafc55f4be18be18babf44b9fecefbff530..a29a9f07fc7e360485aa47a8cb6d45f54b837071 100644 (file)
 #include "ext/standard/info.h"
 #include "php_curl.h"
 
-static void _curl_close (CURL *cp);
-static int  le_curl;
-
+#ifdef ZTS
+int curl_globals_id;
+#else
+php_curl_globals curl_globals;
+#endif
 
 function_entry curl_functions[] = {
        PHP_FE (curl_init,              NULL)
@@ -41,7 +43,6 @@ function_entry curl_functions[] = {
        {NULL, NULL, NULL}
 };
 
-
 zend_module_entry curl_module_entry = {
        "curl",
        curl_functions,
@@ -57,6 +58,12 @@ zend_module_entry curl_module_entry = {
 ZEND_GET_MODULE (curl)
 #endif
 
+static void php_curl_close (CURL *cp);
+static void php_curl_close (CURL *cp)
+{
+       curl_easy_cleanup (cp);
+}
+
 PHP_MINFO_FUNCTION(curl)
 {
        php_info_print_table_start ();
@@ -67,7 +74,9 @@ PHP_MINFO_FUNCTION(curl)
 
 PHP_MINIT_FUNCTION(curl)
 {
-       le_curl = register_list_destructors (_curl_close, NULL);
+       CURLLS_FETCH();
+       
+       CURLG(le_curl) = register_list_destructors (php_curl_close, NULL);
        REGISTER_LONG_CONSTANT ("CURLOPT_PORT", CURLOPT_PORT, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT ("CURLOPT_FILE", CURLOPT_FILE, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT ("CURLOPT_INFILE", CURLOPT_INFILE, CONST_CS | CONST_PERSISTENT);
@@ -113,12 +122,6 @@ PHP_MINIT_FUNCTION(curl)
        return SUCCESS;
 }
 
-
-static void _curl_close (CURL *cp)
-{
-       curl_easy_cleanup (cp);
-}
-
 /* {{{ proto int curl_init ([string url])
    Initialize a CURL session */
 PHP_FUNCTION (curl_init)
@@ -126,6 +129,7 @@ PHP_FUNCTION (curl_init)
        zval **uUrl;
        CURL *cp;
        int numArgs = ZEND_NUM_ARGS();
+       CURLLS_FETCH();
        
        if (numArgs < 0 || numArgs > 1 ||
            zend_get_parameters_ex (numArgs, &uUrl) == FAILURE) {
@@ -144,7 +148,10 @@ PHP_FUNCTION (curl_init)
                curl_easy_setopt (cp, CURLOPT_URL, Z_STRVAL_PP (uUrl));
        }
        
-       ZEND_REGISTER_RESOURCE (return_value, cp, le_curl);
+       curl_easy_setopt(cp, CURLOPT_NOPROGRESS, 1);
+       curl_easy_setopt(cp, CURLOPT_VERBOSE,    0);
+       
+       ZEND_REGISTER_RESOURCE (return_value, cp, CURLG(le_curl));
 }
 /* }}} */
 
@@ -156,28 +163,29 @@ PHP_FUNCTION (curl_setopt)
        CURL *cp;
        CURLcode ret;
        int option;
+       CURLLS_FETCH();
        
        if (ZEND_NUM_ARGS() != 3 ||
            zend_get_parameters_ex (3, &uCurlId, &uCurlOption, &uCurlValue) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
        
-       ZEND_FETCH_RESOURCE (cp, CURL *, uCurlId, -1, "CURL Handle", le_curl);
+       ZEND_FETCH_RESOURCE (cp, CURL *, uCurlId, -1, "CURL Handle", CURLG(le_curl));
        
        convert_to_long_ex (uCurlOption);
        option = Z_LVAL_PP (uCurlOption);
        
-       if (option == CURLOPT_INFILESIZE      || option == CURLOPT_VERBOSE        ||
-           option == CURLOPT_HEADER          || option == CURLOPT_NOPROGRESS     ||
-           option == CURLOPT_NOBODY          || option == CURLOPT_FAILONERROR    ||
-           option == CURLOPT_UPLOAD          || option == CURLOPT_POST           ||
-           option == CURLOPT_FTPLISTONLY     || option == CURLOPT_FTPAPPEND      ||
-           option == CURLOPT_NETRC           || option == CURLOPT_FOLLOWLOCATION ||
-           option == CURLOPT_PUT             ||
-           option == CURLOPT_MUTE            || option == CURLOPT_TIMEOUT        ||
-           option == CURLOPT_LOW_SPEED_LIMIT || option == CURLOPT_LOW_SPEED_TIME ||
-           option == CURLOPT_RESUME_FROM     || option == CURLOPT_SSLVERSION     ||
-           option == CURLOPT_TIMECONDITION   || option == CURLOPT_TIMEVALUE) {
+       if (option == CURLOPT_INFILESIZE      || option == CURLOPT_VERBOSE         ||
+           option == CURLOPT_HEADER          || option == CURLOPT_NOPROGRESS      ||
+           option == CURLOPT_NOBODY          || option == CURLOPT_FAILONERROR     ||
+           option == CURLOPT_UPLOAD          || option == CURLOPT_POST            ||
+           option == CURLOPT_FTPLISTONLY     || option == CURLOPT_FTPAPPEND       ||
+           option == CURLOPT_NETRC           || option == CURLOPT_FOLLOWLOCATION  ||
+           option == CURLOPT_PUT             || option == CURLOPT_MUTE            || 
+           option == CURLOPT_TIMEOUT         || option == CURLOPT_LOW_SPEED_LIMIT || 
+           option == CURLOPT_LOW_SPEED_TIME  || option == CURLOPT_RESUME_FROM     ||
+           option == CURLOPT_SSLVERSION      || option == CURLOPT_TIMECONDITION   ||
+           option == CURLOPT_TIMEVALUE) {
 
                convert_to_long_ex (uCurlValue);
                ret = curl_easy_setopt (cp, option, Z_LVAL_PP (uCurlValue));
@@ -199,7 +207,6 @@ PHP_FUNCTION (curl_setopt)
                FILE *fp;
                ZEND_FETCH_RESOURCE (fp, FILE *, uCurlValue, -1, "File-handle", php_file_le_fopen ());
                ret = curl_easy_setopt (cp, option, fp);
-
        }
        
        if (ret == CURLE_OK) {
@@ -217,13 +224,14 @@ PHP_FUNCTION (curl_exec)
        zval **uCurlId;
        CURL *cp;
        CURLcode ret;
+       CURLLS_FETCH();
        
        if (ZEND_NUM_ARGS() != 1 ||
            zend_get_parameters_ex (1, &uCurlId) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
        
-       ZEND_FETCH_RESOURCE (cp, CURL *, uCurlId, -1, "CURL Handle", le_curl);
+       ZEND_FETCH_RESOURCE (cp, CURL *, uCurlId, -1, "CURL Handle", CURLG(le_curl));
        ret = curl_easy_perform (cp);
 
        if (ret == CURLE_OK) {
@@ -240,12 +248,14 @@ PHP_FUNCTION (curl_close)
 {
        zval **uCurlId;
        CURL *cp;
+       CURLLS_FETCH();
        
        if (ZEND_NUM_ARGS() != 1 ||
            zend_get_parameters_ex (1, &uCurlId) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       ZEND_FETCH_RESOURCE (cp, CURL *, uCurlId, -1, "CURL Handle", le_curl);
+       
+       ZEND_FETCH_RESOURCE (cp, CURL *, uCurlId, -1, "CURL Handle", CURLG(le_curl));
        zend_list_delete (Z_LVAL_PP (uCurlId));
 }
 /* }}} */
index c5d9cf1d84f13969f40c88a3a15ba0924482cec9..b5c6e51dd47de7f43b6b6bafcc269f96d76e4a57 100644 (file)
@@ -38,6 +38,20 @@ PHP_FUNCTION (curl_setopt);
 PHP_FUNCTION (curl_exec);
 PHP_FUNCTION (curl_close);
 
+
+typedef struct {
+       int le_curl;
+} php_curl_globals;
+
+#ifdef ZTS
+#define CURLG(v) (curl_globals->v)
+#define CURLLS_FETCH() php_curl_globals *curl_globals = ts_resource(gd_curl_id)
+#else
+#define CURLG(v) (curl_globals.v)
+#define CURLLS_FETCH()
+#endif
+
+
 #else
 #define curl_module_ptr NULL
 #endif /* HAVE_CURL */