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