Nico Golde:
[apps/madmutt.git] / nntp.h
1 /*
2  * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3  * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
4  * Copyright (C) 2000-2002 Vsevolod Volkov <vvv@mutt.org.ua>
5  * 
6  *     This program is free software; you can redistribute it and/or modify
7  *     it under the terms of the GNU General Public License as published by
8  *     the Free Software Foundation; either version 2 of the License, or
9  *     (at your option) any later version.
10  * 
11  *     This program is distributed in the hope that it will be useful,
12  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *     GNU General Public License for more details.
15  * 
16  *     You should have received a copy of the GNU General Public License
17  *     along with this program; if not, write to the Free Software
18  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */ 
20
21 #ifndef _NNTP_H_
22 #define _NNTP_H_ 1
23
24 #include "mutt_socket.h"
25 #include "mailbox.h"
26
27 #include <time.h>
28
29 #define NNTP_PORT 119
30 #define NNTP_SSL_PORT 563
31
32 /* number of entries in the hash table */
33 #define NNTP_CACHE_LEN 10
34
35 enum
36 {
37   NNTP_NONE = 0,
38   NNTP_OK,
39   NNTP_BYE
40 };
41
42 typedef struct
43 {
44   int first;
45   int last;
46 } NEWSRC_ENTRY;
47
48 typedef struct
49 {
50   unsigned int hasXPAT : 1;
51   unsigned int hasXGTITLE : 1;
52   unsigned int hasXOVER : 1;
53   unsigned int hasLISTGROUP : 1;
54   unsigned int status : 3;
55   char *newsrc;
56   char *cache;
57   int stat;
58   off_t size;
59   time_t mtime;
60   time_t newgroups_time;
61   time_t check_time;
62   HASH *newsgroups;
63   LIST *list;   /* list of newsgroups */
64   LIST *tail;   /* last entry of list */
65   CONNECTION *conn;
66 } NNTP_SERVER;
67
68 typedef struct
69 {
70   unsigned int index;
71   char *path;
72 } NNTP_CACHE;
73
74 typedef struct
75 {
76   NEWSRC_ENTRY *entries;
77   unsigned int num;     /* number of used entries */
78   unsigned int max;     /* number of allocated entries */
79   unsigned int unread;
80   unsigned int firstMessage;
81   unsigned int lastMessage;
82   unsigned int lastLoaded;
83   unsigned int lastCached;
84   unsigned int subscribed : 1;
85   unsigned int rc : 1;
86   unsigned int new : 1;
87   unsigned int allowed : 1;
88   unsigned int deleted : 1;
89   char *group;
90   char *desc;
91   char *cache;
92   NNTP_SERVER *nserv;
93   NNTP_CACHE acache[NNTP_CACHE_LEN];
94 } NNTP_DATA;
95
96 /* internal functions */
97 int nntp_get_active (NNTP_SERVER *);
98 int nntp_get_cache_all (NNTP_SERVER *);
99 int nntp_save_cache_index (NNTP_SERVER *);
100 int nntp_check_newgroups (NNTP_SERVER *, int);
101 int nntp_save_cache_group (CONTEXT *);
102 int nntp_parse_url (const char *, ACCOUNT *, char *, size_t);
103 void newsrc_gen_entries (CONTEXT *);
104 void nntp_get_status (CONTEXT *, HEADER *, char *, int);
105 void mutt_newsgroup_stat (NNTP_DATA *);
106 void nntp_delete_cache (NNTP_DATA *);
107 void nntp_add_to_list (NNTP_SERVER *, NNTP_DATA *);
108 void nntp_cache_expand (char *, const char *);
109 void nntp_delete_data (void *);
110
111 /* exposed interface */
112 NNTP_SERVER *mutt_select_newsserver (char *);
113 NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
114 NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
115 NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
116 NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
117 void nntp_clear_cacheindex (NNTP_SERVER *);
118 int mutt_newsrc_update (NNTP_SERVER *);
119 int nntp_open_mailbox (CONTEXT *);
120 int nntp_sync_mailbox (CONTEXT *);
121 int nntp_check_mailbox (CONTEXT *);
122 int nntp_close_mailbox (CONTEXT *);
123 void nntp_fastclose_mailbox (CONTEXT *);
124 int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
125 int nntp_post (const char *);
126 int nntp_check_msgid (CONTEXT *, const char *);
127 int nntp_check_children (CONTEXT *, const char *);
128 void nntp_buffy (char *);
129 void nntp_expand_path (char *, size_t, ACCOUNT *);
130 void nntp_logout_all ();
131 const char *nntp_format_str (char *, size_t, char, const char *, const char *,
132                 const char *, const char *, unsigned long, format_flag);
133
134 NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
135
136 #endif /* _NNTP_H_ */