8943c9f369e5ad8f6146318537db94802f6c5835
[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
7 #include <lib-lib/lib-lib.h>
8
9 #include "mutt.h"
10 #include "nntp.h"
11
12 #include "mx.h"
13 #include "mx_nntp.h"
14
15 static int nntp_is_magic (const char* path, struct stat* st) {
16   url_scheme_t s = url_check_scheme (NONULL (path));
17   return ((s == U_NNTP || s == U_NNTPS) ? M_NNTP : -1);
18 }
19
20 static int acl_check_nntp (CONTEXT* ctx, int bit) {
21   switch (bit) {
22     case ACL_INSERT:    /* editing messages */
23     case ACL_WRITE:     /* change importance */
24       return (0);
25     case ACL_DELETE:    /* (un)deletion */
26     case ACL_SEEN:      /* mark as read */
27       return (1);
28     default:
29       return (0);
30   }
31 }
32
33 /* called by nntp_init(); don't call elsewhere */
34 mx_t* nntp_reg_mx (void) {
35   mx_t* fmt = p_new(mx_t, 1);
36
37   /* make up mx_t record... */
38   fmt->type = M_NNTP;
39   fmt->mx_is_magic = nntp_is_magic;
40   fmt->mx_open_mailbox = nntp_open_mailbox;
41   fmt->mx_acl_check = acl_check_nntp;
42   fmt->mx_fastclose_mailbox = nntp_fastclose_mailbox;
43   fmt->mx_sync_mailbox = nntp_sync_mailbox;
44   fmt->mx_check_mailbox = nntp_check_mailbox;
45   return (fmt);
46 }