diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2007-08-30 20:34:57 +0000 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2007-08-30 20:34:57 +0000 |
commit | 9f44a95522162c0f4a61093efe1bf1f58b087358 (patch) | |
tree | ea90ca762a9a7a4f6772cb44b23e994b41f32644 /lib | |
parent | 4b60c3e9d3d284125857ecf90b1910db5ba318a2 (diff) |
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)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base64.c | 6 | ||||
-rw-r--r-- | lib/connect.c | 6 | ||||
-rw-r--r-- | lib/ftp.c | 14 | ||||
-rw-r--r-- | lib/gtls.c | 2 | ||||
-rw-r--r-- | lib/nss.c | 4 | ||||
-rw-r--r-- | lib/speedcheck.c | 2 | ||||
-rw-r--r-- | lib/ssh.c | 26 | ||||
-rw-r--r-- | lib/ssluse.c | 2 | ||||
-rw-r--r-- | lib/strerror.c | 68 | ||||
-rw-r--r-- | lib/telnet.c | 2 | ||||
-rw-r--r-- | lib/tftp.c | 6 | ||||
-rw-r--r-- | lib/transfer.c | 4 | ||||
-rw-r--r-- | lib/url.c | 18 |
13 files changed, 71 insertions, 89 deletions
diff --git a/lib/base64.c b/lib/base64.c index 302d49885..912aaf050 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -137,7 +137,7 @@ size_t Curl_base64_decode(const char *src, unsigned char **outptr) * * Returns the length of the newly created base64 string. The third argument * is a pointer to an allocated area holding the base64 data. If something - * went wrong, -1 is returned. + * went wrong, 0 is returned. * */ size_t Curl_base64_encode(struct SessionHandle *data, @@ -265,7 +265,7 @@ int main(int argc, argv_item_t argv[], char **envp) handle = curl_easy_init(); if(handle == NULL) { fprintf(stderr, "Error: curl_easy_init failed\n"); - return 0; + return 1; } #endif data = (unsigned char *)suck(&dataLen); @@ -305,7 +305,7 @@ int main(int argc, argv_item_t argv[], char **envp) struct SessionHandle *handle = curl_easy_init(); if(handle == NULL) { fprintf(stderr, "Error: curl_easy_init failed\n"); - return 0; + return 1; } #endif diff --git a/lib/connect.c b/lib/connect.c index 9877ae8f4..cfdf5680a 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -552,7 +552,7 @@ CURLcode Curl_is_connected(struct connectdata *conn, if(has_passed > allow ) { /* time-out, bail out, go home */ failf(data, "Connection time-out after %ld ms", has_passed); - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } if(conn->bits.tcpconnect) { /* we are connected already! */ @@ -827,7 +827,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ if(timeout_ms < 0) { /* a precaution, no need to continue if time already is up */ failf(data, "Connection time-out"); - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } } Curl_expire(data, timeout_ms); @@ -863,7 +863,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */ timeout_ms -= Curl_tvdiff(after, before); if(timeout_ms < 0) { failf(data, "connect() timed out!"); - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } before = after; } /* end of connect-to-each-address loop */ @@ -1885,7 +1885,7 @@ static CURLcode ftp_state_type_resp(struct connectdata *conn, successful 'TYPE I'. While that is not as RFC959 says, it is still a positive response code and we allow that. */ failf(data, "Couldn't set desired mode"); - return CURLE_FTP_COULDNT_SET_BINARY; /* FIX */ + return CURLE_FTP_COULDNT_SET_TYPE; } if(ftpcode != 200) infof(data, "Got a %03d response code instead of the assumed 200\n", @@ -2608,7 +2608,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) case FTP_STOR_PREQUOTE: if(ftpcode >= 400) { failf(conn->data, "QUOT command failed with %03d", ftpcode); - return CURLE_FTP_QUOTE_ERROR; + return CURLE_QUOTE_ERROR; } result = ftp_state_quote(conn, FALSE, ftpc->state); if(result) @@ -2631,7 +2631,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) failf(data, "Server denied you to change to the given directory"); ftpc->cwdfail = TRUE; /* don't remember this path as we failed to enter it */ - return CURLE_FTP_ACCESS_DENIED; + return CURLE_REMOTE_ACCESS_DENIED; } } else { @@ -2653,7 +2653,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) if(ftpcode/100 != 2) { /* failure to MKD the dir */ failf(data, "Failed to MKD dir: %03d", ftpcode); - return CURLE_FTP_ACCESS_DENIED; + return CURLE_REMOTE_ACCESS_DENIED; } state(conn, FTP_CWD); /* send CWD */ @@ -2964,10 +2964,10 @@ CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status, bool premature case CURLE_BAD_DOWNLOAD_RESUME: case CURLE_FTP_WEIRD_PASV_REPLY: case CURLE_FTP_PORT_FAILED: - case CURLE_FTP_COULDNT_SET_BINARY: + case CURLE_FTP_COULDNT_SET_TYPE: case CURLE_FTP_COULDNT_RETR_FILE: case CURLE_UPLOAD_FAILED: - case CURLE_FTP_ACCESS_DENIED: + case CURLE_REMOTE_ACCESS_DENIED: case CURLE_FILESIZE_EXCEEDED: /* the connection stays alive fine even though this happened */ /* fall-through */ @@ -3146,7 +3146,7 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote) if (ftpcode >= 400) { failf(conn->data, "QUOT string not accepted: %s", item->data); - return CURLE_FTP_QUOTE_ERROR; + return CURLE_QUOTE_ERROR; } } diff --git a/lib/gtls.c b/lib/gtls.c index 834994069..8d126d005 100644 --- a/lib/gtls.c +++ b/lib/gtls.c @@ -175,7 +175,7 @@ static CURLcode handshake(struct connectdata *conn, if(timeout_ms < 0) { /* a precaution, no need to continue if time already is up */ failf(data, "SSL connection timeout"); - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } rc = Curl_socket_ready(conn->sock[sockindex], @@ -550,7 +550,7 @@ int Curl_nss_send(struct connectdata *conn, /* connection data */ if(err == PR_IO_TIMEOUT_ERROR) { failf(data, "SSL connection timeout"); - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } failf(conn->data, "SSL write: error %d\n", err); @@ -591,7 +591,7 @@ ssize_t Curl_nss_recv(struct connectdata * conn, /* connection data */ } if(err == PR_IO_TIMEOUT_ERROR) { failf(data, "SSL connection timeout"); - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } failf(conn->data, "SSL read: errno %d", err); return -1; diff --git a/lib/speedcheck.c b/lib/speedcheck.c index adda8a963..aa57ccd59 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -57,7 +57,7 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, "Less than %d bytes/sec transfered the last %d seconds", data->set.low_speed_limit, data->set.low_speed_time); - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } Curl_expire(data, howlong); } @@ -722,7 +722,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) if (cp == NULL) { failf(data, "Syntax error in SFTP command. Supply parameter(s)!"); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } @@ -880,7 +880,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) failf(data, "Attempt to get SFTP stats failed: %s", sftp_libssh2_strerror(err)); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } @@ -894,7 +894,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) sshc->quote_path2 = NULL; failf(data, "Syntax error: chgrp gid not a number"); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } } @@ -909,7 +909,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) sshc->quote_path2 = NULL; failf(data, "Syntax error: chmod permissions not a number"); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } } @@ -922,7 +922,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) sshc->quote_path2 = NULL; failf(data, "Syntax error: chown uid not a number"); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } } @@ -945,7 +945,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) failf(data, "Attempt to set SFTP stats failed: %s", sftp_libssh2_strerror(err)); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } state(conn, SSH_SFTP_NEXT_QUOTE); @@ -966,7 +966,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) failf(data, "symlink command failed: %s", sftp_libssh2_strerror(err)); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } state(conn, SSH_SFTP_NEXT_QUOTE); @@ -983,7 +983,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) sshc->quote_path1 = NULL; failf(data, "mkdir command failed: %s", sftp_libssh2_strerror(err)); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } state(conn, SSH_SFTP_NEXT_QUOTE); @@ -1002,7 +1002,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) sshc->quote_path2 = NULL; failf(data, "rename command failed: %s", sftp_libssh2_strerror(err)); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } state(conn, SSH_SFTP_NEXT_QUOTE); @@ -1019,7 +1019,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) sshc->quote_path1 = NULL; failf(data, "rmdir command failed: %s", sftp_libssh2_strerror(err)); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } state(conn, SSH_SFTP_NEXT_QUOTE); @@ -1036,7 +1036,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) sshc->quote_path1 = NULL; failf(data, "rm command failed: %s", sftp_libssh2_strerror(err)); state(conn, SSH_SFTP_CLOSE); - sshc->actualCode = CURLE_FTP_QUOTE_ERROR; + sshc->actualCode = CURLE_QUOTE_ERROR; break; } state(conn, SSH_SFTP_NEXT_QUOTE); @@ -2143,7 +2143,7 @@ get_pathname(const char **cpp, char **path) if (!*cp) { *cpp = cp; *path = NULL; - return CURLE_FTP_QUOTE_ERROR; + return CURLE_QUOTE_ERROR; } *path = malloc(strlen(cp) + 1); @@ -2198,7 +2198,7 @@ get_pathname(const char **cpp, char **path) fail: Curl_safefree(*path); *path = NULL; - return CURLE_FTP_QUOTE_ERROR; + return CURLE_QUOTE_ERROR; } diff --git a/lib/ssluse.c b/lib/ssluse.c index 3aea2dee9..7e4ead790 100644 --- a/lib/ssluse.c +++ b/lib/ssluse.c @@ -1492,7 +1492,7 @@ Curl_ossl_connect_step2(struct connectdata *conn, if(*timeout_ms < 0) { /* a precaution, no need to continue if time already is up */ failf(data, "SSL connection timeout"); - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } err = SSL_connect(connssl->handle); 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; } diff --git a/lib/telnet.c b/lib/telnet.c index 621e5f908..93a598252 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -1390,7 +1390,7 @@ CURLcode Curl_telnet(struct connectdata *conn, bool *done) now = Curl_tvnow(); if(Curl_tvdiff(now, conn->created) >= data->set.timeout) { failf(data, "Time-out"); - code = CURLE_OPERATION_TIMEOUTED; + code = CURLE_OPERATION_TIMEDOUT; keepon = FALSE; } } diff --git a/lib/tftp.c b/lib/tftp.c index 88f0f0a80..cfa20a6b2 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -801,7 +801,7 @@ CURLcode Curl_tftp(struct connectdata *conn, bool *done) code = CURLE_TFTP_PERM; break; case TFTP_ERR_DISKFULL: - code = CURLE_TFTP_DISKFULL; + code = CURLE_REMOTE_DISK_FULL; break; case TFTP_ERR_ILLEGAL: code = CURLE_TFTP_ILLEGAL; @@ -810,13 +810,13 @@ CURLcode Curl_tftp(struct connectdata *conn, bool *done) code = CURLE_TFTP_UNKNOWNID; break; case TFTP_ERR_EXISTS: - code = CURLE_TFTP_EXISTS; + code = CURLE_REMOTE_FILE_EXISTS; break; case TFTP_ERR_NOSUCHUSER: code = CURLE_TFTP_NOSUCHUSER; break; case TFTP_ERR_TIMEOUT: - code = CURLE_OPERATION_TIMEOUTED; + code = CURLE_OPERATION_TIMEDOUT; break; case TFTP_ERR_NORESPONSE: code = CURLE_COULDNT_CONNECT; diff --git a/lib/transfer.c b/lib/transfer.c index 0fb21c528..29eb61985 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -1182,7 +1182,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, * wasn't a GET we did a POST or PUT resume) */ failf(data, "HTTP server doesn't seem to support " "byte ranges. Cannot resume."); - return CURLE_HTTP_RANGE_ERROR; + return CURLE_RANGE_ERROR; } if(data->set.timecondition && !data->reqdata.range) { @@ -1591,7 +1591,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, FORMAT_OFF_T " bytes received", data->set.timeout, k->bytecount); } - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } if(!k->keepon) { @@ -813,16 +813,16 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, */ data->set.ftp_response_timeout = va_arg( param , long ) * 1000; break; - case CURLOPT_FTPLISTONLY: + case CURLOPT_DIRLISTONLY: /* - * An FTP option that changes the command to one that asks for a list + * An option that changes the command to one that asks for a list * only, no file info details. */ data->set.ftp_list_only = (bool)(0 != va_arg(param, long)); break; - case CURLOPT_FTPAPPEND: + case CURLOPT_APPEND: /* - * We want to upload and append to an existing (FTP) file. + * We want to upload and append to an existing file. */ data->set.ftp_append = (bool)(0 != va_arg(param, long)); break; @@ -1524,9 +1524,9 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE], va_arg(param, char *)); break; - case CURLOPT_SSLKEYPASSWD: + case CURLOPT_KEYPASSWD: /* - * String that holds the SSL private key password. + * String that holds the SSL or SSH private key password. */ result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD], va_arg(param, char *)); @@ -1730,9 +1730,9 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, data->set.max_filesize = va_arg(param, long); break; - case CURLOPT_FTP_SSL: + case CURLOPT_USE_SSL: /* - * Make FTP transfers attempt to use SSL/TLS. + * Make transfers attempt to use SSL/TLS. */ data->set.ftp_ssl = (curl_ftpssl)va_arg(param, long); break; @@ -4226,7 +4226,7 @@ static CURLcode CreateConnection(struct SessionHandle *data, won't, and zero would be to switch it off so we never set it to less than 1! */ alarm(1); - result = CURLE_OPERATION_TIMEOUTED; + result = CURLE_OPERATION_TIMEDOUT; failf(data, "Previous alarm fired off!"); } else |