diff -ur curl-7.11.0/configure.ac curl-7.11.0-new/configure.ac --- curl-7.11.0/configure.ac 2004-01-19 09:54:07.000000000 +1100 +++ curl-7.11.0-new/configure.ac 2004-02-28 15:04:57.000000000 +1100 @@ -1009,7 +1009,7 @@ CPPFLAGS="$CPPFLAGS -DCURLDEBUG" CFLAGS="$CFLAGS -g" if test "$GCC" = "yes"; then - CFLAGS="$CFLAGS -W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs" + CFLAGS="$CFLAGS -W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs -Werror" fi dnl strip off optimizer flags NEWFLAGS="" diff -ur curl-7.11.0/docs/INTERNALS curl-7.11.0-new/docs/INTERNALS --- curl-7.11.0/docs/INTERNALS 2002-02-28 19:01:08.000000000 +1100 +++ curl-7.11.0-new/docs/INTERNALS 2004-03-10 10:30:08.000000000 +1100 @@ -310,6 +310,11 @@ them. They are best used when revealing information that isn't otherwise obvious. + You can also use the curl_easy_strerror function to translate CURLcode + values into human-readable error descriptions, or the curl_multi_strerror + function to translate CURLMcode values into human-readable error + descriptions. + Client ====== diff -ur curl-7.11.0/docs/libcurl/curl_easy_getinfo.3 curl-7.11.0-new/docs/libcurl/curl_easy_getinfo.3 --- curl-7.11.0/docs/libcurl/curl_easy_getinfo.3 2003-12-19 03:16:19.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/curl_easy_getinfo.3 2004-02-28 17:32:48.000000000 +1100 @@ -111,6 +111,7 @@ If the operation was successful, CURLE_OK is returned. Otherwise an appropriate error code will be returned. .SH "SEE ALSO" -.BR curl_easy_setopt "(3)" +.BR curl_easy_setopt "(3)," +.BR libcurl-errors "(3)" .SH BUGS Surely there are some, you tell me! diff -ur curl-7.11.0/docs/libcurl/curl_easy_perform.3 curl-7.11.0-new/docs/libcurl/curl_easy_perform.3 --- curl-7.11.0/docs/libcurl/curl_easy_perform.3 2002-03-04 21:09:49.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/curl_easy_perform.3 2004-02-28 17:33:28.000000000 +1100 @@ -41,6 +41,8 @@ there will be a readable error message in the error buffer when non-zero is returned. .SH "SEE ALSO" -.BR curl_easy_init "(3), " curl_easy_setopt "(3), " +.BR curl_easy_init "(3)," +.BR curl_easy_setopt "(3)," +.BR libcurl-errors "(3)" .SH BUGS Surely there are some, you tell me! diff -ur curl-7.11.0/docs/libcurl/curl_easy_setopt.3 curl-7.11.0-new/docs/libcurl/curl_easy_setopt.3 --- curl-7.11.0/docs/libcurl/curl_easy_setopt.3 2004-01-22 20:15:37.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/curl_easy_setopt.3 2004-02-28 17:33:52.000000000 +1100 @@ -885,4 +885,6 @@ error occurred as \fI\fP defines. See the \fIlibcurl-errors.3\fP man page for the full list with descriptions. .SH "SEE ALSO" -.BR curl_easy_init "(3), " curl_easy_cleanup "(3), " +.BR curl_easy_init "(3)," +.BR curl_easy_cleanup "(3)," +.BR libcurl-errors "(3)" diff -ur curl-7.11.0/docs/libcurl/curl_formparse.3 curl-7.11.0-new/docs/libcurl/curl_formparse.3 --- curl-7.11.0/docs/libcurl/curl_formparse.3 2002-03-04 21:09:49.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/curl_formparse.3 2004-02-28 17:34:17.000000000 +1100 @@ -16,3 +16,5 @@ This has been removed deliberately. The \fBcurl_formadd\fP has been introduced to replace this function. Do not use this. Convert to the new function now. curl_formparse() will be removed from a future version of libcurl. +.SH "SEE ALSO" +.BR libcurl-errors "(3)" diff -ur curl-7.11.0/docs/libcurl/curl_global_init.3 curl-7.11.0-new/docs/libcurl/curl_global_init.3 --- curl-7.11.0/docs/libcurl/curl_global_init.3 2002-03-04 21:09:49.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/curl_global_init.3 2004-02-28 17:34:35.000000000 +1100 @@ -43,7 +43,7 @@ If this function returns non-zero, something went wrong and you cannot use the other curl functions. .SH "SEE ALSO" -.BR curl_global_cleanup "(3), " +.BR curl_global_cleanup "(3)," +.BR libcurl-errors "(3)" .SH BUGS None. - diff -ur curl-7.11.0/docs/libcurl/curl_multi_add_handle.3 curl-7.11.0-new/docs/libcurl/curl_multi_add_handle.3 --- curl-7.11.0/docs/libcurl/curl_multi_add_handle.3 2002-03-08 18:54:05.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/curl_multi_add_handle.3 2004-02-28 17:29:54.000000000 +1100 @@ -17,4 +17,6 @@ .SH RETURN VALUE CURLMcode type, general libcurl multi interface error code. .SH "SEE ALSO" -.BR curl_multi_cleanup "(3)," curl_multi_init "(3)" +.BR curl_multi_cleanup "(3)," +.BR curl_multi_init "(3)," +.BR libcurl-errors "(3)" diff -ur curl-7.11.0/docs/libcurl/curl_multi_cleanup.3 curl-7.11.0-new/docs/libcurl/curl_multi_cleanup.3 --- curl-7.11.0/docs/libcurl/curl_multi_cleanup.3 2002-03-04 21:09:49.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/curl_multi_cleanup.3 2004-02-28 17:29:38.000000000 +1100 @@ -15,4 +15,7 @@ .SH RETURN VALUE CURLMcode type, general libcurl multi interface error code. .SH "SEE ALSO" -.BR curl_multi_init "(3)," curl_easy_cleanup "(3)," curl_easy_init "(3)" +.BR curl_multi_init "(3)," +.BR curl_easy_cleanup "(3)," +.BR curl_easy_init "(3)," +.BR libcurl-errors "(3)" diff -ur curl-7.11.0/docs/libcurl/curl_multi_fdset.3 curl-7.11.0-new/docs/libcurl/curl_multi_fdset.3 --- curl-7.11.0/docs/libcurl/curl_multi_fdset.3 2002-10-15 18:39:30.000000000 +1000 +++ curl-7.11.0-new/docs/libcurl/curl_multi_fdset.3 2004-02-28 17:31:03.000000000 +1100 @@ -24,4 +24,6 @@ .SH RETURN VALUE CURLMcode type, general libcurl multi interface error code. .SH "SEE ALSO" -.BR curl_multi_cleanup "(3)," curl_multi_init "(3)" +.BR curl_multi_cleanup "(3)," +.BR curl_multi_init "(3)," +.BR libcurl-errors "(3)" diff -ur curl-7.11.0/docs/libcurl/curl_multi_perform.3 curl-7.11.0-new/docs/libcurl/curl_multi_perform.3 --- curl-7.11.0/docs/libcurl/curl_multi_perform.3 2002-12-03 23:40:13.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/curl_multi_perform.3 2004-02-28 17:31:36.000000000 +1100 @@ -33,4 +33,6 @@ file descriptors, then it'll wait for action on them using select() and as soon as one or more of them are ready, \fIcurl_multi_perform\fP gets called. .SH "SEE ALSO" -.BR curl_multi_cleanup "(3)," curl_multi_init "(3)" +.BR curl_multi_cleanup "(3)," +.BR curl_multi_init "(3)," +.BR libcurl-errors "(3)" diff -ur curl-7.11.0/docs/libcurl/curl_multi_remove_handle.3 curl-7.11.0-new/docs/libcurl/curl_multi_remove_handle.3 --- curl-7.11.0/docs/libcurl/curl_multi_remove_handle.3 2003-03-11 07:43:59.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/curl_multi_remove_handle.3 2004-02-28 17:32:04.000000000 +1100 @@ -20,4 +20,6 @@ .SH RETURN VALUE CURLMcode type, general libcurl multi interface error code. .SH "SEE ALSO" -.BR curl_multi_cleanup "(3)," curl_multi_init "(3)" +.BR curl_multi_cleanup "(3)," +.BR curl_multi_init "(3)," +.BR libcurl-errors "(3)" diff -ur curl-7.11.0/docs/libcurl/libcurl-errors.3 curl-7.11.0-new/docs/libcurl/libcurl-errors.3 --- curl-7.11.0/docs/libcurl/libcurl-errors.3 2003-12-19 03:16:19.000000000 +1100 +++ curl-7.11.0-new/docs/libcurl/libcurl-errors.3 2004-03-10 10:48:56.000000000 +1100 @@ -11,9 +11,12 @@ .SH "CURLcode" Almost all "easy" interface functions return a CURLcode error code. No matter what, using \fICURLOPT_ERRORBUFFER\fP is a good idea as it will give you a -human readable error string that may offer more details about the error cause +human-readable error string that may offer more details about the error cause than just the error code does. - +.PP +Alternatively, you can use the curl_easy_strerror function to obtain a +human-readable string from the CURLcode value. +.PP CURLcode is one of the following: .RS 0 .IP "CURLE_OK (0)" @@ -188,3 +191,13 @@ .SH "CURLMcode" This is the generic return code used by functions in the libcurl multi interface. +.PP +You can use the curl_multi_strerror function to obtain a +human-readable string from the CURLMcode value. + +.SH "CURLSHcode" +This is the generic return code used by functions in the libcurl share +interface. +.PP +You can use the curl_share_strerror function to obtain a +human-readable string from the CURLSHcode value. diff -ur curl-7.11.0/include/curl/curl.h curl-7.11.0-new/include/curl/curl.h --- curl-7.11.0/include/curl/curl.h 2004-01-22 20:17:51.000000000 +1100 +++ curl-7.11.0-new/include/curl/curl.h 2004-03-10 10:38:52.000000000 +1100 @@ -228,6 +228,13 @@ OpenSSL SSL_CTX */ void *userptr); +/** + * The curl_easy_strerror function may be used to turn a CURLcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +const char *curl_easy_strerror(CURLcode); + /* Make a spelling correction for the operation timed-out define */ #define CURLE_OPERATION_TIMEDOUT CURLE_OPERATION_TIMEOUTED #define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR @@ -1140,6 +1147,13 @@ CURLSHE_LAST /* never use */ } CURLSHcode; +/** + * The curl_share_strerror function may be used to turn a CURLSHcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +const char *curl_share_strerror(CURLSHcode); + typedef enum { CURLSHOPT_NONE, /* don't use */ CURLSHOPT_SHARE, /* specify a data type to share */ diff -ur curl-7.11.0/include/curl/multi.h curl-7.11.0-new/include/curl/multi.h --- curl-7.11.0/include/curl/multi.h 2004-01-09 08:56:50.000000000 +1100 +++ curl-7.11.0-new/include/curl/multi.h 2004-03-10 10:29:29.000000000 +1100 @@ -85,6 +85,14 @@ CURLM_LAST } CURLMcode; + +/** + * The curl_multi_strerror function may be used to turn a CURLMcode + * value into the equivalent human readable error string. This is + * useful for printing meaningful error messages. + */ +const char *curl_multi_strerror(CURLMcode); + typedef enum { CURLMSG_NONE, /* first, not used */ CURLMSG_DONE, /* This easy handle has completed. 'result' contains diff -ur curl-7.11.0/lib/Makefile.am curl-7.11.0-new/lib/Makefile.am --- curl-7.11.0/lib/Makefile.am 2004-01-06 09:29:32.000000000 +1100 +++ curl-7.11.0-new/lib/Makefile.am 2004-03-10 10:43:17.000000000 +1100 @@ -75,7 +75,7 @@ content_encoding.c content_encoding.h share.c share.h http_digest.c \ md5.c md5.h http_digest.h http_negotiate.c http_negotiate.h \ http_ntlm.c http_ntlm.h ca-bundle.h inet_pton.c inet_pton.h \ -strtoofft.c strtoofft.h +strtoofft.c strtoofft.h curl_strerror.c curlm_strerror.c curlsh_strerror.c noinst_HEADERS = setup.h transfer.h diff -u /dev/null curl-7.11.0-new/lib/curl_strerror.c --- /dev/null 2003-01-30 21:24:37.000000000 +1100 +++ curl-7.11.0-new/lib/curl_strerror.c 2004-03-10 10:31:05.000000000 +1100 @@ -0,0 +1,244 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + + +const char * +curl_easy_strerror(CURLcode x) +{ + switch (x) + { + 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"; +} diff -u /dev/null curl-7.11.0-new/lib/curlm_strerror.c --- /dev/null 2003-01-30 21:24:37.000000000 +1100 +++ curl-7.11.0-new/lib/curlm_strerror.c 2004-03-10 10:28:58.000000000 +1100 @@ -0,0 +1,67 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + + +const char * +curl_multi_strerror(CURLMcode x) +{ + switch (x) + { + 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; + } + /* + * 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 "CURLMcode unknown"; +} diff -u /dev/null curl-7.11.0-new/lib/curlsh_strerror.c --- /dev/null 2003-01-30 21:24:37.000000000 +1100 +++ curl-7.11.0-new/lib/curlsh_strerror.c 2004-03-10 10:42:44.000000000 +1100 @@ -0,0 +1,61 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 + + +const char * +curl_share_strerror(CURLSHcode x) +{ + switch (x) + { + 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; + } + /* + * 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 "CURLSH unknown"; +}