address.h
5.75 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
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999-2000, 2005-2007, 2009-2012, 2014-2016 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, see
<http://www.gnu.org/licenses/>. */
#ifndef _MAILUTILS_ADDRESS_H
#define _MAILUTILS_ADDRESS_H
#include <mailutils/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MU_ADDR_HINT_PRINTABLE 0x0001 /* Not used yet */
#define MU_ADDR_HINT_COMMENTS 0x0002
#define MU_ADDR_HINT_PERSONAL 0x0004
#define MU_ADDR_HINT_EMAIL 0x0008
#define MU_ADDR_HINT_LOCAL 0x0010
#define MU_ADDR_HINT_DOMAIN 0x0020
#define MU_ADDR_HINT_ROUTE 0x0040
/*
* The data-structure representing an RFC822 MAILBOX. It may be
* one MAILBOX or a list of them, as found in an ADDRESS or
* a MAILBOX list (as found in a GROUP).
*
* Capitalized names are from RFC 822, section 6.1 (Address Syntax).
*/
struct mu_address
{
char *printable;
/* Printable representation of this address. Normally, it is
* the original string that this list of addresses was created
* from, only present at the head of the list
*/
char *comments;
/* the collection of comments stripped during parsing this MAILBOX */
char *personal;
/* the PHRASE portion of a MAILBOX, called the DISPLAY-NAME in drums */
char *email;
/* the ADDR-SPEC, the LOCAL-PART@DOMAIN */
char *local_part;
/* the LOCAL-PART of a MAILBOX */
char *domain;
/* the DOMAIN of a MAILBOX */
char *route;
/* the optional ROUTE in the ROUTE-ADDR form of MAILBOX */
struct mu_address *next;
};
extern int mu_address_create_null (mu_address_t *);
extern int mu_address_create_hint (mu_address_t *, const char *,
mu_address_t, int);
extern int mu_address_create (mu_address_t *, const char *);
extern int mu_address_createv (mu_address_t *, const char *v[], size_t);
extern void mu_address_destroy (mu_address_t *);
extern mu_address_t mu_address_dup (mu_address_t src);
/* Set FROM to null, after adding its addresses to TO. */
extern int mu_address_concatenate (mu_address_t to, mu_address_t* from);
extern int mu_address_get_nth
(mu_address_t addr, size_t no, mu_address_t *pret);
extern int mu_address_set_email (mu_address_t, size_t, const char *);
extern int mu_address_sget_email
(mu_address_t, size_t, const char **);
extern int mu_address_get_email
(mu_address_t, size_t, char *, size_t, size_t *);
extern int mu_address_aget_email
(mu_address_t, size_t, char **);
extern int mu_address_set_comments (mu_address_t, size_t, const char *);
extern int mu_address_sget_comments
(mu_address_t, size_t, const char **);
extern int mu_address_get_comments
(mu_address_t, size_t, char *, size_t, size_t *);
extern int mu_address_aget_comments
(mu_address_t, size_t, char **);
extern int mu_address_set_local_part (mu_address_t, size_t, const char *);
extern int mu_address_sget_local_part
(mu_address_t, size_t, const char **);
extern int mu_address_get_local_part
(mu_address_t, size_t, char *, size_t, size_t *);
extern int mu_address_aget_local_part
(mu_address_t, size_t, char **);
extern int mu_address_set_personal (mu_address_t, size_t, const char *);
extern int mu_address_sget_personal
(mu_address_t, size_t, const char **);
extern int mu_address_get_personal
(mu_address_t, size_t, char *, size_t, size_t *);
extern int mu_address_aget_personal
(mu_address_t, size_t, char **);
extern int mu_address_set_domain (mu_address_t, size_t, const char *);
extern int mu_address_sget_domain
(mu_address_t, size_t, const char **);
extern int mu_address_get_domain
(mu_address_t, size_t, char *, size_t, size_t *);
extern int mu_address_aget_domain
(mu_address_t, size_t, char **);
extern int mu_address_set_route (mu_address_t, size_t, const char *);
extern int mu_address_sget_route
(mu_address_t, size_t, const char **);
extern int mu_address_get_route
(mu_address_t, size_t, char *, size_t, size_t *);
extern int mu_address_aget_route
(mu_address_t, size_t, char **);
extern int mu_address_is_group
(mu_address_t, size_t, int*);
extern int mu_address_sget_printable (mu_address_t addr, const char **sptr);
extern int mu_address_aget_printable (mu_address_t addr, char **presult);
extern int mu_address_get_printable (mu_address_t addr, char *buf, size_t len,
size_t *n);
extern int mu_address_get_count (mu_address_t, size_t *);
extern int mu_address_get_group_count (mu_address_t, size_t *);
extern int mu_address_get_email_count (mu_address_t, size_t *);
extern int mu_address_get_unix_mailbox_count (mu_address_t, size_t *);
extern int mu_address_contains_email (mu_address_t addr, const char *email);
extern int mu_address_union (mu_address_t *a, mu_address_t b);
extern int mu_stream_format_address (mu_stream_t str, mu_address_t addr);
/* Deprecated calls */
extern int mu_address_to_string (mu_address_t, char *, size_t, size_t *)
MU_DEPRECATED; /* Use mu_address_get_printable, if you really have to */
extern size_t mu_address_format_string (mu_address_t addr, char *buf,
size_t buflen)
MU_DEPRECATED; /* Use mu_stream_format_address, or any of the
_get_printable functions */
extern int mu_validate_email (mu_address_t subaddr);
#ifdef __cplusplus
}
#endif
#endif /* _MAILUTILS_ADDRESS_H */