2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 1999-2002 Thomas Roessler <roessler@does-not-exist.org>
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
13 * when adding code dealing with folders or whatever,
14 * please use these only
24 * supported mailbox formats
25 * in mx_init() the registration order must be exactly as given here!!!1!
54 /* ugly hack to define macro once (for pager+index) */
55 #define CHECK_MX_ACL(c,f,s) if(!mx_acl_check(c,f)) \
58 mutt_error(_("%s not permitted by ACL."), s); \
63 FILE *fp; /* pointer to the message data */
64 char *path; /* path to temp file */
65 short magic; /* type of mailbox this message belongs to */
66 short write; /* nonzero if message is open for writing */
72 time_t received; /* the time at which this message was received */
78 /* may we stat() it? */
79 unsigned int local : 1;
80 /* tests if given path is of its magic */
81 int (*mx_is_magic) (const char*, struct stat*);
82 /* tests if folder is empty */
83 int (*mx_check_empty) (const char*);
85 int (*mx_access) (const char*, int);
86 /* read mailbox into ctx structure */
87 int (*mx_open_mailbox) (CONTEXT*);
88 /* open new message */
89 int (*mx_open_new_message) (MESSAGE*, CONTEXT*, HEADER*);
90 /* check ACL flags; if not implemented, always assume granted
92 int (*mx_acl_check) (CONTEXT*, int);
93 /* check for new mail; see mx_check_mailbox() below for return vals */
94 int (*mx_check_mailbox) (CONTEXT*, int*, int);
96 void (*mx_fastclose_mailbox) (CONTEXT*);
97 /* write out changes */
98 int (*mx_sync_mailbox) (CONTEXT*, int, int*);
99 /* commit a message to a folder */
100 int (*mx_commit_message) (MESSAGE*, CONTEXT*);
103 /* called from main: init all folder types */
106 /* flags for mx_open_mailbox() */
107 #define M_NOSORT (1<<0) /* do not sort the mailbox after opening it */
108 #define M_APPEND (1<<1) /* open mailbox for appending messages */
109 #define M_READONLY (1<<2) /* open in read-only mode */
110 #define M_QUIET (1<<3) /* do not print any messages */
111 #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses
112 * safe_fopen() for mbox-style folders. */
113 #define M_COUNT (1<<5) /* just do counting? needed to do speed optimizations
116 /* mx_open_new_message() */
117 #define M_ADD_FROM 1 /* add a From_ line */
119 #define MAXLOCKATTEMPT 5
121 WHERE short DefaultMagic INITVAL (M_MBOX);
124 * please use the following _ONLY_ when doing "something"
128 CONTEXT *mx_open_mailbox (const char *, int, CONTEXT *);
130 MESSAGE *mx_open_message (CONTEXT *, int);
131 MESSAGE *mx_open_new_message (CONTEXT *, HEADER *, int);
133 void mx_fastclose_mailbox (CONTEXT *);
135 int mx_close_mailbox (CONTEXT *, int *);
136 int mx_sync_mailbox (CONTEXT *, int *);
137 int mx_commit_message (MESSAGE *, CONTEXT *);
138 int mx_close_message (MESSAGE **);
140 /* determines magic for given folder */
141 int mx_get_magic (const char*);
142 /* sets/parses DefaultMagic */
143 int mx_set_magic (const char *);
144 /* tests whether given folder magic is (valid and) local */
145 int mx_is_local (int);
147 /* return values from mx_check_mailbox() */
149 M_NEW_MAIL = 1, /* new mail received in mailbox */
150 M_LOCKED, /* couldn't lock the mailbox */
151 M_REOPENED, /* mailbox was reopened */
152 M_FLAGS /* nondestructive flags change (IMAP) */
154 int mx_check_mailbox (CONTEXT *, int *, int);
156 int mx_access (const char *, int);
157 int mx_check_empty (const char *);
159 int mx_acl_check (CONTEXT*, int);
161 void mx_alloc_memory (CONTEXT *);
162 void mx_update_context (CONTEXT *, int);
163 void mx_update_tables (CONTEXT *, int);
165 int mx_lock_file (const char *, int, int, int, int);
166 int mx_unlock_file (const char *path, int fd, int dot);
168 int mx_rebuild_cache (void);
169 void mutt_parse_mime_message (CONTEXT * ctx, HEADER *);