Fix dereferencing for the mutt_hcache_close calls. Use hcache_t* instead of evil...
[apps/madmutt.git] / nntp.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4  * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
5  * Copyright (C) 2000-2002 Vsevolod Volkov <vvv@mutt.org.ua>
6  *
7  * This file is part of mutt-ng, see http://www.muttng.org/.
8  * It's licensed under the GNU General Public License,
9  * please see the file GPL in the top level source directory.
10  */
11
12 #ifndef _NNTP_H_
13 #define _NNTP_H_ 1
14
15 #include <lib-sys/mutt_socket.h>
16 #include <lib-mx/mx.h>
17
18 extern mx_t const nntp_mx;
19
20 /* number of entries in the hash table */
21 #define NNTP_CACHE_LEN 10
22
23 enum {
24     NNTP_NONE = 0,
25     NNTP_OK,
26     NNTP_BYE
27 };
28
29 typedef struct nntp_data_t nntp_data_t;
30
31 typedef struct nntp_server_t {
32     unsigned feat_known   : 1;
33     unsigned hasXPAT      : 1;
34     unsigned hasXGTITLE   : 1;
35     unsigned hasXOVER     : 1;
36     unsigned hasLISTGROUP : 1;
37     unsigned status       : 3;
38     char *newsrc;
39     char *cache;
40     int stat;
41     off_t size;
42     time_t mtime;
43     time_t newgroups_time;
44     time_t check_time;
45     hash_t *newsgroups;
46     nntp_data_t *list;                   /* list of newsgroups */
47     nntp_data_t **tail;
48     CONNECTION *conn;
49 } nntp_server_t;
50
51 typedef struct {
52     int   index;
53     char *path;
54 } NNTP_CACHE;
55
56 typedef struct {
57     int first;
58     int last;
59 } NEWSRC_ENTRY;
60
61 struct nntp_data_t {
62     struct nntp_data_t *next;
63
64     NEWSRC_ENTRY *entries;
65     int num;             /* number of used entries */
66     int max;             /* number of allocated entries */
67     int unread;
68     int first, last;
69     int lastLoaded;
70     int lastCached;
71     unsigned subscribed:1;
72     unsigned rc:1;
73     unsigned new:1;
74     unsigned allowed:1;
75     unsigned deleted:1;
76     char *group;
77     char *desc;
78     char *cache;
79     nntp_server_t *nserv;
80     NNTP_CACHE acache[NNTP_CACHE_LEN];
81 };
82
83 DO_INIT(nntp_data_t, nntp_data);
84 void nntp_data_wipe(nntp_data_t *);
85 DO_NEW(nntp_data_t, nntp_data);
86 DO_DELETE(nntp_data_t, nntp_data);
87 DO_SLIST(nntp_data_t, nntp_data, nntp_data_delete);
88
89 nntp_server_t *mutt_select_newsserver (char *);
90 nntp_data_t *mutt_newsgroup_subscribe (nntp_server_t *, char *);
91 nntp_data_t *mutt_newsgroup_unsubscribe (nntp_server_t *, char *);
92 nntp_data_t *mutt_newsgroup_catchup (nntp_server_t *, char *);
93 nntp_data_t *mutt_newsgroup_uncatchup (nntp_server_t *, char *);
94 int mutt_newsrc_update (nntp_server_t *);
95 int nntp_close_mailbox (CONTEXT *);
96 int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
97 int nntp_post (const char *);
98 int nntp_check_msgid (CONTEXT *, const char *);
99 int nntp_check_children (CONTEXT *, const char *);
100 int nntp_get_active (nntp_server_t *);
101 void nntp_buffy (char* dst, ssize_t dstlen);
102 void nntp_expand_path (char *, ssize_t, ACCOUNT *);
103 void nntp_logout_all(void);
104 void nntp_sync_sidebar (nntp_data_t*);
105
106 WHERE nntp_server_t *CurrentNewsSrv INITVAL (NULL);
107
108 #endif /* _NNTP_H_ */