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