]>
Commit | Line | Data |
---|---|---|
715d9963 JR |
1 | diff -urN php-pecl-idn-0.1/idn-0.1/config.m4 php-pecl-idn-cvs/idn-0.1/config.m4 |
2 | --- php-pecl-idn-0.1/idn-0.1/config.m4 2004-04-26 17:41:17.000000000 +0200 | |
3 | +++ php-pecl-idn-cvs/idn-0.1/config.m4 2004-04-27 21:36:38.000000000 +0200 | |
4 | @@ -1,12 +1,13 @@ | |
5 | -dnl $Id$ | |
6 | +dnl $Id$ | |
7 | dnl config.m4 for extension idn | |
8 | ||
9 | -PHP_ARG_WITH(idn, for idn support, | |
10 | -[ --with-idn Include GNU Libidn support]) | |
11 | +PHP_ARG_WITH(idn, for GNU Libidn support, | |
12 | +[ --with-idn[=DIR] Include GNU Libidn support]) | |
13 | ||
14 | if test "$PHP_IDN" != "no"; then | |
15 | SEARCH_PATH="/usr/local /usr" | |
16 | - SEARCH_FOR="/include/idn.h" | |
17 | + SEARCH_FOR="/include/idna.h" | |
18 | + | |
19 | if test -r $PHP_IDN/$SEARCH_FOR; then # path given as parameter | |
20 | IDN_DIR=$PHP_IDN | |
21 | else | |
22 | @@ -19,9 +20,17 @@ | |
23 | done | |
24 | fi | |
25 | ||
26 | - if test "PHP_IDN" == "no"; then | |
27 | + if test -z "$IDN_DIR"; then | |
28 | AC_MSG_RESULT([not found]) | |
29 | - AC_MSG_ERROR([Please reinstall the GNU libidn distribution]) | |
30 | + AC_MSG_ERROR([Please reinstall the GNU Libidn distribution]) | |
31 | + fi | |
32 | + | |
33 | + AC_MSG_CHECKING([for optional tld files]) | |
34 | + if test -r "$IDN_DIR/include/tld.h"; then | |
35 | + AC_MSG_RESULT(yes) | |
36 | + AC_DEFINE(HAVE_TLD,1,[ ]) | |
37 | + else | |
38 | + AC_MSG_RESULT([no]) | |
39 | fi | |
40 | ||
41 | PHP_ADD_INCLUDE($IDN_DIR/include) | |
42 | diff -urN php-pecl-idn-0.1/idn-0.1/EXPERIMENTAL php-pecl-idn-cvs/idn-0.1/EXPERIMENTAL | |
43 | --- php-pecl-idn-0.1/idn-0.1/EXPERIMENTAL 2004-04-26 17:17:39.000000000 +0200 | |
44 | +++ php-pecl-idn-cvs/idn-0.1/EXPERIMENTAL 2004-04-27 02:19:11.000000000 +0200 | |
45 | @@ -0,0 +1,5 @@ | |
46 | +This extension is experimental, | |
47 | +its functions may change their names | |
48 | +or move to extension all together | |
49 | +so do not rely to much on them | |
50 | +you have been warned! | |
51 | diff -urN php-pecl-idn-0.1/idn-0.1/idn.c php-pecl-idn-cvs/idn-0.1/idn.c | |
52 | --- php-pecl-idn-0.1/idn-0.1/idn.c 2004-04-26 17:41:17.000000000 +0200 | |
53 | +++ php-pecl-idn-cvs/idn-0.1/idn.c 2008-03-31 11:43:28.000000000 +0200 | |
54 | @@ -16,7 +16,7 @@ | |
55 | +----------------------------------------------------------------------+ | |
56 | */ | |
57 | ||
58 | -/* $Id$ */ | |
59 | +/* $Id$ */ | |
60 | ||
61 | #ifdef HAVE_CONFIG_H | |
62 | #include "config.h" | |
63 | @@ -59,7 +59,7 @@ | |
64 | PHP_RSHUTDOWN(idn), /* Replace with NULL if there's nothing to do at request end */ | |
65 | PHP_MINFO(idn), | |
66 | #if ZEND_MODULE_API_NO >= 20010901 | |
67 | - "0.1", /* Replace with version number for your extension */ | |
68 | + PHP_IDN_VERSION, | |
69 | #endif | |
70 | STANDARD_MODULE_PROPERTIES | |
71 | }; | |
72 | @@ -153,8 +153,9 @@ | |
73 | PHP_MINFO_FUNCTION(idn) | |
74 | { | |
75 | php_info_print_table_start(); | |
76 | - php_info_print_table_header(2, "GNU libidn support", "enabled"); | |
77 | - php_info_print_table_row(2, "GNU libidn version", STRINGPREP_VERSION); | |
78 | + php_info_print_table_header(2, "GNU Libidn support", "enabled"); | |
79 | + php_info_print_table_row(2, "GNU Libidn version", STRINGPREP_VERSION); | |
80 | + php_info_print_table_row(2, "Extension version", PHP_IDN_VERSION); | |
81 | php_info_print_table_end(); | |
82 | ||
83 | /* Remove comments if you have entries in php.ini | |
84 | @@ -167,94 +168,84 @@ | |
85 | Converts an UTF-8 encoded string to corresponding ASCII name */ | |
86 | PHP_FUNCTION(idn_to_ascii) | |
87 | { | |
88 | - /* The domain name the user enters */ | |
89 | + /* The domainname the user enters */ | |
90 | char *domain = NULL; | |
91 | int domain_len, len; | |
92 | ||
93 | /* PHP reference for error code */ | |
94 | - zval *errorcode = NULL; | |
95 | - | |
96 | - /* For returning error messages */ | |
97 | - char string[256]; | |
98 | + zval *php_errorcode = NULL; | |
99 | ||
100 | /* libidn return values */ | |
101 | - char *p; | |
102 | - int rc; | |
103 | - size_t i; | |
104 | + char *punycode; /* Punycode represantation of domain String */ | |
105 | + int idna_returncode; /* Returned value from idna_to_ascii call */ | |
106 | ||
107 | ||
108 | - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &domain, &domain_len, &errorcode) == FAILURE) { | |
109 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &domain, &domain_len, &php_errorcode) == FAILURE) { | |
110 | return; | |
111 | } | |
112 | ||
113 | - if (errorcode != NULL && !PZVAL_IS_REF(errorcode)) { | |
114 | - zend_error(E_WARNING, "Second parameter wasn't passed by reference"); | |
115 | + if (php_errorcode != NULL && !PZVAL_IS_REF(php_errorcode)) { | |
116 | + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Second parameter wasn't passed by reference"); | |
117 | RETURN_FALSE; | |
118 | } | |
119 | ||
120 | - rc = idna_to_ascii_8z(domain, &p, 0); | |
121 | - if (rc != IDNA_SUCCESS) { | |
122 | - free(p); | |
123 | - | |
124 | - len = sprintf(string, "Couldn't convert domainname"); | |
125 | - if (errorcode != NULL) { | |
126 | - ZVAL_LONG(errorcode, rc); | |
127 | + idna_returncode = idna_to_ascii_8z(domain, &punycode, 0); | |
128 | + if (idna_returncode != IDNA_SUCCESS) { | |
129 | + free(punycode); | |
130 | + | |
131 | + if (php_errorcode != NULL) { | |
132 | + ZVAL_LONG(php_errorcode, idna_returncode); | |
133 | } | |
134 | ||
135 | - zend_error(E_WARNING, string); | |
136 | + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not convert domainname"); | |
137 | RETURN_FALSE; | |
138 | } | |
139 | ||
140 | - RETVAL_STRINGL(p, strlen(p), 1); | |
141 | - free(p); | |
142 | + RETVAL_STRING(punycode, 1); | |
143 | + free(punycode); | |
144 | return; | |
145 | } | |
146 | /* }}} */ | |
147 | ||
148 | /* {{{ proto string idn_to_utf8(string arg) | |
149 | - Converts an ASCII compatible domain name to UTF-8 */ | |
150 | + Converts an ASCII compatible domainname to UTF-8 */ | |
151 | PHP_FUNCTION(idn_to_utf8) | |
152 | { | |
153 | - /* The domain name the user enters */ | |
154 | + /* The domainname the user enters */ | |
155 | char *domain = NULL; | |
156 | int domain_len, len; | |
157 | ||
158 | /* PHP reference for error code */ | |
159 | - zval *errorcode = NULL; | |
160 | - | |
161 | - /* For returning error messages */ | |
162 | - char string[256]; | |
163 | + zval *php_errorcode = NULL; | |
164 | ||
165 | /* libidn return values */ | |
166 | - char *p; | |
167 | - int rc; | |
168 | - size_t i; | |
169 | + char *utf8; /* UTF-8 representation of domain */ | |
170 | + int idna_returncode; /* Returned value from idna_to_unicode call */ | |
171 | ||
172 | ||
173 | - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &domain, &domain_len, &errorcode) == FAILURE) { | |
174 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &domain, &domain_len, &php_errorcode) == FAILURE) { | |
175 | return; | |
176 | } | |
177 | ||
178 | - if (errorcode != NULL && !PZVAL_IS_REF(errorcode)) { | |
179 | - zend_error(E_WARNING, "Second parameter wasn't passed by reference"); | |
180 | + if (php_errorcode != NULL && !PZVAL_IS_REF(php_errorcode)) { | |
181 | + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Second parameter wasn't passed by reference"); | |
182 | RETURN_FALSE; | |
183 | } | |
184 | ||
185 | - rc = idna_to_unicode_8z8z(domain, &p, 0); | |
186 | - if (rc != IDNA_SUCCESS) { | |
187 | - free(p); | |
188 | - | |
189 | - len = sprintf(string, "Couldn't convert domainname"); | |
190 | - if (errorcode != NULL) { | |
191 | - ZVAL_LONG(errorcode, rc); | |
192 | + idna_returncode = idna_to_unicode_8z8z(domain, &utf8, 0); | |
193 | + if (idna_returncode != IDNA_SUCCESS) { | |
194 | + free(utf8); | |
195 | + | |
196 | + if (php_errorcode != NULL) { | |
197 | + ZVAL_LONG(php_errorcode, idna_returncode); | |
198 | } | |
199 | ||
200 | - zend_error(E_WARNING, string); | |
201 | + php_error_docref(NULL TSRMLS_CC, E_WARNING, 'Could not convert domainname'); | |
202 | RETURN_FALSE; | |
203 | } | |
204 | ||
205 | - RETVAL_STRINGL(p, strlen(p), 1); | |
206 | - free(p); | |
207 | + RETVAL_STRING(utf8, 1); | |
208 | + free(utf8); | |
209 | return; | |
210 | } | |
211 | /* }}} */ | |
212 | diff -urN php-pecl-idn-0.1/idn-0.1/idn.php php-pecl-idn-cvs/idn-0.1/idn.php | |
213 | --- php-pecl-idn-0.1/idn-0.1/idn.php 1970-01-01 01:00:00.000000000 +0100 | |
214 | +++ php-pecl-idn-cvs/idn-0.1/idn.php 2004-04-26 17:41:17.000000000 +0200 | |
215 | @@ -0,0 +1,19 @@ | |
216 | +<? | |
217 | +if(!extension_loaded('idn')) { | |
218 | + dl('idn.' . PHP_SHLIB_SUFFIX); | |
219 | +} | |
220 | +$module = 'idn'; | |
221 | +$functions = get_extension_funcs($module); | |
222 | +echo "Functions available in the test extension:<br>\n"; | |
223 | +foreach($functions as $func) { | |
224 | + echo $func."<br>\n"; | |
225 | +} | |
226 | +echo "<br>\n"; | |
227 | +$function = 'confirm_' . $module . '_compiled'; | |
228 | +if (extension_loaded($module)) { | |
229 | + $str = $function($module); | |
230 | +} else { | |
231 | + $str = "Module $module is not compiled into PHP"; | |
232 | +} | |
233 | +echo "$str\n"; | |
234 | +?> | |
235 | diff -urN php-pecl-idn-0.1/idn-0.1/php_idn.h php-pecl-idn-cvs/idn-0.1/php_idn.h | |
236 | --- php-pecl-idn-0.1/idn-0.1/php_idn.h 2004-04-26 17:41:17.000000000 +0200 | |
237 | +++ php-pecl-idn-cvs/idn-0.1/php_idn.h 2008-03-31 11:43:28.000000000 +0200 | |
238 | @@ -16,7 +16,7 @@ | |
239 | +----------------------------------------------------------------------+ | |
240 | */ | |
241 | ||
242 | -/* $Id$ */ | |
243 | +/* $Id$ */ | |
244 | ||
245 | #ifndef PHP_IDN_H | |
246 | #define PHP_IDN_H | |
247 | @@ -24,6 +24,8 @@ | |
248 | extern zend_module_entry idn_module_entry; | |
249 | #define phpext_idn_ptr &idn_module_entry | |
250 | ||
251 | +#define PHP_IDN_VERSION "0.2.0-dev" | |
252 | + | |
253 | #ifdef PHP_WIN32 | |
254 | #define PHP_IDN_API __declspec(dllexport) | |
255 | #else | |
256 | diff -urN php-pecl-idn-0.1/idn-0.1/tests/001.phpt php-pecl-idn-cvs/idn-0.1/tests/001.phpt | |
257 | --- php-pecl-idn-0.1/idn-0.1/tests/001.phpt 2004-04-26 17:17:41.000000000 +0200 | |
258 | +++ php-pecl-idn-cvs/idn-0.1/tests/001.phpt 2004-04-27 02:19:11.000000000 +0200 | |
259 | @@ -1,5 +1,5 @@ | |
260 | --TEST-- | |
261 | -Check for GNU libidn | |
262 | +idn: Testing idn_to_ascii & idn_to_utf8 | |
263 | --SKIPIF-- | |
264 | <?php @dl('idn.so'); if (!extension_loaded("idn")) print "skip"; ?> | |
265 | --POST-- | |
266 | diff -urN php-pecl-idn-0.1/idn-0.1/tests/002.phpt php-pecl-idn-cvs/idn-0.1/tests/002.phpt | |
267 | --- php-pecl-idn-0.1/idn-0.1/tests/002.phpt 1970-01-01 01:00:00.000000000 +0100 | |
268 | +++ php-pecl-idn-cvs/idn-0.1/tests/002.phpt 2004-04-27 02:19:11.000000000 +0200 | |
269 | @@ -0,0 +1,20 @@ | |
270 | +--TEST-- | |
271 | +idn: Testing error handling on bad input | |
272 | +--SKIPIF-- | |
273 | +<?php @dl('idn.so'); if (!extension_loaded("idn")) print "skip"; ?> | |
274 | +--POST-- | |
275 | +--GET-- | |
276 | +--INI-- | |
277 | +--FILE-- | |
278 | +<?php | |
279 |