From e161bdc5bebaf08dbd664202acb04c5e728cbcd6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 25 Mar 2004 13:40:24 +0000 Subject: cut off 'curl_' from the strerror file names --- lib/strerror.c | 539 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 539 insertions(+) create mode 100644 lib/strerror.c (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c new file mode 100644 index 000000000..570759603 --- /dev/null +++ b/lib/strerror.c @@ -0,0 +1,539 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "setup.h" + +#include +#include +#include +#include + +#include "curl_strerror.h" + +#define _MPRINTF_REPLACE /* use our functions only */ +#include + +const char * +curl_easy_strerror(CURLcode error) +{ + switch (error) { + case CURLE_OK: + return "no error"; + + case CURLE_UNSUPPORTED_PROTOCOL: + return "unsupported protocol"; + + case CURLE_FAILED_INIT: + return "failed init"; + + case CURLE_URL_MALFORMAT: + return "url malformat"; + + case CURLE_URL_MALFORMAT_USER: + return "url malformat user"; + + case CURLE_COULDNT_RESOLVE_PROXY: + return "couldnt resolve proxy"; + + case CURLE_COULDNT_RESOLVE_HOST: + return "couldnt resolve host"; + + case CURLE_COULDNT_CONNECT: + return "couldn't connect"; + + case CURLE_FTP_WEIRD_SERVER_REPLY: + return "ftp weird server reply"; + + case CURLE_FTP_ACCESS_DENIED: + return "ftp access denied"; + + case CURLE_FTP_USER_PASSWORD_INCORRECT: + return "ftp user password incorrect"; + + case CURLE_FTP_WEIRD_PASS_REPLY: + return "ftp weird pass reply"; + + case CURLE_FTP_WEIRD_USER_REPLY: + return "ftp weird user reply"; + + case CURLE_FTP_WEIRD_PASV_REPLY: + return "ftp weird pasv reply"; + + case CURLE_FTP_WEIRD_227_FORMAT: + return "ftp weird 227 format"; + + case CURLE_FTP_CANT_GET_HOST: + return "ftp cant get host"; + + case CURLE_FTP_CANT_RECONNECT: + return "ftp can't reconnect"; + + case CURLE_FTP_COULDNT_SET_BINARY: + return "ftp couldn't set binary"; + + case CURLE_PARTIAL_FILE: + return "partial file"; + + case CURLE_FTP_COULDNT_RETR_FILE: + return "ftp couldn't retr file"; + + case CURLE_FTP_WRITE_ERROR: + return "ftp write error"; + + case CURLE_FTP_QUOTE_ERROR: + return "ftp quote error"; + + case CURLE_HTTP_NOT_FOUND: + return "http not found"; + + case CURLE_WRITE_ERROR: + return "write error"; + + case CURLE_MALFORMAT_USER: + return "user name is illegally specified"; + + case CURLE_FTP_COULDNT_STOR_FILE: + return "failed FTP upload"; + + case CURLE_READ_ERROR: + return "could open/read from file"; + + case CURLE_OUT_OF_MEMORY: + return "out of memory"; + + case CURLE_OPERATION_TIMEOUTED: + return "the timeout time was reached"; + + case CURLE_FTP_COULDNT_SET_ASCII: + return "TYPE A failed"; + + case CURLE_FTP_PORT_FAILED: + return "FTP PORT operation failed"; + + case CURLE_FTP_COULDNT_USE_REST: + return "the REST command failed"; + + case CURLE_FTP_COULDNT_GET_SIZE: + return "the SIZE command failed"; + + case CURLE_HTTP_RANGE_ERROR: + return "RANGE \"command\" didn't work"; + + case CURLE_HTTP_POST_ERROR: + return "http post error"; + + case CURLE_SSL_CONNECT_ERROR: + return "wrong when connecting with SSL"; + + case CURLE_FTP_BAD_DOWNLOAD_RESUME: + return "couldn't resume download"; + + case CURLE_FILE_COULDNT_READ_FILE: + return "file couldn't read file"; + + case CURLE_LDAP_CANNOT_BIND: + return "ldap cannot bind"; + + case CURLE_LDAP_SEARCH_FAILED: + return "ldap search failed"; + + case CURLE_LIBRARY_NOT_FOUND: + return "library not found"; + + case CURLE_FUNCTION_NOT_FOUND: + return "function not found"; + + case CURLE_ABORTED_BY_CALLBACK: + return "aborted by callback"; + + case CURLE_BAD_FUNCTION_ARGUMENT: + return "bad function argument"; + + case CURLE_BAD_CALLING_ORDER: + return "bad calling order"; + + case CURLE_HTTP_PORT_FAILED: + return "HTTP Interface operation failed"; + + case CURLE_BAD_PASSWORD_ENTERED: + return "my getpass() returns fail"; + + case CURLE_TOO_MANY_REDIRECTS : + return "catch endless re-direct loops"; + + case CURLE_UNKNOWN_TELNET_OPTION: + return "User specified an unknown option"; + + case CURLE_TELNET_OPTION_SYNTAX : + return "Malformed telnet option"; + + case CURLE_OBSOLETE: + return "obsolete"; + + case CURLE_SSL_PEER_CERTIFICATE: + return "peer's certificate wasn't ok"; + + case CURLE_GOT_NOTHING: + return "when this is a specific error"; + + case CURLE_SSL_ENGINE_NOTFOUND: + return "SSL crypto engine not found"; + + case CURLE_SSL_ENGINE_SETFAILED: + return "can not set SSL crypto engine as default"; + + case CURLE_SEND_ERROR: + return "failed sending network data"; + + case CURLE_RECV_ERROR: + return "failure in receiving network data"; + + case CURLE_SHARE_IN_USE: + return "CURLE_SHARE_IN_USER"; + + case CURLE_SSL_CERTPROBLEM: + return "problem with the local certificate"; + + case CURLE_SSL_CIPHER: + return "couldn't use specified cipher"; + + case CURLE_SSL_CACERT: + return "problem with the CA cert (path? access rights?)"; + + case CURLE_BAD_CONTENT_ENCODING: + return "Unrecognized transfer encoding"; + + case CURLE_LDAP_INVALID_URL: + return "Invalid LDAP URL"; + + case CURLE_FILESIZE_EXCEEDED: + return "Maximum file size exceeded"; + + case CURLE_FTP_SSL_FAILED: + return "Requested FTP SSL level failed"; + + case CURL_LAST: + break; + } + /* + * By using a switch, gcc -Wall will complain about enum values + * which do not appear, helping keep this function up-to-date. + * By using gcc -Wall -Werror, you can't forget. + * + * A table would not have the same benefit. Most compilers will + * generate code very similar to a table in any case, so there + * is little performance gain from a table. And something is broken + * for the user's application, anyways, so does it matter how fast + * it _doesn't_ work? + * + * The line number for the error will be near this comment, which + * is why it is here, and not at the start of the switch. + */ + return "CURLcode unknown"; +} + +const char * +curl_multi_strerror(CURLMcode error) +{ + switch (error) + { + case CURLM_CALL_MULTI_PERFORM: + return "please call curl_multi_perform() soon"; + + case CURLM_OK: + return "no error"; + + case CURLM_BAD_HANDLE: + return "CURLM not valid multi handle"; + + case CURLM_BAD_EASY_HANDLE: + return "CURLM not valid easy handle"; + + case CURLM_OUT_OF_MEMORY: + return "CURLM libcurl out of memory"; + + case CURLM_INTERNAL_ERROR: + return "CURLM libcurl internal bug"; + + case CURLM_LAST: + break; + } + + return "CURLMcode unknown"; +} + +const char * +curl_share_strerror(CURLSHcode error) +{ + switch (error) + { + case CURLSHE_OK: + return "no error"; + + case CURLSHE_BAD_OPTION: + return "CURLSH bad option"; + + case CURLSHE_IN_USE: + return "CURLSH in use"; + + case CURLSHE_INVALID: + return "CURLSH invalid"; + + case CURLSHE_LAST: + break; + } + + return "CURLSH unknown"; +} + +#if defined(WIN32) && !defined(__CYGWIN__) + +/* 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) +{ + char *p; + + switch (err) + { + case WSAEINTR: + p = "Call interrupted."; + break; + case WSAEBADF: + p = "Bad file"; + break; + case WSAEACCES: + p = "Bad access"; + break; + case WSAEFAULT: + p = "Bad argument"; + break; + case WSAEINVAL: + p = "Invalid arguments"; + break; + case WSAEMFILE: + p = "Out of file descriptors"; + break; + case WSAEWOULDBLOCK: + p = "Call would block"; + break; + case WSAEINPROGRESS: + case WSAEALREADY: + p = "Blocking call in progress"; + break; + case WSAENOTSOCK: + p = "Descriptor is not a socket."; + break; + case WSAEDESTADDRREQ: + p = "Need destination address"; + break; + case WSAEMSGSIZE: + p = "Bad message size"; + break; + case WSAEPROTOTYPE: + p = "Bad protocol"; + break; + case WSAENOPROTOOPT: + p = "Protocol option is unsupported"; + break; + case WSAEPROTONOSUPPORT: + p = "Protocol is unsupported"; + break; + case WSAESOCKTNOSUPPORT: + p = "Socket is unsupported"; + break; + case WSAEOPNOTSUPP: + p = "Operation not supported"; + break; + case WSAEAFNOSUPPORT: + p = "Address family not supported"; + break; + case WSAEPFNOSUPPORT: + p = "Protocol family not supported"; + break; + case WSAEADDRINUSE: + p = "Address already in use"; + break; + case WSAEADDRNOTAVAIL: + p = "Address not available"; + break; + case WSAENETDOWN: + p = "Network down"; + break; + case WSAENETUNREACH: + p = "Network unreachable"; + break; + case WSAENETRESET: + p = "Network has been reset"; + break; + case WSAECONNABORTED: + p = "Connection was aborted"; + break; + case WSAECONNRESET: + p = "Connection was reset"; + break; + case WSAENOBUFS: + p = "No buffer space"; + break; + case WSAEISCONN: + p = "Socket is already connected"; + break; + case WSAENOTCONN: + p = "Socket is not connected"; + break; + case WSAESHUTDOWN: + p = "Socket has been shut down"; + break; + case WSAETOOMANYREFS: + p = "Too many references"; + break; + case WSAETIMEDOUT: + p = "Timed out"; + break; + case WSAECONNREFUSED: + p = "Connection refused"; + break; + case WSAELOOP: + p = "Loop??"; + break; + case WSAENAMETOOLONG: + p = "Name too long"; + break; + case WSAEHOSTDOWN: + p = "Host down"; + break; + case WSAEHOSTUNREACH: + p = "Host unreachable"; + break; + case WSAENOTEMPTY: + p = "Not empty"; + break; + case WSAEPROCLIM: + p = "Process limit reached"; + break; + case WSAEUSERS: + p = "Too many users"; + break; + case WSAEDQUOT: + p = "Bad quota"; + break; + case WSAESTALE: + p = "Something is stale"; + break; + case WSAEREMOTE: + p = "Remote error"; + break; + case WSAEDISCON: + p = "Disconnected"; + break; + + /* Extended Winsock errors */ + case WSASYSNOTREADY: + p = "Winsock library is not ready"; + break; + case WSANOTINITIALISED: + p = "Winsock library not initalised"; + break; + case WSAVERNOTSUPPORTED: + p = "Winsock version not supported."; + break; + + /* getXbyY() errors (already handled in herrmsg): + * Authoritative Answer: Host not found */ + case WSAHOST_NOT_FOUND: + p = "Host not found"; + break; + + /* Non-Authoritative: Host not found, or SERVERFAIL */ + case WSATRY_AGAIN: + p = "Host not found, try again"; + break; + + /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ + case WSANO_RECOVERY: + p = "Unrecoverable error in call to nameserver"; + break; + + /* Valid name, no data record of requested type */ + case WSANO_DATA: + p = "No data record of requested type"; + break; + + default: + return NULL; + } + strncpy (buf, p, len); + buf [len-1] = '\0'; + return buf; +} +#endif /* WIN32 && !__CYGWIN__ */ + +extern int sys_nerr; + +/* + * Our thread-safe and smart strerror() replacement. + */ +const char *Curl_strerror(struct connectdata *conn, int err) +{ + char *buf, *p; + size_t max; + + curlassert(conn); + + buf = conn->syserr_buf; + max = sizeof(conn->syserr_buf)-1; + *buf = '\0'; + if (err >= 0 && err < sys_nerr) { + /* These should be atomic and hopefully thread-safe */ +#ifdef HAVE_STRERROR_R +#ifdef HAVE_POSIX_STRERROR_R + strerror_r(err, buf, max); + /* this may set errno to ERANGE if insufficient storage was supplied via + strerrbuf and buflen to contain the generated message string, or EINVAL + if the value of errnum is not a valid error number.*/ +#else + /* HAVE_GLIBC_STRERROR_R */ + char buffer[256]; + char *msg = strerror_r(err, buffer, sizeof(buffer)); + strncpy(buf, msg, max); +#endif +#else + strncpy(buf, strerror(err), max); +#endif + *(buf+max) = '\0'; + } + else +#if defined(WIN32) && !defined(__CYGWIN__) + if (!get_winsock_error (err, buf, max) && + !FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, + LANG_NEUTRAL, buf, max, NULL)) +#endif + snprintf(buf, max, "Unknown error %d (%#x)", err, err); + + /* strip trailing '\r\n' or '\n'. */ + if ((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2) + *p = '\0'; + if ((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1) + *p = '\0'; + return buf; +} -- cgit v1.2.1 From 762dcf0780b0100f50fad21a5d3e5e5613def267 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 25 Mar 2004 13:42:23 +0000 Subject: include the strerror.h file without curl_ prefix --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 570759603..32ece136e 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -27,7 +27,7 @@ #include #include -#include "curl_strerror.h" +#include "strerror.h" #define _MPRINTF_REPLACE /* use our functions only */ #include -- cgit v1.2.1 From 3ecf63fa66e268c8a76996f8d453cca12cfae324 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 25 Mar 2004 13:43:19 +0000 Subject: win32 doesn't need and even doesn't build if we extern declare sys_nerr --- lib/strerror.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 32ece136e..a6f25d0c4 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -488,7 +488,9 @@ get_winsock_error (int err, char *buf, size_t len) } #endif /* WIN32 && !__CYGWIN__ */ +#ifndef WIN32 extern int sys_nerr; +#endif /* * Our thread-safe and smart strerror() replacement. -- cgit v1.2.1 From 4b49b2e3cf339644a22cc983a11487accb7ee429 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 29 Mar 2004 07:25:59 +0000 Subject: re-indented to use curl-standard source formatting --- lib/strerror.c | 322 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 160 insertions(+), 162 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index a6f25d0c4..4b1df9446 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -254,14 +254,13 @@ curl_easy_strerror(CURLcode error) const char * curl_multi_strerror(CURLMcode error) { - switch (error) - { + switch (error) { case CURLM_CALL_MULTI_PERFORM: return "please call curl_multi_perform() soon"; - + case CURLM_OK: return "no error"; - + case CURLM_BAD_HANDLE: return "CURLM not valid multi handle"; @@ -284,8 +283,7 @@ curl_multi_strerror(CURLMcode error) const char * curl_share_strerror(CURLSHcode error) { - switch (error) - { + switch (error) { case CURLSHE_OK: return "no error"; @@ -314,173 +312,172 @@ get_winsock_error (int err, char *buf, size_t len) { char *p; - switch (err) - { - case WSAEINTR: - p = "Call interrupted."; - break; - case WSAEBADF: - p = "Bad file"; - break; - case WSAEACCES: - p = "Bad access"; - break; - case WSAEFAULT: - p = "Bad argument"; - break; - case WSAEINVAL: - p = "Invalid arguments"; - break; - case WSAEMFILE: - p = "Out of file descriptors"; - break; - case WSAEWOULDBLOCK: - p = "Call would block"; - break; - case WSAEINPROGRESS: - case WSAEALREADY: - p = "Blocking call in progress"; - break; - case WSAENOTSOCK: - p = "Descriptor is not a socket."; - break; - case WSAEDESTADDRREQ: - p = "Need destination address"; - break; - case WSAEMSGSIZE: - p = "Bad message size"; - break; - case WSAEPROTOTYPE: - p = "Bad protocol"; - break; - case WSAENOPROTOOPT: - p = "Protocol option is unsupported"; - break; - case WSAEPROTONOSUPPORT: - p = "Protocol is unsupported"; - break; - case WSAESOCKTNOSUPPORT: - p = "Socket is unsupported"; - break; - case WSAEOPNOTSUPP: - p = "Operation not supported"; - break; - case WSAEAFNOSUPPORT: - p = "Address family not supported"; - break; - case WSAEPFNOSUPPORT: - p = "Protocol family not supported"; - break; - case WSAEADDRINUSE: - p = "Address already in use"; - break; - case WSAEADDRNOTAVAIL: - p = "Address not available"; - break; - case WSAENETDOWN: - p = "Network down"; - break; - case WSAENETUNREACH: - p = "Network unreachable"; - break; - case WSAENETRESET: - p = "Network has been reset"; - break; - case WSAECONNABORTED: - p = "Connection was aborted"; - break; - case WSAECONNRESET: - p = "Connection was reset"; - break; - case WSAENOBUFS: - p = "No buffer space"; - break; - case WSAEISCONN: - p = "Socket is already connected"; - break; - case WSAENOTCONN: - p = "Socket is not connected"; - break; - case WSAESHUTDOWN: - p = "Socket has been shut down"; - break; - case WSAETOOMANYREFS: - p = "Too many references"; - break; - case WSAETIMEDOUT: - p = "Timed out"; - break; - case WSAECONNREFUSED: - p = "Connection refused"; - break; - case WSAELOOP: - p = "Loop??"; - break; - case WSAENAMETOOLONG: - p = "Name too long"; - break; - case WSAEHOSTDOWN: - p = "Host down"; - break; - case WSAEHOSTUNREACH: - p = "Host unreachable"; - break; - case WSAENOTEMPTY: - p = "Not empty"; - break; - case WSAEPROCLIM: - p = "Process limit reached"; - break; - case WSAEUSERS: - p = "Too many users"; - break; - case WSAEDQUOT: - p = "Bad quota"; - break; - case WSAESTALE: - p = "Something is stale"; - break; - case WSAEREMOTE: - p = "Remote error"; - break; - case WSAEDISCON: - p = "Disconnected"; - break; + switch (err) { + case WSAEINTR: + p = "Call interrupted."; + break; + case WSAEBADF: + p = "Bad file"; + break; + case WSAEACCES: + p = "Bad access"; + break; + case WSAEFAULT: + p = "Bad argument"; + break; + case WSAEINVAL: + p = "Invalid arguments"; + break; + case WSAEMFILE: + p = "Out of file descriptors"; + break; + case WSAEWOULDBLOCK: + p = "Call would block"; + break; + case WSAEINPROGRESS: + case WSAEALREADY: + p = "Blocking call in progress"; + break; + case WSAENOTSOCK: + p = "Descriptor is not a socket."; + break; + case WSAEDESTADDRREQ: + p = "Need destination address"; + break; + case WSAEMSGSIZE: + p = "Bad message size"; + break; + case WSAEPROTOTYPE: + p = "Bad protocol"; + break; + case WSAENOPROTOOPT: + p = "Protocol option is unsupported"; + break; + case WSAEPROTONOSUPPORT: + p = "Protocol is unsupported"; + break; + case WSAESOCKTNOSUPPORT: + p = "Socket is unsupported"; + break; + case WSAEOPNOTSUPP: + p = "Operation not supported"; + break; + case WSAEAFNOSUPPORT: + p = "Address family not supported"; + break; + case WSAEPFNOSUPPORT: + p = "Protocol family not supported"; + break; + case WSAEADDRINUSE: + p = "Address already in use"; + break; + case WSAEADDRNOTAVAIL: + p = "Address not available"; + break; + case WSAENETDOWN: + p = "Network down"; + break; + case WSAENETUNREACH: + p = "Network unreachable"; + break; + case WSAENETRESET: + p = "Network has been reset"; + break; + case WSAECONNABORTED: + p = "Connection was aborted"; + break; + case WSAECONNRESET: + p = "Connection was reset"; + break; + case WSAENOBUFS: + p = "No buffer space"; + break; + case WSAEISCONN: + p = "Socket is already connected"; + break; + case WSAENOTCONN: + p = "Socket is not connected"; + break; + case WSAESHUTDOWN: + p = "Socket has been shut down"; + break; + case WSAETOOMANYREFS: + p = "Too many references"; + break; + case WSAETIMEDOUT: + p = "Timed out"; + break; + case WSAECONNREFUSED: + p = "Connection refused"; + break; + case WSAELOOP: + p = "Loop??"; + break; + case WSAENAMETOOLONG: + p = "Name too long"; + break; + case WSAEHOSTDOWN: + p = "Host down"; + break; + case WSAEHOSTUNREACH: + p = "Host unreachable"; + break; + case WSAENOTEMPTY: + p = "Not empty"; + break; + case WSAEPROCLIM: + p = "Process limit reached"; + break; + case WSAEUSERS: + p = "Too many users"; + break; + case WSAEDQUOT: + p = "Bad quota"; + break; + case WSAESTALE: + p = "Something is stale"; + break; + case WSAEREMOTE: + p = "Remote error"; + break; + case WSAEDISCON: + p = "Disconnected"; + break; /* Extended Winsock errors */ - case WSASYSNOTREADY: - p = "Winsock library is not ready"; - break; - case WSANOTINITIALISED: - p = "Winsock library not initalised"; - break; - case WSAVERNOTSUPPORTED: - p = "Winsock version not supported."; - break; + case WSASYSNOTREADY: + p = "Winsock library is not ready"; + break; + case WSANOTINITIALISED: + p = "Winsock library not initalised"; + break; + case WSAVERNOTSUPPORTED: + p = "Winsock version not supported."; + break; /* getXbyY() errors (already handled in herrmsg): * Authoritative Answer: Host not found */ - case WSAHOST_NOT_FOUND: - p = "Host not found"; - break; + case WSAHOST_NOT_FOUND: + p = "Host not found"; + break; /* Non-Authoritative: Host not found, or SERVERFAIL */ - case WSATRY_AGAIN: - p = "Host not found, try again"; - break; + case WSATRY_AGAIN: + p = "Host not found, try again"; + break; /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ - case WSANO_RECOVERY: - p = "Unrecoverable error in call to nameserver"; - break; + case WSANO_RECOVERY: + p = "Unrecoverable error in call to nameserver"; + break; /* Valid name, no data record of requested type */ - case WSANO_DATA: - p = "No data record of requested type"; - break; + case WSANO_DATA: + p = "No data record of requested type"; + break; - default: - return NULL; + default: + return NULL; } strncpy (buf, p, len); buf [len-1] = '\0'; @@ -524,13 +521,14 @@ const char *Curl_strerror(struct connectdata *conn, int err) #endif *(buf+max) = '\0'; } - else + else { #if defined(WIN32) && !defined(__CYGWIN__) if (!get_winsock_error (err, buf, max) && !FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, LANG_NEUTRAL, buf, max, NULL)) #endif snprintf(buf, max, "Unknown error %d (%#x)", err, err); + } /* strip trailing '\r\n' or '\n'. */ if ((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2) -- cgit v1.2.1 From 1b171b02acbb9736a566fdd7170c3d1b5779b86c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 6 Apr 2004 06:06:10 +0000 Subject: remove the general use of sys_nerr --- lib/strerror.c | 56 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 4b1df9446..03ddc1a2b 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -485,12 +485,16 @@ get_winsock_error (int err, char *buf, size_t len) } #endif /* WIN32 && !__CYGWIN__ */ -#ifndef WIN32 -extern int sys_nerr; -#endif - /* * Our thread-safe and smart strerror() replacement. + * + * The 'err' argument passed in to this function MUST be a true errno number + * as reported on this system. We do no range checking on the number before + * we pass it to the "number-to-message" convertion function and there might + * be systems that don't do proper range checking in there themselves. + * + * We don't do range checking (on systems other than Windows) since there is + * no good reliable and portable way to do it. */ const char *Curl_strerror(struct connectdata *conn, int err) { @@ -498,37 +502,45 @@ const char *Curl_strerror(struct connectdata *conn, int err) size_t max; curlassert(conn); + curlassert(err >= 0); buf = conn->syserr_buf; max = sizeof(conn->syserr_buf)-1; *buf = '\0'; + +#if defined(WIN32) && !defined(__CYGWIN__) + /* 'sys_nerr' is the maximum errno number, it is not widely portable */ if (err >= 0 && err < sys_nerr) { - /* These should be atomic and hopefully thread-safe */ + if (!get_winsock_error (err, buf, max) && + !FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, + LANG_NEUTRAL, buf, max, NULL)) + snprintf(buf, max, "Unknown error %d (%#x)", err, err); + } +#else /* not native Windows coming up */ + + /* These should be atomic and hopefully thread-safe */ #ifdef HAVE_STRERROR_R + /* There are two different APIs for strerror_r(). The POSIX and the GLIBC + versions. */ #ifdef HAVE_POSIX_STRERROR_R - strerror_r(err, buf, max); - /* this may set errno to ERANGE if insufficient storage was supplied via - strerrbuf and buflen to contain the generated message string, or EINVAL - if the value of errnum is not a valid error number.*/ + strerror_r(err, buf, max); + /* this may set errno to ERANGE if insufficient storage was supplied via + 'strerrbuf' and 'buflen' to contain the generated message string, or + EINVAL if the value of 'errnum' is not a valid error number.*/ #else + { /* HAVE_GLIBC_STRERROR_R */ char buffer[256]; char *msg = strerror_r(err, buffer, sizeof(buffer)); strncpy(buf, msg, max); -#endif -#else - strncpy(buf, strerror(err), max); -#endif - *(buf+max) = '\0'; - } - else { -#if defined(WIN32) && !defined(__CYGWIN__) - if (!get_winsock_error (err, buf, max) && - !FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, - LANG_NEUTRAL, buf, max, NULL)) -#endif - snprintf(buf, max, "Unknown error %d (%#x)", err, err); } +#endif /* end of HAVE_GLIBC_STRERROR_R */ +#else /* HAVE_STRERROR_R */ + strncpy(buf, strerror(err), max); +#endif /* end of HAVE_STRERROR_R */ +#endif /* end of ! Windows */ + + buf[max] = '\0'; /* make sure the string is zero terminated */ /* strip trailing '\r\n' or '\n'. */ if ((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2) -- cgit v1.2.1 From ca7f0852df06c59ba7583fa68359d39dbfc4b148 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 6 Apr 2004 12:02:36 +0000 Subject: Gisle Vanem caught me breaking the windows version of Curl_strerror() --- lib/strerror.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 03ddc1a2b..5e734faa7 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -510,7 +510,9 @@ const char *Curl_strerror(struct connectdata *conn, int err) #if defined(WIN32) && !defined(__CYGWIN__) /* 'sys_nerr' is the maximum errno number, it is not widely portable */ - if (err >= 0 && err < sys_nerr) { + if (err >= 0 && err < sys_nerr) + strncpy(buf, strerror(err), max); + else { if (!get_winsock_error (err, buf, max) && !FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, LANG_NEUTRAL, buf, max, NULL)) -- cgit v1.2.1 From fbeb6744799276d5f4ddabbf947b013de07862e5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 26 Apr 2004 07:12:29 +0000 Subject: major update of the error strings --- lib/strerror.c | 137 +++++++++++++++++++++++++++------------------------------ 1 file changed, 65 insertions(+), 72 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 5e734faa7..6cc87091b 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -46,10 +46,7 @@ curl_easy_strerror(CURLcode error) return "failed init"; case CURLE_URL_MALFORMAT: - return "url malformat"; - - case CURLE_URL_MALFORMAT_USER: - return "url malformat user"; + return "URL using bad/illegal format or missing URL"; case CURLE_COULDNT_RESOLVE_PROXY: return "couldnt resolve proxy"; @@ -61,124 +58,115 @@ curl_easy_strerror(CURLcode error) return "couldn't connect"; case CURLE_FTP_WEIRD_SERVER_REPLY: - return "ftp weird server reply"; + return "FTP: weird server reply"; case CURLE_FTP_ACCESS_DENIED: - return "ftp access denied"; + return "FTP: access denied"; case CURLE_FTP_USER_PASSWORD_INCORRECT: - return "ftp user password incorrect"; + return "FTP: user and/or password incorrect"; case CURLE_FTP_WEIRD_PASS_REPLY: - return "ftp weird pass reply"; + return "FTP: unknown PASS reply"; case CURLE_FTP_WEIRD_USER_REPLY: - return "ftp weird user reply"; + return "FTP: unknown USER reply"; case CURLE_FTP_WEIRD_PASV_REPLY: - return "ftp weird pasv reply"; + return "FTP: unknown PASV reply"; case CURLE_FTP_WEIRD_227_FORMAT: - return "ftp weird 227 format"; + return "FTP: unknown 227 response format"; case CURLE_FTP_CANT_GET_HOST: - return "ftp cant get host"; + return "FTP: can't figure out the host in the PASV response"; case CURLE_FTP_CANT_RECONNECT: - return "ftp can't reconnect"; + return "FTP: can't connect to server the response code is unknown"; case CURLE_FTP_COULDNT_SET_BINARY: - return "ftp couldn't set binary"; + return "FTP: couldn't set binary mode"; case CURLE_PARTIAL_FILE: - return "partial file"; + return "Transferred a partial file"; case CURLE_FTP_COULDNT_RETR_FILE: - return "ftp couldn't retr file"; + return "FTP: couldn't retrieve (RETR failed) the specified file"; case CURLE_FTP_WRITE_ERROR: - return "ftp write error"; + return "FTP: the post-transfer acknowledge response was not OK"; case CURLE_FTP_QUOTE_ERROR: - return "ftp quote error"; + return "FTP: a quote command returned error"; - case CURLE_HTTP_NOT_FOUND: - return "http not found"; + case CURLE_HTTP_RETURNED_ERROR: + return "HTTP response code said error"; case CURLE_WRITE_ERROR: - return "write error"; - - case CURLE_MALFORMAT_USER: - return "user name is illegally specified"; + return "failed writing received data to disk/application"; case CURLE_FTP_COULDNT_STOR_FILE: - return "failed FTP upload"; + return "failed FTP upload (the STOR command)"; case CURLE_READ_ERROR: - return "could open/read from file"; + return "failed to open/read local data from file/application"; case CURLE_OUT_OF_MEMORY: return "out of memory"; case CURLE_OPERATION_TIMEOUTED: - return "the timeout time was reached"; + return "a timeout was reached"; case CURLE_FTP_COULDNT_SET_ASCII: - return "TYPE A failed"; + return "FTP could not set ASCII mode (TYPE A)"; case CURLE_FTP_PORT_FAILED: - return "FTP PORT operation failed"; + return "FTP command PORT failed"; case CURLE_FTP_COULDNT_USE_REST: - return "the REST command failed"; + return "FTP command REST failed"; case CURLE_FTP_COULDNT_GET_SIZE: - return "the SIZE command failed"; + return "FTP command SIZE failed"; case CURLE_HTTP_RANGE_ERROR: - return "RANGE \"command\" didn't work"; + return "a range was requested but the server did not deliver it"; case CURLE_HTTP_POST_ERROR: - return "http post error"; + return "internal problem setting up the POST"; case CURLE_SSL_CONNECT_ERROR: - return "wrong when connecting with SSL"; + return "SSL connect error"; case CURLE_FTP_BAD_DOWNLOAD_RESUME: - return "couldn't resume download"; + return "couldn't resume FTP download"; case CURLE_FILE_COULDNT_READ_FILE: - return "file couldn't read file"; + return "couldn't read a file:// file"; case CURLE_LDAP_CANNOT_BIND: - return "ldap cannot bind"; + return "LDAP: cannot bind"; case CURLE_LDAP_SEARCH_FAILED: - return "ldap search failed"; + return "LDAP: search failed"; case CURLE_LIBRARY_NOT_FOUND: - return "library not found"; + return "a required shared library was not found"; case CURLE_FUNCTION_NOT_FOUND: - return "function not found"; + return "a required function in the shared library was not found"; case CURLE_ABORTED_BY_CALLBACK: - return "aborted by callback"; + return "the operation was aborted by an application callback"; case CURLE_BAD_FUNCTION_ARGUMENT: - return "bad function argument"; - - case CURLE_BAD_CALLING_ORDER: - return "bad calling order"; + return "a libcurl function was given a bad argument"; - case CURLE_HTTP_PORT_FAILED: - return "HTTP Interface operation failed"; - - case CURLE_BAD_PASSWORD_ENTERED: - return "my getpass() returns fail"; + case CURLE_INTERFACE_FAILED: + return "failed binding local connection end"; case CURLE_TOO_MANY_REDIRECTS : - return "catch endless re-direct loops"; + return "number of redirects hit maximum amount"; case CURLE_UNKNOWN_TELNET_OPTION: return "User specified an unknown option"; @@ -186,14 +174,11 @@ curl_easy_strerror(CURLcode error) case CURLE_TELNET_OPTION_SYNTAX : return "Malformed telnet option"; - case CURLE_OBSOLETE: - return "obsolete"; - case CURLE_SSL_PEER_CERTIFICATE: - return "peer's certificate wasn't ok"; + return "SSL peer certificate was not ok"; case CURLE_GOT_NOTHING: - return "when this is a specific error"; + return "server returned nothing (no headers, no data)"; case CURLE_SSL_ENGINE_NOTFOUND: return "SSL crypto engine not found"; @@ -202,25 +187,25 @@ curl_easy_strerror(CURLcode error) return "can not set SSL crypto engine as default"; case CURLE_SEND_ERROR: - return "failed sending network data"; + return "failed sending data to the peer"; case CURLE_RECV_ERROR: - return "failure in receiving network data"; + return "failure when receiving data from the peer"; case CURLE_SHARE_IN_USE: - return "CURLE_SHARE_IN_USER"; + return "share is already in use"; case CURLE_SSL_CERTPROBLEM: - return "problem with the local certificate"; + return "problem with the local SSL certificate"; case CURLE_SSL_CIPHER: - return "couldn't use specified cipher"; + return "couldn't use specified SSL cipher"; case CURLE_SSL_CACERT: - return "problem with the CA cert (path? access rights?)"; + return "problem with the SSL CA cert (path? access rights?)"; case CURLE_BAD_CONTENT_ENCODING: - return "Unrecognized transfer encoding"; + return "Unrecognized HTTP Content-Encoding"; case CURLE_LDAP_INVALID_URL: return "Invalid LDAP URL"; @@ -231,6 +216,11 @@ curl_easy_strerror(CURLcode error) case CURLE_FTP_SSL_FAILED: return "Requested FTP SSL level failed"; + case CURLE_URL_MALFORMAT_USER: /* not used by current libcurl */ + case CURLE_MALFORMAT_USER: /* not used by current libcurl */ + case CURLE_BAD_CALLING_ORDER: /* not used by current libcurl */ + case CURLE_BAD_PASSWORD_ENTERED:/* not used by current libcurl */ + case CURLE_OBSOLETE: /* not used by current libcurl */ case CURL_LAST: break; } @@ -248,7 +238,7 @@ curl_easy_strerror(CURLcode error) * The line number for the error will be near this comment, which * is why it is here, and not at the start of the switch. */ - return "CURLcode unknown"; + return "unknown error"; } const char * @@ -262,22 +252,22 @@ curl_multi_strerror(CURLMcode error) return "no error"; case CURLM_BAD_HANDLE: - return "CURLM not valid multi handle"; + return "invalid multi handle"; case CURLM_BAD_EASY_HANDLE: - return "CURLM not valid easy handle"; + return "invalid easy handle"; case CURLM_OUT_OF_MEMORY: - return "CURLM libcurl out of memory"; + return "out of memory"; case CURLM_INTERNAL_ERROR: - return "CURLM libcurl internal bug"; + return "internal error"; case CURLM_LAST: break; } - return "CURLMcode unknown"; + return "unknown error"; } const char * @@ -288,13 +278,13 @@ curl_share_strerror(CURLSHcode error) return "no error"; case CURLSHE_BAD_OPTION: - return "CURLSH bad option"; + return "unknown share option"; case CURLSHE_IN_USE: - return "CURLSH in use"; + return "share currently in use"; case CURLSHE_INVALID: - return "CURLSH invalid"; + return "invalid share handle"; case CURLSHE_LAST: break; @@ -534,6 +524,9 @@ const char *Curl_strerror(struct connectdata *conn, int err) /* HAVE_GLIBC_STRERROR_R */ char buffer[256]; char *msg = strerror_r(err, buffer, sizeof(buffer)); + /* this version of strerror_r() only *might* use the buffer we pass to + the function, but it always returns the error message as a pointer, + so we must copy that string unconditionally */ strncpy(buf, msg, max); } #endif /* end of HAVE_GLIBC_STRERROR_R */ -- cgit v1.2.1 From 6f74820cfc2319ebd5b52ebfbe90a7ba612923c7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 6 May 2004 10:49:40 +0000 Subject: if no strerror_r prototype is found, we provide our own to prevent picky compilers to warn --- lib/strerror.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 6cc87091b..d5c80d1a6 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -32,6 +32,15 @@ #define _MPRINTF_REPLACE /* use our functions only */ #include +#ifdef HAVE_NO_STRERROR_R_DECL +#ifdef HAVE_POSIX_STRERROR_R +/* seen on AIX 5100-02 gcc 2.9 */ +extern int strerror_r(int errnum, char *strerrbuf, size_t buflen); +#else +extern char *strerror_r(int errnum, char *buf, size_t buflen); +#endif +#endif + const char * curl_easy_strerror(CURLcode error) { -- cgit v1.2.1 From 512e54ff8514181c9ad5677ba125fdcc176eed1b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 14 May 2004 11:46:35 +0000 Subject: added string for the new share error code --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index d5c80d1a6..3179dd694 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -295,6 +295,9 @@ curl_share_strerror(CURLSHcode error) case CURLSHE_INVALID: return "invalid share handle"; + case CURLSHE_NOMEM: + return "out of memory"; + case CURLSHE_LAST: break; } -- cgit v1.2.1 From 0d37f8564e1d07def79c702265849690c5289ce5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 19 Sep 2004 14:28:16 +0000 Subject: kill trailing whitespace and clarify a few errors --- lib/strerror.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 3179dd694..5263f442c 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -1,8 +1,8 @@ /*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 2004, Daniel Stenberg, , et al. @@ -10,7 +10,7 @@ * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. - * + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. @@ -58,13 +58,13 @@ curl_easy_strerror(CURLcode error) return "URL using bad/illegal format or missing URL"; case CURLE_COULDNT_RESOLVE_PROXY: - return "couldnt resolve proxy"; + return "couldnt resolve proxy name"; case CURLE_COULDNT_RESOLVE_HOST: - return "couldnt resolve host"; + return "couldnt resolve host name"; case CURLE_COULDNT_CONNECT: - return "couldn't connect"; + return "couldn't connect to server"; case CURLE_FTP_WEIRD_SERVER_REPLY: return "FTP: weird server reply"; @@ -256,10 +256,10 @@ curl_multi_strerror(CURLMcode error) switch (error) { case CURLM_CALL_MULTI_PERFORM: return "please call curl_multi_perform() soon"; - + case CURLM_OK: return "no error"; - + case CURLM_BAD_HANDLE: return "invalid multi handle"; @@ -521,13 +521,13 @@ const char *Curl_strerror(struct connectdata *conn, int err) snprintf(buf, max, "Unknown error %d (%#x)", err, err); } #else /* not native Windows coming up */ - + /* These should be atomic and hopefully thread-safe */ #ifdef HAVE_STRERROR_R /* There are two different APIs for strerror_r(). The POSIX and the GLIBC versions. */ #ifdef HAVE_POSIX_STRERROR_R - strerror_r(err, buf, max); + strerror_r(err, buf, max); /* this may set errno to ERANGE if insufficient storage was supplied via 'strerrbuf' and 'buflen' to contain the generated message string, or EINVAL if the value of 'errnum' is not a valid error number.*/ -- cgit v1.2.1 From 19b284c21452b2c50924de3e0a04f5ed8040430d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 2 Oct 2004 13:01:44 +0000 Subject: Gisle Vanem provided code that displays an error message when the (libidn based) IDN conversion fails. This is really due to a missing suitable function in the libidn API that I hope we can remove once libidn gets a function like this. --- lib/strerror.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 5263f442c..b64af1cb8 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -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 @@ const char *Curl_strerror(struct connectdata *conn, int err) *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 */ -- cgit v1.2.1 From bb999d82134b73a500ce7dfecc5b1175930584c2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 5 Oct 2004 08:40:26 +0000 Subject: use idna_strerror() if it is available (only in libidn 0.5.6 or later) --- lib/strerror.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index b64af1cb8..c9e6c3a18 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -563,11 +563,13 @@ const char *Curl_strerror(struct connectdata *conn, int err) #ifdef USE_LIBIDN /* - * Return error-string for libidn status as returned - * from idna_to_ascii_lz(). + * 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 + return idna_strerror((Idna_rc) err); +#else const char *str; char *buf; size_t max; @@ -623,5 +625,6 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) strncpy(buf, str, max); buf[max] = '\0'; return (buf); +#endif } #endif /* USE_LIBIDN */ -- cgit v1.2.1 From 70c3f6a8ddf5d2d358544e38fcadd8d4c1581e29 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 5 Oct 2004 08:42:56 +0000 Subject: avoid warning for unused variable --- lib/strerror.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index c9e6c3a18..dd5acc81b 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -568,6 +568,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) 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; -- cgit v1.2.1 From 24d47a6e07304cf0921f2d30734b3c64360773c3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Nov 2004 10:12:22 +0000 Subject: Paul Nolan fix to make libcurl build nicely on Windows CE --- lib/strerror.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index dd5acc81b..fa84a1731 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -515,15 +515,29 @@ const char *Curl_strerror(struct connectdata *conn, int err) *buf = '\0'; #if defined(WIN32) && !defined(__CYGWIN__) + +#if _WIN32_WCE + buf[0]=0; + { + wchar_t wbuf[256]; + + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, + LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL); + wcstombs(buf,wbuf,max); + } + +#else + /* 'sys_nerr' is the maximum errno number, it is not widely portable */ if (err >= 0 && err < sys_nerr) strncpy(buf, strerror(err), max); else { - if (!get_winsock_error (err, buf, max) && - !FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, - LANG_NEUTRAL, buf, max, NULL)) + if (!get_winsock_error(err, buf, max) && + !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, + LANG_NEUTRAL, buf, max, NULL)) snprintf(buf, max, "Unknown error %d (%#x)", err, err); } +#endif #else /* not native Windows coming up */ /* These should be atomic and hopefully thread-safe */ -- cgit v1.2.1 From 710e370c34497100873dcf6252c862d77ef8c25b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 11 Nov 2004 16:34:24 +0000 Subject: Dan Fandrich added --disable-verbose --- lib/strerror.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index fa84a1731..d8e085880 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -48,6 +48,7 @@ extern char *strerror_r(int errnum, char *buf, size_t buflen); const char * curl_easy_strerror(CURLcode error) { +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch (error) { case CURLE_OK: return "no error"; @@ -252,11 +253,18 @@ curl_easy_strerror(CURLcode error) * is why it is here, and not at the start of the switch. */ return "unknown error"; +#else + if (error == CURLE_OK) + return "no error"; + else + return "error"; +#endif } const char * curl_multi_strerror(CURLMcode error) { +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch (error) { case CURLM_CALL_MULTI_PERFORM: return "please call curl_multi_perform() soon"; @@ -281,11 +289,18 @@ curl_multi_strerror(CURLMcode error) } return "unknown error"; +#else + if (error == CURLM_OK) + return "no error"; + else + return "error"; +#endif } const char * curl_share_strerror(CURLSHcode error) { +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch (error) { case CURLSHE_OK: return "no error"; @@ -307,6 +322,12 @@ curl_share_strerror(CURLSHcode error) } return "CURLSH unknown"; +#else + if (error == CURLSHE_OK) + return "no error"; + else + return "error"; +#endif } #if defined(WIN32) && !defined(__CYGWIN__) @@ -318,6 +339,7 @@ get_winsock_error (int err, char *buf, size_t len) { char *p; +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch (err) { case WSAEINTR: p = "Call interrupted."; @@ -485,6 +507,12 @@ get_winsock_error (int err, char *buf, size_t len) default: return NULL; } +#else + if (error == CURLE_OK) + return NULL; + else + p = "error"; +#endif strncpy (buf, p, len); buf [len-1] = '\0'; return buf; @@ -594,6 +622,7 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) buf = conn->syserr_buf; max = sizeof(conn->syserr_buf)-1; +#ifndef CURL_DISABLE_VERBOSE_STRINGS switch ((Idna_rc)err) { case IDNA_SUCCESS: str = "No error"; @@ -636,6 +665,12 @@ const char *Curl_idn_strerror (struct connectdata *conn, int 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'; -- cgit v1.2.1 From 7b3fba1ad5bbfd7c6466aa54dc1a601e124d225c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Nov 2004 18:25:33 +0000 Subject: added missing new error string --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index d8e085880..cc7454c7e 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -230,6 +230,9 @@ curl_easy_strerror(CURLcode error) case CURLE_FTP_SSL_FAILED: return "Requested FTP SSL level failed"; + case CURLE_SEND_FAIL_REWIND: + return "Send failed since rewinding of the data stream failed"; + case CURLE_URL_MALFORMAT_USER: /* not used by current libcurl */ case CURLE_MALFORMAT_USER: /* not used by current libcurl */ case CURLE_BAD_CALLING_ORDER: /* not used by current libcurl */ -- cgit v1.2.1 From bd2db872376bc8e9c9bce24dfad490850c775cb6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 11 Dec 2004 18:55:23 +0000 Subject: fixed error message --- lib/strerror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index cc7454c7e..10cc80453 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -152,8 +152,8 @@ curl_easy_strerror(CURLcode error) case CURLE_SSL_CONNECT_ERROR: return "SSL connect error"; - case CURLE_FTP_BAD_DOWNLOAD_RESUME: - return "couldn't resume FTP download"; + case CURLE_BAD_DOWNLOAD_RESUME: + return "couldn't resume download"; case CURLE_FILE_COULDNT_READ_FILE: return "couldn't read a file:// file"; -- cgit v1.2.1 From bdb0620529ecb58b879dcf7de67885f211812aee Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Mon, 13 Dec 2004 16:43:00 +0000 Subject: Added handling of CURLINFO_SSL_ENGINES; Added Curl_SSL_engines_list(), cleanup SSL in url.c (no HAVE_OPENSSL_x etc.). --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 10cc80453..ae618c6e4 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -200,6 +200,9 @@ curl_easy_strerror(CURLcode error) case CURLE_SSL_ENGINE_SETFAILED: return "can not set SSL crypto engine as default"; + case CURLE_SSL_ENGINE_INITFAILED: + return "failed to initialise SSL crypto engine"; + case CURLE_SEND_ERROR: return "failed sending data to the peer"; -- cgit v1.2.1 From bb9e5565f2f9ca4d9cf1a4392f9527a5438492d6 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Tue, 11 Jan 2005 14:32:09 +0000 Subject: ".\lib\multi.h" shadows for in Watcom. Force including ../include/curl/multi.h. --- lib/strerror.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index ae618c6e4..f07e1df47 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -31,6 +31,7 @@ #include #endif +#include "multi.h" #include "strerror.h" #define _MPRINTF_REPLACE /* use our functions only */ -- cgit v1.2.1 From e3fa7d021e4f37db40229a7c8f93296d4132e4db Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 11 Jan 2005 15:25:29 +0000 Subject: Renamed easy.h and multi.h to easyif.h and multiif.h to make sure they don't shadow our public headers with the former names. --- lib/strerror.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index f07e1df47..ae618c6e4 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -31,7 +31,6 @@ #include #endif -#include "multi.h" #include "strerror.h" #define _MPRINTF_REPLACE /* use our functions only */ -- cgit v1.2.1 From 64dd9c76563269ca7a0aec0642b396e83b16c8f6 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Wed, 9 Feb 2005 13:59:40 +0000 Subject: Handle CURLE_LOGIN_DENIED in strerror.c. For ftp only? --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index ae618c6e4..0f0c0fff2 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -236,6 +236,9 @@ curl_easy_strerror(CURLcode error) case CURLE_SEND_FAIL_REWIND: return "Send failed since rewinding of the data stream failed"; + case CURLE_LOGIN_DENIED: + return "FTP: login denied";; + case CURLE_URL_MALFORMAT_USER: /* not used by current libcurl */ case CURLE_MALFORMAT_USER: /* not used by current libcurl */ case CURLE_BAD_CALLING_ORDER: /* not used by current libcurl */ -- cgit v1.2.1 From 3916d1e6cbe8eb5cb4dbbc43690b44b0b8fe6cc1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 14 Mar 2005 15:43:23 +0000 Subject: silence compiler warnings for mingw win32 builds --enable-debug --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 0f0c0fff2..85baa635d 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -346,7 +346,7 @@ curl_share_strerror(CURLSHcode error) static const char * get_winsock_error (int err, char *buf, size_t len) { - char *p; + const char *p; #ifndef CURL_DISABLE_VERBOSE_STRINGS switch (err) { -- cgit v1.2.1 From d5bdd2b2f98f22388527e2749ff77b95a03b86c5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 15 Mar 2005 07:47:59 +0000 Subject: prevent compiler warning --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 85baa635d..b567f9bee 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -553,7 +553,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) #if defined(WIN32) && !defined(__CYGWIN__) -#if _WIN32_WCE +#ifdef _WIN32_WCE buf[0]=0; { wchar_t wbuf[256]; -- cgit v1.2.1 From 6b1220b61d5ed2481dbf31714a68be6ef6eed3da Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 26 Apr 2005 13:08:49 +0000 Subject: Cory Nelson's work on nuking compiler warnings when building on x64 with VS2005. --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index b567f9bee..dcc7f5040 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -571,7 +571,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) else { if (!get_winsock_error(err, buf, max) && !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, - LANG_NEUTRAL, buf, max, NULL)) + LANG_NEUTRAL, buf, (DWORD)max, NULL)) snprintf(buf, max, "Unknown error %d (%#x)", err, err); } #endif -- cgit v1.2.1 From dd7b6aef392c3d7cf4e3e346c1d15a3067da6d19 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 18 May 2005 13:24:23 +0000 Subject: The configure check for strerror_r() failed to detect the proper API at times, like on my HP-UX 10.20 tests. And then lib/strerror.c badly assumed the glibc version if the posix define wasn't set (since it _had_ found a strerror_r). --- lib/strerror.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index dcc7f5040..68e00cf2d 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -22,6 +22,12 @@ #include "setup.h" +#ifdef HAVE_STRERROR_R +#if !defined(HAVE_POSIX_STRERROR_R) && !defined(HAVE_GLIBC_STRERROR_R) +#error "you MUST have either POSIX or glibc strerror_r if strerror_r is found" +#endif /* !POSIX && !glibc */ +#endif /* HAVE_STRERROR_R */ + #include #include #include -- cgit v1.2.1 From 6e87cf5b30ac44447315f66ffa164e8eec8df831 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 21 Jul 2005 22:18:35 +0000 Subject: Fixed some typos in output messages. --- lib/strerror.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 68e00cf2d..2d0b34270 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -69,10 +69,10 @@ curl_easy_strerror(CURLcode error) return "URL using bad/illegal format or missing URL"; case CURLE_COULDNT_RESOLVE_PROXY: - return "couldnt resolve proxy name"; + return "couldn't resolve proxy name"; case CURLE_COULDNT_RESOLVE_HOST: - return "couldnt resolve host name"; + return "couldn't resolve host name"; case CURLE_COULDNT_CONNECT: return "couldn't connect to server"; @@ -492,7 +492,7 @@ get_winsock_error (int err, char *buf, size_t len) p = "Winsock library is not ready"; break; case WSANOTINITIALISED: - p = "Winsock library not initalised"; + p = "Winsock library not initialised"; break; case WSAVERNOTSUPPORTED: p = "Winsock version not supported."; -- cgit v1.2.1 From 56d9624b566ac15ffb4b4b6eef220a5000b767e0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 2 Sep 2005 15:11:08 +0000 Subject: John Kelly added TFTP support to libcurl. A bunch of new error codes was added. TODO: add them to docs. add TFTP server to test suite. add TFTP to list of protocols whereever those are mentioned. --- lib/strerror.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 2d0b34270..4edd28ac7 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -245,6 +245,27 @@ curl_easy_strerror(CURLcode error) case CURLE_LOGIN_DENIED: return "FTP: login denied";; + case CURLE_TFTP_NOTFOUND: + return "TFTP: File Not Found";; + + case CURLE_TFTP_PERM: + return "TFTP: Access Violation";; + + case CURLE_TFTP_DISKFULL: + return "TFTP: Disk full or allocation exceeded";; + + case CURLE_TFTP_ILLEGAL: + return "TFTP: Illegal operation";; + + case CURLE_TFTP_UNKNOWNID: + return "TFTP: Unknown transfer ID";; + + case CURLE_TFTP_EXISTS: + return "TFTP: File already exists";; + + case CURLE_TFTP_NOSUCHUSER: + return "TFTP: No such user";; + case CURLE_URL_MALFORMAT_USER: /* not used by current libcurl */ case CURLE_MALFORMAT_USER: /* not used by current libcurl */ case CURLE_BAD_CALLING_ORDER: /* not used by current libcurl */ -- cgit v1.2.1 From 9c312637d1875602bdb8f69c6e9741ffc5d4e5af Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 2 Dec 2005 23:22:45 +0000 Subject: Yang Tse's fix to only provide the proto if there is such a function and we didn't find any proto --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 4edd28ac7..216ac2964 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -42,7 +42,7 @@ #define _MPRINTF_REPLACE /* use our functions only */ #include -#ifdef HAVE_NO_STRERROR_R_DECL +#if defined(HAVE_STRERROR_R) && defined(HAVE_NO_STRERROR_R_DECL) #ifdef HAVE_POSIX_STRERROR_R /* seen on AIX 5100-02 gcc 2.9 */ extern int strerror_r(int errnum, char *strerrbuf, size_t buflen); -- cgit v1.2.1 From 5a4b43848ac21b3d831f00ce11136e20f820f0a0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 7 Apr 2006 21:50:47 +0000 Subject: First commit of David McCreedy's EBCDIC and TPF changes. --- lib/strerror.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 216ac2964..b690fc1b7 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -132,7 +132,11 @@ curl_easy_strerror(CURLcode error) return "failed to open/read local data from file/application"; case CURLE_OUT_OF_MEMORY: +#ifdef CURL_DOES_CONVERSIONS + return "conversion failed -or- out of memory"; +#else return "out of memory"; +#endif /* CURL_DOES_CONVERSIONS */ case CURLE_OPERATION_TIMEOUTED: return "a timeout was reached"; @@ -266,6 +270,12 @@ curl_easy_strerror(CURLcode error) case CURLE_TFTP_NOSUCHUSER: return "TFTP: No such user";; + case CURLE_CONV_FAILED: + return "conversion failed"; + + case CURLE_CONV_REQD: + return "caller must register CURLOPT_CONV_ callback options"; + case CURLE_URL_MALFORMAT_USER: /* not used by current libcurl */ case CURLE_MALFORMAT_USER: /* not used by current libcurl */ case CURLE_BAD_CALLING_ORDER: /* not used by current libcurl */ -- cgit v1.2.1 From a21a77d2308157dc6058f4356b2d29008e5bc155 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 9 Apr 2006 22:41:22 +0000 Subject: CURLE_FTP_USER_PASSWORD_INCORRECT is not returned by libcurl anymore! --- lib/strerror.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index b690fc1b7..df3bac084 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004, Daniel Stenberg, , et al. + * Copyright (C) 2004, 2006, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -83,9 +83,6 @@ curl_easy_strerror(CURLcode error) case CURLE_FTP_ACCESS_DENIED: return "FTP: access denied"; - case CURLE_FTP_USER_PASSWORD_INCORRECT: - return "FTP: user and/or password incorrect"; - case CURLE_FTP_WEIRD_PASS_REPLY: return "FTP: unknown PASS reply"; @@ -276,11 +273,13 @@ curl_easy_strerror(CURLcode error) case CURLE_CONV_REQD: return "caller must register CURLOPT_CONV_ callback options"; - case CURLE_URL_MALFORMAT_USER: /* not used by current libcurl */ - case CURLE_MALFORMAT_USER: /* not used by current libcurl */ - case CURLE_BAD_CALLING_ORDER: /* not used by current libcurl */ - case CURLE_BAD_PASSWORD_ENTERED:/* not used by current libcurl */ - case CURLE_OBSOLETE: /* not used by current libcurl */ + /* error codes not used by current libcurl */ + case CURLE_URL_MALFORMAT_USER: + case CURLE_FTP_USER_PASSWORD_INCORRECT: + case CURLE_MALFORMAT_USER: + case CURLE_BAD_CALLING_ORDER: + case CURLE_BAD_PASSWORD_ENTERED: + case CURLE_OBSOLETE: case CURL_LAST: break; } -- cgit v1.2.1 From 686d90745be4417127050ad4b36d0a5403def200 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 10 Apr 2006 15:00:53 +0000 Subject: First curl_multi_socket() commit. Should primarily be considered as an internal code rearrange to fit the future better. --- lib/strerror.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index df3bac084..b035e6772 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -329,6 +329,12 @@ curl_multi_strerror(CURLMcode error) case CURLM_INTERNAL_ERROR: return "internal error"; + case CURLM_BAD_SOCKET: + return "invalid socket argument"; + + case CURLM_UNKNOWN_OPTION: + return "unknown option"; + case CURLM_LAST: break; } -- cgit v1.2.1 From 12db20be4e8b0130aba7342a1124eb85e3115822 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Wed, 26 Apr 2006 17:26:22 +0000 Subject: Fixed signed/unsigned convertion errors in Salford-C. #ifdef around WSAEDISCON in strerror.c. --- lib/strerror.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index b035e6772..faa750856 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -519,10 +519,11 @@ get_winsock_error (int err, char *buf, size_t len) case WSAEREMOTE: p = "Remote error"; break; +#ifdef WSAEDISCON /* missing in SalfordC! */ case WSAEDISCON: p = "Disconnected"; break; - +#endif /* Extended Winsock errors */ case WSASYSNOTREADY: p = "Winsock library is not ready"; -- cgit v1.2.1 From 06a7b0561bca2b7dccabeef4c9bb9237e514e1a5 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Wed, 26 Apr 2006 17:27:36 +0000 Subject: Added revision ID-tag. --- lib/strerror.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index faa750856..c730670c9 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -18,6 +18,7 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * + * $Id$ ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From ee642859ef04b9588e654ded629224fb0756f017 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 1 Aug 2006 09:39:01 +0000 Subject: Maciej Karpiuk fixed a crash that would occur if we passed Curl_strerror() an unknown error number on glibc systems. http://curl.haxx.se/bug/view.cgi?id=1532289 --- lib/strerror.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index c730670c9..0309e4ff7 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004, 2006, Daniel Stenberg, , et al. + * Copyright (C) 2004 - 2006, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -637,8 +637,11 @@ const char *Curl_strerror(struct connectdata *conn, int err) char *msg = strerror_r(err, buffer, sizeof(buffer)); /* this version of strerror_r() only *might* use the buffer we pass to the function, but it always returns the error message as a pointer, - so we must copy that string unconditionally */ - strncpy(buf, msg, max); + so we must copy that string unconditionally (if non-NULL) */ + if(msg) + strncpy(buf, msg, max); + else + snprintf(buf, max, "Unknown error %d", err); } #endif /* end of HAVE_GLIBC_STRERROR_R */ #else /* HAVE_STRERROR_R */ -- cgit v1.2.1 From e150150d9f1e0578c85af05de15ab6336066cec1 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 11 Oct 2006 16:01:16 +0000 Subject: Remove redundant __CYGWIN__ symbol check --- lib/strerror.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 0309e4ff7..5b01a2297 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -382,7 +382,7 @@ curl_share_strerror(CURLSHcode error) #endif } -#if defined(WIN32) && !defined(__CYGWIN__) +#ifdef WIN32 /* This function handles most / all (?) Winsock errors cURL is able to produce. */ @@ -570,7 +570,7 @@ get_winsock_error (int err, char *buf, size_t len) buf [len-1] = '\0'; return buf; } -#endif /* WIN32 && !__CYGWIN__ */ +#endif /* WIN32 */ /* * Our thread-safe and smart strerror() replacement. @@ -595,7 +595,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) max = sizeof(conn->syserr_buf)-1; *buf = '\0'; -#if defined(WIN32) && !defined(__CYGWIN__) +#ifdef WIN32 #ifdef _WIN32_WCE buf[0]=0; -- cgit v1.2.1 From 2260c8aa11ef1bb0d7e119ad523ee0387647d9e7 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Sun, 15 Oct 2006 20:28:03 +0000 Subject: Replace ";;" with ";". --- lib/strerror.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 5b01a2297..5a1a83dd1 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -245,28 +245,28 @@ curl_easy_strerror(CURLcode error) return "Send failed since rewinding of the data stream failed"; case CURLE_LOGIN_DENIED: - return "FTP: login denied";; + return "FTP: login denied"; case CURLE_TFTP_NOTFOUND: - return "TFTP: File Not Found";; + return "TFTP: File Not Found"; case CURLE_TFTP_PERM: - return "TFTP: Access Violation";; + return "TFTP: Access Violation"; case CURLE_TFTP_DISKFULL: - return "TFTP: Disk full or allocation exceeded";; + return "TFTP: Disk full or allocation exceeded"; case CURLE_TFTP_ILLEGAL: - return "TFTP: Illegal operation";; + return "TFTP: Illegal operation"; case CURLE_TFTP_UNKNOWNID: - return "TFTP: Unknown transfer ID";; + return "TFTP: Unknown transfer ID"; case CURLE_TFTP_EXISTS: - return "TFTP: File already exists";; + return "TFTP: File already exists"; case CURLE_TFTP_NOSUCHUSER: - return "TFTP: No such user";; + return "TFTP: No such user"; case CURLE_CONV_FAILED: return "conversion failed"; -- cgit v1.2.1 From 5df4be11657fc49d74e1e6b39c0003f7cf2f3772 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 18 Oct 2006 21:05:40 +0000 Subject: Check for USE_WINSOCK instead of WIN32 where the check was done to verify winsock API availability. --- lib/strerror.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 5a1a83dd1..62ccfe9a0 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -382,7 +382,7 @@ curl_share_strerror(CURLSHcode error) #endif } -#ifdef WIN32 +#ifdef USE_WINSOCK /* This function handles most / all (?) Winsock errors cURL is able to produce. */ @@ -570,7 +570,7 @@ get_winsock_error (int err, char *buf, size_t len) buf [len-1] = '\0'; return buf; } -#endif /* WIN32 */ +#endif /* USE_WINSOCK */ /* * Our thread-safe and smart strerror() replacement. @@ -595,7 +595,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) max = sizeof(conn->syserr_buf)-1; *buf = '\0'; -#ifdef WIN32 +#ifdef USE_WINSOCK #ifdef _WIN32_WCE buf[0]=0; @@ -619,7 +619,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) snprintf(buf, max, "Unknown error %d (%#x)", err, err); } #endif -#else /* not native Windows coming up */ +#else /* not USE_WINSOCK coming up */ /* These should be atomic and hopefully thread-safe */ #ifdef HAVE_STRERROR_R @@ -647,7 +647,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) #else /* HAVE_STRERROR_R */ strncpy(buf, strerror(err), max); #endif /* end of HAVE_STRERROR_R */ -#endif /* end of ! Windows */ +#endif /* end of ! USE_WINSOCK */ buf[max] = '\0'; /* make sure the string is zero terminated */ -- cgit v1.2.1 From 4e717cdb300adeff3b259b3619b29a944c2960a8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 21 Oct 2006 11:32:05 +0000 Subject: Armel Asselin separated CA cert verification problems from problems with reading the (local) CA cert file to let users easier pinpoint the actual problem. CURLE_SSL_CACERT_BADFILE (77) is the new libcurl error code. --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 62ccfe9a0..3e466c688 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -227,6 +227,9 @@ curl_easy_strerror(CURLcode error) return "couldn't use specified SSL cipher"; case CURLE_SSL_CACERT: + return "peer certificate cannot be authenticated with known CA certificates"; + + case CURLE_SSL_CACERT_BADFILE: return "problem with the SSL CA cert (path? access rights?)"; case CURLE_BAD_CONTENT_ENCODING: -- cgit v1.2.1 From 2147284cad624325f5b0034c2f394db62086d9e6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 2 Nov 2006 21:56:40 +0000 Subject: James Housley brought support for SCP transfers --- lib/strerror.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 3e466c688..4c2dacabc 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -277,6 +277,12 @@ curl_easy_strerror(CURLcode error) case CURLE_CONV_REQD: return "caller must register CURLOPT_CONV_ callback options"; + case CURLE_REMOTE_FILE_NOT_FOUND: + return "Remote file not found"; + + case CURLE_SSH: + return "Error in the SSH layer"; + /* error codes not used by current libcurl */ case CURLE_URL_MALFORMAT_USER: case CURLE_FTP_USER_PASSWORD_INCORRECT: -- cgit v1.2.1 From 4750e6f3c5fd42e19998242ddb63d7d5506b9fd9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Jan 2007 23:11:14 +0000 Subject: - Linus Nielsen Feltzing introduced the --ftp-ssl-ccc command line option to curl that uses the new CURLOPT_FTP_SSL_CCC option in libcurl. If enabled, it will make libcurl shutdown SSL/TLS after the authentication is done on a FTP-SSL operation. --- lib/strerror.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 4c2dacabc..2634dffdb 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004 - 2006, Daniel Stenberg, , et al. + * Copyright (C) 2004 - 2007, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -244,6 +244,9 @@ curl_easy_strerror(CURLcode error) case CURLE_FTP_SSL_FAILED: return "Requested FTP SSL level failed"; + case CURLE_FTP_SSL_CCC_FAILED: + return "Failed to clear the FTP command channel"; + case CURLE_SEND_FAIL_REWIND: return "Send failed since rewinding of the data stream failed"; -- cgit v1.2.1 From d4651994110612c476a2b65dfa0f9b4f138fca68 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Mon, 8 Jan 2007 11:24:11 +0000 Subject: Correct error code for CCC/SSL shutdown failure --- lib/strerror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 2634dffdb..6304fe89d 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -244,8 +244,8 @@ curl_easy_strerror(CURLcode error) case CURLE_FTP_SSL_FAILED: return "Requested FTP SSL level failed"; - case CURLE_FTP_SSL_CCC_FAILED: - return "Failed to clear the FTP command channel"; + case CURLE_SSL_SHUTDOWN_FAILED: + return "Failed to shut down the SSL connection"; case CURLE_SEND_FAIL_REWIND: return "Send failed since rewinding of the data stream failed"; -- cgit v1.2.1 From f99ca905404b4215bf077fa36dd603706958f2cd Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 15 Feb 2007 01:38:07 +0000 Subject: Daniel Mirchandani fix to make libcurl build nicely on Winsock build targets when --disable-verbose is specified. --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 6304fe89d..e18af7286 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -573,7 +573,7 @@ get_winsock_error (int err, char *buf, size_t len) return NULL; } #else - if (error == CURLE_OK) + if (err == CURLE_OK) return NULL; else p = "error"; -- cgit v1.2.1 From 3a634a273a7bff3d219883f572db786e2c1004b1 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 21 Feb 2007 19:03:20 +0000 Subject: curlassert macro replaced with DEBUGASSERT macro defined in setup_once.h --- lib/strerror.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index e18af7286..b07067cec 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -600,8 +600,8 @@ const char *Curl_strerror(struct connectdata *conn, int err) char *buf, *p; size_t max; - curlassert(conn); - curlassert(err >= 0); + DEBUGASSERT(conn); + DEBUGASSERT(err >= 0); buf = conn->syserr_buf; max = sizeof(conn->syserr_buf)-1; @@ -685,7 +685,7 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) char *buf; size_t max; - curlassert(conn); + DEBUGASSERT(conn); buf = conn->syserr_buf; max = sizeof(conn->syserr_buf)-1; -- cgit v1.2.1 From 1b7f00b2a68b59249181dac6557630e20f394ea6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 8 May 2007 11:34:31 +0000 Subject: CURLE_FTP_COULDNT_STOR_FILE is now known as CURLE_UPLOAD_FAILED. This is because I just made SCP uploads return this value if the file size of the upload file isn't given with CURLOPT_INFILESIZE*. Docs updated to reflect this news, and a define for the old name was added to the public header file. --- lib/strerror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index b07067cec..118c98ede 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -123,8 +123,8 @@ curl_easy_strerror(CURLcode error) case CURLE_WRITE_ERROR: return "failed writing received data to disk/application"; - case CURLE_FTP_COULDNT_STOR_FILE: - return "failed FTP upload (the STOR command)"; + case CURLE_UPLOAD_FAILED: + return "upload failed (at start/before it took off)"; case CURLE_READ_ERROR: return "failed to open/read local data from file/application"; -- cgit v1.2.1 From 9f44a95522162c0f4a61093efe1bf1f58b087358 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 30 Aug 2007 20:34:57 +0000 Subject: Renamed several libcurl error codes and options to make them more general and allow reuse by multiple protocols. Several unused error codes were removed. In all cases, macros were added to preserve source (and binary) compatibility with the old names. These macros are subject to removal at a future date, but probably not before 2009. An application can be tested to see if it is using any obsolete code by compiling it with the CURL_NO_OLDIES macro defined. Documented some newer error codes in libcurl-error(3) --- lib/strerror.c | 68 +++++++++++++++++++++------------------------------------- 1 file changed, 25 insertions(+), 43 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 118c98ede..1c33d216d 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -81,15 +81,12 @@ curl_easy_strerror(CURLcode error) case CURLE_FTP_WEIRD_SERVER_REPLY: return "FTP: weird server reply"; - case CURLE_FTP_ACCESS_DENIED: - return "FTP: access denied"; + case CURLE_REMOTE_ACCESS_DENIED: + return "access denied"; case CURLE_FTP_WEIRD_PASS_REPLY: return "FTP: unknown PASS reply"; - case CURLE_FTP_WEIRD_USER_REPLY: - return "FTP: unknown USER reply"; - case CURLE_FTP_WEIRD_PASV_REPLY: return "FTP: unknown PASV reply"; @@ -99,11 +96,8 @@ curl_easy_strerror(CURLcode error) case CURLE_FTP_CANT_GET_HOST: return "FTP: can't figure out the host in the PASV response"; - case CURLE_FTP_CANT_RECONNECT: - return "FTP: can't connect to server the response code is unknown"; - - case CURLE_FTP_COULDNT_SET_BINARY: - return "FTP: couldn't set binary mode"; + case CURLE_FTP_COULDNT_SET_TYPE: + return "FTP: couldn't set file type"; case CURLE_PARTIAL_FILE: return "Transferred a partial file"; @@ -111,11 +105,8 @@ curl_easy_strerror(CURLcode error) case CURLE_FTP_COULDNT_RETR_FILE: return "FTP: couldn't retrieve (RETR failed) the specified file"; - case CURLE_FTP_WRITE_ERROR: - return "FTP: the post-transfer acknowledge response was not OK"; - - case CURLE_FTP_QUOTE_ERROR: - return "FTP: a quote command returned error"; + case CURLE_QUOTE_ERROR: + return "a quote command returned error"; case CURLE_HTTP_RETURNED_ERROR: return "HTTP response code said error"; @@ -130,28 +121,18 @@ curl_easy_strerror(CURLcode error) return "failed to open/read local data from file/application"; case CURLE_OUT_OF_MEMORY: -#ifdef CURL_DOES_CONVERSIONS - return "conversion failed -or- out of memory"; -#else return "out of memory"; -#endif /* CURL_DOES_CONVERSIONS */ - case CURLE_OPERATION_TIMEOUTED: + case CURLE_OPERATION_TIMEDOUT: return "a timeout was reached"; - case CURLE_FTP_COULDNT_SET_ASCII: - return "FTP could not set ASCII mode (TYPE A)"; - case CURLE_FTP_PORT_FAILED: return "FTP command PORT failed"; case CURLE_FTP_COULDNT_USE_REST: return "FTP command REST failed"; - case CURLE_FTP_COULDNT_GET_SIZE: - return "FTP command SIZE failed"; - - case CURLE_HTTP_RANGE_ERROR: + case CURLE_RANGE_ERROR: return "a range was requested but the server did not deliver it"; case CURLE_HTTP_POST_ERROR: @@ -172,9 +153,6 @@ curl_easy_strerror(CURLcode error) case CURLE_LDAP_SEARCH_FAILED: return "LDAP: search failed"; - case CURLE_LIBRARY_NOT_FOUND: - return "a required shared library was not found"; - case CURLE_FUNCTION_NOT_FOUND: return "a required function in the shared library was not found"; @@ -217,9 +195,6 @@ curl_easy_strerror(CURLcode error) case CURLE_RECV_ERROR: return "failure when receiving data from the peer"; - case CURLE_SHARE_IN_USE: - return "share is already in use"; - case CURLE_SSL_CERTPROBLEM: return "problem with the local SSL certificate"; @@ -259,8 +234,8 @@ curl_easy_strerror(CURLcode error) case CURLE_TFTP_PERM: return "TFTP: Access Violation"; - case CURLE_TFTP_DISKFULL: - return "TFTP: Disk full or allocation exceeded"; + case CURLE_REMOTE_DISK_FULL: + return "Disk full or allocation exceeded"; case CURLE_TFTP_ILLEGAL: return "TFTP: Illegal operation"; @@ -268,8 +243,8 @@ curl_easy_strerror(CURLcode error) case CURLE_TFTP_UNKNOWNID: return "TFTP: Unknown transfer ID"; - case CURLE_TFTP_EXISTS: - return "TFTP: File already exists"; + case CURLE_REMOTE_FILE_EXISTS: + return "File already exists"; case CURLE_TFTP_NOSUCHUSER: return "TFTP: No such user"; @@ -287,12 +262,19 @@ curl_easy_strerror(CURLcode error) return "Error in the SSH layer"; /* error codes not used by current libcurl */ - case CURLE_URL_MALFORMAT_USER: - case CURLE_FTP_USER_PASSWORD_INCORRECT: - case CURLE_MALFORMAT_USER: - case CURLE_BAD_CALLING_ORDER: - case CURLE_BAD_PASSWORD_ENTERED: - case CURLE_OBSOLETE: + case CURLE_OBSOLETE4: + case CURLE_OBSOLETE10: + case CURLE_OBSOLETE12: + case CURLE_OBSOLETE16: + case CURLE_OBSOLETE20: + case CURLE_OBSOLETE24: + case CURLE_OBSOLETE29: + case CURLE_OBSOLETE32: + case CURLE_OBSOLETE40: + case CURLE_OBSOLETE44: + case CURLE_OBSOLETE46: + case CURLE_OBSOLETE50: + case CURLE_OBSOLETE57: case CURL_LAST: break; } -- cgit v1.2.1 From ac6e0501c6a337ee39516d2ae085307d0c4f7a6e Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 31 Aug 2007 17:56:06 +0000 Subject: Made some of the error strings returned by the *strerror functions more generic, and more consistent with each other. --- lib/strerror.c | 134 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 67 insertions(+), 67 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 1c33d216d..9193fd0ca 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -58,31 +58,31 @@ curl_easy_strerror(CURLcode error) #ifndef CURL_DISABLE_VERBOSE_STRINGS switch (error) { case CURLE_OK: - return "no error"; + return "No error"; case CURLE_UNSUPPORTED_PROTOCOL: - return "unsupported protocol"; + return "Unsupported protocol"; case CURLE_FAILED_INIT: - return "failed init"; + return "Failed initialization"; case CURLE_URL_MALFORMAT: return "URL using bad/illegal format or missing URL"; case CURLE_COULDNT_RESOLVE_PROXY: - return "couldn't resolve proxy name"; + return "Couldn't resolve proxy name"; case CURLE_COULDNT_RESOLVE_HOST: - return "couldn't resolve host name"; + return "Couldn't resolve host name"; case CURLE_COULDNT_CONNECT: - return "couldn't connect to server"; + return "Couldn't connect to server"; case CURLE_FTP_WEIRD_SERVER_REPLY: return "FTP: weird server reply"; case CURLE_REMOTE_ACCESS_DENIED: - return "access denied"; + return "Access denied to remote resource"; case CURLE_FTP_WEIRD_PASS_REPLY: return "FTP: unknown PASS reply"; @@ -106,46 +106,46 @@ curl_easy_strerror(CURLcode error) return "FTP: couldn't retrieve (RETR failed) the specified file"; case CURLE_QUOTE_ERROR: - return "a quote command returned error"; + return "Quote command returned error"; case CURLE_HTTP_RETURNED_ERROR: return "HTTP response code said error"; case CURLE_WRITE_ERROR: - return "failed writing received data to disk/application"; + return "Failed writing received data to disk/application"; case CURLE_UPLOAD_FAILED: - return "upload failed (at start/before it took off)"; + return "Upload failed (at start/before it took off)"; case CURLE_READ_ERROR: - return "failed to open/read local data from file/application"; + return "Failed to open/read local data from file/application"; case CURLE_OUT_OF_MEMORY: - return "out of memory"; + return "Out of memory"; case CURLE_OPERATION_TIMEDOUT: - return "a timeout was reached"; + return "Timeout was reached"; case CURLE_FTP_PORT_FAILED: - return "FTP command PORT failed"; + return "FTP: command PORT failed"; case CURLE_FTP_COULDNT_USE_REST: - return "FTP command REST failed"; + return "FTP: command REST failed"; case CURLE_RANGE_ERROR: - return "a range was requested but the server did not deliver it"; + return "Requested range was not delivered by the server"; case CURLE_HTTP_POST_ERROR: - return "internal problem setting up the POST"; + return "Internal problem setting up the POST"; case CURLE_SSL_CONNECT_ERROR: return "SSL connect error"; case CURLE_BAD_DOWNLOAD_RESUME: - return "couldn't resume download"; + return "Couldn't resume download"; case CURLE_FILE_COULDNT_READ_FILE: - return "couldn't read a file:// file"; + return "Couldn't read a file:// file"; case CURLE_LDAP_CANNOT_BIND: return "LDAP: cannot bind"; @@ -154,58 +154,58 @@ curl_easy_strerror(CURLcode error) return "LDAP: search failed"; case CURLE_FUNCTION_NOT_FOUND: - return "a required function in the shared library was not found"; + return "A required function in the library was not found"; case CURLE_ABORTED_BY_CALLBACK: - return "the operation was aborted by an application callback"; + return "Operation was aborted by an application callback"; case CURLE_BAD_FUNCTION_ARGUMENT: - return "a libcurl function was given a bad argument"; + return "A libcurl function was given a bad argument"; case CURLE_INTERFACE_FAILED: - return "failed binding local connection end"; + return "Failed binding local connection end"; case CURLE_TOO_MANY_REDIRECTS : - return "number of redirects hit maximum amount"; + return "Number of redirects hit maximum amount"; case CURLE_UNKNOWN_TELNET_OPTION: - return "User specified an unknown option"; + return "User specified an unknown telnet option"; case CURLE_TELNET_OPTION_SYNTAX : return "Malformed telnet option"; case CURLE_SSL_PEER_CERTIFICATE: - return "SSL peer certificate was not ok"; + return "SSL peer certificate was not OK"; case CURLE_GOT_NOTHING: - return "server returned nothing (no headers, no data)"; + return "Server returned nothing (no headers, no data)"; case CURLE_SSL_ENGINE_NOTFOUND: return "SSL crypto engine not found"; case CURLE_SSL_ENGINE_SETFAILED: - return "can not set SSL crypto engine as default"; + return "Can not set SSL crypto engine as default"; case CURLE_SSL_ENGINE_INITFAILED: - return "failed to initialise SSL crypto engine"; + return "Failed to initialise SSL crypto engine"; case CURLE_SEND_ERROR: - return "failed sending data to the peer"; + return "Failed sending data to the peer"; case CURLE_RECV_ERROR: - return "failure when receiving data from the peer"; + return "Failure when receiving data from the peer"; case CURLE_SSL_CERTPROBLEM: - return "problem with the local SSL certificate"; + return "Problem with the local SSL certificate"; case CURLE_SSL_CIPHER: - return "couldn't use specified SSL cipher"; + return "Couldn't use specified SSL cipher"; case CURLE_SSL_CACERT: - return "peer certificate cannot be authenticated with known CA certificates"; + return "Peer certificate cannot be authenticated with known CA certificates"; case CURLE_SSL_CACERT_BADFILE: - return "problem with the SSL CA cert (path? access rights?)"; + return "Problem with the SSL CA cert (path? access rights?)"; case CURLE_BAD_CONTENT_ENCODING: return "Unrecognized HTTP Content-Encoding"; @@ -226,7 +226,7 @@ curl_easy_strerror(CURLcode error) return "Send failed since rewinding of the data stream failed"; case CURLE_LOGIN_DENIED: - return "FTP: login denied"; + return "Login denied"; case CURLE_TFTP_NOTFOUND: return "TFTP: File Not Found"; @@ -244,16 +244,16 @@ curl_easy_strerror(CURLcode error) return "TFTP: Unknown transfer ID"; case CURLE_REMOTE_FILE_EXISTS: - return "File already exists"; + return "Remote file already exists"; case CURLE_TFTP_NOSUCHUSER: return "TFTP: No such user"; case CURLE_CONV_FAILED: - return "conversion failed"; + return "Conversion failed"; case CURLE_CONV_REQD: - return "caller must register CURLOPT_CONV_ callback options"; + return "Caller must register CURLOPT_CONV_ callback options"; case CURLE_REMOTE_FILE_NOT_FOUND: return "Remote file not found"; @@ -292,12 +292,12 @@ curl_easy_strerror(CURLcode error) * The line number for the error will be near this comment, which * is why it is here, and not at the start of the switch. */ - return "unknown error"; + return "Unknown error"; #else if (error == CURLE_OK) - return "no error"; + return "No error"; else - return "error"; + return "Error"; #endif } @@ -307,39 +307,39 @@ curl_multi_strerror(CURLMcode error) #ifndef CURL_DISABLE_VERBOSE_STRINGS switch (error) { case CURLM_CALL_MULTI_PERFORM: - return "please call curl_multi_perform() soon"; + return "Please call curl_multi_perform() soon"; case CURLM_OK: - return "no error"; + return "No error"; case CURLM_BAD_HANDLE: - return "invalid multi handle"; + return "Invalid multi handle"; case CURLM_BAD_EASY_HANDLE: - return "invalid easy handle"; + return "Invalid easy handle"; case CURLM_OUT_OF_MEMORY: - return "out of memory"; + return "Out of memory"; case CURLM_INTERNAL_ERROR: - return "internal error"; + return "Internal error"; case CURLM_BAD_SOCKET: - return "invalid socket argument"; + return "Invalid socket argument"; case CURLM_UNKNOWN_OPTION: - return "unknown option"; + return "Unknown option"; case CURLM_LAST: break; } - return "unknown error"; + return "Unknown error"; #else if (error == CURLM_OK) - return "no error"; + return "No error"; else - return "error"; + return "Error"; #endif } @@ -349,30 +349,30 @@ curl_share_strerror(CURLSHcode error) #ifndef CURL_DISABLE_VERBOSE_STRINGS switch (error) { case CURLSHE_OK: - return "no error"; + return "No error"; case CURLSHE_BAD_OPTION: - return "unknown share option"; + return "Unknown share option"; case CURLSHE_IN_USE: - return "share currently in use"; + return "Share currently in use"; case CURLSHE_INVALID: - return "invalid share handle"; + return "Invalid share handle"; case CURLSHE_NOMEM: - return "out of memory"; + return "Out of memory"; case CURLSHE_LAST: break; } - return "CURLSH unknown"; + return "CURLSHcode unknown"; #else if (error == CURLSHE_OK) - return "no error"; + return "No error"; else - return "error"; + return "Error"; #endif } @@ -388,7 +388,7 @@ get_winsock_error (int err, char *buf, size_t len) #ifndef CURL_DISABLE_VERBOSE_STRINGS switch (err) { case WSAEINTR: - p = "Call interrupted."; + p = "Call interrupted"; break; case WSAEBADF: p = "Bad file"; @@ -413,7 +413,7 @@ get_winsock_error (int err, char *buf, size_t len) p = "Blocking call in progress"; break; case WSAENOTSOCK: - p = "Descriptor is not a socket."; + p = "Descriptor is not a socket"; break; case WSAEDESTADDRREQ: p = "Need destination address"; @@ -527,7 +527,7 @@ get_winsock_error (int err, char *buf, size_t len) p = "Winsock library not initialised"; break; case WSAVERNOTSUPPORTED: - p = "Winsock version not supported."; + p = "Winsock version not supported"; break; /* getXbyY() errors (already handled in herrmsg): @@ -571,7 +571,7 @@ get_winsock_error (int err, char *buf, size_t len) * * The 'err' argument passed in to this function MUST be a true errno number * as reported on this system. We do no range checking on the number before - * we pass it to the "number-to-message" convertion function and there might + * we pass it to the "number-to-message" conversion function and there might * be systems that don't do proper range checking in there themselves. * * We don't do range checking (on systems other than Windows) since there is @@ -696,7 +696,7 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) str = "No ACE prefix (\"xn--\")"; break; case IDNA_ROUNDTRIP_VERIFY_ERROR: - str = "Roundtrip verify error"; + str = "Round trip verify error"; break; case IDNA_CONTAINS_ACE_PREFIX: str = "Already have ACE prefix (\"xn--\")"; @@ -719,7 +719,7 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) if ((Idna_rc)err == IDNA_SUCCESS) str = "No error"; else - str = "error"; + str = "Error"; #endif if (str) strncpy(buf, str, max); -- cgit v1.2.1 From 3fa60164af98720696cf157158e78ad4e0540aba Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 31 Aug 2007 19:36:32 +0000 Subject: Renamed the CURLE_FTP_SSL_FAILED error code to CURLE_USE_SSL_FAILED. Renamed the curl_ftpssl enum to curl_usessl and its enumerated constants, creating macros for backward compatibility. --- lib/strerror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 9193fd0ca..658a8cba1 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -216,8 +216,8 @@ curl_easy_strerror(CURLcode error) case CURLE_FILESIZE_EXCEEDED: return "Maximum file size exceeded"; - case CURLE_FTP_SSL_FAILED: - return "Requested FTP SSL level failed"; + case CURLE_USE_SSL_FAILED: + return "Requested SSL level failed"; case CURLE_SSL_SHUTDOWN_FAILED: return "Failed to shut down the SSL connection"; -- cgit v1.2.1 From ce81cd21d3865270867d68935c9700dbaf5b5fcc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 3 Oct 2007 08:07:50 +0000 Subject: I renamed the CURLE_SSL_PEER_CERTIFICATE error code to CURLE_PEER_FAILED_VERIFICATION (standard CURL_NO_OLDIES style), and made this return code get used by the previous SSH MD5 fingerprint check in case it fails. --- lib/strerror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 658a8cba1..94c0f8820 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -174,8 +174,8 @@ curl_easy_strerror(CURLcode error) case CURLE_TELNET_OPTION_SYNTAX : return "Malformed telnet option"; - case CURLE_SSL_PEER_CERTIFICATE: - return "SSL peer certificate was not OK"; + case CURLE_PEER_FAILED_VERIFICATION: + return "SSL peer certificate or SSH md5 fingerprint was not OK"; case CURLE_GOT_NOTHING: return "Server returned nothing (no headers, no data)"; -- cgit v1.2.1 From cbd1a77ec24e397d05f20c6de106625676343c9d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 7 Nov 2007 09:21:35 +0000 Subject: if () => if() while () => while() and some other minor re-indentings --- lib/strerror.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 94c0f8820..d2d46a308 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -294,7 +294,7 @@ curl_easy_strerror(CURLcode error) */ return "Unknown error"; #else - if (error == CURLE_OK) + if(error == CURLE_OK) return "No error"; else return "Error"; @@ -336,7 +336,7 @@ curl_multi_strerror(CURLMcode error) return "Unknown error"; #else - if (error == CURLM_OK) + if(error == CURLM_OK) return "No error"; else return "Error"; @@ -369,7 +369,7 @@ curl_share_strerror(CURLSHcode error) return "CURLSHcode unknown"; #else - if (error == CURLSHE_OK) + if(error == CURLSHE_OK) return "No error"; else return "Error"; @@ -555,7 +555,7 @@ get_winsock_error (int err, char *buf, size_t len) return NULL; } #else - if (err == CURLE_OK) + if(err == CURLE_OK) return NULL; else p = "error"; @@ -604,10 +604,10 @@ const char *Curl_strerror(struct connectdata *conn, int err) #else /* 'sys_nerr' is the maximum errno number, it is not widely portable */ - if (err >= 0 && err < sys_nerr) + if(err >= 0 && err < sys_nerr) strncpy(buf, strerror(err), max); else { - if (!get_winsock_error(err, buf, max) && + if(!get_winsock_error(err, buf, max) && !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, LANG_NEUTRAL, buf, (DWORD)max, NULL)) snprintf(buf, max, "Unknown error %d (%#x)", err, err); @@ -646,9 +646,9 @@ const char *Curl_strerror(struct connectdata *conn, int err) buf[max] = '\0'; /* make sure the string is zero terminated */ /* strip trailing '\r\n' or '\n'. */ - if ((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2) + if((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2) *p = '\0'; - if ((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1) + if((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1) *p = '\0'; return buf; } @@ -716,12 +716,12 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) break; } #else - if ((Idna_rc)err == IDNA_SUCCESS) + if((Idna_rc)err == IDNA_SUCCESS) str = "No error"; else str = "Error"; #endif - if (str) + if(str) strncpy(buf, str, max); buf[max] = '\0'; return (buf); -- cgit v1.2.1 From 514592b89207e83d13b5a4e79bc247aa6f74c4b7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 12 May 2008 21:43:24 +0000 Subject: - Introducing curl_easy_send() and curl_easy_recv(). They can be used to send and receive data over a connection previously setup with curl_easy_perform() and its CURLOPT_CONNECT_ONLY option. The sendrecv.c example was added to show how they can be used. --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index d2d46a308..fe5a76df5 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -261,6 +261,9 @@ curl_easy_strerror(CURLcode error) case CURLE_SSH: return "Error in the SSH layer"; + case CURLE_AGAIN: + return "Socket not ready for send/recv"; + /* error codes not used by current libcurl */ case CURLE_OBSOLETE4: case CURLE_OBSOLETE10: -- cgit v1.2.1 From 3fe8251dfbb533803e25cc38365114b28c5a1c85 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 6 Jun 2008 18:40:21 +0000 Subject: - Axel Tillequin and Arnaud Ebalard added support for CURLOPT_CRLFILE, for OpenSSL, NSS and GnuTLS-built libcurls. --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index fe5a76df5..03b01582c 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -222,6 +222,9 @@ curl_easy_strerror(CURLcode error) case CURLE_SSL_SHUTDOWN_FAILED: return "Failed to shut down the SSL connection"; + case CURLE_SSL_CRL_BADFILE: + return "Failed to load CRL file (path? access rights?, format?)"; + case CURLE_SEND_FAIL_REWIND: return "Send failed since rewinding of the data stream failed"; -- cgit v1.2.1 From 621c2b901527248b4822895bc0305373a7d2dd63 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 6 Jun 2008 20:52:32 +0000 Subject: - Axel Tillequin and Arnaud Ebalard added support for CURLOPT_ISSUERCERT, for OpenSSL, NSS and GnuTLS-built libcurls. --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 03b01582c..032e2c747 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -225,6 +225,9 @@ curl_easy_strerror(CURLcode error) case CURLE_SSL_CRL_BADFILE: return "Failed to load CRL file (path? access rights?, format?)"; + case CURLE_SSL_ISSUER_ERROR: + return "Issuer check against peer certificate failed"; + case CURLE_SEND_FAIL_REWIND: return "Send failed since rewinding of the data stream failed"; -- cgit v1.2.1 From 3dcd2b82c4095e34342c8d0778d45d547c23b06d Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 4 Sep 2008 18:59:05 +0000 Subject: fix print formatting string directives --- lib/strerror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 032e2c747..f1d22e143 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 2004 - 2008, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -720,7 +720,7 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) str = "dlopen() error"; break; default: - snprintf(buf, max, "error %d", (int)err); + snprintf(buf, max, "error %d", err); str = NULL; break; } -- cgit v1.2.1 From c3d1b07c455928de7497677b2da7ffa470a62fee Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 12 Sep 2008 10:51:57 +0000 Subject: ensure that errno is not modified inside Curl_strerror() --- lib/strerror.c | 72 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index f1d22e143..526187bb8 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -24,10 +24,11 @@ #include "setup.h" #ifdef HAVE_STRERROR_R -#if !defined(HAVE_POSIX_STRERROR_R) && !defined(HAVE_GLIBC_STRERROR_R) -#error "you MUST have either POSIX or glibc strerror_r if strerror_r is found" -#endif /* !POSIX && !glibc */ -#endif /* HAVE_STRERROR_R */ +# if (!defined(HAVE_POSIX_STRERROR_R) && !defined(HAVE_GLIBC_STRERROR_R)) || \ + (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)) +# error "strerror_r MUST be either POSIX-style or glibc-style" +# endif +#endif #include #include @@ -43,14 +44,6 @@ #define _MPRINTF_REPLACE /* use our functions only */ #include -#if defined(HAVE_STRERROR_R) && defined(HAVE_NO_STRERROR_R_DECL) -#ifdef HAVE_POSIX_STRERROR_R -/* seen on AIX 5100-02 gcc 2.9 */ -extern int strerror_r(int errnum, char *strerrbuf, size_t buflen); -#else -extern char *strerror_r(int errnum, char *buf, size_t buflen); -#endif -#endif const char * curl_easy_strerror(CURLcode error) @@ -590,6 +583,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) { char *buf, *p; size_t max; + int old_errno = ERRNO; DEBUGASSERT(conn); DEBUGASSERT(err >= 0); @@ -601,17 +595,15 @@ const char *Curl_strerror(struct connectdata *conn, int err) #ifdef USE_WINSOCK #ifdef _WIN32_WCE - buf[0]=0; { wchar_t wbuf[256]; + wbuf[0] = L'\0'; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL); wcstombs(buf,wbuf,max); } - #else - /* 'sys_nerr' is the maximum errno number, it is not widely portable */ if(err >= 0 && err < sys_nerr) strncpy(buf, strerror(err), max); @@ -622,34 +614,43 @@ const char *Curl_strerror(struct connectdata *conn, int err) snprintf(buf, max, "Unknown error %d (%#x)", err, err); } #endif + #else /* not USE_WINSOCK coming up */ - /* These should be atomic and hopefully thread-safe */ -#ifdef HAVE_STRERROR_R - /* There are two different APIs for strerror_r(). The POSIX and the GLIBC - versions. */ -#ifdef HAVE_POSIX_STRERROR_R - strerror_r(err, buf, max); - /* this may set errno to ERANGE if insufficient storage was supplied via - 'strerrbuf' and 'buflen' to contain the generated message string, or - EINVAL if the value of 'errnum' is not a valid error number.*/ -#else +#if defined(HAVE_STRERROR_R) && defined(HAVE_POSIX_STRERROR_R) + /* + * The POSIX-style strerror_r() may set errno to ERANGE if insufficient + * storage is supplied via 'strerrbuf' and 'buflen' to hold the generated + * message string, or EINVAL if 'errnum' is not a valid error number. + */ + if(0 != strerror_r(err, buf, max)) { + if('\0' == buf[0]) + snprintf(buf, max, "Unknown error %d", err); + } +#elif defined(HAVE_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R) + /* + * The glibc-style strerror_r() only *might* use the buffer we pass to + * the function, but it always returns the error message as a pointer, + * so we must copy that string unconditionally (if non-NULL). + */ { - /* HAVE_GLIBC_STRERROR_R */ char buffer[256]; char *msg = strerror_r(err, buffer, sizeof(buffer)); - /* this version of strerror_r() only *might* use the buffer we pass to - the function, but it always returns the error message as a pointer, - so we must copy that string unconditionally (if non-NULL) */ if(msg) strncpy(buf, msg, max); else snprintf(buf, max, "Unknown error %d", err); } -#endif /* end of HAVE_GLIBC_STRERROR_R */ -#else /* HAVE_STRERROR_R */ - strncpy(buf, strerror(err), max); -#endif /* end of HAVE_STRERROR_R */ +#else + { + char *msg = strerror(err); + if(msg) + strncpy(buf, msg, max); + else + snprintf(buf, max, "Unknown error %d", err); + } +#endif + #endif /* end of ! USE_WINSOCK */ buf[max] = '\0'; /* make sure the string is zero terminated */ @@ -659,6 +660,10 @@ const char *Curl_strerror(struct connectdata *conn, int err) *p = '\0'; if((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1) *p = '\0'; + + if(old_errno != ERRNO) + SET_ERRNO(old_errno); + return buf; } @@ -680,6 +685,7 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) buf = conn->syserr_buf; max = sizeof(conn->syserr_buf)-1; + *buf = '\0'; #ifndef CURL_DISABLE_VERBOSE_STRINGS switch ((Idna_rc)err) { -- cgit v1.2.1 From 00883822be245d2660a569e6bde38892b9433aa2 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 4 Jun 2009 19:11:11 +0000 Subject: allow building libcurl for VxWorks --- lib/strerror.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 526187bb8..a45e1f181 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 2004 - 2009, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,9 +24,13 @@ #include "setup.h" #ifdef HAVE_STRERROR_R -# if (!defined(HAVE_POSIX_STRERROR_R) && !defined(HAVE_GLIBC_STRERROR_R)) || \ - (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)) -# error "strerror_r MUST be either POSIX-style or glibc-style" +# if (!defined(HAVE_POSIX_STRERROR_R) && \ + !defined(HAVE_GLIBC_STRERROR_R) && \ + !defined(HAVE_VXWORKS_STRERROR_R)) || \ + (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \ + (defined(HAVE_GLIBC_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \ + (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)) +# error "strerror_r MUST be either POSIX-style, glibc-style or vxworks-style" # endif #endif @@ -641,6 +645,18 @@ const char *Curl_strerror(struct connectdata *conn, int err) else snprintf(buf, max, "Unknown error %d", err); } +#elif defined(HAVE_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R) + /* + * The vxworks-style strerror_r() does use the buffer we pass to the function. + * The buffer size should be at least MAXERRSTR_SIZE (150) defined in rtsold.h + */ + { + char buffer[256]; + if(OK == strerror_r(err, buffer)) + strncpy(buf, buffer, max); + else + snprintf(buf, max, "Unknown error %d", err); + } #else { char *msg = strerror(err); -- cgit v1.2.1 From 47c392e135f17d400acc5d7e99b88d16578cb406 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 22 Jul 2009 22:49:01 +0000 Subject: - Added CURLOPT_SSH_KNOWNHOSTS, CURLOPT_SSH_KEYFUNCTION, CURLOPT_SSH_KEYDATA. They introduce known_host support for SSH keys to libcurl. See docs for details. --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index a45e1f181..75067a7d0 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -172,7 +172,7 @@ curl_easy_strerror(CURLcode error) return "Malformed telnet option"; case CURLE_PEER_FAILED_VERIFICATION: - return "SSL peer certificate or SSH md5 fingerprint was not OK"; + return "SSL peer certificate or SSH remote key was not OK"; case CURLE_GOT_NOTHING: return "Server returned nothing (no headers, no data)"; -- cgit v1.2.1 From 605bbfc4c0fa838f50bf9d18e69e417168f524c0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 1 Jan 2010 14:44:44 +0000 Subject: - Ingmar Runge enhanced libcurl's FTP engine to support the PRET command. This command is a special "hack" used by the drftpd server, but even though it is a custom extension I've deemed it fine to add to libcurl since this server seems to survive and people keep using it and want libcurl to support it. The new libcurl option is named CURLOPT_FTP_USE_PRET, and it is also usable from the curl tool with --ftp-pret. Using this option on a server that doesn't support this command will make libcurl fail. --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 75067a7d0..da223f58d 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -81,6 +81,9 @@ curl_easy_strerror(CURLcode error) case CURLE_REMOTE_ACCESS_DENIED: return "Access denied to remote resource"; + case CURLE_FTP_PRET_FAILED: + return "FTP: The server did not accept the PRET command."; + case CURLE_FTP_WEIRD_PASS_REPLY: return "FTP: unknown PASS reply"; -- cgit v1.2.1 From a62f32d3c2012a4e2e48dac3d9ec780733c4a844 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 1 Jan 2010 14:52:50 +0000 Subject: update copyright year since we are in 2010 now --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index da223f58d..540886919 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 2004 - 2010, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From bc4582b68a673d3b0f5a2e7d971605de2c8b3730 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 21 Jan 2010 13:58:30 +0000 Subject: Chris Conroy brought support for RTSP transfers, and with it comes 8(!) new libcurl options for controlling what to get and how to receive posssibly interleaved RTP data. Initial commit. --- lib/strerror.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 540886919..b16e04b82 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -270,6 +270,12 @@ curl_easy_strerror(CURLcode error) case CURLE_AGAIN: return "Socket not ready for send/recv"; + case CURLE_RTSP_CSEQ_ERROR: + return "RTSP CSeq mismatch or invalid CSeq"; + + case CURLE_RTSP_SESSION_ERROR: + return "RTSP session error"; + /* error codes not used by current libcurl */ case CURLE_OBSOLETE4: case CURLE_OBSOLETE10: -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- lib/strerror.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index b16e04b82..673e89c1f 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -18,7 +18,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From 0825cd80a62c21725fb3615f1fdd3aa6cc5f0f34 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Wed, 12 May 2010 15:33:22 +0200 Subject: FTP: WILDCARDMATCH/CHUNKING/FNMATCH added --- lib/strerror.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 673e89c1f..6fde47702 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -275,6 +275,12 @@ curl_easy_strerror(CURLcode error) case CURLE_RTSP_SESSION_ERROR: return "RTSP session error"; + case CURLE_FTP_BAD_FILE_LIST: + return "Unable to parse FTP file list"; + + case CURLE_CHUNK_FAILED: + return "Chunk callback failed"; + /* error codes not used by current libcurl */ case CURLE_OBSOLETE4: case CURLE_OBSOLETE10: -- cgit v1.2.1 From dcc061543af355d0b8f30d9bfbbd67ebcb0e5752 Mon Sep 17 00:00:00 2001 From: Tor Arntsen Date: Sun, 16 May 2010 22:01:17 +0200 Subject: lib: Change some CRLF line endings to LF An update had added a couple of lines with DOS line endings, and some compilers will choke on that (e.g. the Tru64 compiler). --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 6fde47702..e8ecea59f 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -279,7 +279,7 @@ curl_easy_strerror(CURLcode error) return "Unable to parse FTP file list"; case CURLE_CHUNK_FAILED: - return "Chunk callback failed"; + return "Chunk callback failed"; /* error codes not used by current libcurl */ case CURLE_OBSOLETE4: -- cgit v1.2.1 From 59cf93ccdbaa5e866f9de6b2d9b1ae5cee84863f Mon Sep 17 00:00:00 2001 From: Quinn Slack Date: Wed, 19 Jan 2011 20:35:02 +0100 Subject: TLS-SRP: support added when using GnuTLS --- lib/strerror.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index e8ecea59f..6b67a8777 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 2004 - 2011, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -281,6 +281,9 @@ curl_easy_strerror(CURLcode error) case CURLE_CHUNK_FAILED: return "Chunk callback failed"; + case CURLE_TLSAUTH_FAILED: + return "TLS Authentication failed"; + /* error codes not used by current libcurl */ case CURLE_OBSOLETE4: case CURLE_OBSOLETE10: -- cgit v1.2.1 From 3cffcba3d0cf78a2aa17197059f810f5a7ce05a5 Mon Sep 17 00:00:00 2001 From: Quinn Slack Date: Wed, 9 Feb 2011 23:34:30 +0100 Subject: CURLE_TLSAUTH_FAILED: removed On second thought, I think CURLE_TLSAUTH_FAILED should be eliminated. It was only being raised when an internal error occurred while allocating or setting the GnuTLS SRP client credentials struct. For TLS authentication failures, the general CURLE_SSL_CONNECT_ERROR seems appropriate; its error string already includes "passwords" as a possible cause. Having a separate TLS auth error code might also cause people to think that a TLS auth failure means the wrong username or password was entered, when it could also be a sign of a man-in-the-middle attack. --- lib/strerror.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 6b67a8777..a88cdc4eb 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -281,9 +281,6 @@ curl_easy_strerror(CURLcode error) case CURLE_CHUNK_FAILED: return "Chunk callback failed"; - case CURLE_TLSAUTH_FAILED: - return "TLS Authentication failed"; - /* error codes not used by current libcurl */ case CURLE_OBSOLETE4: case CURLE_OBSOLETE10: -- cgit v1.2.1 From 01f05d0c758795e5bb02c6245fc73b8458eb397a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 5 Apr 2011 15:14:02 +0200 Subject: return code cleanup: build, init and run-time errors Stop the abuse of CURLE_FAILED_INIT as return code for things not being init related by introducing two new return codes: CURLE_NOT_BUILT_IN and CURLE_UNKNOWN_OPTION CURLE_NOT_BUILT_IN replaces return code 4 that has been obsoleted for several years. It is used for returning error when something is attempted to be used but the feature/option was not enabled or explictitly disabled at build-time. Getting this error mostly means that libcurl needs to be rebuilt. CURLE_FAILED_INIT is now saved and used strictly for init failures. Getting this problem means something went seriously wrong, like a resource shortage or similar. CURLE_UNKNOWN_OPTION is the option formerly known as CURLE_UNKNOWN_TELNET_OPTION (and the old name is still present, separately defined to be removed in a very distant future). This error code is meant to be used to return when an option is given to libcurl that isn't known. This problem would mostly indicate a problem in the program that uses libcurl. --- lib/strerror.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index a88cdc4eb..8144f78f0 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -65,6 +65,10 @@ curl_easy_strerror(CURLcode error) case CURLE_URL_MALFORMAT: return "URL using bad/illegal format or missing URL"; + case CURLE_NOT_BUILT_IN: + return "A requested feature, protocol or option was not found built-in in" + " this libcurl due to a build-time decision."; + case CURLE_COULDNT_RESOLVE_PROXY: return "Couldn't resolve proxy name"; @@ -167,8 +171,8 @@ curl_easy_strerror(CURLcode error) case CURLE_TOO_MANY_REDIRECTS : return "Number of redirects hit maximum amount"; - case CURLE_UNKNOWN_TELNET_OPTION: - return "User specified an unknown telnet option"; + case CURLE_UNKNOWN_OPTION: + return "An unknown option was passed in to libcurl"; case CURLE_TELNET_OPTION_SYNTAX : return "Malformed telnet option"; @@ -282,7 +286,6 @@ curl_easy_strerror(CURLcode error) return "Chunk callback failed"; /* error codes not used by current libcurl */ - case CURLE_OBSOLETE4: case CURLE_OBSOLETE10: case CURLE_OBSOLETE12: case CURLE_OBSOLETE16: -- cgit v1.2.1 From ebb37eac8ba8caca5282c41635e491f19fe7df48 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 12 Apr 2011 22:09:18 +0200 Subject: CURLE_BAD_CONTENT_ENCODING: now used for transfer encoding too --- lib/strerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 8144f78f0..59f2df5f7 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -211,7 +211,7 @@ curl_easy_strerror(CURLcode error) return "Problem with the SSL CA cert (path? access rights?)"; case CURLE_BAD_CONTENT_ENCODING: - return "Unrecognized HTTP Content-Encoding"; + return "Unrecognized or bad HTTP Content or Transfer-Encoding"; case CURLE_LDAP_INVALID_URL: return "Invalid LDAP URL"; -- cgit v1.2.1 From b903186fa0189ff241d756d25d07fdfe9885ae49 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 20 Apr 2011 15:17:42 +0200 Subject: source cleanup: unify look, style and indent levels By the use of a the new lib/checksrc.pl script that checks that our basic source style rules are followed. --- lib/strerror.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 59f2df5f7..0a883421e 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -29,7 +29,7 @@ (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \ (defined(HAVE_GLIBC_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \ (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)) -# error "strerror_r MUST be either POSIX-style, glibc-style or vxworks-style" +# error "strerror_r MUST be either POSIX, glibc or vxworks-style" # endif #endif @@ -205,7 +205,8 @@ curl_easy_strerror(CURLcode error) return "Couldn't use specified SSL cipher"; case CURLE_SSL_CACERT: - return "Peer certificate cannot be authenticated with known CA certificates"; + return "Peer certificate cannot be authenticated with given CA " + "certificates"; case CURLE_SSL_CACERT_BADFILE: return "Problem with the SSL CA cert (path? access rights?)"; -- cgit v1.2.1 From ef2176109fca302ed89193716b62c3a7113552a3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 24 Jul 2011 04:39:43 +0200 Subject: errno.h inclusion conditionally done in setup_once.h --- lib/strerror.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 0a883421e..adee28891 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -36,7 +36,6 @@ #include #include #include -#include #ifdef USE_LIBIDN #include -- cgit v1.2.1 From f1586cb4775681810afd8e6626e7842d459f3b85 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 26 Jul 2011 17:23:27 +0200 Subject: stdio.h, stdlib.h, string.h, stdarg.h and ctype.h inclusion done in setup_once.h --- lib/strerror.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index adee28891..f038f8ec0 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -34,8 +34,6 @@ #endif #include -#include -#include #ifdef USE_LIBIDN #include -- cgit v1.2.1 From 15e3e451702396e870c00d186ff7710792a1f28e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 3 Oct 2011 22:32:36 +0200 Subject: share: don't use SSL unless enabled Don't even declare the struct members for disabled features Introducing the CURLSHE_NOT_BUILT_IN return code for the share interface when trying to set a sharing option that has been disabled (or not enabled) in the library. --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index f038f8ec0..fcb617cf2 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -384,6 +384,9 @@ curl_share_strerror(CURLSHcode error) case CURLSHE_NOMEM: return "Out of memory"; + case CURLSHE_NOT_BUILT_IN: + return "Feature not enabled in this library"; + case CURLSHE_LAST: break; } -- cgit v1.2.1 From c834213ad52c52431e9ca597862dc81839cabe84 Mon Sep 17 00:00:00 2001 From: Gokhan Sengun Date: Mon, 19 Dec 2011 14:35:20 +0100 Subject: FTP: perform active connections non-blocking 1- Two new error codes are introduced. CURLE_FTP_ACCEPT_FAILED to be set whenever ACCEPTing fails because of FTP server connected. CURLE_FTP_ACCEPT_TIMEOUT to be set whenever ACCEPTing timeouts. Neither of these errors are considered fatal and control connection remains OK because it could just be a firewall blocking server to connect to the client. 2- One new setopt option was introduced. CURLOPT_ACCEPTTIMEOUT_MS It sets the maximum amount of time FTP client is going to wait for a server to connect. Internal default accept timeout is 60 seconds. --- lib/strerror.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index fcb617cf2..4aa125735 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -81,6 +81,12 @@ curl_easy_strerror(CURLcode error) case CURLE_REMOTE_ACCESS_DENIED: return "Access denied to remote resource"; + case CURLE_FTP_ACCEPT_FAILED: + return "FTP: The server failed to connect to data port"; + + case CURLE_FTP_ACCEPT_TIMEOUT: + return "FTP: Accepting server connect has timed out"; + case CURLE_FTP_PRET_FAILED: return "FTP: The server did not accept the PRET command."; @@ -284,8 +290,6 @@ curl_easy_strerror(CURLcode error) return "Chunk callback failed"; /* error codes not used by current libcurl */ - case CURLE_OBSOLETE10: - case CURLE_OBSOLETE12: case CURLE_OBSOLETE16: case CURLE_OBSOLETE20: case CURLE_OBSOLETE24: -- cgit v1.2.1 From 764a5e4a50286c27b0fa0c16bc44659880a184a5 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 12 Jun 2012 01:06:48 +0200 Subject: sspi: make Curl_sspi_strerror() libcurl's sspi status code string function --- lib/strerror.c | 314 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 313 insertions(+), 1 deletion(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 4aa125735..ffe701048 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 2004 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -781,3 +781,315 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) #endif } #endif /* USE_LIBIDN */ + +#ifdef USE_WINDOWS_SSPI +const char *Curl_sspi_strerror (struct connectdata *conn, int err) +{ +#ifndef CURL_DISABLE_VERBOSE_STRINGS + char txtbuf[sizeof("Unknown error (0xffffffff)")]; + char msgbuf[sizeof(conn->syserr_buf)]; + int old_errno; + char *msg = NULL; +#endif + const char *txt; + char *outbuf; + size_t outmax; + + DEBUGASSERT(conn); + + outbuf = conn->syserr_buf; + outmax = sizeof(conn->syserr_buf)-1; + *outbuf = '\0'; + +#ifndef CURL_DISABLE_VERBOSE_STRINGS + + old_errno = ERRNO; + + switch (err) { + case SEC_E_OK: + txt = "No error"; + break; + case SEC_E_ALGORITHM_MISMATCH: + txt = "SEC_E_ALGORITHM_MISMATCH"; + break; + case SEC_E_BAD_BINDINGS: + txt = "SEC_E_BAD_BINDINGS"; + break; + case SEC_E_BAD_PKGID: + txt = "SEC_E_BAD_PKGID"; + break; + case SEC_E_BUFFER_TOO_SMALL: + txt = "SEC_E_BUFFER_TOO_SMALL"; + break; + case SEC_E_CANNOT_INSTALL: + txt = "SEC_E_CANNOT_INSTALL"; + break; + case SEC_E_CANNOT_PACK: + txt = "SEC_E_CANNOT_PACK"; + break; + case SEC_E_CERT_EXPIRED: + txt = "SEC_E_CERT_EXPIRED"; + break; + case SEC_E_CERT_UNKNOWN: + txt = "SEC_E_CERT_UNKNOWN"; + break; + case SEC_E_CERT_WRONG_USAGE: + txt = "SEC_E_CERT_WRONG_USAGE"; + break; + case SEC_E_CONTEXT_EXPIRED: + txt = "SEC_E_CONTEXT_EXPIRED"; + break; + case SEC_E_CROSSREALM_DELEGATION_FAILURE: + txt = "SEC_E_CROSSREALM_DELEGATION_FAILURE"; + break; + case SEC_E_CRYPTO_SYSTEM_INVALID: + txt = "SEC_E_CRYPTO_SYSTEM_INVALID"; + break; + case SEC_E_DECRYPT_FAILURE: + txt = "SEC_E_DECRYPT_FAILURE"; + break; + case SEC_E_DELEGATION_POLICY: + txt = "SEC_E_DELEGATION_POLICY"; + break; + case SEC_E_DELEGATION_REQUIRED: + txt = "SEC_E_DELEGATION_REQUIRED"; + break; + case SEC_E_DOWNGRADE_DETECTED: + txt = "SEC_E_DOWNGRADE_DETECTED"; + break; + case SEC_E_ENCRYPT_FAILURE: + txt = "SEC_E_ENCRYPT_FAILURE"; + break; + case SEC_E_ILLEGAL_MESSAGE: + txt = "SEC_E_ILLEGAL_MESSAGE"; + break; + case SEC_E_INCOMPLETE_CREDENTIALS: + txt = "SEC_E_INCOMPLETE_CREDENTIALS"; + break; + case SEC_E_INCOMPLETE_MESSAGE: + txt = "SEC_E_INCOMPLETE_MESSAGE"; + break; + case SEC_E_INSUFFICIENT_MEMORY: + txt = "SEC_E_INSUFFICIENT_MEMORY"; + break; + case SEC_E_INTERNAL_ERROR: + txt = "SEC_E_INTERNAL_ERROR"; + break; + case SEC_E_INVALID_HANDLE: + txt = "SEC_E_INVALID_HANDLE"; + break; + case SEC_E_INVALID_PARAMETER: + txt = "SEC_E_INVALID_PARAMETER"; + break; + case SEC_E_INVALID_TOKEN: + txt = "SEC_E_INVALID_TOKEN"; + break; + case SEC_E_ISSUING_CA_UNTRUSTED: + txt = "SEC_E_ISSUING_CA_UNTRUSTED"; + break; + case SEC_E_ISSUING_CA_UNTRUSTED_KDC: + txt = "SEC_E_ISSUING_CA_UNTRUSTED_KDC"; + break; + case SEC_E_KDC_CERT_EXPIRED: + txt = "SEC_E_KDC_CERT_EXPIRED"; + break; + case SEC_E_KDC_CERT_REVOKED: + txt = "SEC_E_KDC_CERT_REVOKED"; + break; + case SEC_E_KDC_INVALID_REQUEST: + txt = "SEC_E_KDC_INVALID_REQUEST"; + break; + case SEC_E_KDC_UNABLE_TO_REFER: + txt = "SEC_E_KDC_UNABLE_TO_REFER"; + break; + case SEC_E_KDC_UNKNOWN_ETYPE: + txt = "SEC_E_KDC_UNKNOWN_ETYPE"; + break; + case SEC_E_LOGON_DENIED: + txt = "SEC_E_LOGON_DENIED"; + break; + case SEC_E_MAX_REFERRALS_EXCEEDED: + txt = "SEC_E_MAX_REFERRALS_EXCEEDED"; + break; + case SEC_E_MESSAGE_ALTERED: + txt = "SEC_E_MESSAGE_ALTERED"; + break; + case SEC_E_MULTIPLE_ACCOUNTS: + txt = "SEC_E_MULTIPLE_ACCOUNTS"; + break; + case SEC_E_MUST_BE_KDC: + txt = "SEC_E_MUST_BE_KDC"; + break; + case SEC_E_NOT_OWNER: + txt = "SEC_E_NOT_OWNER"; + break; + case SEC_E_NO_AUTHENTICATING_AUTHORITY: + txt = "SEC_E_NO_AUTHENTICATING_AUTHORITY"; + break; + case SEC_E_NO_CREDENTIALS: + txt = "SEC_E_NO_CREDENTIALS"; + break; + case SEC_E_NO_IMPERSONATION: + txt = "SEC_E_NO_IMPERSONATION"; + break; + case SEC_E_NO_IP_ADDRESSES: + txt = "SEC_E_NO_IP_ADDRESSES"; + break; + case SEC_E_NO_KERB_KEY: + txt = "SEC_E_NO_KERB_KEY"; + break; + case SEC_E_NO_PA_DATA: + txt = "SEC_E_NO_PA_DATA"; + break; + case SEC_E_NO_S4U_PROT_SUPPORT: + txt = "SEC_E_NO_S4U_PROT_SUPPORT"; + break; + case SEC_E_NO_TGT_REPLY: + txt = "SEC_E_NO_TGT_REPLY"; + break; + case SEC_E_OUT_OF_SEQUENCE: + txt = "SEC_E_OUT_OF_SEQUENCE"; + break; + case SEC_E_PKINIT_CLIENT_FAILURE: + txt = "SEC_E_PKINIT_CLIENT_FAILURE"; + break; + case SEC_E_PKINIT_NAME_MISMATCH: + txt = "SEC_E_PKINIT_NAME_MISMATCH"; + break; + case SEC_E_POLICY_NLTM_ONLY: + txt = "SEC_E_POLICY_NLTM_ONLY"; + break; + case SEC_E_QOP_NOT_SUPPORTED: + txt = "SEC_E_QOP_NOT_SUPPORTED"; + break; + case SEC_E_REVOCATION_OFFLINE_C: + txt = "SEC_E_REVOCATION_OFFLINE_C"; + break; + case SEC_E_REVOCATION_OFFLINE_KDC: + txt = "SEC_E_REVOCATION_OFFLINE_KDC"; + break; + case SEC_E_SECPKG_NOT_FOUND: + txt = "SEC_E_SECPKG_NOT_FOUND"; + break; + case SEC_E_SECURITY_QOS_FAILED: + txt = "SEC_E_SECURITY_QOS_FAILED"; + break; + case SEC_E_SHUTDOWN_IN_PROGRESS: + txt = "SEC_E_SHUTDOWN_IN_PROGRESS"; + break; + case SEC_E_SMARTCARD_CERT_EXPIRED: + txt = "SEC_E_SMARTCARD_CERT_EXPIRED"; + break; + case SEC_E_SMARTCARD_CERT_REVOKED: + txt = "SEC_E_SMARTCARD_CERT_REVOKED"; + break; + case SEC_E_SMARTCARD_LOGON_REQUIRED: + txt = "SEC_E_SMARTCARD_LOGON_REQUIRED"; + break; + case SEC_E_STRONG_CRYPTO_NOT_SUPPORTED: + txt = "SEC_E_STRONG_CRYPTO_NOT_SUPPORTED"; + break; + case SEC_E_TARGET_UNKNOWN: + txt = "SEC_E_TARGET_UNKNOWN"; + break; + case SEC_E_TIME_SKEW: + txt = "SEC_E_TIME_SKEW"; + break; + case SEC_E_TOO_MANY_PRINCIPALS: + txt = "SEC_E_TOO_MANY_PRINCIPALS"; + break; + case SEC_E_UNFINISHED_CONTEXT_DELETED: + txt = "SEC_E_UNFINISHED_CONTEXT_DELETED"; + break; + case SEC_E_UNKNOWN_CREDENTIALS: + txt = "SEC_E_UNKNOWN_CREDENTIALS"; + break; + case SEC_E_UNSUPPORTED_FUNCTION: + txt = "SEC_E_UNSUPPORTED_FUNCTION"; + break; + case SEC_E_UNSUPPORTED_PREAUTH: + txt = "SEC_E_UNSUPPORTED_PREAUTH"; + break; + case SEC_E_UNTRUSTED_ROOT: + txt = "SEC_E_UNTRUSTED_ROOT"; + break; + case SEC_E_WRONG_CREDENTIAL_HANDLE: + txt = "SEC_E_WRONG_CREDENTIAL_HANDLE"; + break; + case SEC_E_WRONG_PRINCIPAL: + txt = "SEC_E_WRONG_PRINCIPAL"; + break; + case SEC_I_COMPLETE_AND_CONTINUE: + txt = "SEC_I_COMPLETE_AND_CONTINUE"; + break; + case SEC_I_COMPLETE_NEEDED: + txt = "SEC_I_COMPLETE_NEEDED"; + break; + case SEC_I_CONTEXT_EXPIRED: + txt = "SEC_I_CONTEXT_EXPIRED"; + break; + case SEC_I_CONTINUE_NEEDED: + txt = "SEC_I_CONTINUE_NEEDED"; + break; + case SEC_I_INCOMPLETE_CREDENTIALS: + txt = "SEC_I_INCOMPLETE_CREDENTIALS"; + break; + case SEC_I_LOCAL_LOGON: + txt = "SEC_I_LOCAL_LOGON"; + break; + case SEC_I_NO_LSA_CONTEXT: + txt = "SEC_I_NO_LSA_CONTEXT"; + break; + case SEC_I_RENEGOTIATE: + txt = "SEC_I_RENEGOTIATE"; + break; + case SEC_I_SIGNATURE_NEEDED: + txt = "SEC_I_SIGNATURE_NEEDED"; + break; + default: + snprintf(txtbuf, sizeof(txtbuf), "Unknown error (0x%04X%04X)", + (err >> 16) & 0xffff, err & 0xffff); + txtbuf[sizeof(txtbuf)-1] = '\0'; + txt = txtbuf; + } + + if(err != SEC_E_OK) { + char *p; + if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, err, LANG_NEUTRAL, + msgbuf, sizeof(msgbuf)-1, NULL)) { + msgbuf[sizeof(msgbuf)-1] = '\0'; + /* strip trailing '\r\n' or '\n' */ + 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) + snprintf(outbuf, outmax, "%s - %s", txt, msg); + else + strncpy(outbuf, txt, outmax); + + if(old_errno != ERRNO) + SET_ERRNO(old_errno); + +#else + + if(err == SEC_E_OK) + txt = "No error"; + else + txt = "Error"; + + strncpy(outbuf, txt, outmax); + +#endif + + outbuf[outmax] = '\0'; + + return outbuf; +} +#endif /* USE_WINDOWS_SSPI */ -- cgit v1.2.1 From b8edf5bbe941a7ea0fd84bd1f3fa1b6899368a85 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 12 Jun 2012 03:57:15 +0200 Subject: strerror.c: make Curl_sspi_strerror() always return code for errors --- lib/strerror.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index ffe701048..84a900047 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -786,10 +786,10 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err) const char *Curl_sspi_strerror (struct connectdata *conn, int err) { #ifndef CURL_DISABLE_VERBOSE_STRINGS - char txtbuf[sizeof("Unknown error (0xffffffff)")]; + char txtbuf[80]; char msgbuf[sizeof(conn->syserr_buf)]; + char *str, *msg = NULL; int old_errno; - char *msg = NULL; #endif const char *txt; char *outbuf; @@ -1047,18 +1047,21 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err) txt = "SEC_I_SIGNATURE_NEEDED"; break; default: - snprintf(txtbuf, sizeof(txtbuf), "Unknown error (0x%04X%04X)", - (err >> 16) & 0xffff, err & 0xffff); - txtbuf[sizeof(txtbuf)-1] = '\0'; - txt = txtbuf; + txt = "Unknown error"; } - if(err != SEC_E_OK) { - char *p; + if(err == SEC_E_OK) + strncpy(outbuf, txt, outmax); + else { + str = txtbuf; + snprintf(txtbuf, sizeof(txtbuf), "%s (0x%04X%04X)", + txt, (err >> 16) & 0xffff, err & 0xffff); + txtbuf[sizeof(txtbuf)-1] = '\0'; if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, LANG_NEUTRAL, msgbuf, sizeof(msgbuf)-1, NULL)) { + char *p; msgbuf[sizeof(msgbuf)-1] = '\0'; /* strip trailing '\r\n' or '\n' */ if((p = strrchr(msgbuf,'\n')) != NULL && (p - msgbuf) >= 2) @@ -1067,13 +1070,12 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err) *p = '\0'; msg = msgbuf; } + if(msg) + snprintf(outbuf, outmax, "%s - %s", str, msg); + else + strncpy(outbuf, str, outmax); } - if(msg) - snprintf(outbuf, outmax, "%s - %s", txt, msg); - else - strncpy(outbuf, txt, outmax); - if(old_errno != ERRNO) SET_ERRNO(old_errno); -- cgit v1.2.1 From 46480bb9a1569eaf156012f33e3e7e8c3de18f87 Mon Sep 17 00:00:00 2001 From: Mark Salisbury Date: Fri, 15 Jun 2012 18:05:11 +0200 Subject: SSPI related code: Unicode support for WinCE SSPI related code now compiles with ANSI and WCHAR versions of security methods (WinCE requires WCHAR versions of methods). Pulled UTF8 to WCHAR conversion methods out of idn_win32.c into their own file. curl_sasl.c - include curl_memory.h to use correct memory functions. getenv.c and telnet.c - WinCE compatibility fix With some committer adjustments --- lib/strerror.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index 84a900047..dd7d37565 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -635,7 +635,7 @@ const char *Curl_strerror(struct connectdata *conn, int err) strncpy(buf, strerror(err), max); else { if(!get_winsock_error(err, buf, max) && - !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, + !FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, LANG_NEUTRAL, buf, (DWORD)max, NULL)) snprintf(buf, max, "Unknown error %d (%#x)", err, err); } @@ -788,7 +788,8 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err) #ifndef CURL_DISABLE_VERBOSE_STRINGS char txtbuf[80]; char msgbuf[sizeof(conn->syserr_buf)]; - char *str, *msg = NULL; + char *p, *str, *msg = NULL; + bool msg_formatted = FALSE; int old_errno; #endif const char *txt; @@ -1057,11 +1058,29 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err) snprintf(txtbuf, sizeof(txtbuf), "%s (0x%04X%04X)", txt, (err >> 16) & 0xffff, err & 0xffff); txtbuf[sizeof(txtbuf)-1] = '\0'; - if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, err, LANG_NEUTRAL, - msgbuf, sizeof(msgbuf)-1, NULL)) { - char *p; + +#ifdef _WIN32_WCE + { + wchar_t wbuf[256]; + wbuf[0] = L'\0'; + + if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, err, LANG_NEUTRAL, + wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) { + wcstombs(msgbuf,wbuf,sizeof(msgbuf)-1); + msg_formatted = TRUE; + } + } +#else + if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, err, LANG_NEUTRAL, + msgbuf, sizeof(msgbuf)-1, NULL)) { + msg_formatted = TRUE; + } +#endif + if(msg_formatted) { msgbuf[sizeof(msgbuf)-1] = '\0'; /* strip trailing '\r\n' or '\n' */ if((p = strrchr(msgbuf,'\n')) != NULL && (p - msgbuf) >= 2) -- cgit v1.2.1 From ee588fe088077785d9ad9263e03e1e525b074261 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 17 Nov 2012 00:59:42 +0100 Subject: mem-include-scan: verify memory #includes If we use memory functions (malloc, free, strdup etc) in C sources in libcurl and we fail to include curl_memory.h or memdebug.h we either fail to properly support user-provided memory callbacks or the memory leak system of the test suite fails. After Ajit's report of a failure in the first category in http_proxy.c, I spotted a few in the second category as well. These problems are now tested for by test 1132 which runs a perl program that scans for and attempts to check that we use the correct include files if a memory related function is used in the source code. Reported by: Ajit Dhumale Bug: http://curl.haxx.se/mail/lib-2012-11/0125.html --- lib/strerror.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/strerror.c') diff --git a/lib/strerror.c b/lib/strerror.c index dd7d37565..0c82a53e4 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -44,6 +44,9 @@ #define _MPRINTF_REPLACE /* use our functions only */ #include +#include "curl_memory.h" +/* The last #include file should be: */ +#include "memdebug.h" const char * curl_easy_strerror(CURLcode error) -- cgit v1.2.1