/* nntp_parse_url: given an NNPT URL, return host, port,
* username, password and newsgroup will recognise. */
-static int nntp_parse_url(const char *server, ACCOUNT * act, char *group,
+static int nntp_parse_url(const char *server, ACCOUNT *act, char *group,
ssize_t group_len)
{
- ciss_url_t url;
- char *c;
- int ret = -1;
+ ciss_url_t url;
+ char s[STRING];
- /* Defaults */
- act->flags = 0;
- act->port = NNTP_PORT;
- act->type = M_ACCT_TYPE_NNTP;
+ act->flags = 0;
+ act->port = 0;
+ act->type = M_ACCT_TYPE_NNTP;
- c = m_strdup(server);
- url_parse_ciss (&url, c);
-
- if (url.scheme == U_NNTP || url.scheme == U_NNTPS) {
- if (url.scheme == U_NNTPS) {
- act->has_ssl = 1;
- act->port = NNTP_SSL_PORT;
- }
+ m_strcpy(s, sizeof(s), server);
+ url_parse_ciss(&url, s);
- *group = '\0';
- if (url.path)
- m_strcpy(group, group_len, url.path);
+ if (url.scheme != U_NNTP || url.scheme != U_NNTPS)
+ return -1;
- ret = mutt_account_fromurl (act, &url);
- }
+ act->has_ssl = (url.scheme == U_NNTPS);
+ if (!act->port) {
+ act->port = act->has_ssl ? NNTP_PORT : NNTP_SSL_PORT;
+ }
+ m_strcpy(group, group_len, url.path);
- p_delete(&c);
- return ret;
+ return mutt_account_fromurl(act, &url);
}
void nntp_expand_path (char *line, ssize_t len, ACCOUNT * act)