diff options
author | Daniel Stenberg <daniel@haxx.se> | 2009-12-31 21:52:01 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2009-12-31 21:52:01 +0000 |
commit | 3f3f6be825da333055a1113c4998691b086f4601 (patch) | |
tree | 01585ab30e8a0aa6e5e60168b393f8ba71d1f767 | |
parent | 01682cca550802401aefb0538416a17f8271fc88 (diff) |
turned CURLOPT_MAIL_RCPT into a curl_slist list instead to support multiple
receivers, and made the command line tool thus support the option specified
many times
-rw-r--r-- | lib/smtp.c | 19 | ||||
-rw-r--r-- | lib/url.c | 4 | ||||
-rw-r--r-- | lib/urldata.h | 2 | ||||
-rw-r--r-- | src/main.c | 8 |
4 files changed, 26 insertions, 7 deletions
diff --git a/lib/smtp.c b/lib/smtp.c index 5dd90298b..0f34c4f9e 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -345,8 +345,23 @@ static CURLcode smtp_state_mail_resp(struct connectdata *conn, } else { /* send RCPT TO */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s", - data->set.str[STRING_MAIL_RCPT]); + struct curl_slist *rcpt; + char *buffer = NULL; + + for(rcpt = data->set.mail_rcpt; rcpt; rcpt=rcpt->next) { + char *add = aprintf("%s%s%s", buffer?buffer:"", buffer?", ":"", + rcpt->data); + if(!add) { + free(buffer); + return CURLE_OUT_OF_MEMORY; + } + buffer = add; + } + + result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s", buffer); + + free(buffer); + if(result) return result; @@ -2314,8 +2314,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, break; case CURLOPT_MAIL_RCPT: - result = setstropt(&data->set.str[STRING_MAIL_RCPT], - va_arg(param, char *)); + /* get a list of mail recipients */ + data->set.mail_rcpt = va_arg(param, struct curl_slist *); break; default: diff --git a/lib/urldata.h b/lib/urldata.h index 6c852e8ad..4bcb5bf6f 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1166,7 +1166,6 @@ enum dupstring { STRING_SOCKS5_GSSAPI_SERVICE, /* GSSAPI service name */ #endif STRING_MAIL_FROM, - STRING_MAIL_RCPT, /* -- end of strings -- */ STRING_LAST /* not used, just an end-of-list marker */ @@ -1337,6 +1336,7 @@ struct UserDefined { #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) long socks5_gssapi_nec; /* flag to support nec socks5 server */ #endif + struct curl_slist *mail_rcpt; /* linked list of mail recipients */ }; struct Names { diff --git a/src/main.c b/src/main.c index 39120913f..09d4c827b 100644 --- a/src/main.c +++ b/src/main.c @@ -501,7 +501,7 @@ struct Configurable { int proxyver; /* set to CURLPROXY_HTTP* define */ char *noproxy; char *mail_from; - char *mail_rcpt; + struct curl_slist *mail_rcpt; bool proxytunnel; bool ftp_append; /* APPE on ftp */ bool mute; /* shutup */ @@ -2279,7 +2279,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ GetStr(&config->mail_from, nextarg); break; case 'B': /* --mail-rcpt */ - GetStr(&config->mail_rcpt, nextarg); + /* append receiver to a list */ + err = add2list(&config->mail_rcpt, nextarg); + if(err) + return err; break; } break; @@ -3837,6 +3840,7 @@ static void free_config_fields(struct Configurable *config) curl_slist_free_all(config->postquote); curl_slist_free_all(config->headers); curl_slist_free_all(config->telnet_options); + curl_slist_free_all(config->mail_rcpt); if(config->easy) curl_easy_cleanup(config->easy); |