X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..299d2b65f257d19159e3adeaf5d62af7e96e0ec6:/pop_lib.c?ds=inline diff --git a/pop_lib.c b/pop_lib.c index 4b06ab0..ccbf691 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 */