registrar.h
6.63 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2004, 2005, 2006,
2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifndef _MAILUTILS_REGISTRAR_H
#define _MAILUTILS_REGISTRAR_H
#include <mailutils/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Public Interface, to allow static initialization. */
struct _mu_record
{
int priority; /* Higher priority records are scanned first */
const char *scheme;
int (*_url) (mu_url_t);
int (*_mailbox) (mu_mailbox_t);
int (*_mailer) (mu_mailer_t);
int (*_folder) (mu_folder_t);
void *data; /* back pointer. */
/* Stub functions to override. The default is to return the fields. */
int (*_is_scheme) (mu_record_t, mu_url_t, int);
int (*_get_url) (mu_record_t, int (*(*_mu_url)) (mu_url_t));
int (*_get_mailbox) (mu_record_t, int (*(*_mu_mailbox)) (mu_mailbox_t));
int (*_get_mailer) (mu_record_t, int (*(*_mu_mailer)) (mu_mailer_t));
int (*_get_folder) (mu_record_t, int (*(*_mu_folder)) (mu_folder_t));
int (*_list_p) (mu_record_t, const char *, int);
};
/* Defaults */
extern int mu_registrar_set_default_scheme (const char *scheme);
extern const char *mu_registrar_get_default_scheme (void);
extern int mu_registrar_get_default_record (mu_record_t *prec);
extern void mu_registrar_set_default_record (mu_record_t record);
/* Registration. */
extern int mu_registrar_get_iterator (mu_iterator_t *);
extern int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated));
extern int mu_registrar_lookup_scheme (const char *scheme,
mu_record_t *precord);
extern int mu_registrar_lookup (const char *name, int flags,
mu_record_t *precord, int *pflags);
extern int mu_registrar_lookup_url (mu_url_t url, int flags,
mu_record_t *precord, int *pflags);
extern int mu_registrar_record (mu_record_t);
extern int mu_unregistrar_record (mu_record_t);
/* Scheme. */
extern int mu_record_is_scheme (mu_record_t, mu_url_t, int flags);
extern int mu_record_set_scheme (mu_record_t, const char *);
extern int mu_record_set_is_scheme (mu_record_t,
int (*_is_scheme) (mu_record_t, mu_url_t, int));
/* Url. */
extern int mu_record_get_url (mu_record_t, int (*(*)) (mu_url_t));
extern int mu_record_set_url (mu_record_t, int (*) (mu_url_t));
extern int mu_record_set_get_url (mu_record_t,
int (*_get_url) (mu_record_t, int (*(*)) (mu_url_t)));
/* Mailbox. */
extern int mu_record_get_mailbox (mu_record_t, int (*(*)) (mu_mailbox_t));
extern int mu_record_set_mailbox (mu_record_t, int (*) (mu_mailbox_t));
extern int mu_record_set_get_mailbox (mu_record_t,
int (*_get_mailbox) (mu_record_t, int (*(*)) (mu_mailbox_t)));
/* Mailer. */
extern int mu_record_get_mailer (mu_record_t,
int (*(*)) (mu_mailer_t));
extern int mu_record_set_mailer (mu_record_t, int (*) (mu_mailer_t));
extern int mu_record_set_get_mailer (mu_record_t,
int (*_get_mailer) (mu_record_t, int (*(*)) (mu_mailer_t)));
/* Folder. */
extern int mu_record_get_folder (mu_record_t, int (*(*)) (mu_folder_t));
extern int mu_record_set_folder (mu_record_t, int (*) (mu_folder_t));
extern int mu_record_set_get_folder (mu_record_t,
int (*_get_folder) (mu_record_t, int (*(*)) (mu_folder_t)));
extern int mu_record_list_p (mu_record_t record, const char *name, int);
/* Records provided by the library. */
/* Remote Folder "imap://" */
extern mu_record_t mu_imap_record;
extern mu_record_t mu_imaps_record;
/* Remote Mailbox POP3, pop:// */
extern mu_record_t mu_pop_record;
extern mu_record_t mu_pops_record;
/* Remote newsgroup NNTP, nntp:// */
extern mu_record_t mu_nntp_record;
/* Local Mailbox Unix Mailbox, "mbox:" */
extern mu_record_t mu_mbox_record;
/* Local MH, "mh:" */
extern mu_record_t mu_mh_record;
/* Maildir, "maildir:" */
extern mu_record_t mu_maildir_record;
/* Remote mailbox */
extern mu_record_t mu_remote_mbox_record;
#define MU_IMAP_PRIO 100
#define MU_POP_PRIO 200
#define MU_MBOX_PRIO 300
#define MU_MH_PRIO 400
#define MU_MAILDIR_PRIO 500
#define MU_NNTP_PRIO 600
#define MU_PATH_PRIO 1000
#define MU_REMOTE_MBOX_PRIO 10000
#define MU_SMTP_PRIO 10000
#define MU_SENDMAIL_PRIO 10000
#define MU_PROG_PRIO 10000
/* SMTP mailer, "smtp://" */
extern mu_record_t mu_smtp_record;
/* Sendmail, "sendmail:" */
extern mu_record_t mu_sendmail_record;
/* Program mailer, "prog://", "|" */
extern mu_record_t mu_prog_record;
#define mu_register_all_mbox_formats() do {\
mu_registrar_record (mu_mbox_record);\
mu_registrar_record (mu_pop_record);\
mu_registrar_record (mu_pops_record);\
mu_registrar_record (mu_imap_record);\
mu_registrar_record (mu_imaps_record);\
mu_registrar_record (mu_mh_record);\
mu_registrar_record (mu_maildir_record);\
mu_registrar_set_default_record (MU_DEFAULT_RECORD);\
} while (0)
#define mu_register_local_mbox_formats() do {\
mu_registrar_record (mu_mbox_record);\
mu_registrar_record (mu_mh_record);\
mu_registrar_record (mu_maildir_record);\
mu_registrar_set_default_record (MU_DEFAULT_RECORD);\
} while (0)
#define mu_register_remote_mbox_formats() do {\
mu_registrar_record (mu_pop_record);\
mu_registrar_record (mu_pops_record);\
mu_registrar_record (mu_imap_record);\
mu_registrar_record (mu_imaps_record);\
mu_registrar_record (mu_nntp_record);\
} while (0)
#define mu_register_all_mailer_formats() do {\
mu_registrar_record (mu_sendmail_record);\
mu_registrar_record (mu_smtp_record);\
mu_registrar_record (mu_prog_record);\
} while (0)
#define mu_register_extra_formats() do {\
mu_registrar_record (mu_nntp_record);\
} while (0)
#define mu_register_all_formats() do {\
mu_register_all_mbox_formats ();\
mu_register_all_mailer_formats ();\
mu_register_extra_formats();\
} while (0)
#ifdef __cplusplus
}
#endif
#endif /* _MAILUTILS_REGISTRAR_H */