1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 2004 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
25 #ifdef HAVE_STRERROR_R
26 # if (!defined(HAVE_POSIX_STRERROR_R) && \
27 !defined(HAVE_GLIBC_STRERROR_R) && \
28 !defined(HAVE_VXWORKS_STRERROR_R)) || \
29 (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
30 (defined(HAVE_GLIBC_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
31 (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R))
32 # error "strerror_r MUST be either POSIX, glibc or vxworks-style"
36 #include <curl/curl.h>
44 #define _MPRINTF_REPLACE /* use our functions only */
45 #include <curl/mprintf.h>
47 #include "curl_memory.h"
48 /* The last #include file should be: */
52 curl_easy_strerror(CURLcode error)
54 #ifndef CURL_DISABLE_VERBOSE_STRINGS
59 case CURLE_UNSUPPORTED_PROTOCOL:
60 return "Unsupported protocol";
62 case CURLE_FAILED_INIT:
63 return "Failed initialization";
65 case CURLE_URL_MALFORMAT:
66 return "URL using bad/illegal format or missing URL";
68 case CURLE_NOT_BUILT_IN:
69 return "A requested feature, protocol or option was not found built-in in"
70 " this libcurl due to a build-time decision.";
72 case CURLE_COULDNT_RESOLVE_PROXY:
73 return "Couldn't resolve proxy name";
75 case CURLE_COULDNT_RESOLVE_HOST:
76 return "Couldn't resolve host name";
78 case CURLE_COULDNT_CONNECT:
79 return "Couldn't connect to server";
81 case CURLE_FTP_WEIRD_SERVER_REPLY:
82 return "FTP: weird server reply";
84 case CURLE_REMOTE_ACCESS_DENIED:
85 return "Access denied to remote resource";
87 case CURLE_FTP_ACCEPT_FAILED:
88 return "FTP: The server failed to connect to data port";
90 case CURLE_FTP_ACCEPT_TIMEOUT:
91 return "FTP: Accepting server connect has timed out";
93 case CURLE_FTP_PRET_FAILED:
94 return "FTP: The server did not accept the PRET command.";
96 case CURLE_FTP_WEIRD_PASS_REPLY:
97 return "FTP: unknown PASS reply";
99 case CURLE_FTP_WEIRD_PASV_REPLY:
100 return "FTP: unknown PASV reply";
102 case CURLE_FTP_WEIRD_227_FORMAT:
103 return "FTP: unknown 227 response format";
105 case CURLE_FTP_CANT_GET_HOST:
106 return "FTP: can't figure out the host in the PASV response";
108 case CURLE_FTP_COULDNT_SET_TYPE:
109 return "FTP: couldn't set file type";
111 case CURLE_PARTIAL_FILE:
112 return "Transferred a partial file";
114 case CURLE_FTP_COULDNT_RETR_FILE:
115 return "FTP: couldn't retrieve (RETR failed) the specified file";
117 case CURLE_QUOTE_ERROR:
118 return "Quote command returned error";
120 case CURLE_HTTP_RETURNED_ERROR:
121 return "HTTP response code said error";
123 case CURLE_WRITE_ERROR:
124 return "Failed writing received data to disk/application";
126 case CURLE_UPLOAD_FAILED:
127 return "Upload failed (at start/before it took off)";
129 case CURLE_READ_ERROR:
130 return "Failed to open/read local data from file/application";
132 case CURLE_OUT_OF_MEMORY:
133 return "Out of memory";
135 case CURLE_OPERATION_TIMEDOUT:
136 return "Timeout was reached";
138 case CURLE_FTP_PORT_FAILED:
139 return "FTP: command PORT failed";
141 case CURLE_FTP_COULDNT_USE_REST:
142 return "FTP: command REST failed";
144 case CURLE_RANGE_ERROR:
145 return "Requested range was not delivered by the server";
147 case CURLE_HTTP_POST_ERROR:
148 return "Internal problem setting up the POST";
150 case CURLE_SSL_CONNECT_ERROR:
151 return "SSL connect error";
153 case CURLE_BAD_DOWNLOAD_RESUME:
154 return "Couldn't resume download";
156 case CURLE_FILE_COULDNT_READ_FILE:
157 return "Couldn't read a file:// file";
159 case CURLE_LDAP_CANNOT_BIND:
160 return "LDAP: cannot bind";
162 case CURLE_LDAP_SEARCH_FAILED:
163 return "LDAP: search failed";
165 case CURLE_FUNCTION_NOT_FOUND:
166 return "A required function in the library was not found";
168 case CURLE_ABORTED_BY_CALLBACK:
169 return "Operation was aborted by an application callback";
171 case CURLE_BAD_FUNCTION_ARGUMENT:
172 return "A libcurl function was given a bad argument";
174 case CURLE_INTERFACE_FAILED:
175 return "Failed binding local connection end";
177 case CURLE_TOO_MANY_REDIRECTS :
178 return "Number of redirects hit maximum amount";
180 case CURLE_UNKNOWN_OPTION:
181 return "An unknown option was passed in to libcurl";
183 case CURLE_TELNET_OPTION_SYNTAX :
184 return "Malformed telnet option";
186 case CURLE_PEER_FAILED_VERIFICATION:
187 return "SSL peer certificate or SSH remote key was not OK";
189 case CURLE_GOT_NOTHING:
190 return "Server returned nothing (no headers, no data)";
192 case CURLE_SSL_ENGINE_NOTFOUND:
193 return "SSL crypto engine not found";
195 case CURLE_SSL_ENGINE_SETFAILED:
196 return "Can not set SSL crypto engine as default";
198 case CURLE_SSL_ENGINE_INITFAILED:
199 return "Failed to initialise SSL crypto engine";
201 case CURLE_SEND_ERROR:
202 return "Failed sending data to the peer";
204 case CURLE_RECV_ERROR:
205 return "Failure when receiving data from the peer";
207 case CURLE_SSL_CERTPROBLEM:
208 return "Problem with the local SSL certificate";
210 case CURLE_SSL_CIPHER:
211 return "Couldn't use specified SSL cipher";
213 case CURLE_SSL_CACERT:
214 return "Peer certificate cannot be authenticated with given CA "
217 case CURLE_SSL_CACERT_BADFILE:
218 return "Problem with the SSL CA cert (path? access rights?)";
220 case CURLE_BAD_CONTENT_ENCODING:
221 return "Unrecognized or bad HTTP Content or Transfer-Encoding";
223 case CURLE_LDAP_INVALID_URL:
224 return "Invalid LDAP URL";
226 case CURLE_FILESIZE_EXCEEDED:
227 return "Maximum file size exceeded";
229 case CURLE_USE_SSL_FAILED:
230 return "Requested SSL level failed";
232 case CURLE_SSL_SHUTDOWN_FAILED:
233 return "Failed to shut down the SSL connection";
235 case CURLE_SSL_CRL_BADFILE:
236 return "Failed to load CRL file (path? access rights?, format?)";
238 case CURLE_SSL_ISSUER_ERROR:
239 return "Issuer check against peer certificate failed";
241 case CURLE_SEND_FAIL_REWIND:
242 return "Send failed since rewinding of the data stream failed";
244 case CURLE_LOGIN_DENIED:
245 return "Login denied";
247 case CURLE_TFTP_NOTFOUND:
248 return "TFTP: File Not Found";
250 case CURLE_TFTP_PERM:
251 return "TFTP: Access Violation";
253 case CURLE_REMOTE_DISK_FULL:
254 return "Disk full or allocation exceeded";
256 case CURLE_TFTP_ILLEGAL:
257 return "TFTP: Illegal operation";
259 case CURLE_TFTP_UNKNOWNID:
260 return "TFTP: Unknown transfer ID";
262 case CURLE_REMOTE_FILE_EXISTS:
263 return "Remote file already exists";
265 case CURLE_TFTP_NOSUCHUSER:
266 return "TFTP: No such user";
268 case CURLE_CONV_FAILED:
269 return "Conversion failed";
271 case CURLE_CONV_REQD:
272 return "Caller must register CURLOPT_CONV_ callback options";
274 case CURLE_REMOTE_FILE_NOT_FOUND:
275 return "Remote file not found";
278 return "Error in the SSH layer";
281 return "Socket not ready for send/recv";
283 case CURLE_RTSP_CSEQ_ERROR:
284 return "RTSP CSeq mismatch or invalid CSeq";
286 case CURLE_RTSP_SESSION_ERROR:
287 return "RTSP session error";
289 case CURLE_FTP_BAD_FILE_LIST:
290 return "Unable to parse FTP file list";
292 case CURLE_CHUNK_FAILED:
293 return "Chunk callback failed";
295 case CURLE_NO_CONNECTION_AVAILABLE:
296 return "The max connection limit is reached";
298 /* error codes not used by current libcurl */
299 case CURLE_OBSOLETE16:
300 case CURLE_OBSOLETE20:
301 case CURLE_OBSOLETE24:
302 case CURLE_OBSOLETE29:
303 case CURLE_OBSOLETE32:
304 case CURLE_OBSOLETE40:
305 case CURLE_OBSOLETE44:
306 case CURLE_OBSOLETE46:
307 case CURLE_OBSOLETE50:
308 case CURLE_OBSOLETE57:
313 * By using a switch, gcc -Wall will complain about enum values
314 * which do not appear, helping keep this function up-to-date.
315 * By using gcc -Wall -Werror, you can't forget.
317 * A table would not have the same benefit. Most compilers will
318 * generate code very similar to a table in any case, so there
319 * is little performance gain from a table. And something is broken
320 * for the user's application, anyways, so does it matter how fast
323 * The line number for the error will be near this comment, which
324 * is why it is here, and not at the start of the switch.
326 return "Unknown error";
328 if(error == CURLE_OK)
336 curl_multi_strerror(CURLMcode error)
338 #ifndef CURL_DISABLE_VERBOSE_STRINGS
340 case CURLM_CALL_MULTI_PERFORM:
341 return "Please call curl_multi_perform() soon";
346 case CURLM_BAD_HANDLE:
347 return "Invalid multi handle";
349 case CURLM_BAD_EASY_HANDLE:
350 return "Invalid easy handle";
352 case CURLM_OUT_OF_MEMORY:
353 return "Out of memory";
355 case CURLM_INTERNAL_ERROR:
356 return "Internal error";
358 case CURLM_BAD_SOCKET:
359 return "Invalid socket argument";
361 case CURLM_UNKNOWN_OPTION:
362 return "Unknown option";
368 return "Unknown error";
370 if(error == CURLM_OK)
378 curl_share_strerror(CURLSHcode error)
380 #ifndef CURL_DISABLE_VERBOSE_STRINGS
385 case CURLSHE_BAD_OPTION:
386 return "Unknown share option";
389 return "Share currently in use";
391 case CURLSHE_INVALID:
392 return "Invalid share handle";
395 return "Out of memory";
397 case CURLSHE_NOT_BUILT_IN:
398 return "Feature not enabled in this library";
404 return "CURLSHcode unknown";
406 if(error == CURLSHE_OK)
415 /* This function handles most / all (?) Winsock errors cURL is able to produce.
418 get_winsock_error (int err, char *buf, size_t len)
422 #ifndef CURL_DISABLE_VERBOSE_STRINGS
425 p = "Call interrupted";
437 p = "Invalid arguments";
440 p = "Out of file descriptors";
443 p = "Call would block";
447 p = "Blocking call in progress";
450 p = "Descriptor is not a socket";
452 case WSAEDESTADDRREQ:
453 p = "Need destination address";
456 p = "Bad message size";
462 p = "Protocol option is unsupported";
464 case WSAEPROTONOSUPPORT:
465 p = "Protocol is unsupported";
467 case WSAESOCKTNOSUPPORT:
468 p = "Socket is unsupported";
471 p = "Operation not supported";
473 case WSAEAFNOSUPPORT:
474 p = "Address family not supported";
476 case WSAEPFNOSUPPORT:
477 p = "Protocol family not supported";
480 p = "Address already in use";
482 case WSAEADDRNOTAVAIL:
483 p = "Address not available";
489 p = "Network unreachable";
492 p = "Network has been reset";
494 case WSAECONNABORTED:
495 p = "Connection was aborted";
498 p = "Connection was reset";
501 p = "No buffer space";
504 p = "Socket is already connected";
507 p = "Socket is not connected";
510 p = "Socket has been shut down";
512 case WSAETOOMANYREFS:
513 p = "Too many references";
518 case WSAECONNREFUSED:
519 p = "Connection refused";
524 case WSAENAMETOOLONG:
530 case WSAEHOSTUNREACH:
531 p = "Host unreachable";
537 p = "Process limit reached";
540 p = "Too many users";
546 p = "Something is stale";
551 #ifdef WSAEDISCON /* missing in SalfordC! */
556 /* Extended Winsock errors */
558 p = "Winsock library is not ready";
560 case WSANOTINITIALISED:
561 p = "Winsock library not initialised";
563 case WSAVERNOTSUPPORTED:
564 p = "Winsock version not supported";
567 /* getXbyY() errors (already handled in herrmsg):
568 * Authoritative Answer: Host not found */
569 case WSAHOST_NOT_FOUND:
570 p = "Host not found";
573 /* Non-Authoritative: Host not found, or SERVERFAIL */
575 p = "Host not found, try again";
578 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
580 p = "Unrecoverable error in call to nameserver";
583 /* Valid name, no data record of requested type */
585 p = "No data record of requested type";
597 strncpy (buf, p, len);
601 #endif /* USE_WINSOCK */
604 * Our thread-safe and smart strerror() replacement.
606 * The 'err' argument passed in to this function MUST be a true errno number
607 * as reported on this system. We do no range checking on the number before
608 * we pass it to the "number-to-message" conversion function and there might
609 * be systems that don't do proper range checking in there themselves.
611 * We don't do range checking (on systems other than Windows) since there is
612 * no good reliable and portable way to do it.
614 const char *Curl_strerror(struct connectdata *conn, int err)
618 int old_errno = ERRNO;
621 DEBUGASSERT(err >= 0);
623 buf = conn->syserr_buf;
624 max = sizeof(conn->syserr_buf)-1;
634 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
635 LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL);
636 wcstombs(buf,wbuf,max);
639 /* 'sys_nerr' is the maximum errno number, it is not widely portable */
640 if(err >= 0 && err < sys_nerr)
641 strncpy(buf, strerror(err), max);
643 if(!get_winsock_error(err, buf, max) &&
644 !FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
645 LANG_NEUTRAL, buf, (DWORD)max, NULL))
646 snprintf(buf, max, "Unknown error %d (%#x)", err, err);
650 #else /* not USE_WINSOCK coming up */
652 #if defined(HAVE_STRERROR_R) && defined(HAVE_POSIX_STRERROR_R)
654 * The POSIX-style strerror_r() may set errno to ERANGE if insufficient
655 * storage is supplied via 'strerrbuf' and 'buflen' to hold the generated
656 * message string, or EINVAL if 'errnum' is not a valid error number.
658 if(0 != strerror_r(err, buf, max)) {
660 snprintf(buf, max, "Unknown error %d", err);
662 #elif defined(HAVE_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)
664 * The glibc-style strerror_r() only *might* use the buffer we pass to
665 * the function, but it always returns the error message as a pointer,
666 * so we must copy that string unconditionally (if non-NULL).
670 char *msg = strerror_r(err, buffer, sizeof(buffer));
672 strncpy(buf, msg, max);
674 snprintf(buf, max, "Unknown error %d", err);
676 #elif defined(HAVE_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)
678 * The vxworks-style strerror_r() does use the buffer we pass to the function.
679 * The buffer size should be at least MAXERRSTR_SIZE (150) defined in rtsold.h
683 if(OK == strerror_r(err, buffer))
684 strncpy(buf, buffer, max);
686 snprintf(buf, max, "Unknown error %d", err);
690 char *msg = strerror(err);
692 strncpy(buf, msg, max);
694 snprintf(buf, max, "Unknown error %d", err);
698 #endif /* end of ! USE_WINSOCK */
700 buf[max] = '\0'; /* make sure the string is zero terminated */
702 /* strip trailing '\r\n' or '\n'. */
703 if((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2)
705 if((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1)
708 if(old_errno != ERRNO)
709 SET_ERRNO(old_errno);
716 * Return error-string for libidn status as returned from idna_to_ascii_lz().
718 const char *Curl_idn_strerror (struct connectdata *conn, int err)
720 #ifdef HAVE_IDNA_STRERROR
722 return idna_strerror((Idna_rc) err);
730 buf = conn->syserr_buf;
731 max = sizeof(conn->syserr_buf)-1;
734 #ifndef CURL_DISABLE_VERBOSE_STRINGS
735 switch ((Idna_rc)err) {
739 case IDNA_STRINGPREP_ERROR:
740 str = "Error in string preparation";
742 case IDNA_PUNYCODE_ERROR:
743 str = "Error in Punycode operation";
745 case IDNA_CONTAINS_NON_LDH:
746 str = "Illegal ASCII characters";
748 case IDNA_CONTAINS_MINUS:
749 str = "Contains minus";
751 case IDNA_INVALID_LENGTH:
752 str = "Invalid output length";
754 case IDNA_NO_ACE_PREFIX:
755 str = "No ACE prefix (\"xn--\")";
757 case IDNA_ROUNDTRIP_VERIFY_ERROR:
758 str = "Round trip verify error";
760 case IDNA_CONTAINS_ACE_PREFIX:
761 str = "Already have ACE prefix (\"xn--\")";
763 case IDNA_ICONV_ERROR:
764 str = "Locale conversion failed";
766 case IDNA_MALLOC_ERROR:
767 str = "Allocation failed";
769 case IDNA_DLOPEN_ERROR:
770 str = "dlopen() error";
773 snprintf(buf, max, "error %d", err);
778 if((Idna_rc)err == IDNA_SUCCESS)
784 strncpy(buf, str, max);
789 #endif /* USE_LIBIDN */
791 #ifdef USE_WINDOWS_SSPI
792 const char *Curl_sspi_strerror (struct connectdata *conn, int err)
794 #ifndef CURL_DISABLE_VERBOSE_STRINGS
796 char msgbuf[sizeof(conn->syserr_buf)];
797 char *p, *str, *msg = NULL;
798 bool msg_formatted = FALSE;
807 outbuf = conn->syserr_buf;
808 outmax = sizeof(conn->syserr_buf)-1;
811 #ifndef CURL_DISABLE_VERBOSE_STRINGS
819 case SEC_E_ALGORITHM_MISMATCH:
820 txt = "SEC_E_ALGORITHM_MISMATCH";
822 case SEC_E_BAD_BINDINGS:
823 txt = "SEC_E_BAD_BINDINGS";
825 case SEC_E_BAD_PKGID:
826 txt = "SEC_E_BAD_PKGID";
828 case SEC_E_BUFFER_TOO_SMALL:
829 txt = "SEC_E_BUFFER_TOO_SMALL";
831 case SEC_E_CANNOT_INSTALL:
832 txt = "SEC_E_CANNOT_INSTALL";
834 case SEC_E_CANNOT_PACK:
835 txt = "SEC_E_CANNOT_PACK";
837 case SEC_E_CERT_EXPIRED:
838 txt = "SEC_E_CERT_EXPIRED";
840 case SEC_E_CERT_UNKNOWN:
841 txt = "SEC_E_CERT_UNKNOWN";
843 case SEC_E_CERT_WRONG_USAGE:
844 txt = "SEC_E_CERT_WRONG_USAGE";
846 case SEC_E_CONTEXT_EXPIRED:
847 txt = "SEC_E_CONTEXT_EXPIRED";
849 case SEC_E_CROSSREALM_DELEGATION_FAILURE:
850 txt = "SEC_E_CROSSREALM_DELEGATION_FAILURE";
852 case SEC_E_CRYPTO_SYSTEM_INVALID:
853 txt = "SEC_E_CRYPTO_SYSTEM_INVALID";
855 case SEC_E_DECRYPT_FAILURE:
856 txt = "SEC_E_DECRYPT_FAILURE";
858 case SEC_E_DELEGATION_POLICY:
859 txt = "SEC_E_DELEGATION_POLICY";
861 case SEC_E_DELEGATION_REQUIRED:
862 txt = "SEC_E_DELEGATION_REQUIRED";
864 case SEC_E_DOWNGRADE_DETECTED:
865 txt = "SEC_E_DOWNGRADE_DETECTED";
867 case SEC_E_ENCRYPT_FAILURE:
868 txt = "SEC_E_ENCRYPT_FAILURE";
870 case SEC_E_ILLEGAL_MESSAGE:
871 txt = "SEC_E_ILLEGAL_MESSAGE";
873 case SEC_E_INCOMPLETE_CREDENTIALS:
874 txt = "SEC_E_INCOMPLETE_CREDENTIALS";
876 case SEC_E_INCOMPLETE_MESSAGE:
877 txt = "SEC_E_INCOMPLETE_MESSAGE";
879 case SEC_E_INSUFFICIENT_MEMORY:
880 txt = "SEC_E_INSUFFICIENT_MEMORY";
882 case SEC_E_INTERNAL_ERROR:
883 txt = "SEC_E_INTERNAL_ERROR";
885 case SEC_E_INVALID_HANDLE:
886 txt = "SEC_E_INVALID_HANDLE";
888 case SEC_E_INVALID_PARAMETER:
889 txt = "SEC_E_INVALID_PARAMETER";
891 case SEC_E_INVALID_TOKEN:
892 txt = "SEC_E_INVALID_TOKEN";
894 case SEC_E_ISSUING_CA_UNTRUSTED:
895 txt = "SEC_E_ISSUING_CA_UNTRUSTED";
897 case SEC_E_ISSUING_CA_UNTRUSTED_KDC:
898 txt = "SEC_E_ISSUING_CA_UNTRUSTED_KDC";
900 case SEC_E_KDC_CERT_EXPIRED:
901 txt = "SEC_E_KDC_CERT_EXPIRED";
903 case SEC_E_KDC_CERT_REVOKED:
904 txt = "SEC_E_KDC_CERT_REVOKED";
906 case SEC_E_KDC_INVALID_REQUEST:
907 txt = "SEC_E_KDC_INVALID_REQUEST";
909 case SEC_E_KDC_UNABLE_TO_REFER:
910 txt = "SEC_E_KDC_UNABLE_TO_REFER";
912 case SEC_E_KDC_UNKNOWN_ETYPE:
913 txt = "SEC_E_KDC_UNKNOWN_ETYPE";
915 case SEC_E_LOGON_DENIED:
916 txt = "SEC_E_LOGON_DENIED";
918 case SEC_E_MAX_REFERRALS_EXCEEDED:
919 txt = "SEC_E_MAX_REFERRALS_EXCEEDED";
921 case SEC_E_MESSAGE_ALTERED:
922 txt = "SEC_E_MESSAGE_ALTERED";
924 case SEC_E_MULTIPLE_ACCOUNTS:
925 txt = "SEC_E_MULTIPLE_ACCOUNTS";
927 case SEC_E_MUST_BE_KDC:
928 txt = "SEC_E_MUST_BE_KDC";
930 case SEC_E_NOT_OWNER:
931 txt = "SEC_E_NOT_OWNER";
933 case SEC_E_NO_AUTHENTICATING_AUTHORITY:
934 txt = "SEC_E_NO_AUTHENTICATING_AUTHORITY";
936 case SEC_E_NO_CREDENTIALS:
937 txt = "SEC_E_NO_CREDENTIALS";
939 case SEC_E_NO_IMPERSONATION:
940 txt = "SEC_E_NO_IMPERSONATION";
942 case SEC_E_NO_IP_ADDRESSES:
943 txt = "SEC_E_NO_IP_ADDRESSES";
945 case SEC_E_NO_KERB_KEY:
946 txt = "SEC_E_NO_KERB_KEY";
948 case SEC_E_NO_PA_DATA:
949 txt = "SEC_E_NO_PA_DATA";
951 case SEC_E_NO_S4U_PROT_SUPPORT:
952 txt = "SEC_E_NO_S4U_PROT_SUPPORT";
954 case SEC_E_NO_TGT_REPLY:
955 txt = "SEC_E_NO_TGT_REPLY";
957 case SEC_E_OUT_OF_SEQUENCE:
958 txt = "SEC_E_OUT_OF_SEQUENCE";
960 case SEC_E_PKINIT_CLIENT_FAILURE:
961 txt = "SEC_E_PKINIT_CLIENT_FAILURE";
963 case SEC_E_PKINIT_NAME_MISMATCH:
964 txt = "SEC_E_PKINIT_NAME_MISMATCH";
966 case SEC_E_POLICY_NLTM_ONLY:
967 txt = "SEC_E_POLICY_NLTM_ONLY";
969 case SEC_E_QOP_NOT_SUPPORTED:
970 txt = "SEC_E_QOP_NOT_SUPPORTED";
972 case SEC_E_REVOCATION_OFFLINE_C:
973 txt = "SEC_E_REVOCATION_OFFLINE_C";
975 case SEC_E_REVOCATION_OFFLINE_KDC:
976 txt = "SEC_E_REVOCATION_OFFLINE_KDC";
978 case SEC_E_SECPKG_NOT_FOUND:
979 txt = "SEC_E_SECPKG_NOT_FOUND";
981 case SEC_E_SECURITY_QOS_FAILED:
982 txt = "SEC_E_SECURITY_QOS_FAILED";
984 case SEC_E_SHUTDOWN_IN_PROGRESS:
985 txt = "SEC_E_SHUTDOWN_IN_PROGRESS";
987 case SEC_E_SMARTCARD_CERT_EXPIRED:
988 txt = "SEC_E_SMARTCARD_CERT_EXPIRED";
990 case SEC_E_SMARTCARD_CERT_REVOKED:
991 txt = "SEC_E_SMARTCARD_CERT_REVOKED";
993 case SEC_E_SMARTCARD_LOGON_REQUIRED:
994 txt = "SEC_E_SMARTCARD_LOGON_REQUIRED";
996 case SEC_E_STRONG_CRYPTO_NOT_SUPPORTED:
997 txt = "SEC_E_STRONG_CRYPTO_NOT_SUPPORTED";
999 case SEC_E_TARGET_UNKNOWN:
1000 txt = "SEC_E_TARGET_UNKNOWN";
1002 case SEC_E_TIME_SKEW:
1003 txt = "SEC_E_TIME_SKEW";
1005 case SEC_E_TOO_MANY_PRINCIPALS:
1006 txt = "SEC_E_TOO_MANY_PRINCIPALS";
1008 case SEC_E_UNFINISHED_CONTEXT_DELETED:
1009 txt = "SEC_E_UNFINISHED_CONTEXT_DELETED";
1011 case SEC_E_UNKNOWN_CREDENTIALS:
1012 txt = "SEC_E_UNKNOWN_CREDENTIALS";
1014 case SEC_E_UNSUPPORTED_FUNCTION:
1015 txt = "SEC_E_UNSUPPORTED_FUNCTION";
1017 case SEC_E_UNSUPPORTED_PREAUTH:
1018 txt = "SEC_E_UNSUPPORTED_PREAUTH";
1020 case SEC_E_UNTRUSTED_ROOT:
1021 txt = "SEC_E_UNTRUSTED_ROOT";
1023 case SEC_E_WRONG_CREDENTIAL_HANDLE:
1024 txt = "SEC_E_WRONG_CREDENTIAL_HANDLE";
1026 case SEC_E_WRONG_PRINCIPAL:
1027 txt = "SEC_E_WRONG_PRINCIPAL";
1029 case SEC_I_COMPLETE_AND_CONTINUE:
1030 txt = "SEC_I_COMPLETE_AND_CONTINUE";
1032 case SEC_I_COMPLETE_NEEDED:
1033 txt = "SEC_I_COMPLETE_NEEDED";
1035 case SEC_I_CONTEXT_EXPIRED:
1036 txt = "SEC_I_CONTEXT_EXPIRED";
1038 case SEC_I_CONTINUE_NEEDED:
1039 txt = "SEC_I_CONTINUE_NEEDED";
1041 case SEC_I_INCOMPLETE_CREDENTIALS:
1042 txt = "SEC_I_INCOMPLETE_CREDENTIALS";
1044 case SEC_I_LOCAL_LOGON:
1045 txt = "SEC_I_LOCAL_LOGON";
1047 case SEC_I_NO_LSA_CONTEXT:
1048 txt = "SEC_I_NO_LSA_CONTEXT";
1050 case SEC_I_RENEGOTIATE:
1051 txt = "SEC_I_RENEGOTIATE";
1053 case SEC_I_SIGNATURE_NEEDED:
1054 txt = "SEC_I_SIGNATURE_NEEDED";
1057 txt = "Unknown error";
1061 strncpy(outbuf, txt, outmax);
1064 snprintf(txtbuf, sizeof(txtbuf), "%s (0x%04X%04X)",
1065 txt, (err >> 16) & 0xffff, err & 0xffff);
1066 txtbuf[sizeof(txtbuf)-1] = '\0';
1073 if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
1074 FORMAT_MESSAGE_IGNORE_INSERTS,
1075 NULL, err, LANG_NEUTRAL,
1076 wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) {
1077 wcstombs(msgbuf,wbuf,sizeof(msgbuf)-1);
1078 msg_formatted = TRUE;
1082 if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
1083 FORMAT_MESSAGE_IGNORE_INSERTS,
1084 NULL, err, LANG_NEUTRAL,
1085 msgbuf, sizeof(msgbuf)-1, NULL)) {
1086 msg_formatted = TRUE;
1090 msgbuf[sizeof(msgbuf)-1] = '\0';
1091 /* strip trailing '\r\n' or '\n' */
1092 if((p = strrchr(msgbuf,'\n')) != NULL && (p - msgbuf) >= 2)
1094 if((p = strrchr(msgbuf,'\r')) != NULL && (p - msgbuf) >= 1)
1099 snprintf(outbuf, outmax, "%s - %s", str, msg);
1101 strncpy(outbuf, str, outmax);
1104 if(old_errno != ERRNO)
1105 SET_ERRNO(old_errno);
1114 strncpy(outbuf, txt, outmax);
1118 outbuf[outmax] = '\0';
1122 #endif /* USE_WINDOWS_SSPI */