X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_url_api.h;h=a4c5df0b3690997c9f7a00dfcab08c25b56176c4;hp=72cb5386cc395b995c2dfa3742869a6e95d66ae5;hb=669d2e6a8bdc642b6b52693f4593f199ddd7e8d2;hpb=bf87f6e654235acb023ca052a5e71faeb2635a3f diff --git a/php_http_url_api.h b/php_http_url_api.h index 72cb538..a4c5df0 100644 --- a/php_http_url_api.h +++ b/php_http_url_api.h @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2005, Michael Wallner | + | Copyright (c) 2004-2006, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -17,11 +17,24 @@ #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) @@ -36,35 +49,35 @@ static inline php_url *_array2url(HashTable *ht TSRMLS_DC) 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 {