summaryrefslogtreecommitdiff
path: root/ext/standard/url.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/url.c')
-rw-r--r--ext/standard/url.c66
1 files changed, 44 insertions, 22 deletions
diff --git a/ext/standard/url.c b/ext/standard/url.c
index 8b491baefc..a3a19a2b22 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -340,10 +340,13 @@ PHP_FUNCTION(parse_url)
size_t str_len;
php_url *resource;
zend_long key = -1;
+ zval tmp;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &str_len, &key) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_STRING(str, str_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(key)
+ ZEND_PARSE_PARAMETERS_END();
resource = php_url_parse_ex(str, str_len);
if (resource == NULL) {
@@ -388,22 +391,38 @@ PHP_FUNCTION(parse_url)
array_init(return_value);
/* add the various elements to the array */
- if (resource->scheme != NULL)
- add_assoc_string(return_value, "scheme", resource->scheme);
- if (resource->host != NULL)
- add_assoc_string(return_value, "host", resource->host);
- if (resource->port != 0)
- add_assoc_long(return_value, "port", resource->port);
- if (resource->user != NULL)
- add_assoc_string(return_value, "user", resource->user);
- if (resource->pass != NULL)
- add_assoc_string(return_value, "pass", resource->pass);
- if (resource->path != NULL)
- add_assoc_string(return_value, "path", resource->path);
- if (resource->query != NULL)
- add_assoc_string(return_value, "query", resource->query);
- if (resource->fragment != NULL)
- add_assoc_string(return_value, "fragment", resource->fragment);
+ if (resource->scheme != NULL) {
+ ZVAL_STRING(&tmp, resource->scheme);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_SCHEME), &tmp);
+ }
+ if (resource->host != NULL) {
+ ZVAL_STRING(&tmp, resource->host);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_HOST), &tmp);
+ }
+ if (resource->port != 0) {
+ ZVAL_LONG(&tmp, resource->port);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_PORT), &tmp);
+ }
+ if (resource->user != NULL) {
+ ZVAL_STRING(&tmp, resource->user);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_USER), &tmp);
+ }
+ if (resource->pass != NULL) {
+ ZVAL_STRING(&tmp, resource->pass);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_PASS), &tmp);
+ }
+ if (resource->path != NULL) {
+ ZVAL_STRING(&tmp, resource->path);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_PATH), &tmp);
+ }
+ if (resource->query != NULL) {
+ ZVAL_STRING(&tmp, resource->query);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_QUERY), &tmp);
+ }
+ if (resource->fragment != NULL) {
+ ZVAL_STRING(&tmp, resource->fragment);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_FRAGMENT), &tmp);
+ }
done:
php_url_free(resource);
}
@@ -660,9 +679,12 @@ PHP_FUNCTION(get_headers)
zval *zcontext = NULL;
php_stream_context *context;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lr!", &url, &url_len, &format, &zcontext) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 3)
+ Z_PARAM_STRING(url, url_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(format)
+ Z_PARAM_RESOURCE_EX(zcontext, 1, 0)
+ ZEND_PARSE_PARAMETERS_END();
context = php_stream_context_from_zval(zcontext, 0);