NeoMutt  2018-07-16 +2481-68dcde
Teaching an old dog new tricks
DOXYGEN
address.h
Go to the documentation of this file.
1 
24 #ifndef MUTT_EMAIL_ADDRESS_H
25 #define MUTT_EMAIL_ADDRESS_H
26 
27 #include <stddef.h>
28 #include <stdbool.h>
29 #include "mutt/mutt.h"
30 
34 struct Address
35 {
36  char *personal;
37  char *mailbox;
38  bool group : 1;
39  bool is_intl : 1;
40  bool intl_checked : 1;
41  TAILQ_ENTRY(Address) entries;
42 };
43 TAILQ_HEAD(AddressList, Address);
44 
49 {
56 };
57 
58 extern int AddressError;
59 extern const char *const AddressErrors[];
60 extern const char AddressSpecials[];
61 
62 #define address_error(num) AddressErrors[num]
63 
64 /* Utility functions that don't use struct Address or struct AddressList */
65 void mutt_addr_cat (char *buf, size_t buflen, const char *value, const char *specials);
66 bool mutt_addr_valid_msgid(const char *msgid);
67 
68 /* Functions that work on a single struct Address */
69 bool mutt_addr_cmp (const struct Address *a, const struct Address *b);
70 struct Address *mutt_addr_copy (const struct Address *addr);
71 struct Address *mutt_addr_create (const char *personal, const char *mailbox);
72 const char * mutt_addr_for_display(const struct Address *a);
73 void mutt_addr_free (struct Address **ptr);
74 struct Address *mutt_addr_new (void);
75 bool mutt_addr_to_intl (struct Address *a);
76 bool mutt_addr_to_local (struct Address *a);
77 size_t mutt_addr_write (char *buf, size_t buflen, struct Address *addr, bool display);
78 
79 /* Functions that work on struct AddressList */
80 void mutt_addrlist_append (struct AddressList *al, struct Address *a);
81 void mutt_addrlist_clear (struct AddressList *al);
82 void mutt_addrlist_copy (struct AddressList *dst, const struct AddressList *src, bool prune);
83 int mutt_addrlist_count_recips(const struct AddressList *al);
84 void mutt_addrlist_dedupe (struct AddressList *al);
85 bool mutt_addrlist_equal (const struct AddressList *ala, const struct AddressList *alb);
86 int mutt_addrlist_parse (struct AddressList *al, const char *s);
87 int mutt_addrlist_parse2 (struct AddressList *al, const char *s);
88 void mutt_addrlist_prepend (struct AddressList *al, struct Address *a);
89 void mutt_addrlist_qualify (struct AddressList *al, const char *host);
90 int mutt_addrlist_remove (struct AddressList *al, const char *mailbox);
91 void mutt_addrlist_remove_xrefs(const struct AddressList *a, struct AddressList *b);
92 bool mutt_addrlist_search (const struct Address *needle, const struct AddressList *haystack);
93 int mutt_addrlist_to_intl (struct AddressList *al, char **err);
94 int mutt_addrlist_to_local (struct AddressList *al);
95 size_t mutt_addrlist_write (char *buf, size_t buflen, const struct AddressList *al, bool display);
96 
97 #endif /* MUTT_EMAIL_ADDRESS_H */
void mutt_addrlist_prepend(struct AddressList *al, struct Address *a)
Prepend an Address to an AddressList.
Definition: address.c:1412
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:727
TAILQ_HEAD(AddressList, Address)
TAILQ_ENTRY(Address) entries
Linked list.
void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials)
Copy a string and wrap it in quotes if it contains special characters.
Definition: address.c:671
const char AddressSpecials[]
Characters with special meaning for email addresses.
Definition: address.c:42
bool mutt_addr_valid_msgid(const char *msgid)
Is this a valid Message ID?
Definition: address.c:754
bool mutt_addrlist_search(const struct Address *needle, const struct AddressList *haystack)
Search for an e-mail address in a list.
Definition: address.c:871
struct Address * mutt_addr_copy(const struct Address *addr)
Copy the real address.
Definition: address.c:706
void mutt_addrlist_dedupe(struct AddressList *al)
Remove duplicate addresses.
Definition: address.c:1318
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
bool mutt_addr_to_local(struct Address *a)
Convert an Address from Punycode.
Definition: address.c:1261
const char *const AddressErrors[]
Messages for the error codes in AddressError.
Definition: address.c:63
Bad route address.
Definition: address.h:54
size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display)
Write a single Address to a buffer.
Definition: address.c:1015
bool is_intl
International Domain Name.
Definition: address.h:39
void mutt_addr_free(struct Address **ptr)
Free a single Address.
Definition: address.c:439
struct Address * mutt_addr_create(const char *personal, const char *mailbox)
Create and populate a new Address.
Definition: address.c:397
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
Definition: address.c:1298
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1381
bool mutt_addr_cmp(const struct Address *a, const struct Address *b)
Compare two e-mail addresses.
Definition: address.c:854
bool mutt_addrlist_equal(const struct AddressList *ala, const struct AddressList *alb)
Compare two Address lists for equality.
Definition: address.c:802
void mutt_addrlist_append(struct AddressList *al, struct Address *a)
Append an Address to an AddressList.
Definition: address.c:1401
size_t mutt_addrlist_write(char *buf, size_t buflen, const struct AddressList *al, bool display)
Write an Address to a buffer.
Definition: address.c:1137
bool intl_checked
Checked for IDN?
Definition: address.h:40
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
Definition: address.c:640
Mismatches quotes.
Definition: address.h:52
bool mutt_addr_to_intl(struct Address *a)
Convert an Address to Punycode.
Definition: address.c:1187
AddressError
possible values for AddressError
Definition: address.h:48
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:457
Bad address specifier.
Definition: address.h:55
Out of memory.
Definition: address.h:50
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:606
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1216
char * personal
Real name of address.
Definition: address.h:36
bool group
Group mailbox?
Definition: address.h:38
void mutt_addrlist_remove_xrefs(const struct AddressList *a, struct AddressList *b)
Remove cross-references.
Definition: address.c:1354
const char * mutt_addr_for_display(const struct Address *a)
Convert an Address for display purposes.
Definition: address.c:976
struct Address * mutt_addr_new(void)
Create a new Address.
Definition: address.c:384
int mutt_addrlist_count_recips(const struct AddressList *al)
Count the number of Addresses with valid recipients.
Definition: address.c:834
Mismatched parentheses.
Definition: address.h:51
Bad route.
Definition: address.h:53
int mutt_addrlist_remove(struct AddressList *al, const char *mailbox)
Remove an Address from a list.
Definition: address.c:412