+#if PHP_HTTP_HAVE_LIBIDNKIT || PHP_HTTP_HAVE_LIBIDNKIT2
+# if __GNUC__
+__attribute__ ((unused))
+# endif
+static ZEND_RESULT_CODE parse_kidn(struct parse_state *state)
+{
+ idn_result_t rc;
+#if PHP_HTTP_HAVE_LIBIDNKIT
+ int actions = IDN_DELIMMAP|IDN_LOCALMAP|IDN_NAMEPREP|IDN_IDNCONV|IDN_LENCHECK;
+#elif PHP_HTTP_HAVE_LIBIDNKIT2
+ int actions = IDN_MAP|IDN_ASCLOWER|IDN_RTCONV|IDN_PROHCHECK|IDN_NFCCHECK|IDN_PREFCHECK|IDN_COMBCHECK|IDN_CTXOLITECHECK|IDN_BIDICHECK|IDN_LOCALCHECK|IDN_IDNCONV|IDN_LENCHECK|IDN_RTCHECK;
+#endif
+ char ahost_str[256] = {0}, *ahost_ptr = &ahost_str[0], *host_ptr = state->url.host;
+
+ if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) {
+#if PHP_HTTP_HAVE_LIBIDNKIT
+ actions |= IDN_LOCALCONV;
+#elif PHP_HTTP_HAVE_LIBIDNKIT2
+ actions |= IDN_UNICODECONV;
+#endif
+ }
+
+ rc = idn_encodename(actions, state->url.host, ahost_str, 256);
+ if (rc == idn_success) {
+ PHP_HTTP_DUFF(strlen(ahost_str), *host_ptr++ = *ahost_ptr++);
+
+ *host_ptr = '\0';
+ state->offset += host_ptr - state->url.host;
+
+ return SUCCESS;
+ } else {
+ php_error_docref(NULL, E_WARNING, "Failed to parse IDN; %s", idn_result_tostring(rc));
+ return FAILURE;
+ }
+}
+#endif
+
+#if 0 && PHP_WIN32