5229a1d92cc6e375070cc4567d1c4d644afe37b7
[apps/madmutt.git] / nntp / mx_nntp.c
1 /*
2  * This file is part of mutt-ng, see http://www.muttng.org/.
3  * It's licensed under the GNU General Public License,
4  * please see the file GPL in the top level source directory.
5  */
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif
9
10 #include <sys/stat.h>
11
12 #include "mutt.h"
13 #include "nntp.h"
14
15 #include "mx.h"
16 #include "mx_nntp.h"
17
18 #include "lib/mem.h"
19 #include "lib/str.h"
20
21 #include "url.h"
22
23 static int nntp_is_magic (const char* path, struct stat* st) {
24   url_scheme_t s = url_check_scheme (NONULL (path));
25   return ((s == U_NNTP || s == U_NNTPS) ? M_NNTP : -1);
26 }
27
28 static int acl_check_nntp (CONTEXT* ctx, int bit) {
29   switch (bit) {
30     case ACL_INSERT:    /* editing messages */
31     case ACL_WRITE:     /* change importance */
32       return (0);
33     case ACL_DELETE:    /* (un)deletion */
34     case ACL_SEEN:      /* mark as read */
35       return (1);
36     default:
37       return (0);
38   }
39 }
40
41 /* called by nntp_init(); don't call elsewhere */
42 mx_t* nntp_reg_mx (void) {
43   mx_t* fmt = safe_calloc (1, sizeof (mx_t));
44
45   /* make up mx_t record... */
46   fmt->type = M_NNTP;
47   fmt->mx_is_magic = nntp_is_magic;
48   fmt->mx_open_mailbox = nntp_open_mailbox;
49   fmt->mx_acl_check = acl_check_nntp;
50   fmt->mx_fastclose_mailbox = nntp_fastclose_mailbox;
51   fmt->mx_sync_mailbox = nntp_sync_mailbox;
52   fmt->mx_check_mailbox = nntp_check_mailbox;
53   return (fmt);
54 }