- add flush() to HttpDeflateStream and HttpInflateStream
[m6w6/ext-http] / php_http_url_api.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: http |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2005, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 /* $Id$ */
14
15 #ifndef PHP_HTTP_URL_API_H
16 #define PHP_HTTP_URL_API_H
17
18 #include "ext/standard/url.h"
19
20 #define http_absolute_url(u) _http_absolute_url((u) TSRMLS_CC)
21 PHP_HTTP_API char *_http_absolute_url(const char *url TSRMLS_DC);
22
23 #define http_build_url(o, n, p, s, l) _http_build_url((o), (n), (p), (s), (l) TSRMLS_CC)
24 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);
25
26 #define http_urlencode_hash(h, q) _http_urlencode_hash_ex((h), 1, NULL, 0, (q), NULL TSRMLS_CC)
27 #define http_urlencode_hash_ex(h, o, p, pl, q, ql) _http_urlencode_hash_ex((h), (o), (p), (pl), (q), (ql) TSRMLS_CC)
28 PHP_HTTP_API STATUS _http_urlencode_hash_ex(HashTable *hash, zend_bool override_argsep, char *pre_encoded_data, size_t pre_encoded_len, char **encoded_data, size_t *encoded_len TSRMLS_DC);
29
30 #define http_urlencode_hash_recursive(ht, s, as, al, pr, pl) _http_urlencode_hash_recursive((ht), (s), (as), (al), (pr), (pl) TSRMLS_CC)
31 PHP_HTTP_API STATUS _http_urlencode_hash_recursive(HashTable *ht, phpstr *str, const char *arg_sep, size_t arg_sep_len, const char *prefix, size_t prefix_len TSRMLS_DC);
32
33 #define array2url(ht) _array2url((ht) TSRMLS_CC)
34 static inline php_url *_array2url(HashTable *ht TSRMLS_DC)
35 {
36 zval **e;
37 php_url *url = ecalloc(1, sizeof(php_url));
38
39 if ((SUCCESS == zend_hash_find(ht, "scheme", sizeof("scheme"), (void **) &e))
40 && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
41 url->scheme = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
42 }
43 if ((SUCCESS == zend_hash_find(ht, "user", sizeof("user"), (void **) &e))
44 && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
45 url->user = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
46 }
47 if ((SUCCESS == zend_hash_find(ht, "pass", sizeof("pass"), (void **) &e))
48 && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
49 url->pass = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
50 }
51 if ((SUCCESS == zend_hash_find(ht, "host", sizeof("host"), (void **) &e))
52 && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
53 url->host = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
54 }
55 if ((SUCCESS == zend_hash_find(ht, "path", sizeof("path"), (void **) &e))
56 && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
57 url->path = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
58 }
59 if ((SUCCESS == zend_hash_find(ht, "query", sizeof("query"), (void **) &e))
60 && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
61 url->query = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
62 }
63 if ((SUCCESS == zend_hash_find(ht, "fragment", sizeof("fragment"), (void **) &e))
64 && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
65 url->fragment = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
66 }
67 if (SUCCESS == zend_hash_find(ht, "port", sizeof("port"), (void **) &e)) {
68 if (Z_TYPE_PP(e) == IS_LONG) {
69 url->port = (unsigned short) Z_LVAL_PP(e);
70 } else {
71 zval *o = *e;
72
73 convert_to_long_ex(e);
74 url->port = (unsigned short) Z_LVAL_PP(e);
75 if (o != *e) zval_ptr_dtor(e);
76 }
77 }
78
79 return url;
80 }
81
82 #endif
83
84 /*
85 * Local variables:
86 * tab-width: 4
87 * c-basic-offset: 4
88 * End:
89 * vim600: noet sw=4 ts=4 fdm=marker
90 * vim<600: noet sw=4 ts=4
91 */
92