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