nntp fixes: no more warnings.
[apps/madmutt.git] / nntp / 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 #define NNTP_PORT 119
21 #define NNTP_SSL_PORT 563
22
23 /* number of entries in the hash table */
24 #define NNTP_CACHE_LEN 10
25
26 enum {
27   NNTP_NONE = 0,
28   NNTP_OK,
29   NNTP_BYE
30 };
31
32 typedef struct {
33   int first;
34   int last;
35 } NEWSRC_ENTRY;
36
37 typedef struct {
38   unsigned feat_known   : 1;
39   unsigned hasXPAT      : 1;
40   unsigned hasXGTITLE   : 1;
41   unsigned hasXOVER     : 1;
42   unsigned hasLISTGROUP : 1;
43   unsigned status       : 3;
44   char *newsrc;
45   char *cache;
46   int stat;
47   off_t size;
48   time_t mtime;
49   time_t newgroups_time;
50   time_t check_time;
51   hash_t *newsgroups;
52   string_list_t *list;                   /* list of newsgroups */
53   string_list_t *tail;                   /* last entry of list */
54   CONNECTION *conn;
55 } NNTP_SERVER;
56
57 typedef struct {
58   int   index;
59   char *path;
60 } NNTP_CACHE;
61
62 typedef struct {
63   NEWSRC_ENTRY *entries;
64   int num;             /* number of used entries */
65   int max;             /* number of allocated entries */
66   int unread;
67   int firstMessage;
68   int lastMessage;
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 *nserv;
80   NNTP_CACHE acache[NNTP_CACHE_LEN];
81 } NNTP_DATA;
82
83 /* internal functions */
84 int nntp_get_active (NNTP_SERVER *);
85 int nntp_get_cache_all (NNTP_SERVER *);
86 int nntp_save_cache_index (NNTP_SERVER *);
87 int nntp_check_newgroups (NNTP_SERVER *, int);
88 int nntp_save_cache_group (CONTEXT *);
89 int nntp_parse_url (const char *, ACCOUNT *, char *, ssize_t);
90 void newsrc_gen_entries (CONTEXT *);
91 void nntp_get_status (CONTEXT *, HEADER *, char *, int);
92 void mutt_newsgroup_stat (NNTP_DATA *);
93 void nntp_delete_cache (NNTP_DATA *);
94 void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
95 void nntp_cache_expand (char *, const char *);
96 void nntp_delete_data (void *);
97
98 /* exposed interface */
99 NNTP_SERVER *mutt_select_newsserver (char *);
100 NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
101 NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
102 NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
103 NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
104 void nntp_clear_cacheindex (NNTP_SERVER *);
105 int mutt_newsrc_update (NNTP_SERVER *);
106 int nntp_close_mailbox (CONTEXT *);
107 int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
108 int nntp_post (const char *);
109 int nntp_check_msgid (CONTEXT *, const char *);
110 int nntp_check_children (CONTEXT *, const char *);
111 void nntp_buffy (char* dst, ssize_t dstlen);
112 void nntp_expand_path (char *, ssize_t, ACCOUNT *);
113 void nntp_logout_all(void);
114 const char *nntp_format_str(char *, ssize_t, char, const char *, const char *,
115                             const char *, const char *, anytype, format_flag);
116 void nntp_sync_sidebar (NNTP_DATA*);
117
118 WHERE NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
119
120 #endif /* _NNTP_H_ */