--- CVS-Latest/lib/url.c Tue Sep 28 09:11:32 2004 +++ lib/url.c Wed Sep 29 15:53:02 2004 @@ -116,6 +116,7 @@ #include "progress.h" #include "cookie.h" #include "strequal.h" +#include "strerror.h" #include "escape.h" #include "strtok.h" #include "share.h" @@ -2078,8 +2079,8 @@ infof (data, "Input domain encoded as `%s'\n", stringprep_locale_charset ()); if (rc != IDNA_SUCCESS) - infof(data, "Failed to convert %s to ACE; IDNA error %d\n", - host->name, rc); + infof(data, "Failed to convert %s to ACE; %s\n", + host->name, Curl_idn_strerror(conn,rc)); else { host->encalloc = ace_hostname; /* change the name pointer to point to the encoded hostname */ --- CVS-Latest/lib/strerror.c Sun Sep 19 16:28:16 2004 +++ lib/strerror.c Wed Sep 29 16:10:57 2004 @@ -27,6 +27,10 @@ #include #include +#ifdef USE_LIBIDN +#include +#endif + #include "strerror.h" #define _MPRINTF_REPLACE /* use our functions only */ @@ -556,3 +560,68 @@ *p = '\0'; return buf; } + +#ifdef USE_LIBIDN +/* + * Return error-string for libidn status as returned + * from idna_to_ascii_lz(). + */ +const char *Curl_idn_strerror (struct connectdata *conn, int err) +{ + const char *str; + char *buf; + size_t max; + + curlassert(conn); + + buf = conn->syserr_buf; + max = sizeof(conn->syserr_buf)-1; + + switch ((Idna_rc)err) { + case IDNA_SUCCESS: + str = "No error"; + break; + case IDNA_STRINGPREP_ERROR: + str = "Error in string preparation"; + break; + case IDNA_PUNYCODE_ERROR: + str = "Error in Punycode operation"; + break; + case IDNA_CONTAINS_NON_LDH: + str = "Illegal ASCII characters"; + break; + case IDNA_CONTAINS_MINUS: + str = "Contains minus"; + break; + case IDNA_INVALID_LENGTH: + str = "Invalid output length"; + break; + case IDNA_NO_ACE_PREFIX: + str = "No ACE prefix (\"xn--\")"; + break; + case IDNA_ROUNDTRIP_VERIFY_ERROR: + str = "Roundtrip verify error"; + break; + case IDNA_CONTAINS_ACE_PREFIX: + str = "Already have ACE prefix (\"xn--\")"; + break; + case IDNA_ICONV_ERROR: + str = "Locale conversion failed"; + break; + case IDNA_MALLOC_ERROR: + str = "Allocation failed"; + break; + case IDNA_DLOPEN_ERROR: + str = "dlopen() error"; + break; + default: + snprintf(buf, max, "error %d", (int)err); + str = NULL; + break; + } + if (str) + strncpy(buf, str, max); + buf[max] = '\0'; + return (buf); +} +#endif /* USE_LIBIDN */ --- CVS-Latest/lib/strerror.h Thu Mar 25 15:40:24 2004 +++ lib/strerror.h Sat Sep 25 16:52:25 2004 @@ -26,5 +26,9 @@ #include "urldata.h" const char *Curl_strerror (struct connectdata *conn, int err); + +#ifdef USE_LIBIDN +const char *Curl_idn_strerror (struct connectdata *conn, int err); +#endif #endif