#include <curl/curl.h>
-#ifdef USE_LIBIDN2
-#include <idn2.h>
+#ifdef USE_LIBIDN
+#include <idna.h>
#endif
#ifdef USE_WINDOWS_SSPI
curl_easy_strerror(CURLcode error)
{
#ifndef CURL_DISABLE_VERBOSE_STRINGS
- switch(error) {
+ switch (error) {
case CURLE_OK:
return "No error";
case CURLE_COULDNT_CONNECT:
return "Couldn't connect to server";
- case CURLE_WEIRD_SERVER_REPLY:
- return "Weird server reply";
+ case CURLE_FTP_WEIRD_SERVER_REPLY:
+ return "FTP: weird server reply";
case CURLE_REMOTE_ACCESS_DENIED:
return "Access denied to remote resource";
curl_multi_strerror(CURLMcode error)
{
#ifndef CURL_DISABLE_VERBOSE_STRINGS
- switch(error) {
+ switch (error) {
case CURLM_CALL_MULTI_PERFORM:
return "Please call curl_multi_perform() soon";
curl_share_strerror(CURLSHcode error)
{
#ifndef CURL_DISABLE_VERBOSE_STRINGS
- switch(error) {
+ switch (error) {
case CURLSHE_OK:
return "No error";
#ifdef USE_WINSOCK
-/* This function handles most / all (?) Winsock errors curl is able to produce.
+/* This function handles most / all (?) Winsock errors cURL is able to produce.
*/
static const char *
get_winsock_error (int err, char *buf, size_t len)
const char *p;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
- switch(err) {
+ switch (err) {
case WSAEINTR:
p = "Call interrupted";
break;
else
p = "error";
#endif
- strncpy(buf, p, len);
+ strncpy (buf, p, len);
buf [len-1] = '\0';
return buf;
}
buf[max] = '\0'; /* make sure the string is zero terminated */
/* strip trailing '\r\n' or '\n'. */
- p = strrchr(buf, '\n');
- if(p && (p - buf) >= 2)
- *p = '\0';
- p = strrchr(buf, '\r');
- if(p && (p - buf) >= 1)
- *p = '\0';
+ if((p = strrchr(buf, '\n')) != NULL && (p - buf) >= 2)
+ *p = '\0';
+ if((p = strrchr(buf, '\r')) != NULL && (p - buf) >= 1)
+ *p = '\0';
if(old_errno != ERRNO)
SET_ERRNO(old_errno);
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)
+{
+#ifdef HAVE_IDNA_STRERROR
+ (void)conn;
+ return idna_strerror((Idna_rc) err);
+#else
+ const char *str;
+ char *buf;
+ size_t max;
+
+ DEBUGASSERT(conn);
+
+ buf = conn->syserr_buf;
+ max = sizeof(conn->syserr_buf)-1;
+ *buf = '\0';
+
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+ 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 = "Round trip 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", err);
+ str = NULL;
+ break;
+ }
+#else
+ if((Idna_rc)err == IDNA_SUCCESS)
+ str = "No error";
+ else
+ str = "Error";
+#endif
+ if(str)
+ strncpy(buf, str, max);
+ buf[max] = '\0';
+ return (buf);
+#endif
+}
+#endif /* USE_LIBIDN */
+
#ifdef USE_WINDOWS_SSPI
const char *Curl_sspi_strerror (struct connectdata *conn, int err)
{
old_errno = ERRNO;
- switch(err) {
+ switch (err) {
case SEC_E_OK:
txt = "No error";
break;
if(msg_formatted) {
msgbuf[sizeof(msgbuf)-1] = '\0';
/* strip trailing '\r\n' or '\n' */
- p = strrchr(msgbuf, '\n');
- if(p && (p - msgbuf) >= 2)
- *p = '\0';
- p = strrchr(msgbuf, '\r');
- if(p && (p - msgbuf) >= 1)
- *p = '\0';
+ if((p = strrchr(msgbuf, '\n')) != NULL && (p - msgbuf) >= 2)
+ *p = '\0';
+ if((p = strrchr(msgbuf, '\r')) != NULL && (p - msgbuf) >= 1)
+ *p = '\0';
msg = msgbuf;
}
if(msg)