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