diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-05-05 17:07:21 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-05-05 17:07:21 +0200 |
commit | 32001ac4149b2062402b5914d756d405ab45c212 (patch) | |
tree | 446d0c52870ce3faa9a39eba730d091b0bc45bf3 | |
parent | 9c629e534866169b1445bd6614233ded73ff0460 (diff) |
set_userpass: convert from protocol-specific to generic
The protocol handler's flags field now can set that the protocol
requires a password, so that the set_userpass function doesn't have to
have the specific knowledge of which protocols that do.
-rw-r--r-- | lib/ftp.c | 5 | ||||
-rw-r--r-- | lib/imap.c | 4 | ||||
-rw-r--r-- | lib/url.c | 2 | ||||
-rw-r--r-- | lib/urldata.h | 4 |
4 files changed, 9 insertions, 6 deletions
@@ -181,7 +181,7 @@ const struct Curl_handler Curl_handler_ftp = { ZERO_NULL, /* readwrite */ PORT_FTP, /* defport */ CURLPROTO_FTP, /* protocol */ - PROTOPT_DUAL | PROTOPT_CLOSEACTION /* flags */ + PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD /* flags */ }; @@ -206,7 +206,8 @@ const struct Curl_handler Curl_handler_ftps = { ZERO_NULL, /* readwrite */ PORT_FTPS, /* defport */ CURLPROTO_FTP | CURLPROTO_FTPS, /* protocol */ - PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION /* flags */ + PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION | + PROTOPT_NEEDSPWD /* flags */ }; #endif diff --git a/lib/imap.c b/lib/imap.c index 67f0328e4..b135443d3 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -129,7 +129,7 @@ const struct Curl_handler Curl_handler_imap = { ZERO_NULL, /* readwrite */ PORT_IMAP, /* defport */ CURLPROTO_IMAP, /* protocol */ - PROTOPT_CLOSEACTION /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD /* flags */ }; @@ -154,7 +154,7 @@ const struct Curl_handler Curl_handler_imaps = { ZERO_NULL, /* readwrite */ PORT_IMAPS, /* defport */ CURLPROTO_IMAP | CURLPROTO_IMAPS, /* protocol */ - PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_SSL | PROTOPT_NEEDSPWD /* flags */ }; #endif @@ -4452,7 +4452,7 @@ static CURLcode set_userpass(struct connectdata *conn, const char *user, const char *passwd) { /* If our protocol needs a password and we have none, use the defaults */ - if((conn->handler->protocol & (CURLPROTO_FTP|CURLPROTO_IMAP)) && + if((conn->handler->flags & PROTOPT_NEEDSPWD) && !conn->bits.user_passwd) { conn->user = strdup(CURL_DEFAULT_USER); diff --git a/lib/urldata.h b/lib/urldata.h index e78dbbf3c..f4b4bcc6c 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -703,7 +703,9 @@ struct Curl_handler { the send function might need to be called while uploading, or vice versa. */ #define PROTOPT_DIRLOCK (1<<3) -#define PROTOPT_NONETWORK (1<<4) /* protocol doesn't use the network! */ +#define PROTOPT_NONETWORK (1<<4) /* protocol doesn't use the network! */ +#define PROTOPT_NEEDSPWD (1<<5) /* needs a password, and if none is set it + gets a default */ /* return the count of bytes sent, or -1 on error */ |