cvs: php4 /ext/curl config.m4 curl.c php_curl.h
| From: | Sterling Hughes | Date: | Mon, 24 Jul 2000 20:00:00 +0000 |
| Subject: | cvs: php4 /ext/curl config.m4 curl.c php_curl.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-901@lists.php.net to get a copy of this message | ||
sterling Mon Jul 24 13:00:00 2000 EDT
Modified files:
/php4/ext/curl config.m4 curl.c php_curl.h
Log:
1. Move from experimental -> production
2. Thread safety
3. Set some initial options
4. Redo the placement of some functions and options.
Index: php4/ext/curl/config.m4
diff -u php4/ext/curl/config.m4:1.1 php4/ext/curl/config.m4:1.2
--- php4/ext/curl/config.m4:1.1 Sun Jul 16 12:37:33 2000
+++ php4/ext/curl/config.m4 Mon Jul 24 12:59:59 2000
@@ -1,8 +1,8 @@
-dnl $Id: config.m4,v 1.1 2000/07/16 19:37:33 sterling Exp $
+dnl $Id: config.m4,v 1.2 2000/07/24 19:59:59 sterling Exp $
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: php4/ext/curl/curl.c
diff -u php4/ext/curl/curl.c:1.1 php4/ext/curl/curl.c:1.2
--- php4/ext/curl/curl.c:1.1 Sun Jul 16 12:37:33 2000
+++ php4/ext/curl/curl.c Mon Jul 24 12:59:59 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: curl.c,v 1.1 2000/07/16 19:37:33 sterling Exp $ */
+/* $Id: curl.c,v 1.2 2000/07/24 19:59:59 sterling Exp $ */
#include "php.h"
@@ -29,9 +29,11 @@
#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 @@
{NULL, NULL, NULL}
};
-
zend_module_entry curl_module_entry = {
"curl",
curl_functions,
@@ -57,6 +58,12 @@
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_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 @@
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 @@
zval **uUrl;
CURL *cp;
int numArgs = ZEND_NUM_ARGS();
+ CURLLS_FETCH();
if (numArgs < 0 || numArgs > 1 ||
zend_get_parameters_ex (numArgs, &uUrl) == FAILURE) {
@@ -143,8 +147,11 @@
convert_to_string_ex (uUrl);
curl_easy_setopt (cp, CURLOPT_URL, Z_STRVAL_PP (uUrl));
}
+
+ curl_easy_setopt(cp, CURLOPT_NOPROGRESS, 1);
+ curl_easy_setopt(cp, CURLOPT_VERBOSE, 0);
- ZEND_REGISTER_RESOURCE (return_value, cp, le_curl);
+ ZEND_REGISTER_RESOURCE (return_value, cp, CURLG(le_curl));
}
/* }}} */
@@ -156,28 +163,29 @@
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 @@
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 @@
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 @@
{
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: php4/ext/curl/php_curl.h
diff -u php4/ext/curl/php_curl.h:1.1 php4/ext/curl/php_curl.h:1.2
--- php4/ext/curl/php_curl.h:1.1 Sun Jul 16 12:37:33 2000
+++ php4/ext/curl/php_curl.h Mon Jul 24 13:00:00 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_curl.h,v 1.1 2000/07/16 19:37:33 sterling Exp $ */
+/* $Id: php_curl.h,v 1.2 2000/07/24 20:00:00 sterling Exp $ */
#ifndef _PHP_CURL_H
#define _PHP_CURL_H
@@ -37,6 +37,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