forked from neomutt/neomutt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mx.h
131 lines (111 loc) · 3.89 KB
/
mx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* @file
* API for mailboxes
*
* @authors
* Copyright (C) 1996-2002,2013 Michael R. Elkins <[email protected]>
* Copyright (C) 1999-2002 Thomas Roessler <[email protected]>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This header file contains prototypes for internal functions used by the
* generic mailbox api. None of these functions should be called directly.
*/
#ifndef _MUTT_MX_H
#define _MUTT_MX_H
#include <stdbool.h>
#include <stdio.h>
#include "where.h"
#ifdef USE_HCACHE
#include "hcache/hcache.h"
#endif
struct Header;
struct Context;
struct Message;
struct stat;
/**
* struct MxOps - a structure to store operations on a mailbox
*
* The following operations are mandatory:
* - open
* - close
* - check
*
* Optional operations
* - open_new_msg
*/
struct MxOps
{
int (*open)(struct Context *ctx);
int (*open_append)(struct Context *ctx, int flags);
int (*close)(struct Context *ctx);
int (*check)(struct Context *ctx, int *index_hint);
int (*sync)(struct Context *ctx, int *index_hint);
int (*open_msg)(struct Context *ctx, struct Message *msg, int msgno);
int (*close_msg)(struct Context *ctx, struct Message *msg);
int (*commit_msg)(struct Context *ctx, struct Message *msg);
int (*open_new_msg)(struct Message *msg, struct Context *ctx, struct Header *hdr);
int (*edit_msg_tags)(struct Context *ctx, const char *tags, char *buf, size_t buflen);
int (*commit_msg_tags)(struct Context *msg, struct Header *hdr, char *buf);
};
/**
* enum MailboxFormat - Supported mailbox formats
*/
enum MailboxFormat
{
MUTT_MBOX = 1,
MUTT_MMDF,
MUTT_MH,
MUTT_MAILDIR,
MUTT_NNTP,
MUTT_IMAP,
MUTT_NOTMUCH,
MUTT_POP,
MUTT_COMPRESSED,
};
#define MMDF_SEP "\001\001\001\001\n"
void mbox_reset_atime(struct Context *ctx, struct stat *st);
int mh_check_empty(const char *path);
int maildir_check_empty(const char *path);
struct Header *maildir_parse_message(int magic, const char *fname, bool is_old, struct Header *h);
struct Header *maildir_parse_stream(int magic, FILE *f, const char *fname, bool is_old, struct Header *h);
void maildir_parse_flags(struct Header *h, const char *path);
bool maildir_update_flags(struct Context *ctx, struct Header *o, struct Header *n);
void maildir_flags(char *dest, size_t destlen, struct Header *hdr);
#ifdef USE_HCACHE
int mh_sync_mailbox_message(struct Context *ctx, int msgno, header_cache_t *hc);
#else
int mh_sync_mailbox_message(struct Context *ctx, int msgno);
#endif
#ifdef USE_NOTMUCH
bool mx_is_notmuch(const char *p);
#endif
int mx_tags_editor(struct Context *ctx, const char *tags, char *buf, size_t buflen);
int mx_tags_commit(struct Context *ctx, struct Header *h, char *tags);
bool mx_tags_is_supported(struct Context *ctx);
FILE *maildir_open_find_message(const char *folder, const char *msg, char **newname);
int mbox_strict_cmp_headers(const struct Header *h1, const struct Header *h2);
void mx_alloc_memory(struct Context *ctx);
void mx_update_context(struct Context *ctx, int new_messages);
void mx_update_tables(struct Context *ctx, bool committing);
struct MxOps *mx_get_ops(int magic);
extern struct MxOps mx_maildir_ops;
extern struct MxOps mx_mbox_ops;
extern struct MxOps mx_mh_ops;
extern struct MxOps mx_mmdf_ops;
/* This variable is backing for a config item */
WHERE short MboxType;
#endif /* _MUTT_MX_H */