pierrick Sun, 04 Dec 2011 00:19:12 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=320339
Log:
add CURLOPT_WILDCARDMATCH and CURLOPT_FNMATCH_FUNCTION
Changed paths:
U php/php-src/trunk/ext/curl/interface.c
U php/php-src/trunk/ext/curl/php_curl.h
Modified: php/php-src/trunk/ext/curl/interface.c
===================================================================
--- php/php-src/trunk/ext/curl/interface.c 2011-12-04 00:03:56 UTC (rev
320338)
+++ php/php-src/trunk/ext/curl/interface.c 2011-12-04 00:19:12 UTC (rev
320339)
@@ -1067,12 +1067,17 @@
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_IP);
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_PORT);
REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_PORT);
+ REGISTER_CURL_CONSTANT(CURLOPT_FNMATCH_FUNCTION);
+ REGISTER_CURL_CONSTANT(CURLOPT_WILDCARDMATCH);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMP);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPE);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPS);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPT);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTE);
- REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTS);
+ REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTS);
+ REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_FAIL);
+ REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_MATCH);
+ REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_NOMATCH);
#endif
#if LIBCURL_VERSION_NUM >= 0x071502 /* Available since 7.21.2 */
@@ -1275,6 +1280,71 @@
}
/* }}} */
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+/* {{{ curl_fnmatch
+ */
+static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
+{
+ php_curl *ch = (php_curl *) ctx;
+ php_curl_fnmatch *t = ch->handlers->fnmatch;
+ int rval = CURL_FNMATCHFUNC_FAIL;
+ switch (t->method) {
+ case PHP_CURL_USER: {
+ zval **argv[3];
+ zval *zhandle = NULL;
+ zval *zpattern = NULL;
+ zval *zstring = NULL;
+ zval *retval_ptr;
+ int error;
+ zend_fcall_info fci;
+ TSRMLS_FETCH_FROM_CTX(ch->thread_ctx);
+
+ MAKE_STD_ZVAL(zhandle);
+ MAKE_STD_ZVAL(zpattern);
+ MAKE_STD_ZVAL(zstring);
+
+ ZVAL_RESOURCE(zhandle, ch->id);
+ zend_list_addref(ch->id);
+ ZVAL_STRING(zpattern, pattern, 1);
+ ZVAL_STRING(zstring, string, 1);
+
+ argv[0] = &zhandle;
+ argv[1] = &zpattern;
+ argv[2] = &zstring;
+
+ fci.size = sizeof(fci);
+ fci.function_table = EG(function_table);
+ fci.function_name = t->func_name;
+ fci.object_ptr = NULL;
+ fci.retval_ptr_ptr = &retval_ptr;
+ fci.param_count = 3;
+ fci.params = argv;
+ fci.no_separation = 0;
+ fci.symbol_table = NULL;
+
+ ch->in_callback = 1;
+ 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_FNMATCH_FUNCTION");
+ } else if (retval_ptr) {
+ if (Z_TYPE_P(retval_ptr) != IS_LONG) {
+ convert_to_long_ex(&retval_ptr);
+ }
+ rval = Z_LVAL_P(retval_ptr);
+ zval_ptr_dtor(&retval_ptr);
+ }
+ zval_ptr_dtor(argv[0]);
+ zval_ptr_dtor(argv[1]);
+ zval_ptr_dtor(argv[2]);
+ break;
+ }
+ }
+ return rval;
+}
+/* }}} */
+#endif
+
/* {{{ curl_progress
*/
static size_t curl_progress(void *clientp, double dltotal, double dlnow,
double ultotal, double ulnow)
@@ -1650,6 +1720,9 @@
(*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
(*ch)->handlers->read = ecalloc(1, sizeof(php_curl_read));
(*ch)->handlers->progress = NULL;
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ (*ch)->handlers->fnmatch = NULL;
+#endif
(*ch)->in_callback = 0;
(*ch)->header.str_len = 0;
@@ -2034,6 +2107,9 @@
case CURLOPT_RTSP_REQUEST:
case CURLOPT_RTSP_SERVER_CSEQ:
#endif
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ case CURLOPT_WILDCARDMATCH:
+#endif
#if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */
case CURLOPT_TLSAUTH_TYPE:
#endif
@@ -2453,7 +2529,7 @@
case CURLOPT_PROGRESSFUNCTION:
curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION,
curl_progress);
curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch);
- if (NULL == ch->handlers->progress) {
+ if (ch->handlers->progress == NULL) {
ch->handlers->progress = ecalloc(1,
sizeof(php_curl_progress));
} else if (ch->handlers->progress->func_name) {
zval_ptr_dtor(&ch->handlers->progress->func_name);
@@ -2584,6 +2660,22 @@
}
}
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ case CURLOPT_FNMATCH_FUNCTION:
+ curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_FUNCTION,
curl_fnmatch);
+ curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, ch);
+ if (ch->handlers->fnmatch == NULL) {
+ ch->handlers->fnmatch = ecalloc(1,
sizeof(php_curl_fnmatch));
+ } else if (ch->handlers->fnmatch->func_name) {
+
zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
+ ch->handlers->fnmatch->fci_cache =
empty_fcall_info_cache;
+ }
+ zval_add_ref(zvalue);
+ ch->handlers->fnmatch->func_name = *zvalue;
+ ch->handlers->fnmatch->method = PHP_CURL_USER;
+ break;
+#endif
+
}
SAVE_CURL_ERROR(ch, error);
@@ -3059,6 +3151,15 @@
efree(ch->handlers->progress);
}
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ if (ch->handlers->fnmatch) {
+ if (ch->handlers->fnmatch->func_name) {
+ zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
+ }
+ efree(ch->handlers->fnmatch);
+ }
+#endif
+
efree(ch->handlers);
efree(ch);
}
@@ -3112,6 +3213,17 @@
efree(ch->handlers->progress);
ch->handlers->progress = NULL;
}
+
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ if (ch->handlers->fnmatch) {
+ if (ch->handlers->fnmatch->func_name) {
+ zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
+ }
+ efree(ch->handlers->fnmatch);
+ ch->handlers->fnmatch = NULL;
+ }
+#endif
+
}
/* }}} */
Modified: php/php-src/trunk/ext/curl/php_curl.h
===================================================================
--- php/php-src/trunk/ext/curl/php_curl.h 2011-12-04 00:03:56 UTC (rev
320338)
+++ php/php-src/trunk/ext/curl/php_curl.h 2011-12-04 00:19:12 UTC (rev
320339)
@@ -124,7 +124,7 @@
zval *func_name;
zend_fcall_info_cache fci_cache;
int method;
-} php_curl_progress;
+} php_curl_progress, php_curl_fnmatch;
typedef struct {
php_curl_write *write;
@@ -133,6 +133,9 @@
zval *passwd;
zval *std_err;
php_curl_progress *progress;
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ php_curl_fnmatch *fnmatch;
+#endif
} php_curl_handlers;
struct _php_curl_error {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php