tail is always a list_item**.
[apps/madmutt.git] / nntp / newsrc.c
index 4e897f3..c919d86 100644 (file)
 #include "sort.h"
 #include "nntp.h"
 
-void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d)
+void nntp_add_to_list(NNTP_SERVER *s, NNTP_DATA *d)
 {
-  string_list_t *l;
-
-  if (!s || !d)
-    return;
-
-  l = p_new(string_list_t, 1);
-  if (s->list)
-    s->tail->next = l;
-  else
-    s->list = l;
-  s->tail = l;
-  l->data = (void *) d;
+    *s->tail = p_new(string_list_t, 1);
+    (*s->tail)->data = (void *)d;
+    s->tail = &(*s->tail)->next;
 }
 
 static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
@@ -161,7 +152,7 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news)
   if (!news || !news->conn || !news->conn->account.host)
     return -1;
   unset_option (OPTNEWSCACHE);
-  if (!NewsCacheDir || !*NewsCacheDir)
+  if (m_strisempty(NewsCacheDir))
     return 0;
 
   m_strcpy(dir, sizeof(dir), NewsCacheDir);
@@ -274,7 +265,7 @@ int nntp_parse_url (const char *server, ACCOUNT * act,
 
   if (url.scheme == U_NNTP || url.scheme == U_NNTPS) {
     if (url.scheme == U_NNTPS) {
-      act->flags |= M_ACCT_SSL;
+      act->has_ssl = 1;
       act->port = NNTP_SSL_PORT;
     }
 
@@ -376,15 +367,16 @@ NNTP_SERVER *mutt_select_newsserver (char *server)
 
   /* New newsserver */
   serv = p_new(NNTP_SERVER, 1);
+  serv->tail = &serv->list;
   serv->conn = conn;
   serv->newsrc = m_strdup(file);
-  serv->newsgroups = hash_create(1009, false);
+  serv->newsgroups = hash_new(1009, false);
   slurp_newsrc (serv);          /* load .newsrc */
   nntp_parse_cacheindex (serv); /* load .index */
   if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
     nntp_check_newgroups (serv, 1);
   else if (nntp_get_active (serv) < 0) {
-    hash_destroy (&serv->newsgroups, nntp_delete_data);
+    hash_delete (&serv->newsgroups, nntp_delete_data);
     for (list = serv->list; list; list = list->next)
       list->data = NULL;
     string_list_wipe(&serv->list);
@@ -441,8 +433,7 @@ void nntp_get_status (CONTEXT * ctx, HEADER * h, char *group, int article)
 
 void mutt_newsgroup_stat (NNTP_DATA * data)
 {
-  int i;
-  unsigned int first, last;
+  int i, first, last;
 
   data->unread = 0;
   if (data->lastMessage == 0 || data->firstMessage > data->lastMessage)
@@ -530,7 +521,7 @@ void newsrc_gen_entries (CONTEXT * ctx)
 {
   NNTP_DATA *data = (NNTP_DATA *) ctx->data;
   int series, x;
-  unsigned int last = 0, first = 1;
+  int last = 0, first = 1;
   int save_sort = SORT_ORDER;
 
   if (Sort != SORT_ORDER) {
@@ -1066,7 +1057,7 @@ void nntp_buffy (char* dst, ssize_t dstlen) {
       if (data && data->subscribed && data->unread) {
         if (Context && Context->magic == M_NNTP &&
             !m_strcmp(data->group, ((NNTP_DATA *) Context->data)->group)) {
-          unsigned int i, unread = 0;
+          int i, unread = 0;
 
           for (i = 0; i < Context->msgcount; i++)
             if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)