1 /**
2  * @file
3  * Usenet network mailbox type; talk to an NNTP server
4  *
5  * @authors
6  * Copyright (C) 1998 Brandon Long <blong@fiction.net>
7  * Copyright (C) 1999 Andrej Gritsenko <andrej@lucky.net>
8  * Copyright (C) 2000-2012 Vsevolod Volkov <vvv@mutt.org.ua>
9  *
10  * @copyright
11  * This program is free software: you can redistribute it and/or modify it under
12  * the terms of the GNU General Public License as published by the Free Software
13  * Foundation, either version 2 of the License, or (at your option) any later
14  * version.
15  *
16  * This program is distributed in the hope that it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  * details.
20  *
21  * You should have received a copy of the GNU General Public License along with
22  * this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 /**
26  * @page lib_nntp Nntp
27  *
28  * Usenet network mailbox type; talk to an NNTP server
29  *
30  * | File            | Description            |
31  * | :-------------- | :--------------------- |
32  * | nntp/adata.c    | @subpage nntp_adata    |
33  * | nntp/browse.c   | @subpage nntp_browse   |
34  * | nntp/complete.c | @subpage nntp_complete |
35  * | nntp/config.c   | @subpage nntp_config   |
36  * | nntp/edata.c    | @subpage nntp_edata    |
37  * | nntp/mdata.c    | @subpage nntp_mdata    |
38  * | nntp/newsrc.c   | @subpage nntp_newsrc   |
39  * | nntp/nntp.c     | @subpage nntp_nntp     |
40  */
41 
42 #ifndef MUTT_NNTP_LIB_H
43 #define MUTT_NNTP_LIB_H
44 
45 #include <stdbool.h>
46 #include <stdint.h>
47 #include <stdio.h>
48 #include "core/lib.h"
49 #include "format_flags.h"
50 
51 struct ConnAccount;
52 struct Email;
53 struct NntpAccountData;
54 struct stat;
55 
56 extern struct NntpAccountData *CurrentNewsSrv; ///< Current NNTP news server
57 extern struct MxOps MxNntpOps;
58 
59 /* article number type and format */
60 #define anum_t uint32_t
61 #define ANUM "%u"
62 
63 /**
64  * struct NntpAcache - NNTP article cache
65  */
66 struct NntpAcache
67 {
68   unsigned int index; ///< Index number
69   char *path;         ///< Cache path
70 };
71 
72 /**
73  * struct NewsrcEntry - An entry in a .newsrc (subscribed newsgroups)
74  */
75 struct NewsrcEntry
76 {
77   anum_t first; ///< First article number in run
78   anum_t last;  ///< Last article number in run
79 };
80 
81 /* number of entries in article cache */
82 #define NNTP_ACACHE_LEN 10
83 
84 struct NntpAccountData *nntp_select_server(struct Mailbox *m, const char *server, bool leave_lock);
85 struct NntpMboxData *mutt_newsgroup_subscribe(struct NntpAccountData *adata, char *group);
86 struct NntpMboxData *mutt_newsgroup_unsubscribe(struct NntpAccountData *adata, char *group);
87 struct NntpMboxData *mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group);
88 struct NntpMboxData *mutt_newsgroup_uncatchup(struct Mailbox *m, struct NntpAccountData *adata, char *group);
89 int nntp_active_fetch(struct NntpAccountData *adata, bool mark_new);
90 int nntp_newsrc_update(struct NntpAccountData *adata);
91 int nntp_post(struct Mailbox *m, const char *msg);
92 int nntp_check_msgid(struct Mailbox *m, const char *msgid);
93 int nntp_check_children(struct Mailbox *m, const char *msgid);
94 int nntp_newsrc_parse(struct NntpAccountData *adata);
95 void nntp_newsrc_close(struct NntpAccountData *adata);
96 void nntp_mailbox(struct Mailbox *m, char *buf, size_t buflen);
97 void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct);
98 void nntp_clear_cache(struct NntpAccountData *adata);
99 const char *nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags);
100 int nntp_compare_order(const struct Email *a, const struct Email *b, bool reverse);
101 enum MailboxType nntp_path_probe(const char *path, const struct stat *st);
102 const char *group_index_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags);
103 int nntp_complete(char *buf, size_t buflen);
104 
105 #endif /* MUTT_NNTP_LIB_H */
106