003e7df24836c54450b1324192954758fb2f89d5
[apps/madmutt.git] / mailbox.h
1 /*
2  * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
3  * 
4  *     This program is free software; you can redistribute it and/or modify
5  *     it under the terms of the GNU General Public License as published by
6  *     the Free Software Foundation; either version 2 of the License, or
7  *     (at your option) any later version.
8  * 
9  *     This program is distributed in the hope that it will be useful,
10  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *     GNU General Public License for more details.
13  * 
14  *     You should have received a copy of the GNU General Public License
15  *     along with this program; if not, write to the Free Software
16  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17  */
18
19 #ifndef _MAILBOX_H
20 #define _MAILBOX_H
21
22 /* flags for mutt_open_mailbox() */
23 #define M_NOSORT        (1<<0)  /* do not sort the mailbox after opening it */
24 #define M_APPEND        (1<<1)  /* open mailbox for appending messages */
25 #define M_READONLY      (1<<2)  /* open in read-only mode */
26 #define M_QUIET         (1<<3)  /* do not print any messages */
27 #define M_NEWFOLDER     (1<<4)  /* create a new folder - same as M_APPEND, but uses
28                                  * safe_fopen() for mbox-style folders.
29                                  */
30
31 /* mx_open_new_message() */
32 #define M_ADD_FROM      1       /* add a From_ line */
33
34 /* return values from mx_check_mailbox() */
35 enum {
36   M_NEW_MAIL = 1,               /* new mail received in mailbox */
37   M_LOCKED,                     /* couldn't lock the mailbox */
38   M_REOPENED,                   /* mailbox was reopened */
39   M_FLAGS                       /* nondestructive flags change (IMAP) */
40 };
41
42 typedef struct {
43   FILE *fp;                     /* pointer to the message data */
44   char *path;                   /* path to temp file */
45   short magic;                  /* type of mailbox this message belongs to */
46   short write;                  /* nonzero if message is open for writing */
47   struct {
48     unsigned read:1;
49     unsigned flagged:1;
50     unsigned replied:1;
51   } flags;
52   time_t received;              /* the time at which this message was received */
53 } MESSAGE;
54
55 CONTEXT *mx_open_mailbox (const char *, int, CONTEXT *);
56
57 MESSAGE *mx_open_message (CONTEXT *, int);
58 MESSAGE *mx_open_new_message (CONTEXT *, HEADER *, int);
59
60 void mx_fastclose_mailbox (CONTEXT *);
61
62 int mx_close_mailbox (CONTEXT *, int *);
63 int mx_sync_mailbox (CONTEXT *, int *);
64 int mx_commit_message (MESSAGE *, CONTEXT *);
65 int mx_close_message (MESSAGE **);
66 int mx_get_magic (const char *);
67 int mx_set_magic (const char *);
68 int mx_check_mailbox (CONTEXT *, int *, int);
69
70 #ifdef USE_IMAP
71 int mx_is_imap (const char *);
72 #endif
73 #ifdef USE_POP
74 int mx_is_pop (const char *);
75 #endif
76 #ifdef USE_NNTP
77 int mx_is_nntp (const char *);
78 #endif
79
80 int mx_access (const char *, int);
81 int mx_check_empty (const char *);
82
83 #endif