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