NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
Go to the documentation of this file.
27 #include <stddef.h>
28 #include <stdbool.h>
29 #include <stdio.h>
30 #include "mutt/lib.h"
35 struct Address
36 {
37  char *personal;
38  char *mailbox;
39  bool group : 1;
40  bool is_intl : 1;
41  bool intl_checked : 1;
42  TAILQ_ENTRY(Address) entries;
43 };
44 TAILQ_HEAD(AddressList, Address);
50 {
57 };
59 extern int AddressError;
60 extern const char *const AddressErrors[];
61 extern const char AddressSpecials[];
63 #define address_error(num) AddressErrors[num]
70 typedef bool (*addr_predicate_t)(const struct Address *a);
72 /* Utility functions that don't use struct Address or struct AddressList */
73 void mutt_addr_cat (char *buf, size_t buflen, const char *value, const char *specials);
74 bool mutt_addr_valid_msgid(const char *msgid);
76 /* Functions that work on a single struct Address */
77 bool mutt_addr_cmp (const struct Address *a, const struct Address *b);
78 struct Address *mutt_addr_copy (const struct Address *addr);
79 struct Address *mutt_addr_create (const char *personal, const char *mailbox);
80 const char * mutt_addr_for_display(const struct Address *a);
81 void mutt_addr_free (struct Address **ptr);
82 struct Address *mutt_addr_new (void);
83 bool mutt_addr_to_intl (struct Address *a);
84 bool mutt_addr_to_local (struct Address *a);
85 bool mutt_addr_uses_unicode(const char *str);
86 size_t mutt_addr_write (char *buf, size_t buflen, struct Address *addr, bool display);
88 /* Functions that work on struct AddressList */
89 void mutt_addrlist_append (struct AddressList *al, struct Address *a);
90 void mutt_addrlist_clear (struct AddressList *al);
91 void mutt_addrlist_copy (struct AddressList *dst, const struct AddressList *src, bool prune);
92 int mutt_addrlist_count_recips(const struct AddressList *al);
93 void mutt_addrlist_dedupe (struct AddressList *al);
94 bool mutt_addrlist_equal (const struct AddressList *ala, const struct AddressList *alb);
95 int mutt_addrlist_parse (struct AddressList *al, const char *s);
96 int mutt_addrlist_parse2 (struct AddressList *al, const char *s);
97 void mutt_addrlist_prepend (struct AddressList *al, struct Address *a);
98 void mutt_addrlist_qualify (struct AddressList *al, const char *host);
99 int mutt_addrlist_remove (struct AddressList *al, const char *mailbox);
100 void mutt_addrlist_remove_xrefs(const struct AddressList *a, struct AddressList *b);
101 bool mutt_addrlist_search (const struct AddressList *haystack, const struct Address *needle);
102 int mutt_addrlist_to_intl (struct AddressList *al, char **err);
103 int mutt_addrlist_to_local (struct AddressList *al);
104 bool mutt_addrlist_uses_unicode(const struct AddressList *al);
105 size_t mutt_addrlist_write (const struct AddressList *al, char *buf, size_t buflen, bool display);
106 void mutt_addrlist_write_file (const struct AddressList *addr, FILE *fp, int start_col, bool display);
107 size_t mutt_addrlist_write_list (const struct AddressList *al, struct ListHead *list);
109 #endif /* MUTT_EMAIL_ADDRESS_H */
void mutt_addrlist_prepend(struct AddressList *al, struct Address *a)
Prepend an Address to an AddressList.
Definition: address.c:1501
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:737
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:681
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:764
struct Address * mutt_addr_copy(const struct Address *addr)
Copy the real address.
Definition: address.c:716
void mutt_addrlist_dedupe(struct AddressList *al)
Remove duplicate addresses.
Definition: address.c:1407
An email address.
Definition: address.h:35
char * mailbox
Mailbox and host address.
Definition: address.h:38
bool mutt_addr_to_local(struct Address *a)
Convert an Address from Punycode.
Definition: address.c:1351
const char *const AddressErrors[]
Messages for the error codes in AddressError.
Definition: address.c:64
Bad route address.
Definition: address.h:55
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:1025
bool is_intl
International Domain Name.
Definition: address.h:40
void mutt_addr_free(struct Address **ptr)
Free a single Address.
Definition: address.c:440
struct Address * mutt_addr_create(const char *personal, const char *mailbox)
Create and populate a new Address.
Definition: address.c:398
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
Definition: address.c:1388
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1470
bool mutt_addr_cmp(const struct Address *a, const struct Address *b)
Compare two e-mail addresses.
Definition: address.c:864
bool mutt_addrlist_equal(const struct AddressList *ala, const struct AddressList *alb)
Compare two Address lists for equality.
Definition: address.c:812
bool(* addr_predicate_t)(const struct Address *a)
Test an Address for some condition.
Definition: address.h:70
void mutt_addrlist_append(struct AddressList *al, struct Address *a)
Append an Address to an AddressList.
Definition: address.c:1490
void mutt_addrlist_write_file(const struct AddressList *addr, FILE *fp, int start_col, bool display)
Wrapper for mutt_write_address()
Definition: address.c:1231
bool intl_checked
Checked for IDN?
Definition: address.h:41
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
Definition: address.c:650
Mismatches quotes.
Definition: address.h:53
bool mutt_addr_to_intl(struct Address *a)
Convert an Address to Punycode.
Definition: address.c:1276
possible values for AddressError
Definition: address.h:49
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:458
Bad address specifier.
Definition: address.h:56
Out of memory.
Definition: address.h:51
bool mutt_addrlist_search(const struct AddressList *haystack, const struct Address *needle)
Search for an e-mail address in a list.
Definition: address.c:881
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:616
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1305
bool mutt_addrlist_uses_unicode(const struct AddressList *al)
Do any of a list of addresses use Unicode characters.
Definition: address.c:1532
char * personal
Real name of address.
Definition: address.h:37
bool group
Group mailbox?
Definition: address.h:39
void mutt_addrlist_remove_xrefs(const struct AddressList *a, struct AddressList *b)
Remove cross-references.
Definition: address.c:1443
const char * mutt_addr_for_display(const struct Address *a)
Convert an Address for display purposes.
Definition: address.c:986
struct Address * mutt_addr_new(void)
Create a new Address.
Definition: address.c:385
int mutt_addrlist_count_recips(const struct AddressList *al)
Count the number of Addresses with valid recipients.
Definition: address.c:844
Mismatched parentheses.
Definition: address.h:52
Bad route.
Definition: address.h:54
size_t mutt_addrlist_write(const struct AddressList *al, char *buf, size_t buflen, bool display)
Write an Address to a buffer.
Definition: address.c:1150
int mutt_addrlist_remove(struct AddressList *al, const char *mailbox)
Remove an Address from a list.
Definition: address.c:413
Convenience wrapper for the library headers.
size_t mutt_addrlist_write_list(const struct AddressList *al, struct ListHead *list)
Write Addresses to a List.
Definition: address.c:1201
bool mutt_addr_uses_unicode(const char *str)
Does this address use Unicode character.
Definition: address.c:1512