Deep rework of nntp_data_t (ex-NNTP_DATA) to make it list-able.
[apps/madmutt.git] / nntp.h
diff --git a/nntp.h b/nntp.h
index 7acfa9e..3bc9103 100644 (file)
--- a/nntp.h
+++ b/nntp.h
@@ -21,67 +21,76 @@ extern mx_t const nntp_mx;
 #define NNTP_CACHE_LEN 10
 
 enum {
-  NNTP_NONE = 0,
-  NNTP_OK,
-  NNTP_BYE
+    NNTP_NONE = 0,
+    NNTP_OK,
+    NNTP_BYE
 };
 
+typedef struct nntp_data_t nntp_data_t;
+
 typedef struct {
-  unsigned feat_known   : 1;
-  unsigned hasXPAT      : 1;
-  unsigned hasXGTITLE   : 1;
-  unsigned hasXOVER     : 1;
-  unsigned hasLISTGROUP : 1;
-  unsigned status       : 3;
-  char *newsrc;
-  char *cache;
-  int stat;
-  off_t size;
-  time_t mtime;
-  time_t newgroups_time;
-  time_t check_time;
-  hash_t *newsgroups;
-  string_list_t *list;                   /* list of newsgroups */
-  string_list_t **tail;                  /* last entry of list */
-  CONNECTION *conn;
+    unsigned feat_known   : 1;
+    unsigned hasXPAT      : 1;
+    unsigned hasXGTITLE   : 1;
+    unsigned hasXOVER     : 1;
+    unsigned hasLISTGROUP : 1;
+    unsigned status       : 3;
+    char *newsrc;
+    char *cache;
+    int stat;
+    off_t size;
+    time_t mtime;
+    time_t newgroups_time;
+    time_t check_time;
+    hash_t *newsgroups;
+    nntp_data_t *list;                   /* list of newsgroups */
+    CONNECTION *conn;
 } NNTP_SERVER;
 
 typedef struct {
-  int   index;
-  char *path;
+    int   index;
+    char *path;
 } NNTP_CACHE;
 
 typedef struct {
-  int first;
-  int last;
+    int first;
+    int last;
 } NEWSRC_ENTRY;
 
-typedef struct {
-  NEWSRC_ENTRY *entries;
-  int num;             /* number of used entries */
-  int max;             /* number of allocated entries */
-  int unread;
-  int firstMessage;
-  int lastMessage;
-  int lastLoaded;
-  int lastCached;
-  unsigned subscribed:1;
-  unsigned rc:1;
-  unsigned new:1;
-  unsigned allowed:1;
-  unsigned deleted:1;
-  char *group;
-  char *desc;
-  char *cache;
-  NNTP_SERVER *nserv;
-  NNTP_CACHE acache[NNTP_CACHE_LEN];
-} NNTP_DATA;
+struct nntp_data_t {
+    struct nntp_data_t *next;
+
+    NEWSRC_ENTRY *entries;
+    int num;             /* number of used entries */
+    int max;             /* number of allocated entries */
+    int unread;
+    int firstMessage;
+    int lastMessage;
+    int lastLoaded;
+    int lastCached;
+    unsigned subscribed:1;
+    unsigned rc:1;
+    unsigned new:1;
+    unsigned allowed:1;
+    unsigned deleted:1;
+    char *group;
+    char *desc;
+    char *cache;
+    NNTP_SERVER *nserv;
+    NNTP_CACHE acache[NNTP_CACHE_LEN];
+};
+
+DO_INIT(nntp_data_t, nntp_data);
+void nntp_data_wipe(nntp_data_t *);
+DO_NEW(nntp_data_t, nntp_data);
+DO_DELETE(nntp_data_t, nntp_data);
+DO_SLIST(nntp_data_t, nntp_data, nntp_data_delete);
 
 NNTP_SERVER *mutt_select_newsserver (char *);
-NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
-NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
-NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
-NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
+nntp_data_t *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
+nntp_data_t *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
+nntp_data_t *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
+nntp_data_t *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
 void nntp_clear_cacheindex (NNTP_SERVER *);
 int mutt_newsrc_update (NNTP_SERVER *);
 int nntp_close_mailbox (CONTEXT *);
@@ -95,7 +104,7 @@ void nntp_expand_path (char *, ssize_t, ACCOUNT *);
 void nntp_logout_all(void);
 const char *nntp_format_str(char *, ssize_t, char, const char *, const char *,
                             const char *, const char *, anytype, format_flag);
-void nntp_sync_sidebar (NNTP_DATA*);
+void nntp_sync_sidebar (nntp_data_t*);
 
 WHERE NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);