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!
60 /* ugly hack to define macro once (for pager+index) */
61 #define CHECK_MX_ACL(c,f,s) if(!mx_acl_check(c,f)) \
64 mutt_error(_("%s not permitted by ACL."), s); \
71 /* may we stat() it? */
72 unsigned int local : 1;
73 /* tests if given path is of its magic */
74 int (*mx_is_magic) (const char*, struct stat*);
75 /* tests if folder is empty */
76 int (*mx_check_empty) (const char*);
78 int (*mx_access) (const char*, int);
79 /* read mailbox into ctx structure */
80 int (*mx_open_mailbox) (CONTEXT*);
81 /* check ACL flags; if not implemented, always assume granted
83 int (*mx_acl_check) (CONTEXT*, int);
85 void (*mx_fastclose_mailbox) (CONTEXT*);
86 /* write out changes */
87 int (*mx_sync_mailbox) (CONTEXT*, int, int*);
90 /* called from main: init all folder types */
93 /* flags for mx_open_mailbox() */
94 #define M_NOSORT (1<<0) /* do not sort the mailbox after opening it */
95 #define M_APPEND (1<<1) /* open mailbox for appending messages */
96 #define M_READONLY (1<<2) /* open in read-only mode */
97 #define M_QUIET (1<<3) /* do not print any messages */
98 #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses
99 * safe_fopen() for mbox-style folders. */
100 #define M_COUNT (1<<5) /* just do counting? needed to do speed optimizations
103 /* mx_open_new_message() */
104 #define M_ADD_FROM 1 /* add a From_ line */
106 #define MAXLOCKATTEMPT 5
108 /* return values from mx_check_mailbox() */
110 M_NEW_MAIL = 1, /* new mail received in mailbox */
111 M_LOCKED, /* couldn't lock the mailbox */
112 M_REOPENED, /* mailbox was reopened */
113 M_FLAGS /* nondestructive flags change (IMAP) */
117 FILE *fp; /* pointer to the message data */
118 char *path; /* path to temp file */
119 short magic; /* type of mailbox this message belongs to */
120 short write; /* nonzero if message is open for writing */
126 time_t received; /* the time at which this message was received */
129 WHERE short DefaultMagic INITVAL (M_MBOX);
132 * please use the following _ONLY_ when doing "something"
136 CONTEXT *mx_open_mailbox (const char *, int, CONTEXT *);
138 MESSAGE *mx_open_message (CONTEXT *, int);
139 MESSAGE *mx_open_new_message (CONTEXT *, HEADER *, int);
141 void mx_fastclose_mailbox (CONTEXT *);
143 int mx_close_mailbox (CONTEXT *, int *);
144 int mx_sync_mailbox (CONTEXT *, int *);
145 int mx_commit_message (MESSAGE *, CONTEXT *);
146 int mx_close_message (MESSAGE **);
148 /* determines magic for given folder */
149 int mx_get_magic (const char*);
150 /* sets/parses DefaultMagic */
151 int mx_set_magic (const char *);
152 /* tests whether given folder magic is (valid and) local */
153 int mx_is_local (int);
155 int mx_check_mailbox (CONTEXT *, int *, int);
157 int mx_access (const char *, int);
158 int mx_check_empty (const char *);
160 int mx_acl_check (CONTEXT*, int);
162 void mx_alloc_memory (CONTEXT *);
163 void mx_update_context (CONTEXT *, int);
164 void mx_update_tables (CONTEXT *, int);
166 int mx_lock_file (const char *, int, int, int, int);
167 int mx_unlock_file (const char *path, int fd, int dot);