Lines Matching refs:ch

151 static void _php_curl_close_ex(php_curl *ch TSRMLS_DC);
168 static int php_curl_option_str(php_curl *ch, long option, const char *str, const int len, zend_bool… in php_curl_option_str() argument
184 error = curl_easy_setopt(ch->cp, option, copystr); in php_curl_option_str()
185 zend_llist_add_element(&ch->to_free->str, &copystr); in php_curl_option_str()
188 error = curl_easy_setopt(ch->cp, option, str); in php_curl_option_str()
192 SAVE_CURL_ERROR(ch, error) in php_curl_option_str()
197 static int php_curl_option_url(php_curl *ch, const char *url, const int len TSRMLS_DC) /* {{{ */ in php_curl_option_url() argument
202 curl_easy_setopt(ch->cp, CURLOPT_PROTOCOLS, CURLPROTO_ALL & ~CURLPROTO_FILE); in php_curl_option_url()
220 return php_curl_option_str(ch, CURLOPT_URL, url, len, 0 TSRMLS_CC); in php_curl_option_url()
224 void _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC) /* {{{ */ in _php_curl_verify_handlers() argument
227 if (!ch || !ch->handlers) { in _php_curl_verify_handlers()
231 if (ch->handlers->std_err) { in _php_curl_verify_handlers()
232 …stream = (php_stream *) zend_fetch_resource(&ch->handlers->std_err TSRMLS_CC, -1, NULL, NULL, 2, p… in _php_curl_verify_handlers()
237 zval_ptr_dtor(&ch->handlers->std_err); in _php_curl_verify_handlers()
238 ch->handlers->std_err = NULL; in _php_curl_verify_handlers()
240 curl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr); in _php_curl_verify_handlers()
243 if (ch->handlers->read && ch->handlers->read->stream) { in _php_curl_verify_handlers()
244 …stream = (php_stream *) zend_fetch_resource(&ch->handlers->read->stream TSRMLS_CC, -1, NULL, NULL,… in _php_curl_verify_handlers()
249 zval_ptr_dtor(&ch->handlers->read->stream); in _php_curl_verify_handlers()
250 ch->handlers->read->fd = 0; in _php_curl_verify_handlers()
251 ch->handlers->read->fp = 0; in _php_curl_verify_handlers()
252 ch->handlers->read->stream = NULL; in _php_curl_verify_handlers()
254 curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch); in _php_curl_verify_handlers()
257 if (ch->handlers->write_header && ch->handlers->write_header->stream) { in _php_curl_verify_handlers()
258 …stream = (php_stream *) zend_fetch_resource(&ch->handlers->write_header->stream TSRMLS_CC, -1, NUL… in _php_curl_verify_handlers()
263 zval_ptr_dtor(&ch->handlers->write_header->stream); in _php_curl_verify_handlers()
264 ch->handlers->write_header->fp = 0; in _php_curl_verify_handlers()
265 ch->handlers->write_header->stream = NULL; in _php_curl_verify_handlers()
267 ch->handlers->write_header->method = PHP_CURL_IGNORE; in _php_curl_verify_handlers()
268 curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); in _php_curl_verify_handlers()
271 if (ch->handlers->write && ch->handlers->write->stream) { in _php_curl_verify_handlers()
272 …stream = (php_stream *) zend_fetch_resource(&ch->handlers->write->stream TSRMLS_CC, -1, NULL, NULL… in _php_curl_verify_handlers()
277 zval_ptr_dtor(&ch->handlers->write->stream); in _php_curl_verify_handlers()
278 ch->handlers->write->fp = 0; in _php_curl_verify_handlers()
279 ch->handlers->write->stream = NULL; in _php_curl_verify_handlers()
281 ch->handlers->write->method = PHP_CURL_STDOUT; in _php_curl_verify_handlers()
282 curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch); in _php_curl_verify_handlers()
299 ZEND_ARG_INFO(0, ch)
303 ZEND_ARG_INFO(0, ch)
309 ZEND_ARG_INFO(0, ch)
314 ZEND_ARG_INFO(0, ch)
318 ZEND_ARG_INFO(0, ch)
323 ZEND_ARG_INFO(0, ch)
327 ZEND_ARG_INFO(0, ch)
331 ZEND_ARG_INFO(0, ch)
336 ZEND_ARG_INFO(0, ch)
342 ZEND_ARG_INFO(0, ch)
347 ZEND_ARG_INFO(0, ch)
363 ZEND_ARG_INFO(0, ch)
368 ZEND_ARG_INFO(0, ch)
382 ZEND_ARG_INFO(0, ch)
419 ZEND_ARG_INFO(0, ch)
1302 php_curl *ch = (php_curl *) ctx; in curl_write() local
1303 php_curl_write *t = ch->handlers->write; in curl_write()
1305 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_write()
1332 ZVAL_RESOURCE(handle, ch->id); in curl_write()
1333 zend_list_addref(ch->id); in curl_write()
1350 ch->in_callback = 1; in curl_write()
1352 ch->in_callback = 0; in curl_write()
1357 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in curl_write()
1380 php_curl *ch = (php_curl *) ctx; in curl_fnmatch() local
1381 php_curl_fnmatch *t = ch->handlers->fnmatch; in curl_fnmatch()
1392 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_fnmatch()
1398 ZVAL_RESOURCE(zhandle, ch->id); in curl_fnmatch()
1399 zend_list_addref(ch->id); in curl_fnmatch()
1417 ch->in_callback = 1; in curl_fnmatch()
1419 ch->in_callback = 0; in curl_fnmatch()
1423 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in curl_fnmatch()
1445 php_curl *ch = (php_curl *) clientp; in curl_progress() local
1446 php_curl_progress *t = ch->handlers->progress; in curl_progress()
1465 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_progress()
1473 ZVAL_RESOURCE(handle, ch->id); in curl_progress()
1474 zend_list_addref(ch->id); in curl_progress()
1496 ch->in_callback = 1; in curl_progress()
1498 ch->in_callback = 0; in curl_progress()
1502 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in curl_progress()
1527 php_curl *ch = (php_curl *) ctx; in curl_read() local
1528 php_curl_read *t = ch->handlers->read; in curl_read()
1545 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_read()
1551 ZVAL_RESOURCE(handle, ch->id); in curl_read()
1552 zend_list_addref(ch->id); in curl_read()
1571 ch->in_callback = 1; in curl_read()
1573 ch->in_callback = 0; in curl_read()
1580 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in curl_read()
1603 php_curl *ch = (php_curl *) ctx; in curl_write_header() local
1604 php_curl_write *t = ch->handlers->write_header; in curl_write_header()
1606 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_write_header()
1612 if (ch->handlers->write->method == PHP_CURL_RETURN && length > 0) { in curl_write_header()
1613 smart_str_appendl(&ch->handlers->write->buf, data, (int) length); in curl_write_header()
1631 ZVAL_RESOURCE(handle, ch->id); in curl_write_header()
1632 zend_list_addref(ch->id); in curl_write_header()
1648 ch->in_callback = 1; in curl_write_header()
1650 ch->in_callback = 0; in curl_write_header()
1655 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in curl_write_header()
1680 php_curl *ch = (php_curl *) ctx; in curl_debug() local
1683 if (ch->header.str_len) { in curl_debug()
1684 efree(ch->header.str); in curl_debug()
1687 ch->header.str = estrndup(buf, buf_len); in curl_debug()
1688 ch->header.str_len = buf_len; in curl_debug()
1701 php_curl *ch = (php_curl *) ctx; in curl_passwd() local
1702 zval *func = ch->handlers->passwd; in curl_passwd()
1707 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_passwd()
1713 ZVAL_RESOURCE(argv[0], ch->id); in curl_passwd()
1714 zend_list_addref(ch->id); in curl_passwd()
1810 static void alloc_curl_handle(php_curl **ch) in alloc_curl_handle() argument
1812 *ch = emalloc(sizeof(php_curl)); in alloc_curl_handle()
1813 (*ch)->to_free = ecalloc(1, sizeof(struct _php_curl_free)); in alloc_curl_handle()
1814 (*ch)->handlers = ecalloc(1, sizeof(php_curl_handlers)); in alloc_curl_handle()
1815 (*ch)->handlers->write = ecalloc(1, sizeof(php_curl_write)); in alloc_curl_handle()
1816 (*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write)); in alloc_curl_handle()
1817 (*ch)->handlers->read = ecalloc(1, sizeof(php_curl_read)); in alloc_curl_handle()
1818 (*ch)->handlers->progress = NULL; in alloc_curl_handle()
1820 (*ch)->handlers->fnmatch = NULL; in alloc_curl_handle()
1823 (*ch)->in_callback = 0; in alloc_curl_handle()
1824 (*ch)->header.str_len = 0; in alloc_curl_handle()
1826 memset(&(*ch)->err, 0, sizeof((*ch)->err)); in alloc_curl_handle()
1827 (*ch)->handlers->write->stream = NULL; in alloc_curl_handle()
1828 (*ch)->handlers->write_header->stream = NULL; in alloc_curl_handle()
1829 (*ch)->handlers->read->stream = NULL; in alloc_curl_handle()
1831 …zend_llist_init(&(*ch)->to_free->str, sizeof(char *), (llist_dtor_func_t) curl_free_s… in alloc_curl_handle()
1832 …zend_llist_init(&(*ch)->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_p… in alloc_curl_handle()
1833 (*ch)->safe_upload = 0; /* for now, for BC reason we allow unsafe API */ in alloc_curl_handle()
1835 (*ch)->to_free->slist = emalloc(sizeof(HashTable)); in alloc_curl_handle()
1836 zend_hash_init((*ch)->to_free->slist, 4, NULL, curl_free_slist, 0); in alloc_curl_handle()
1920 static void _php_curl_set_default_options(php_curl *ch) in _php_curl_set_default_options() argument
1924 curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1); in _php_curl_set_default_options()
1925 curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); in _php_curl_set_default_options()
1926 curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); in _php_curl_set_default_options()
1927 curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write); in _php_curl_set_default_options()
1928 curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch); in _php_curl_set_default_options()
1929 curl_easy_setopt(ch->cp, CURLOPT_READFUNCTION, curl_read); in _php_curl_set_default_options()
1930 curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch); in _php_curl_set_default_options()
1931 curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header); in _php_curl_set_default_options()
1932 curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); in _php_curl_set_default_options()
1933 curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1); in _php_curl_set_default_options()
1934 curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120); in _php_curl_set_default_options()
1935 curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */ in _php_curl_set_default_options()
1939 curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo); in _php_curl_set_default_options()
1943 curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1); in _php_curl_set_default_options()
1952 php_curl *ch; in PHP_FUNCTION() local
1968 alloc_curl_handle(&ch); in PHP_FUNCTION()
1969 TSRMLS_SET_CTX(ch->thread_ctx); in PHP_FUNCTION()
1971 ch->cp = cp; in PHP_FUNCTION()
1973 ch->handlers->write->method = PHP_CURL_STDOUT; in PHP_FUNCTION()
1974 ch->handlers->read->method = PHP_CURL_DIRECT; in PHP_FUNCTION()
1975 ch->handlers->write_header->method = PHP_CURL_IGNORE; in PHP_FUNCTION()
1978 ch->clone = clone; in PHP_FUNCTION()
1980 _php_curl_set_default_options(ch); in PHP_FUNCTION()
1983 if (php_curl_option_url(ch, url, url_len TSRMLS_CC) == FAILURE) { in PHP_FUNCTION()
1984 _php_curl_close_ex(ch TSRMLS_CC); in PHP_FUNCTION()
1989 ZEND_REGISTER_RESOURCE(return_value, ch, le_curl); in PHP_FUNCTION()
1990 ch->id = Z_LVAL_P(return_value); in PHP_FUNCTION()
2000 php_curl *ch, *dupch; in PHP_FUNCTION() local
2006 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2008 cp = curl_easy_duphandle(ch->cp); in PHP_FUNCTION()
2019 if (ch->handlers->write->stream) { in PHP_FUNCTION()
2020 Z_ADDREF_P(ch->handlers->write->stream); in PHP_FUNCTION()
2022 dupch->handlers->write->stream = ch->handlers->write->stream; in PHP_FUNCTION()
2023 dupch->handlers->write->method = ch->handlers->write->method; in PHP_FUNCTION()
2024 if (ch->handlers->read->stream) { in PHP_FUNCTION()
2025 Z_ADDREF_P(ch->handlers->read->stream); in PHP_FUNCTION()
2027 dupch->handlers->read->stream = ch->handlers->read->stream; in PHP_FUNCTION()
2028 dupch->handlers->read->method = ch->handlers->read->method; in PHP_FUNCTION()
2029 dupch->handlers->write_header->method = ch->handlers->write_header->method; in PHP_FUNCTION()
2030 if (ch->handlers->write_header->stream) { in PHP_FUNCTION()
2031 Z_ADDREF_P(ch->handlers->write_header->stream); in PHP_FUNCTION()
2033 dupch->handlers->write_header->stream = ch->handlers->write_header->stream; in PHP_FUNCTION()
2035 dupch->handlers->write->fp = ch->handlers->write->fp; in PHP_FUNCTION()
2036 dupch->handlers->write_header->fp = ch->handlers->write_header->fp; in PHP_FUNCTION()
2037 dupch->handlers->read->fp = ch->handlers->read->fp; in PHP_FUNCTION()
2038 dupch->handlers->read->fd = ch->handlers->read->fd; in PHP_FUNCTION()
2040 if (ch->handlers->passwd) { in PHP_FUNCTION()
2041 zval_add_ref(&ch->handlers->passwd); in PHP_FUNCTION()
2042 dupch->handlers->passwd = ch->handlers->passwd; in PHP_FUNCTION()
2043 curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) dupch); in PHP_FUNCTION()
2046 if (ch->handlers->write->func_name) { in PHP_FUNCTION()
2047 zval_add_ref(&ch->handlers->write->func_name); in PHP_FUNCTION()
2048 dupch->handlers->write->func_name = ch->handlers->write->func_name; in PHP_FUNCTION()
2050 if (ch->handlers->read->func_name) { in PHP_FUNCTION()
2051 zval_add_ref(&ch->handlers->read->func_name); in PHP_FUNCTION()
2052 dupch->handlers->read->func_name = ch->handlers->read->func_name; in PHP_FUNCTION()
2054 if (ch->handlers->write_header->func_name) { in PHP_FUNCTION()
2055 zval_add_ref(&ch->handlers->write_header->func_name); in PHP_FUNCTION()
2056 dupch->handlers->write_header->func_name = ch->handlers->write_header->func_name; in PHP_FUNCTION()
2064 if (ch->handlers->progress) { in PHP_FUNCTION()
2066 if (ch->handlers->progress->func_name) { in PHP_FUNCTION()
2067 zval_add_ref(&ch->handlers->progress->func_name); in PHP_FUNCTION()
2068 dupch->handlers->progress->func_name = ch->handlers->progress->func_name; in PHP_FUNCTION()
2070 dupch->handlers->progress->method = ch->handlers->progress->method; in PHP_FUNCTION()
2076 if (ch->handlers->fnmatch) { in PHP_FUNCTION()
2078 if (ch->handlers->fnmatch->func_name) { in PHP_FUNCTION()
2079 zval_add_ref(&ch->handlers->fnmatch->func_name); in PHP_FUNCTION()
2080 dupch->handlers->fnmatch->func_name = ch->handlers->fnmatch->func_name; in PHP_FUNCTION()
2082 dupch->handlers->fnmatch->method = ch->handlers->fnmatch->method; in PHP_FUNCTION()
2089 dupch->to_free = ch->to_free; in PHP_FUNCTION()
2092 Z_ADDREF_P(ch->clone); in PHP_FUNCTION()
2093 dupch->clone = ch->clone; in PHP_FUNCTION()
2100 static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue TSRMLS_DC) /* {{{ */ in _php_curl_setopt() argument
2112 error = curl_easy_setopt(ch->cp, option, 2); in _php_curl_setopt()
2270 error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); in _php_curl_setopt()
2274 ch->safe_upload = (Z_LVAL_PP(zvalue) != 0); in _php_curl_setopt()
2336 return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue), 0 TSRMLS_CC); in _php_curl_setopt()
2356 error = curl_easy_setopt(ch->cp, option, NULL); in _php_curl_setopt()
2359 return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue), 0 TSRMLS_CC); in _php_curl_setopt()
2367 return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue), 1 TSRMLS_CC); in _php_curl_setopt()
2372 return php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue) TSRMLS_CC); in _php_curl_setopt()
2402 if (ch->handlers->write->stream) { in _php_curl_setopt()
2403 Z_DELREF_P(ch->handlers->write->stream); in _php_curl_setopt()
2404 ch->handlers->write->stream = NULL; in _php_curl_setopt()
2406 ch->handlers->write->fp = NULL; in _php_curl_setopt()
2407 ch->handlers->write->method = PHP_CURL_STDOUT; in _php_curl_setopt()
2409 if (ch->handlers->write->stream) { in _php_curl_setopt()
2410 Z_DELREF_P(ch->handlers->write->stream); in _php_curl_setopt()
2413 ch->handlers->write->fp = fp; in _php_curl_setopt()
2414 ch->handlers->write->method = PHP_CURL_FILE; in _php_curl_setopt()
2415 ch->handlers->write->stream = *zvalue; in _php_curl_setopt()
2423 if (ch->handlers->write_header->stream) { in _php_curl_setopt()
2424 Z_DELREF_P(ch->handlers->write_header->stream); in _php_curl_setopt()
2425 ch->handlers->write_header->stream = NULL; in _php_curl_setopt()
2427 ch->handlers->write_header->fp = NULL; in _php_curl_setopt()
2428 ch->handlers->write_header->method = PHP_CURL_IGNORE; in _php_curl_setopt()
2430 if (ch->handlers->write_header->stream) { in _php_curl_setopt()
2431 Z_DELREF_P(ch->handlers->write_header->stream); in _php_curl_setopt()
2434 ch->handlers->write_header->fp = fp; in _php_curl_setopt()
2435 ch->handlers->write_header->method = PHP_CURL_FILE; in _php_curl_setopt()
2436 ch->handlers->write_header->stream = *zvalue; in _php_curl_setopt()
2444 if (ch->handlers->read->stream) { in _php_curl_setopt()
2445 Z_DELREF_P(ch->handlers->read->stream); in _php_curl_setopt()
2446 ch->handlers->read->stream = NULL; in _php_curl_setopt()
2448 ch->handlers->read->fp = NULL; in _php_curl_setopt()
2449 ch->handlers->read->fd = 0; in _php_curl_setopt()
2451 if (ch->handlers->read->stream) { in _php_curl_setopt()
2452 Z_DELREF_P(ch->handlers->read->stream); in _php_curl_setopt()
2455 ch->handlers->read->fp = fp; in _php_curl_setopt()
2456 ch->handlers->read->fd = Z_LVAL_PP(zvalue); in _php_curl_setopt()
2457 ch->handlers->read->stream = *zvalue; in _php_curl_setopt()
2462 if (ch->handlers->std_err) { in _php_curl_setopt()
2463 zval_ptr_dtor(&ch->handlers->std_err); in _php_curl_setopt()
2464 ch->handlers->std_err = NULL; in _php_curl_setopt()
2467 if (ch->handlers->std_err) { in _php_curl_setopt()
2468 zval_ptr_dtor(&ch->handlers->std_err); in _php_curl_setopt()
2471 ch->handlers->std_err = *zvalue; in _php_curl_setopt()
2478 error = curl_easy_setopt(ch->cp, option, fp); in _php_curl_setopt()
2552 …zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NU… in _php_curl_setopt()
2554 error = curl_easy_setopt(ch->cp, option, slist); in _php_curl_setopt()
2571 error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); in _php_curl_setopt()
2575 if (ch->handlers->write_header->func_name) { in _php_curl_setopt()
2576 zval_ptr_dtor(&ch->handlers->write_header->func_name); in _php_curl_setopt()
2577 ch->handlers->write_header->fci_cache = empty_fcall_info_cache; in _php_curl_setopt()
2580 ch->handlers->write_header->func_name = *zvalue; in _php_curl_setopt()
2581 ch->handlers->write_header->method = PHP_CURL_USER; in _php_curl_setopt()
2664 if (!ch->safe_upload && *postval == '@') { in _php_curl_setopt()
2707 SAVE_CURL_ERROR(ch, error); in _php_curl_setopt()
2712 if (Z_REFCOUNT_P(ch->clone) <= 1) { in _php_curl_setopt()
2713 zend_llist_clean(&ch->to_free->post); in _php_curl_setopt()
2715 zend_llist_add_element(&ch->to_free->post, &first); in _php_curl_setopt()
2716 error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first); in _php_curl_setopt()
2722 error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, Z_STRLEN_PP(zvalue)); in _php_curl_setopt()
2723 error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, Z_STRVAL_PP(zvalue)); in _php_curl_setopt()
2729 zend_llist_add_element(&ch->to_free->str, &post); in _php_curl_setopt()
2731 curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, post); in _php_curl_setopt()
2732 error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, Z_STRLEN_PP(zvalue)); in _php_curl_setopt()
2738 curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION, curl_progress); in _php_curl_setopt()
2739 curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch); in _php_curl_setopt()
2740 if (ch->handlers->progress == NULL) { in _php_curl_setopt()
2741 ch->handlers->progress = ecalloc(1, sizeof(php_curl_progress)); in _php_curl_setopt()
2742 } else if (ch->handlers->progress->func_name) { in _php_curl_setopt()
2743 zval_ptr_dtor(&ch->handlers->progress->func_name); in _php_curl_setopt()
2744 ch->handlers->progress->fci_cache = empty_fcall_info_cache; in _php_curl_setopt()
2747 ch->handlers->progress->func_name = *zvalue; in _php_curl_setopt()
2748 ch->handlers->progress->method = PHP_CURL_USER; in _php_curl_setopt()
2752 if (ch->handlers->read->func_name) { in _php_curl_setopt()
2753 zval_ptr_dtor(&ch->handlers->read->func_name); in _php_curl_setopt()
2754 ch->handlers->read->fci_cache = empty_fcall_info_cache; in _php_curl_setopt()
2757 ch->handlers->read->func_name = *zvalue; in _php_curl_setopt()
2758 ch->handlers->read->method = PHP_CURL_USER; in _php_curl_setopt()
2764 ch->handlers->write->method = PHP_CURL_RETURN; in _php_curl_setopt()
2766 ch->handlers->write->method = PHP_CURL_STDOUT; in _php_curl_setopt()
2771 if (ch->handlers->write->func_name) { in _php_curl_setopt()
2772 zval_ptr_dtor(&ch->handlers->write->func_name); in _php_curl_setopt()
2773 ch->handlers->write->fci_cache = empty_fcall_info_cache; in _php_curl_setopt()
2776 ch->handlers->write->func_name = *zvalue; in _php_curl_setopt()
2777 ch->handlers->write->method = PHP_CURL_USER; in _php_curl_setopt()
2784 error = curl_easy_setopt(ch->cp, option, (curl_off_t)Z_LVAL_PP(zvalue)); in _php_curl_setopt()
2791 error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_PP(zvalue) & CURL_REDIR_POST_ALL); in _php_curl_setopt()
2797 if (ch->handlers->passwd) { in _php_curl_setopt()
2798 zval_ptr_dtor(&ch->handlers->passwd); in _php_curl_setopt()
2801 ch->handlers->passwd = *zvalue; in _php_curl_setopt()
2802 error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDFUNCTION, curl_passwd); in _php_curl_setopt()
2803 error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) ch); in _php_curl_setopt()
2835 return php_curl_option_str(ch, option, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue), 0 TSRMLS_CC); in _php_curl_setopt()
2841 curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, curl_debug); in _php_curl_setopt()
2842 curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *)ch); in _php_curl_setopt()
2843 curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 1); in _php_curl_setopt()
2845 curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, NULL); in _php_curl_setopt()
2846 curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, NULL); in _php_curl_setopt()
2847 curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); in _php_curl_setopt()
2856 curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share); in _php_curl_setopt()
2863 curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_FUNCTION, curl_fnmatch); in _php_curl_setopt()
2864 curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, ch); in _php_curl_setopt()
2865 if (ch->handlers->fnmatch == NULL) { in _php_curl_setopt()
2866 ch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch)); in _php_curl_setopt()
2867 } else if (ch->handlers->fnmatch->func_name) { in _php_curl_setopt()
2868 zval_ptr_dtor(&ch->handlers->fnmatch->func_name); in _php_curl_setopt()
2869 ch->handlers->fnmatch->fci_cache = empty_fcall_info_cache; in _php_curl_setopt()
2872 ch->handlers->fnmatch->func_name = *zvalue; in _php_curl_setopt()
2873 ch->handlers->fnmatch->method = PHP_CURL_USER; in _php_curl_setopt()
2879 SAVE_CURL_ERROR(ch, error); in _php_curl_setopt()
2894 php_curl *ch; in PHP_FUNCTION() local
2900 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2907 if (_php_curl_setopt(ch, options, zvalue TSRMLS_CC) == SUCCESS) { in PHP_FUNCTION()
2920 php_curl *ch; in PHP_FUNCTION() local
2930 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2938 if (_php_curl_setopt(ch, (long) option, entry TSRMLS_CC) == FAILURE) { in PHP_FUNCTION()
2949 void _php_curl_cleanup_handle(php_curl *ch) in _php_curl_cleanup_handle() argument
2951 if (ch->handlers->write->buf.len > 0) { in _php_curl_cleanup_handle()
2952 smart_str_free(&ch->handlers->write->buf); in _php_curl_cleanup_handle()
2954 if (ch->header.str_len) { in _php_curl_cleanup_handle()
2955 efree(ch->header.str); in _php_curl_cleanup_handle()
2956 ch->header.str_len = 0; in _php_curl_cleanup_handle()
2959 memset(ch->err.str, 0, CURL_ERROR_SIZE + 1); in _php_curl_cleanup_handle()
2960 ch->err.no = 0; in _php_curl_cleanup_handle()
2970 php_curl *ch; in PHP_FUNCTION() local
2976 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2978 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in PHP_FUNCTION()
2980 _php_curl_cleanup_handle(ch); in PHP_FUNCTION()
2982 error = curl_easy_perform(ch->cp); in PHP_FUNCTION()
2983 SAVE_CURL_ERROR(ch, error); in PHP_FUNCTION()
2986 if (ch->handlers->write->buf.len > 0) { in PHP_FUNCTION()
2987 smart_str_free(&ch->handlers->write->buf); in PHP_FUNCTION()
2992 if (ch->handlers->std_err) { in PHP_FUNCTION()
2994 …stream = (php_stream*)zend_fetch_resource(&ch->handlers->std_err TSRMLS_CC, -1, NULL, NULL, 2, php… in PHP_FUNCTION()
3000 if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.len > 0) { in PHP_FUNCTION()
3001 smart_str_0(&ch->handlers->write->buf); in PHP_FUNCTION()
3002 RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 1); in PHP_FUNCTION()
3006 if (ch->handlers->write->method == PHP_CURL_FILE && ch->handlers->write->fp) { in PHP_FUNCTION()
3007 fflush(ch->handlers->write->fp); in PHP_FUNCTION()
3009 if (ch->handlers->write_header->method == PHP_CURL_FILE && ch->handlers->write_header->fp) { in PHP_FUNCTION()
3010 fflush(ch->handlers->write_header->fp); in PHP_FUNCTION()
3013 if (ch->handlers->write->method == PHP_CURL_RETURN) { in PHP_FUNCTION()
3026 php_curl *ch; in PHP_FUNCTION() local
3033 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
3046 if (curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_URL, &s_code) == CURLE_OK) { in PHP_FUNCTION()
3049 if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_TYPE, &s_code) == CURLE_OK) { in PHP_FUNCTION()
3059 if (curl_easy_getinfo(ch->cp, CURLINFO_HTTP_CODE, &l_code) == CURLE_OK) { in PHP_FUNCTION()
3062 if (curl_easy_getinfo(ch->cp, CURLINFO_HEADER_SIZE, &l_code) == CURLE_OK) { in PHP_FUNCTION()
3065 if (curl_easy_getinfo(ch->cp, CURLINFO_REQUEST_SIZE, &l_code) == CURLE_OK) { in PHP_FUNCTION()
3068 if (curl_easy_getinfo(ch->cp, CURLINFO_FILETIME, &l_code) == CURLE_OK) { in PHP_FUNCTION()
3071 if (curl_easy_getinfo(ch->cp, CURLINFO_SSL_VERIFYRESULT, &l_code) == CURLE_OK) { in PHP_FUNCTION()
3074 if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_COUNT, &l_code) == CURLE_OK) { in PHP_FUNCTION()
3077 if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3080 if (curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3083 if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3086 if (curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3089 if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_UPLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3092 if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3095 if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3098 if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_UPLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3101 if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3104 if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3107 if (curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3110 if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
3114 if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) { in PHP_FUNCTION()
3119 if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) { in PHP_FUNCTION()
3124 if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) { in PHP_FUNCTION()
3132 if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_PORT, &l_code) == CURLE_OK) { in PHP_FUNCTION()
3135 if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_IP, &s_code) == CURLE_OK) { in PHP_FUNCTION()
3138 if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_PORT, &l_code) == CURLE_OK) { in PHP_FUNCTION()
3142 if (ch->header.str_len > 0) { in PHP_FUNCTION()
3143 CAAS("request_header", ch->header.str); in PHP_FUNCTION()
3148 if (ch->header.str_len > 0) { in PHP_FUNCTION()
3149 RETURN_STRINGL(ch->header.str, ch->header.str_len, 1); in PHP_FUNCTION()
3159 if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) { in PHP_FUNCTION()
3174 if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) { in PHP_FUNCTION()
3185 if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) { in PHP_FUNCTION()
3196 if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) { in PHP_FUNCTION()
3208 if (curl_easy_getinfo(ch->cp, option, &slist) == CURLE_OK) { in PHP_FUNCTION()
3234 php_curl *ch; in PHP_FUNCTION() local
3240 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
3242 ch->err.str[CURL_ERROR_SIZE] = 0; in PHP_FUNCTION()
3243 RETURN_STRING(ch->err.str, 1); in PHP_FUNCTION()
3252 php_curl *ch; in PHP_FUNCTION() local
3258 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
3260 RETURN_LONG(ch->err.no); in PHP_FUNCTION()
3269 php_curl *ch; in PHP_FUNCTION() local
3275 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
3277 if (ch->in_callback) { in PHP_FUNCTION()
3288 static void _php_curl_close_ex(php_curl *ch TSRMLS_DC) in _php_curl_close_ex()
3291 fprintf(stderr, "DTOR CALLED, ch = %x\n", ch); in _php_curl_close_ex()
3294 _php_curl_verify_handlers(ch, 0 TSRMLS_CC); in _php_curl_close_ex()
3307 curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_nothing); in _php_curl_close_ex()
3308 curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write_nothing); in _php_curl_close_ex()
3310 curl_easy_cleanup(ch->cp); in _php_curl_close_ex()
3313 if (Z_REFCOUNT_P(ch->clone) <= 1) { in _php_curl_close_ex()
3314 zend_llist_clean(&ch->to_free->str); in _php_curl_close_ex()
3315 zend_llist_clean(&ch->to_free->post); in _php_curl_close_ex()
3316 zend_hash_destroy(ch->to_free->slist); in _php_curl_close_ex()
3317 efree(ch->to_free->slist); in _php_curl_close_ex()
3318 efree(ch->to_free); in _php_curl_close_ex()
3319 FREE_ZVAL(ch->clone); in _php_curl_close_ex()
3321 Z_DELREF_P(ch->clone); in _php_curl_close_ex()
3324 if (ch->handlers->write->buf.len > 0) { in _php_curl_close_ex()
3325 smart_str_free(&ch->handlers->write->buf); in _php_curl_close_ex()
3327 if (ch->handlers->write->func_name) { in _php_curl_close_ex()
3328 zval_ptr_dtor(&ch->handlers->write->func_name); in _php_curl_close_ex()
3330 if (ch->handlers->read->func_name) { in _php_curl_close_ex()
3331 zval_ptr_dtor(&ch->handlers->read->func_name); in _php_curl_close_ex()
3333 if (ch->handlers->write_header->func_name) { in _php_curl_close_ex()
3334 zval_ptr_dtor(&ch->handlers->write_header->func_name); in _php_curl_close_ex()
3337 if (ch->handlers->passwd) { in _php_curl_close_ex()
3338 zval_ptr_dtor(&ch->handlers->passwd); in _php_curl_close_ex()
3341 if (ch->handlers->std_err) { in _php_curl_close_ex()
3342 zval_ptr_dtor(&ch->handlers->std_err); in _php_curl_close_ex()
3344 if (ch->header.str_len > 0) { in _php_curl_close_ex()
3345 efree(ch->header.str); in _php_curl_close_ex()
3348 if (ch->handlers->write_header->stream) { in _php_curl_close_ex()
3349 zval_ptr_dtor(&ch->handlers->write_header->stream); in _php_curl_close_ex()
3351 if (ch->handlers->write->stream) { in _php_curl_close_ex()
3352 zval_ptr_dtor(&ch->handlers->write->stream); in _php_curl_close_ex()
3354 if (ch->handlers->read->stream) { in _php_curl_close_ex()
3355 zval_ptr_dtor(&ch->handlers->read->stream); in _php_curl_close_ex()
3358 efree(ch->handlers->write); in _php_curl_close_ex()
3359 efree(ch->handlers->write_header); in _php_curl_close_ex()
3360 efree(ch->handlers->read); in _php_curl_close_ex()
3362 if (ch->handlers->progress) { in _php_curl_close_ex()
3363 if (ch->handlers->progress->func_name) { in _php_curl_close_ex()
3364 zval_ptr_dtor(&ch->handlers->progress->func_name); in _php_curl_close_ex()
3366 efree(ch->handlers->progress); in _php_curl_close_ex()
3370 if (ch->handlers->fnmatch) { in _php_curl_close_ex()
3371 if (ch->handlers->fnmatch->func_name) { in _php_curl_close_ex()
3372 zval_ptr_dtor(&ch->handlers->fnmatch->func_name); in _php_curl_close_ex()
3374 efree(ch->handlers->fnmatch); in _php_curl_close_ex()
3378 efree(ch->handlers); in _php_curl_close_ex()
3379 efree(ch); in _php_curl_close_ex()
3387 php_curl *ch = (php_curl *) rsrc->ptr; in _php_curl_close() local
3388 _php_curl_close_ex(ch TSRMLS_CC); in _php_curl_close()
3417 static void _php_curl_reset_handlers(php_curl *ch) in _php_curl_reset_handlers() argument
3419 if (ch->handlers->write->stream) { in _php_curl_reset_handlers()
3420 Z_DELREF_P(ch->handlers->write->stream); in _php_curl_reset_handlers()
3421 ch->handlers->write->stream = NULL; in _php_curl_reset_handlers()
3423 ch->handlers->write->fp = NULL; in _php_curl_reset_handlers()
3424 ch->handlers->write->method = PHP_CURL_STDOUT; in _php_curl_reset_handlers()
3426 if (ch->handlers->write_header->stream) { in _php_curl_reset_handlers()
3427 Z_DELREF_P(ch->handlers->write_header->stream); in _php_curl_reset_handlers()
3428 ch->handlers->write_header->stream = NULL; in _php_curl_reset_handlers()
3430 ch->handlers->write_header->fp = NULL; in _php_curl_reset_handlers()
3431 ch->handlers->write_header->method = PHP_CURL_IGNORE; in _php_curl_reset_handlers()
3433 if (ch->handlers->read->stream) { in _php_curl_reset_handlers()
3434 Z_DELREF_P(ch->handlers->read->stream); in _php_curl_reset_handlers()
3435 ch->handlers->read->stream = NULL; in _php_curl_reset_handlers()
3437 ch->handlers->read->fp = NULL; in _php_curl_reset_handlers()
3438 ch->handlers->read->fd = 0; in _php_curl_reset_handlers()
3439 ch->handlers->read->method = PHP_CURL_DIRECT; in _php_curl_reset_handlers()
3441 if (ch->handlers->std_err) { in _php_curl_reset_handlers()
3442 zval_ptr_dtor(&ch->handlers->std_err); in _php_curl_reset_handlers()
3443 ch->handlers->std_err = NULL; in _php_curl_reset_handlers()
3446 if (ch->handlers->progress) { in _php_curl_reset_handlers()
3447 if (ch->handlers->progress->func_name) { in _php_curl_reset_handlers()
3448 zval_ptr_dtor(&ch->handlers->progress->func_name); in _php_curl_reset_handlers()
3450 efree(ch->handlers->progress); in _php_curl_reset_handlers()
3451 ch->handlers->progress = NULL; in _php_curl_reset_handlers()
3455 if (ch->handlers->fnmatch) { in _php_curl_reset_handlers()
3456 if (ch->handlers->fnmatch->func_name) { in _php_curl_reset_handlers()
3457 zval_ptr_dtor(&ch->handlers->fnmatch->func_name); in _php_curl_reset_handlers()
3459 efree(ch->handlers->fnmatch); in _php_curl_reset_handlers()
3460 ch->handlers->fnmatch = NULL; in _php_curl_reset_handlers()
3472 php_curl *ch; in PHP_FUNCTION() local
3478 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
3480 if (ch->in_callback) { in PHP_FUNCTION()
3485 curl_easy_reset(ch->cp); in PHP_FUNCTION()
3486 _php_curl_reset_handlers(ch); in PHP_FUNCTION()
3487 _php_curl_set_default_options(ch); in PHP_FUNCTION()
3500 php_curl *ch; in PHP_FUNCTION() local
3506 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
3508 if ((res = curl_easy_escape(ch->cp, str, str_len))) { in PHP_FUNCTION()
3524 php_curl *ch; in PHP_FUNCTION() local
3530 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
3532 if ((out = curl_easy_unescape(ch->cp, str, str_len, &out_len))) { in PHP_FUNCTION()
3549 php_curl *ch; in PHP_FUNCTION() local
3555 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
3557 RETURN_LONG(curl_easy_pause(ch->cp, bitmask)); in PHP_FUNCTION()