NeoMutt  2020-08-07-1-gab41a1
Teaching an old dog new tricks
Go to the documentation of this file.
39 #ifndef MUTT_NNTP_LIB_H
40 #define MUTT_NNTP_LIB_H
42 #include <stdbool.h>
43 #include <stdint.h>
44 #include <stdio.h>
45 #include <sys/types.h>
46 #include <time.h>
47 #include "core/lib.h"
48 #include "format_flags.h"
49 #include "mx.h"
51 struct ConfigSet;
52 struct ConnAccount;
53 struct stat;
55 // These Config Variables are used outside of libnntp
56 extern unsigned char C_CatchupNewsgroup;
57 extern unsigned char C_FollowupToPoster;
58 extern char * C_GroupIndexFormat;
59 extern char * C_NewsServer;
60 extern char * C_NewsgroupsCharset;
61 extern unsigned char C_PostModerated;
62 extern bool C_ShowOnlyUnread;
63 extern bool C_XCommentTo;
65 extern struct NntpAccountData *CurrentNewsSrv;
66 extern struct MxOps MxNntpOps;
68 /* article number type and format */
69 #define anum_t uint32_t
70 #define ANUM "%u"
76 {
77  bool hasCAPABILITIES : 1;
78  bool hasSTARTTLS : 1;
79  bool hasDATE : 1;
81  bool hasXGTITLE : 1;
82  bool hasLISTGROUP : 1;
84  bool hasOVER : 1;
85  bool hasXOVER : 1;
86  unsigned int use_tls : 3;
87  unsigned int status : 3;
88  bool cacheable : 1;
89  bool newsrc_modified : 1;
90  FILE *fp_newsrc;
91  char *newsrc_file;
93  char *overview_fmt;
94  off_t size;
95  time_t mtime;
97  time_t check_time;
98  unsigned int groups_num;
99  unsigned int groups_max;
100  void **groups_list;
102  struct Connection *conn;
103 };
109 {
111  bool parsed : 1;
112 };
118 {
119  unsigned int index;
120  char *path;
121 };
127 {
130 };
132 /* number of entries in article cache */
133 #define NNTP_ACACHE_LEN 10
139 {
140  char *group;
141  char *desc;
147  bool subscribed : 1;
148  bool has_new_mail : 1;
149  bool allowed : 1;
150  bool deleted : 1;
151  unsigned int newsrc_len;
154  struct NntpAcache acache[NNTP_ACACHE_LEN];
155  struct BodyCache *bcache;
156 };
158 struct NntpAccountData *nntp_select_server(struct Mailbox *m, char *server, bool leave_lock);
161 struct NntpMboxData *mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group);
162 struct NntpMboxData *mutt_newsgroup_uncatchup(struct Mailbox *m, struct NntpAccountData *adata, char *group);
163 int nntp_active_fetch(struct NntpAccountData *adata, bool mark_new);
165 int nntp_post(struct Mailbox *m, const char *msg);
166 int nntp_check_msgid(struct Mailbox *m, const char *msgid);
167 int nntp_check_children(struct Mailbox *m, const char *msgid);
170 void nntp_mailbox(struct Mailbox *m, char *buf, size_t buflen);
171 void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct);
173 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);
174 int nntp_compare_order(const void *a, const void *b);
175 enum MailboxType nntp_path_probe(const char *path, const struct stat *st);
176 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);
177 int nntp_complete(char *buf, size_t buflen);
179 #endif /* MUTT_NNTP_LIB_H */
bool has_new_mail
Definition: lib.h:148
char * path
Definition: lib.h:120
Container for lots of config items.
Definition: set.h:227
uint8_t MuttFormatFlags
Flags for mutt_expando_format(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: format_flags.h:29
char * newsrc_file
Definition: lib.h:91
A Hash Table.
Definition: hash.h:84
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)
Expand the newsrc filename - Implements format_t.
Definition: newsrc.c:916
int nntp_complete(char *buf, size_t buflen)
Auto-complete NNTP newsgroups.
Definition: complete.c:45
void nntp_clear_cache(struct NntpAccountData *adata)
Clear the NNTP cache.
Definition: newsrc.c:839
unsigned int use_tls
Definition: lib.h:86
bool newsrc_modified
Definition: lib.h:89
struct NntpAccountData * adata
Definition: lib.h:153
struct NntpMboxData * mutt_newsgroup_uncatchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Uncatchup newsgroup.
Definition: newsrc.c:1332
time_t mtime
Definition: lib.h:95
bool parsed
Definition: lib.h:111
An open network connection (socket)
Definition: connection.h:34
int nntp_check_msgid(struct Mailbox *m, const char *msgid)
Fetch article by Message-ID.
Definition: nntp.c:2222
struct NntpMboxData * mutt_newsgroup_subscribe(struct NntpAccountData *adata, char *group)
Subscribe newsgroup.
Definition: newsrc.c:1243
anum_t article_num
Definition: lib.h:110
Definition: lib.h:133
struct MxOps MxNntpOps
NNTP Mailbox - Implements MxOps.
Definition: nntp.c:2875
void nntp_newsrc_close(struct NntpAccountData *adata)
Unlock and close .newsrc file.
Definition: newsrc.c:117
bool hasSTARTTLS
Definition: lib.h:78
NNTP-specific Email data -.
Definition: lib.h:108
Flags to control mutt_expando_format()
struct NntpAccountData * nntp_select_server(struct Mailbox *m, char *server, bool leave_lock)
Open a connection to an NNTP server.
Definition: newsrc.c:1008
struct HashTable * groups_hash
Definition: lib.h:101
NNTP-specific Account data -.
Definition: lib.h:75
anum_t last
Definition: lib.h:129
bool subscribed
Definition: lib.h:147
anum_t last_cached
Definition: lib.h:145
bool cacheable
Definition: lib.h:88
int nntp_active_fetch(struct NntpAccountData *adata, bool mark_new)
Fetch list of all newsgroups from server.
Definition: nntp.c:2052
API for mailboxes.
time_t newgroups_time
Definition: lib.h:96
An entry in a .newsrc (subscribed newsgroups)
Definition: lib.h:126
anum_t last_loaded
Definition: lib.h:144
unsigned char C_PostModerated
Config: (nntp) Allow posting to moderated newsgroups.
Definition: config.c:51
Definition: lib.h:80
char * overview_fmt
Definition: lib.h:93
Convenience wrapper for the core headers.
char * group
Definition: lib.h:140
int nntp_check_children(struct Mailbox *m, const char *msgid)
Fetch children of article with the Message-ID.
Definition: nntp.c:2292
int flags
Definition: mailbox.h:134
off_t size
Definition: lib.h:94
unsigned char C_CatchupNewsgroup
Config: (nntp) Mark all articles as read when leaving a newsgroup.
Definition: config.c:37
struct BodyCache * bcache
Definition: lib.h:155
unsigned int status
Definition: lib.h:87
A mailbox.
Definition: mailbox.h:81
bool hasXGTITLE
Definition: lib.h:81
bool allowed
Definition: lib.h:149
unsigned int groups_max
Definition: lib.h:99
int nntp_compare_order(const void *a, const void *b)
Sort to mailbox order - Implements sort_t.
Definition: nntp.c:2361
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
Definition: lib.h:82
enum MailboxType nntp_path_probe(const char *path, const struct stat *st)
Is this an NNTP Mailbox? - Implements MxOps::path_probe()
Definition: nntp.c:2828
int nntp_post(struct Mailbox *m, const char *msg)
Post article.
Definition: nntp.c:1970
unsigned int groups_num
Definition: lib.h:98
int nntp_newsrc_parse(struct NntpAccountData *adata)
Parse .newsrc file.
Definition: newsrc.c:161
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)
Format a string for the newsgroup menu - Implements format_t.
Definition: browse.c:52
char * C_NewsgroupsCharset
Config: (nntp) Character set of newsgroups&#39; descriptions.
Definition: config.c:42
char * C_GroupIndexFormat
Config: (nntp) printf-like format string for the browser&#39;s display of newsgroups. ...
Definition: config.c:39
struct NntpMboxData * mutt_newsgroup_unsubscribe(struct NntpAccountData *adata, char *group)
Unsubscribe newsgroup.
Definition: newsrc.c:1267
bool C_XCommentTo
Config: (nntp) Add &#39;X-Comment-To&#39; header that contains article author.
Definition: config.c:55
Login details for a remote server.
Definition: connaccount.h:51
struct NewsrcEntry * newsrc_ent
Definition: lib.h:152
bool hasOVER
Definition: lib.h:84
NNTP-specific Mailbox data -.
Definition: lib.h:138
unsigned int newsrc_len
Definition: lib.h:151
unsigned int index
Definition: lib.h:119
Local cache of email bodies.
Definition: bcache.c:53
struct Connection * conn
Definition: lib.h:102
char * authenticators
Definition: lib.h:92
time_t check_time
Definition: lib.h:97
Supported mailbox formats.
Definition: mailbox.h:43
bool deleted
Definition: lib.h:150
bool C_ShowOnlyUnread
Config: (nntp) Only show subscribed newsgroups with unread articles.
Definition: config.c:54
bool hasLISTGROUPrange
Definition: lib.h:83
anum_t first_message
Definition: lib.h:142
NNTP article cache.
Definition: lib.h:117
anum_t unread
Definition: lib.h:146
void ** groups_list
Definition: lib.h:100
FILE * fp_newsrc
Definition: lib.h:90
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Definition: nntp.c:76
char * C_NewsServer
Config: (nntp) Url of the news server.
Definition: config.c:41
bool hasXOVER
Definition: lib.h:85
bool hasDATE
Definition: lib.h:79
int nntp_newsrc_update(struct NntpAccountData *adata)
Update .newsrc file.
Definition: newsrc.c:439
unsigned char C_FollowupToPoster
Config: (nntp) Reply to the poster if &#39;poster&#39; is in the &#39;Followup-To&#39; header.
Definition: config.c:38
Definition: lib.h:77
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition: newsrc.c:1293
#define anum_t
Definition: lib.h:69
void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct)
Make fully qualified url from newsgroup name.
Definition: newsrc.c:557
anum_t first
Definition: lib.h:128
The Mailbox API.
Definition: mx.h:105
char * desc
Definition: lib.h:141
anum_t last_message
Definition: lib.h:143
void nntp_mailbox(struct Mailbox *m, char *buf, size_t buflen)
Get first newsgroup with new messages.
Definition: newsrc.c:1375