#include <time.h>
#include <fcntl.h>
+#include "mlmmj.h"
+
char *lowercase(const char *);
intmax_t strtoim(const char *np, intmax_t minval, intmax_t maxval,
const char **errpp);
int exec_and_wait(const char *arg, ...);
time_t strtotimet(const char *np, const char **errpp);
bool lock(int fd, bool write);
+bool find_email(strlist *list, strlist *matches, const char *delim, char **recipextra);
log_error(LOG_ARGS, "list address is not defined");
err(EXIT_FAILURE, "list address is not defined");
}
- tll_foreach(dtemails, it) {
- tll_foreach(*listaddrs, la) {
- if (addrmatch(la->item, it->item,
- ml.delim,
- recipextra != NULL ? NULL : &recipextra)) {
- findaddress = 0;
- break;
- }
- }
- }
+ findaddress = !find_email(&dtemails, listaddrs, ml.delim,
+ recipextra != NULL ? NULL : &recipextra);
}
if(addr_in_to_or_cc || findaddress) {
- tll_foreach(toemails, it) {
- tll_foreach(*listaddrs, la) {
- if(addrmatch(la->item, it->item,
- ml.delim,
- recipextra != NULL ? NULL : &recipextra)) {
- intocc = true;
- break;
- }
- }
- }
+ intocc = find_email(&toemails, listaddrs, ml.delim,
+ recipextra != NULL ? NULL : &recipextra);
if (!intocc)
- tll_foreach(ccemails, it) {
- tll_foreach(*listaddrs, la) {
- if(addrmatch(la->item, it->item,
- ml.delim,
- recipextra != NULL ? NULL : &recipextra)) {
- intocc = true;
- break;
- }
- }
- }
+ intocc = find_email(&ccemails, listaddrs, ml.delim,
+ recipextra != NULL ? NULL : &recipextra);
}
if (listaddrs)
tll_free_and_free(*listaddrs, free);
return (true);
}
+
+bool
+find_email(strlist *list, strlist *matches, const char *delim, char **recipextra)
+{
+ tll_foreach(*list, lit) {
+ tll_foreach(*matches, mit) {
+ if (addrmatch(mit->item, lit->item, delim, recipextra))
+ return true;
+ }
+ }
+ return false;
+}
+