static int php_curl_option_url(php_curl *ch, const char *url, const int len TSRMLS_DC) /* {{{ */
{
	CURLcode error = CURLE_OK;
#if LIBCURL_VERSION_NUM < 0x071100
	char *copystr = NULL;
#endif

	if (strlen(url) != len) {
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Curl option contains invalid characters (\\0)");
		return 0;
	}

	/* Disable file:// if open_basedir are used */
	if (PG(open_basedir) && *PG(open_basedir)) {
#if LIBCURL_VERSION_NUM >= 0x071304
		error = curl_easy_setopt(ch->cp, CURLOPT_PROTOCOLS, CURLPROTO_ALL & ~CURLPROTO_FILE);
#else
		php_url *uri;

		if (!(uri = php_url_parse_ex(url, len))) {
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid URL '%s'", url);
			return 0;
		}

		if (uri->scheme && !strncasecmp("file", uri->scheme, sizeof("file"))) {
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Protocol 'file' disabled in cURL");
			php_url_free(uri);
			return 0;
		}
		php_url_free(uri);
#endif
	}
	/* Strings passed to libcurl as 'char *' arguments, are copied by the library... NOTE: before 7.17.0 strings were not copied. */
#if LIBCURL_VERSION_NUM >= 0x071100
	error = curl_easy_setopt(ch->cp, CURLOPT_URL, url);
#else
	copystr = estrndup(url, len);
	error = curl_easy_setopt(ch->cp, CURLOPT_URL, copystr);
	zend_llist_add_element(&ch->to_free->str, &copystr);
#endif

	return (error == CURLE_OK ? 1 : 0);
}
static int php_curl_option_url(php_curl *ch, const char *url, const int len TSRMLS_DC)  
{
	CURLcode error = CURLE_OK;
#if LIBCURL_VERSION_NUM < 0x071100
	char *copystr = NULL;
#endif

	if (strlen(url) != len) {
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Curl option contains invalid characters (\\0)");
		return 0;
	}

	 
	if (PG(open_basedir) && *PG(open_basedir)) {
#if LIBCURL_VERSION_NUM >= 0x071304
		error = curl_easy_setopt(ch->cp, CURLOPT_PROTOCOLS, CURLPROTO_ALL & ~CURLPROTO_FILE);
#else
		php_url *uri;

		if (!(uri = php_url_parse_ex(url, len))) {
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid URL '%s'", url);
			return 0;
		}

		if (uri->scheme && !strncasecmp("file", uri->scheme, sizeof("file"))) {
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Protocol 'file' disabled in cURL");
			php_url_free(uri);
			return 0;
		}
		php_url_free(uri);
#endif
	}
	 
#if LIBCURL_VERSION_NUM >= 0x071100
	error = curl_easy_setopt(ch->cp, CURLOPT_URL, url);
#else
	copystr = estrndup(url, len);
	error = curl_easy_setopt(ch->cp, CURLOPT_URL, copystr);
	zend_llist_add_element(&ch->to_free->str, &copystr);
#endif

	return (error == CURLE_OK ? 1 : 0);
}