/* 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;
-
- /* Defaults */
- act->flags = 0;
- act->port = NNTP_PORT;
- act->type = M_ACCT_TYPE_NNTP;
+ ciss_url_t url;
+ char s[STRING];
- c = m_strdup(server);
- url_parse_ciss (&url, c);
+ act->flags = 0;
+ act->port = 0;
+ act->type = M_ACCT_TYPE_NNTP;
- 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_SSL_PORT : NNTP_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)
h->old = 1;
}
-static void nntp_create_newsrc_line(nntp_data_t *data, buffer_t *buf)
-{
- buffer_addstr(buf, data->group);
- buffer_addch(buf, data->subscribed ? ':' : '!');
- buffer_addch(buf, ' ');
-
- for (int x = 0; x < data->num; x++) {
- if (x) {
- buffer_addch(buf, ',');
- }
-
- buffer_addf(buf, "%d-%d", data->entries[x].first,
- data->entries[x].last);
- }
- buffer_addch(buf, '\n');
-}
-
static void newsrc_gen_entries (CONTEXT * ctx)
{
nntp_data_t *data = (nntp_data_t *) ctx->data;
for (data = news->list; data; data = data->next) {
if (!data || !data->rc)
continue;
- nntp_create_newsrc_line(data, &buf);
+
+ buffer_addstr(&buf, data->group);
+ buffer_addch(&buf, data->subscribed ? ':' : '!');
+
+ for (int x = 0; x < data->num; x++) {
+ buffer_addch(&buf, x ? ',' : ' ');
+ buffer_addf(&buf, "%d-%d", data->entries[x].first,
+ data->entries[x].last);
+ }
+ buffer_addch(&buf, '\n');
}
+
/* newrc being fully rewritten */
if (news->newsrc
&& (r = mutt_update_list_file(news->newsrc, NULL, "", buf.data)) == 0)
if (data && data->group) {
key = data->group;
- snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
- data->firstMessage, data->lastLoaded);
- }
- else {
+ snprintf(buf, sizeof(buf), "%s %s %d %d", key, data->cache,
+ data->firstMessage, data->lastLoaded);
+ } else {
m_strcpy(file, sizeof(file), serv->cache);
- snprintf (buf, sizeof (buf), "ALL %s 0 %d", file,
- (int) serv->newgroups_time);
+ snprintf(buf, sizeof (buf), "ALL %s 0 %d", file,
+ (int)serv->newgroups_time);
}
nntp_cache_expand(file, ssizeof(file), "%s.index", serv->conn->account.host);
return mutt_update_list_file(file, serv->conn->account.host, key, buf);
{
CONNECTION *conn = serv->conn;
char buf[STRING];
- unsigned char flags = conn->account.flags;
+ int flags = conn->account.flags;
if (mutt_account_getuser(&conn->account) || !conn->account.user[0] ||
mutt_account_getpass(&conn->account) || !conn->account.pass[0]) {