#define CAAZ(s, v) add_assoc_zval_ex(return_value, s, sizeof(s), (zval *) v);
#if defined(PHP_WIN32) || defined(__GNUC__)
- #define php_curl_ret(__ret) RETVAL_FALSE; return __ret;
+# define php_curl_ret(__ret) RETVAL_FALSE; return __ret;
#else
- #define php_curl_ret(__ret) RETVAL_FALSE; return;
+# define php_curl_ret(__ret) RETVAL_FALSE; return;
#endif
-static int php_curl_option_url(php_curl *ch, const char *url, const int len) {
- CURLcode error=CURLE_OK;
+static int php_curl_option_url(php_curl *ch, const char *url, const int len) /* {{{ */
+{
+ CURLcode error = CURLE_OK;
#if LIBCURL_VERSION_NUM < 0x071100
char *copystr = NULL;
#endif
return (error == CURLE_OK ? 1 : 0);
}
+/* }}} */
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_curl_version, 0, 0, 0)
ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_close, 0)
ZEND_ARG_INFO(0, mh)
ZEND_END_ARG_INFO()
-
/* }}} */
/* {{{ curl_functions[]
php_info_print_table_row(2, "Age", str);
/* To update on each new cURL release using src/main.c in cURL sources */
- if(d->features) {
+ if (d->features) {
struct feat {
const char *name;
int bitmask;
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);
-
/* See http://curl.haxx.se/lxr/source/docs/libcurl/symbols-in-versions
or curl src/docs/libcurl/symbols-in-versions for a (almost) complete list
of options and which version they were introduced */
/* {{{ curl_progress
*/
-static size_t curl_progress(void *clientp,
- double dltotal,
- double dlnow,
- double ultotal,
- double ulnow)
+static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
php_curl *ch = (php_curl *) clientp;
php_curl_progress *t = ch->handlers->progress;
if (Z_TYPE_P(retval_ptr) != IS_LONG) {
convert_to_long_ex(&retval_ptr);
}
- if(0 != Z_LVAL_P(retval_ptr))
+ if (0 != Z_LVAL_P(retval_ptr)) {
rval = 1;
+ }
zval_ptr_dtor(&retval_ptr);
}
zval_ptr_dtor(argv[0]);
}
/* }}} */
-
/* {{{ curl_read
*/
static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
Initialize a cURL session */
PHP_FUNCTION(curl_init)
{
- php_curl *ch;
- CURL *cp;
- char *url = NULL;
- int url_len = 0;
+ php_curl *ch;
+ CURL *cp;
+ char *url = NULL;
+ int url_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &url, &url_len) == FAILURE) {
return;
Copy a cURL handle along with all of it's preferences */
PHP_FUNCTION(curl_copy_handle)
{
- zval *zid;
- CURL *cp;
- php_curl *ch;
- php_curl *dupch;
+ CURL *cp;
+ zval *zid;
+ php_curl *ch, *dupch;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zid) == FAILURE) {
return;
}
+
ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl);
cp = curl_easy_duphandle(ch->cp);
PHP_FUNCTION(curl_setopt)
{
zval *zid, **zvalue;
- long zoption;
- php_curl *ch;
+ long options;
+ php_curl *ch;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlZ", &zid, &zoption, &zvalue) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlZ", &zid, &options, &zvalue) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl);
- if (!_php_curl_setopt(ch, zoption, zvalue, return_value TSRMLS_CC)) {
+ if (!_php_curl_setopt(ch, options, zvalue, return_value TSRMLS_CC)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
{
zval *zid, *arr, **entry;
php_curl *ch;
- long option;
+ ulong option;
HashPosition pos;
- char *string_key;
- uint str_key_len;
+ char *string_key;
+ uint str_key_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "za", &zid, &arr) == FAILURE) {
- RETURN_FALSE;
+ return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl);
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) {
+ if (zend_hash_get_current_key_ex(Z_ARRVAL_P(arr), &string_key, &str_key_len, &option, 0, &pos) != HASH_KEY_IS_LONG) {
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)) {
+ if (_php_curl_setopt(ch, (long) option, entry, return_value TSRMLS_CC)) {
RETURN_FALSE;
}
zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos);
Perform a cURL session */
PHP_FUNCTION(curl_exec)
{
- zval *zid;
- php_curl *ch;
- CURLcode error;
+ CURLcode error;
+ zval *zid;
+ php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zid) == FAILURE) {
return;
Get information regarding a specific transfer */
PHP_FUNCTION(curl_getinfo)
{
- zval *zid;
- php_curl *ch;
- long option = 0;
+ zval *zid;
+ php_curl *ch;
+ long option = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zid, &option) == FAILURE) {
return;
Return a string contain the last error for the current session */
PHP_FUNCTION(curl_error)
{
- zval *zid;
- php_curl *ch;
+ zval *zid;
+ php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zid) == FAILURE) {
return;
Return an integer containing the last error number */
PHP_FUNCTION(curl_errno)
{
- zval *zid;
- php_curl *ch;
+ zval *zid;
+ php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zid) == FAILURE) {
return;
Close a cURL session */
PHP_FUNCTION(curl_close)
{
- zval *zid;
- php_curl *ch;
+ zval *zid;
+ php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zid) == FAILURE) {
return;