| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
- | Copyright (c) 2004-2005, Michael Wallner <mike@php.net> |
+ | Copyright (c) 2004-2006, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
*/
#include "ext/standard/url.h"
+extern PHP_MINIT_FUNCTION(http_url);
+
#define http_absolute_url(u) _http_absolute_url((u) TSRMLS_CC)
PHP_HTTP_API char *_http_absolute_url(const char *url TSRMLS_DC);
-#define http_build_url(o, n, p, s, l) _http_build_url((o), (n), (p), (s), (l) TSRMLS_CC)
-PHP_HTTP_API void _http_build_url(const php_url *old_url, const php_url *new_url, php_url **url_ptr, char **url_str, size_t *url_len TSRMLS_DC);
+#define HTTP_URL_REPLACE 0x000
+#define HTTP_URL_JOIN_PATH 0x001
+#define HTTP_URL_JOIN_QUERY 0x002
+#define HTTP_URL_STRIP_USER 0x004
+#define HTTP_URL_STRIP_PASS 0x008
+#define HTTP_URL_STRIP_AUTH 0x010
+#define HTTP_URL_STRIP_PORT 0x020
+#define HTTP_URL_STRIP_PATH 0x040
+#define HTTP_URL_STRIP_QUERY 0x080
+#define HTTP_URL_STRIP_FRAGMENT 0x100
+
+#define http_build_url(f, o, n, p, s, l) _http_build_url((f), (o), (n), (p), (s), (l) TSRMLS_CC)
+PHP_HTTP_API void _http_build_url(int flags, const php_url *old_url, const php_url *new_url, php_url **url_ptr, char **url_str, size_t *url_len TSRMLS_DC);
#define http_urlencode_hash(h, q) _http_urlencode_hash_ex((h), 1, NULL, 0, (q), NULL TSRMLS_CC)
#define http_urlencode_hash_ex(h, o, p, pl, q, ql) _http_urlencode_hash_ex((h), (o), (p), (pl), (q), (ql) TSRMLS_CC)
zval **e;
php_url *url = ecalloc(1, sizeof(php_url));
- if ((SUCCESS == zend_hash_find(ht, "scheme", sizeof("scheme"), (void **) &e))
+ if ((SUCCESS == zend_hash_find(ht, "scheme", sizeof("scheme"), (void *) &e))
&& (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
url->scheme = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
}
- if ((SUCCESS == zend_hash_find(ht, "user", sizeof("user"), (void **) &e))
+ if ((SUCCESS == zend_hash_find(ht, "user", sizeof("user"), (void *) &e))
&& (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
url->user = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
}
- if ((SUCCESS == zend_hash_find(ht, "pass", sizeof("pass"), (void **) &e))
+ if ((SUCCESS == zend_hash_find(ht, "pass", sizeof("pass"), (void *) &e))
&& (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
url->pass = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
}
- if ((SUCCESS == zend_hash_find(ht, "host", sizeof("host"), (void **) &e))
+ if ((SUCCESS == zend_hash_find(ht, "host", sizeof("host"), (void *) &e))
&& (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
url->host = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
}
- if ((SUCCESS == zend_hash_find(ht, "path", sizeof("path"), (void **) &e))
+ if ((SUCCESS == zend_hash_find(ht, "path", sizeof("path"), (void *) &e))
&& (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
url->path = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
}
- if ((SUCCESS == zend_hash_find(ht, "query", sizeof("query"), (void **) &e))
+ if ((SUCCESS == zend_hash_find(ht, "query", sizeof("query"), (void *) &e))
&& (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
url->query = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
}
- if ((SUCCESS == zend_hash_find(ht, "fragment", sizeof("fragment"), (void **) &e))
+ if ((SUCCESS == zend_hash_find(ht, "fragment", sizeof("fragment"), (void *) &e))
&& (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
url->fragment = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
}
- if (SUCCESS == zend_hash_find(ht, "port", sizeof("port"), (void **) &e)) {
+ if (SUCCESS == zend_hash_find(ht, "port", sizeof("port"), (void *) &e)) {
if (Z_TYPE_PP(e) == IS_LONG) {
url->port = (unsigned short) Z_LVAL_PP(e);
} else {