From d647997c068102e22a159612ba83740f1d776e7e Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Thu, 16 Apr 2009 19:23:32 +0200 Subject: [PATCH] POP: Default to using getservbyname() as we do for IMAP and SMTP --- ChangeLog | 15 +++++++++++++++ pop_lib.c | 30 ++++++++++++++++++------------ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1380c9b5..80af26cb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-04-16 19:14 +0200 Rocco Rutte (ca73c9e8c141) + + * doc/manual.xml.head: Manual: Improve docs on URL syntax, add + examples + +2009-04-16 16:17 +0200 Rocco Rutte (052b17f5f7f7) + + * doc/manual.xml.head: Manual: Add user-defined variables to variable + types + +2009-04-11 10:35 +0200 Rocco Rutte (7d7976cd4fc4) + + * ChangeLog, buffy.c, buffy.h, commands.c, sendlib.c: Don't raise new + mail flag on mbox/mmdf Fcc mailboxes. Closes #1896. + 2009-04-08 16:25 +0200 Rocco Rutte (5b631ee33281) * hdrline.c: For %F, display Bcc recipient if no other recipients diff --git a/pop_lib.c b/pop_lib.c index 4b06ab0af..ccbf69184 100644 --- a/pop_lib.c +++ b/pop_lib.c @@ -31,36 +31,42 @@ #include #include #include +#include /* given an POP mailbox name, return host, port, username and password */ int pop_parse_path (const char* path, ACCOUNT* acct) { ciss_url_t url; char *c; - int ret = -1; + struct servent *service; /* Defaults */ acct->flags = 0; - acct->port = POP_PORT; acct->type = M_ACCT_TYPE_POP; c = safe_strdup (path); url_parse_ciss (&url, c); - if (url.scheme == U_POP || url.scheme == U_POPS) + if ((url.scheme != U_POP && url.scheme != U_POPS) || + mutt_account_fromurl (acct, &url) < 0) { - if (url.scheme == U_POPS) - { - acct->flags |= M_ACCT_SSL; - acct->port = POP_SSL_PORT; - } - - if ((!url.path || !*url.path) && mutt_account_fromurl (acct, &url) == 0) - ret = 0; + FREE(&c); + mutt_error(_("Invalid POP URL: %s\n"), path); + mutt_sleep(1); + return -1; } + if (url.scheme == U_POPS) + acct->flags |= M_ACCT_SSL; + + service = getservbyname (url.scheme == U_POP ? "pop3" : "pop3s", "tcp"); + if (service) + acct->port = ntohs (service->s_port); + else + acct->port = url.scheme == U_POP ? POP_PORT : POP_SSL_PORT;; + FREE (&c); - return ret; + return 0; } /* Copy error message to err_msg buffer */ -- 2.40.0