Nico Golde:
[apps/madmutt.git] / mailbox.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9
10 #ifndef _MAILBOX_H
11 #define _MAILBOX_H
12
13 /* flags for mutt_open_mailbox() */
14 #define M_NOSORT        (1<<0)  /* do not sort the mailbox after opening it */
15 #define M_APPEND        (1<<1)  /* open mailbox for appending messages */
16 #define M_READONLY      (1<<2)  /* open in read-only mode */
17 #define M_QUIET         (1<<3)  /* do not print any messages */
18 #define M_NEWFOLDER     (1<<4)  /* create a new folder - same as M_APPEND, but uses
19                                  * safe_fopen() for mbox-style folders.
20                                  */
21
22 /* mx_open_new_message() */
23 #define M_ADD_FROM      1       /* add a From_ line */
24
25 /* return values from mx_check_mailbox() */
26 enum {
27   M_NEW_MAIL = 1,               /* new mail received in mailbox */
28   M_LOCKED,                     /* couldn't lock the mailbox */
29   M_REOPENED,                   /* mailbox was reopened */
30   M_FLAGS                       /* nondestructive flags change (IMAP) */
31 };
32
33 typedef struct {
34   FILE *fp;                     /* pointer to the message data */
35   char *path;                   /* path to temp file */
36   short magic;                  /* type of mailbox this message belongs to */
37   short write;                  /* nonzero if message is open for writing */
38   struct {
39     unsigned read:1;
40     unsigned flagged:1;
41     unsigned replied:1;
42   } flags;
43   time_t received;              /* the time at which this message was received */
44 } MESSAGE;
45
46 CONTEXT *mx_open_mailbox (const char *, int, CONTEXT *);
47
48 MESSAGE *mx_open_message (CONTEXT *, int);
49 MESSAGE *mx_open_new_message (CONTEXT *, HEADER *, int);
50
51 void mx_fastclose_mailbox (CONTEXT *);
52
53 int mx_close_mailbox (CONTEXT *, int *);
54 int mx_sync_mailbox (CONTEXT *, int *);
55 int mx_commit_message (MESSAGE *, CONTEXT *);
56 int mx_close_message (MESSAGE **);
57 int mx_get_magic (const char *);
58 int mx_set_magic (const char *);
59 int mx_check_mailbox (CONTEXT *, int *, int);
60
61 #ifdef USE_IMAP
62 int mx_is_imap (const char *);
63 #endif
64 #ifdef USE_POP
65 int mx_is_pop (const char *);
66 #endif
67 #ifdef USE_NNTP
68 int mx_is_nntp (const char *);
69 #endif
70
71 int mx_access (const char *, int);
72 int mx_check_empty (const char *);
73
74 #endif