From: Baptiste Daroussin Date: Tue, 3 Jan 2023 11:13:10 +0000 (+0100) Subject: Replace custom struct email_contianer with generic strlist X-Git-Tag: RELEASE_1_4_0_a2~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8212e17f920f0cd1657a4384538d63efef1aa4a7;p=thirdparty%2Fmlmmj.git Replace custom struct email_contianer with generic strlist --- diff --git a/include/find_email_adr.h b/include/find_email_adr.h index 92180889..e5da89b3 100644 --- a/include/find_email_adr.h +++ b/include/find_email_adr.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2002, 2003 Mads Martin Joergensen - * - * $Id$ +/* + * Copyright (C) 2002, 2003 Mads Martin Joergensen + * Copyright (C) 2023 Baptiste Daroussin * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -26,12 +26,6 @@ #include -struct email_container { - int emailcount; - char **emaillist; -}; - -struct email_container *find_email_adr(const char *str, - struct email_container *retval); +strlist *find_email_adr(const char *str, strlist *retval); #endif /* FIND_EMAIL_ADR_H */ diff --git a/include/listcontrol.h b/include/listcontrol.h index 78316d95..bc45a272 100644 --- a/include/listcontrol.h +++ b/include/listcontrol.h @@ -24,9 +24,9 @@ #ifndef LISTCONTROL_H #define LISTCONTROL_H -#include "find_email_adr.h" +#include "mlmmj.h" -int listcontrol(struct email_container *fromemails, const char *listdir, +int listcontrol(strlist *fromemails, const char *listdir, const char *controlstr, const char *mlmmjsub, const char *mlmmjunsub, const char *mlmmjsend, const char *mailname, int listfd, int ctrlfd); diff --git a/include/mlmmj.h b/include/mlmmj.h index b8a7d82f..5371f73d 100644 --- a/include/mlmmj.h +++ b/include/mlmmj.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2002, 2003, 2004 Mads Martin Joergensen - * - * $Id$ +/* + * Copyright (C) 2002, 2003, 2004 Mads Martin Joergensen + * Copyright (C) 2022-2023 Baptiste Daroussin * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -27,6 +27,7 @@ #include "config.h" #include #include +#include #define RELAYHOST "127.0.0.1" #define READ_BUFSIZE 2048 @@ -58,6 +59,8 @@ #define OPLOGFNAME "mlmmj.operation.log" /* logfile to log operations */ #define OPLOGSIZE 524288 +typedef tll(char *) strlist; + typedef enum bounce { BOUNCE_OK, BOUNCE_FAIL, diff --git a/src/find_email_adr.c b/src/find_email_adr.c index 11d90bc7..08300988 100644 --- a/src/find_email_adr.c +++ b/src/find_email_adr.c @@ -44,6 +44,7 @@ #include #include +#include "mlmmj.h" #include "find_email_adr.h" #include "xmalloc.h" @@ -181,8 +182,8 @@ static char *skin(char *name) } -struct email_container *find_email_adr(const char *str, - struct email_container *retstruct) +strlist * +find_email_adr(const char *str, strlist *retstruct) { char *c1 = NULL, *c2 = NULL; char *p; @@ -230,12 +231,8 @@ oncemore: } adr = skin(cur); - if (adr) { - retstruct->emailcount++; - retstruct->emaillist = (char **)xrealloc(retstruct->emaillist, - sizeof(char *) * retstruct->emailcount); - retstruct->emaillist[retstruct->emailcount-1] = adr; - } + if (adr) + tll_push_back(*retstruct, adr); } free(s); diff --git a/src/listcontrol.c b/src/listcontrol.c index 0d5ffd7a..8b40341a 100644 --- a/src/listcontrol.c +++ b/src/listcontrol.c @@ -112,7 +112,7 @@ static struct ctrl_command ctrl_commands[] = { }; -int listcontrol(struct email_container *fromemails, const char *listdir, +int listcontrol(strlist *fromemails, const char *listdir, const char *controlstr, const char *mlmmjsub, const char *mlmmjunsub, const char *mlmmjsend, const char *mailname, int listfd, int ctrlfd) @@ -145,8 +145,8 @@ int listcontrol(struct email_container *fromemails, const char *listdir, #if 0 log_error(LOG_ARGS, "controlstr = [%s]\n", controlstr); - log_error(LOG_ARGS, "fromemails->emaillist[0] = [%s]\n", - fromemails->emaillist[0]); + log_error(LOG_ARGS, "tll_front(*fromemails) = [%s]\n", + tll_front(*fromemails)); #endif for (ctrl=0; ctrlemailcount != 1 && ctrl != CTRL_BOUNCES) { + if(tll_length(*fromemails) != 1 && ctrl != CTRL_BOUNCES) { errno = 0; log_error(LOG_ARGS, "Ignoring mail with invalid From: " - "which was not a bounce: %d", fromemails->emailcount); + "which was not a bounce: %d", tll_length(*fromemails)); return -1; } @@ -213,7 +213,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, " sent to a closed list. Ignoring mail"); return -1; } - if (!strchr(fromemails->emaillist[0], '@')) { + if (!strchr(tll_front(*fromemails), '@')) { /* Not a valid From: address */ errno = 0; log_error(LOG_ARGS, "A subscribe-digest request was" @@ -229,21 +229,21 @@ int listcontrol(struct email_container *fromemails, const char *listdir, "digest", "sub-deny-digest"); MY_ASSERT(txt); register_unformatted(txt, "subaddr", - fromemails->emaillist[0]); + tll_front(*fromemails)); queuefilename = prepstdreply(txt, listdir, "$listowner$", - fromemails->emaillist[0], NULL, listfd, ctrlfd); + tll_front(*fromemails), NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, - fromemails->emaillist[0], mlmmjsend, ctrlfd); + tll_front(*fromemails), mlmmjsend, ctrlfd); return -1; } log_oper(listdir, OPLOGFNAME, "mlmmj-sub: request for digest" " subscription from %s", - fromemails->emaillist[0]); + tll_front(*fromemails)); exec_or_die(mlmmjsub, "-L", listdir, "-a", - fromemails->emaillist[0], "-d", "-r", "-c", + tll_front(*fromemails), "-d", "-r", "-c", (nosubconfirm ? NULL : "-C"), NULL); break; @@ -255,7 +255,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, " sent to a closed list. Ignoring mail"); return -1; } - if (!strchr(fromemails->emaillist[0], '@')) { + if (!strchr(tll_front(*fromemails), '@')) { /* Not a valid From: address */ errno = 0; log_error(LOG_ARGS, "A subscribe-nomail request was" @@ -271,21 +271,21 @@ int listcontrol(struct email_container *fromemails, const char *listdir, "nomail", "sub-deny-nomail"); MY_ASSERT(txt); register_unformatted(txt, "subaddr", - fromemails->emaillist[0]); + tll_front(*fromemails)); queuefilename = prepstdreply(txt, listdir, "$listowner$", - fromemails->emaillist[0], NULL, listfd, ctrlfd); + tll_front(*fromemails), NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, - fromemails->emaillist[0], mlmmjsend, ctrlfd); + tll_front(*fromemails), mlmmjsend, ctrlfd); return -1; } log_oper(listdir, OPLOGFNAME, "mlmmj-sub: request for nomail" " subscription from %s", - fromemails->emaillist[0]); + tll_front(*fromemails)); exec_or_die(mlmmjsub, "-L", listdir, "-a", - fromemails->emaillist[0], "-n", "-r", "-c", + tll_front(*fromemails), "-n", "-r", "-c", (nosubconfirm ? NULL : "-C"), NULL); break; @@ -297,7 +297,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, " sent to a closed list. Ignoring mail"); return -1; } - if (!strchr(fromemails->emaillist[0], '@')) { + if (!strchr(tll_front(*fromemails), '@')) { /* Not a valid From: address */ errno = 0; log_error(LOG_ARGS, "A subscribe-both request was" @@ -313,21 +313,21 @@ int listcontrol(struct email_container *fromemails, const char *listdir, "both", "sub-deny-digest"); MY_ASSERT(txt); register_unformatted(txt, "subaddr", - fromemails->emaillist[0]); + tll_front(*fromemails)); queuefilename = prepstdreply(txt, listdir, "$listowner$", - fromemails->emaillist[0], NULL, listfd, ctrlfd); + tll_front(*fromemails), NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, - fromemails->emaillist[0], mlmmjsend, ctrlfd); + tll_front(*fromemails), mlmmjsend, ctrlfd); return -1; } log_oper(listdir, OPLOGFNAME, "mlmmj-sub: request for both" " subscription from %s", - fromemails->emaillist[0]); + tll_front(*fromemails)); exec_or_die(mlmmjsub, "-L", listdir, "-a", - fromemails->emaillist[0], "-b", "-r", "-c", + tll_front(*fromemails), "-b", "-r", "-c", (nosubconfirm ? NULL : "-C"), NULL); break; @@ -339,7 +339,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, " sent to a closed list. Ignoring mail"); return -1; } - if (!strchr(fromemails->emaillist[0], '@')) { + if (!strchr(tll_front(*fromemails), '@')) { /* Not a valid From: address */ errno = 0; log_error(LOG_ARGS, "A subscribe request was" @@ -349,9 +349,9 @@ int listcontrol(struct email_container *fromemails, const char *listdir, } log_oper(listdir, OPLOGFNAME, "mlmmj-sub: request for regular" " subscription from %s", - fromemails->emaillist[0]); + tll_front(*fromemails)); exec_or_die(mlmmjsub, "-L", listdir, "-a", - fromemails->emaillist[0], "-r", "-c", + tll_front(*fromemails), "-r", "-c", (nosubconfirm ? NULL : "-C"), NULL); break; @@ -427,7 +427,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, " sent to a closed list. Ignoring mail"); return -1; } - if (!strchr(fromemails->emaillist[0], '@')) { + if (!strchr(tll_front(*fromemails), '@')) { /* Not a valid From: address */ errno = 0; log_error(LOG_ARGS, "An unsubscribe request was" @@ -437,9 +437,9 @@ int listcontrol(struct email_container *fromemails, const char *listdir, } log_oper(listdir, OPLOGFNAME, "mlmmj-unsub: %s requests" " unsubscribe", - fromemails->emaillist[0]); + tll_front(*fromemails)); exec_or_die(mlmmjunsub, "-L", listdir, "-a", - fromemails->emaillist[0], "-r", + tll_front(*fromemails), "-r", (nosubconfirm ? "-c" : "-C"), NULL); break; @@ -603,7 +603,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, free(moderatefilename); log_oper(listdir, OPLOGFNAME, "%s released %s", - fromemails->emaillist[0], param); + tll_front(*fromemails), param); if (omit != NULL) exec_or_die(mlmmjsend, "-L", listdir, "-o", omit, @@ -624,7 +624,7 @@ int listcontrol(struct email_container *fromemails, const char *listdir, return -1; } log_oper(listdir, OPLOGFNAME, "%s rejected %s", - fromemails->emaillist[0], param); + tll_front(*fromemails), param); free(param); if (unlink(moderatefilename) != 0) { log_error(LOG_ARGS, "Could not unlink %s", @@ -650,7 +650,7 @@ permit: return -1; } log_oper(listdir, OPLOGFNAME, "%s permitted %s", - fromemails->emaillist[0], param); + tll_front(*fromemails), param); exec_or_die(mlmmjsub, "-L", listdir, "-m", param, "-c", NULL); break; @@ -668,7 +668,7 @@ permit: return -1; } log_oper(listdir, OPLOGFNAME, "%s obstructed %s", - fromemails->emaillist[0], param); + tll_front(*fromemails), param); free(param); if (unlink(gatekeepfilename) != 0) { log_error(LOG_ARGS, "Could not unlink %s", @@ -681,7 +681,7 @@ permit: /* listname+help@domain.tld */ case CTRL_HELP: - if(!strchr(fromemails->emaillist[0], '@')) { + if(!strchr(tll_front(*fromemails), '@')) { /* Not a valid From: address */ errno = 0; log_error(LOG_ARGS, "A help request was" @@ -690,20 +690,20 @@ permit: return -1; } log_oper(listdir, OPLOGFNAME, "%s requested help", - fromemails->emaillist[0]); + tll_front(*fromemails)); txt = open_text(listdir, "help", NULL, NULL, NULL, "listhelp"); MY_ASSERT(txt); queuefilename = prepstdreply(txt, listdir, - "$listowner$", fromemails->emaillist[0], NULL, listfd, ctrlfd); + "$listowner$", tll_front(*fromemails), NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, - fromemails->emaillist[0], mlmmjsend, ctrlfd); + tll_front(*fromemails), mlmmjsend, ctrlfd); break; /* listname+faq@domain.tld */ case CTRL_FAQ: - if(!strchr(fromemails->emaillist[0], '@')) { + if(!strchr(tll_front(*fromemails), '@')) { /* Not a valid From: address */ errno = 0; log_error(LOG_ARGS, "A faq request was" @@ -712,15 +712,15 @@ permit: return -1; } log_oper(listdir, OPLOGFNAME, "%s requested faq", - fromemails->emaillist[0]); + tll_front(*fromemails)); txt = open_text(listdir, "faq", NULL, NULL, NULL, "listfaq"); MY_ASSERT(txt); queuefilename = prepstdreply(txt, listdir, - "$listowner$", fromemails->emaillist[0], NULL, listfd, ctrlfd); + "$listowner$", tll_front(*fromemails), NULL, listfd, ctrlfd); MY_ASSERT(queuefilename); close_text(txt); send_help(listdir, queuefilename, - fromemails->emaillist[0], mlmmjsend, ctrlfd); + tll_front(*fromemails), mlmmjsend, ctrlfd); break; /* listname+get-INDEX@domain.tld */ @@ -734,7 +734,7 @@ permit: } subonlyget = statctrl(ctrlfd, "subonlyget"); if(subonlyget) { - if(is_subbed(listfd, fromemails->emaillist[0], 0) == + if(is_subbed(listfd, tll_front(*fromemails), 0) == SUB_NONE) { errno = 0; log_error(LOG_ARGS, "A get request was sent" @@ -760,8 +760,8 @@ permit: exit(EXIT_FAILURE); } log_oper(listdir, OPLOGFNAME, "%s got archive/%s", - fromemails->emaillist[0], archivefilename); - exec_or_die(mlmmjsend, "-T", fromemails->emaillist[0], "-L", + tll_front(*fromemails), archivefilename); + exec_or_die(mlmmjsend, "-T", tll_front(*fromemails), "-L", listdir, "-l", "6", "-m", archivefilename, "-a", "-D", NULL); break; @@ -774,11 +774,11 @@ permit: owners = ctrlvalues(listdir, "owner"); if (owners != NULL) { for(i = 0; i < owners->count; i++) { - if(strcasecmp(fromemails->emaillist[0], + if(strcasecmp(tll_front(*fromemails), owners->strs[i]) == 0) { log_oper(listdir, OPLOGFNAME, "%s requested sub list", - fromemails->emaillist[0]); + tll_front(*fromemails)); owner_idx = i; break; } diff --git a/src/mlmmj-process.c b/src/mlmmj-process.c index da61320e..8bd871fe 100644 --- a/src/mlmmj-process.c +++ b/src/mlmmj-process.c @@ -438,13 +438,13 @@ int main(int argc, char **argv) char *envstr, *efrom; struct stat st; uid_t uid; - struct email_container fromemails = { 0, NULL }; - struct email_container originalfromemails = { 0, NULL }; - struct email_container toemails = { 0, NULL }; - struct email_container ccemails = { 0, NULL }; - struct email_container rpemails = { 0, NULL }; - struct email_container dtemails = { 0, NULL }; - struct email_container *testfrom = NULL; + strlist fromemails = tll_init(); + strlist originalfromemails = tll_init(); + strlist toemails = tll_init(); + strlist ccemails = tll_init(); + strlist rpemails = tll_init(); + strlist dtemails = tll_init(); + strlist *testfrom = NULL; struct strlist *access_rules = NULL; struct strlist *list_rules = NULL; struct strlist *delheaders = NULL; @@ -633,9 +633,9 @@ int main(int argc, char **argv) } if(addrtocc || findaddress) { listaddrs = ctrlvalues(listdir, "listaddress"); - for(i = 0; i < dtemails.emailcount; i++) { + tll_foreach(dtemails, it) { for(j = 0; j < listaddrs->count; j++) { - if(addrmatch(listaddrs->strs[j], dtemails.emaillist[i], + if(addrmatch(listaddrs->strs[j], it->item, listdelim, &recipextra)) { findaddress = 0; free(listdelim); @@ -646,24 +646,25 @@ int main(int argc, char **argv) } } if(addrtocc || findaddress) { - for(i = 0; i < toemails.emailcount; i++) { + tll_foreach(toemails, it) { for(j = 0; j < listaddrs->count; j++) { - if(addrmatch(listaddrs->strs[j], toemails.emaillist[i], + if(addrmatch(listaddrs->strs[j], it->item, listdelim, &recipextra)) { intocc = 1; break; } } } - if (!intocc) for(i = 0; i < ccemails.emailcount; i++) { - for(j = 0; j < listaddrs->count; j++) { - if(addrmatch(listaddrs->strs[j], ccemails.emaillist[i], + if (!intocc) + tll_foreach(ccemails, it) { + for(j = 0; j < listaddrs->count; j++) { + if(addrmatch(listaddrs->strs[j], it->item, listdelim, &recipextra)) { - intocc = 1; - break; + intocc = 1; + break; + } } } - } } if (listdelim) { free(listdelim); @@ -687,19 +688,19 @@ int main(int argc, char **argv) } /* discard malformed mail with invalid From: unless it's a bounce */ - if(fromemails.emailcount != 1 && + if(tll_length(fromemails) != 1 && (recipextra == NULL || strncmp(recipextra, "bounces", 7) != 0)) { - for(i = 0; i < fromemails.emailcount; i++) - printf("fromemails.emaillist[%d] = %s\n", - i, fromemails.emaillist[i]); + tll_foreach(fromemails, it) + printf("fromemails.emaillist[] = %s\n", + it->item); discardname = concatstr(3, listdir, "/queue/discarded/", randomstr); log_error(LOG_ARGS, "Discarding %s due to invalid From:", mailfile); - for(i = 0; i < fromemails.emailcount; i++) - log_error(LOG_ARGS, "fromemails.emaillist[%d] = %s\n", - i, fromemails.emaillist[i]); + tll_foreach(fromemails, it) + log_error(LOG_ARGS, "fromemails.emaillist[] = %s\n", + it->item); rename(mailfile, discardname); unlink(donemailname); free(donemailname); @@ -711,8 +712,8 @@ int main(int argc, char **argv) /* The only time posteraddr will remain unset is when the mail is a * bounce, so the mail will be processed by listcontrol() and the * program will terminate before posteraddr is used. */ - if (fromemails.emailcount > 0) - posteraddr = fromemails.emaillist[0]; + if (tll_length(fromemails) > 0) + posteraddr = tll_front(fromemails); /* Return-Path: addresses */ for(i = 0; i < readhdrs[3].valuecount; i++) { @@ -723,9 +724,9 @@ int main(int argc, char **argv) if((envstr = getenv("SENDER")) != NULL) { /* qmail, postfix, exim */ efrom = xstrdup(envstr); - } else if(rpemails.emailcount >= 1) { + } else if(tll_length(rpemails) >= 1) { /* the (first) Return-Path: header */ - efrom = xstrdup(rpemails.emaillist[0]); + efrom = xstrdup(tll_front(rpemails)); } else { efrom = xstrdup(""); } @@ -782,7 +783,7 @@ int main(int argc, char **argv) log_error(LOG_ARGS, "listcontrol(from, %s, %s, %s, %s, %s, %s, %s)\n", listdir, toemails.emaillist[0], mlmmjsub, mlmmjunsub, mlmmjsend, mlmmjbounce, donemailname); #endif unlink(mailfile); - if (originalfromemails.emailcount > 0) + if (tll_length(originalfromemails) > 0) testfrom = &originalfromemails; else testfrom = &fromemails; @@ -999,8 +1000,8 @@ int main(int argc, char **argv) /* Don't send a mail about denial to the list, but silently * discard and exit. */ char *testaddr = posteraddr; - if (originalfromemails.emailcount > 0) - testaddr = originalfromemails.emaillist[0]; + if (tll_length(originalfromemails) > 0) + testaddr = tll_front(originalfromemails); if (strcasecmp(listaddr, testaddr) == 0) { log_error(LOG_ARGS, "Discarding %s because" " there are sender restrictions but" diff --git a/src/mlmmj.c b/src/mlmmj.c index 38cb8764..63c4cb8d 100644 --- a/src/mlmmj.c +++ b/src/mlmmj.c @@ -389,11 +389,11 @@ save_lastbouncedmsg(int listfd, const char *address, const char *mailname) char *dsnparseaddr(const char *mailname) { - int fd, i; + int fd; char *line, *hdr, *walk, *addr = NULL, *boundary = NULL; bool quoted = false; bool indsn = false; - struct email_container emails = { 0, NULL }; + strlist emails = tll_init(); fd = open(mailname, O_RDONLY); if(fd < 0) { @@ -452,11 +452,9 @@ char *dsnparseaddr(const char *mailname) break; } find_email_adr(walk+1, &emails); - if(emails.emailcount > 0) { - addr = xstrdup(emails.emaillist[0]); - for(i = 0; i < emails.emailcount; i++) - free(emails.emaillist[i]); - free(emails.emaillist); + if(tll_length(emails) > 0) { + addr = xstrdup(tll_front(emails)); + tll_free_and_free(emails, free); } free(line); break; diff --git a/tests/mlmmj.c b/tests/mlmmj.c index 5823ef7e..10f9c71c 100644 --- a/tests/mlmmj.c +++ b/tests/mlmmj.c @@ -355,92 +355,92 @@ ATF_TC_BODY(exec_and_wait, tc) ATF_TC_BODY(find_email_adr, tc) { - struct email_container c = {0, NULL}; - struct email_container c1 = {0, NULL}; - struct email_container c2 = {0, NULL}; - struct email_container c3 = {0, NULL}; - struct email_container c4 = {0, NULL}; - struct email_container c5 = {0, NULL}; - struct email_container c6 = {0, NULL}; - struct email_container c7 = {0, NULL}; + strlist c = tll_init(); + strlist c1 = tll_init(); + strlist c2 = tll_init(); + strlist c3 = tll_init(); + strlist c4 = tll_init(); + strlist c5 = tll_init(); + strlist c6 = tll_init(); + strlist c7 = tll_init(); find_email_adr("test@foo.bar", &c); - ATF_REQUIRE_EQ(c.emailcount, 1); + ATF_REQUIRE_EQ(tll_length(c), 1); find_email_adr("test@foo.bar, meh@bar", &c1); - ATF_REQUIRE_EQ(c1.emailcount, 2); + ATF_REQUIRE_EQ(tll_length(c1), 2); find_email_adr("test@foo.bar, meh@bar, nope", &c2); - ATF_REQUIRE_EQ(c2.emailcount, 3); + ATF_REQUIRE_EQ(tll_length(c2), 3); find_email_adr("name ", &c3); - ATF_REQUIRE_EQ(c3.emailcount, 1); - ATF_REQUIRE_STREQ(c3.emaillist[0], "test@foo.com"); + ATF_REQUIRE_EQ(tll_length(c3), 1); + ATF_REQUIRE_STREQ(tll_front(c3), "test@foo.com"); find_email_adr("(name ) test@foo.com", &c4); - ATF_REQUIRE_EQ(c4.emailcount, 1); - ATF_REQUIRE_STREQ(c4.emaillist[0], " test@foo.com"); + ATF_REQUIRE_EQ(tll_length(c4), 1); + ATF_REQUIRE_STREQ(tll_front(c4), " test@foo.com"); find_email_adr("\"name \" test@foo.com", &c5); - ATF_REQUIRE_EQ(c5.emailcount, 1); - ATF_REQUIRE_STREQ(c5.emaillist[0], "name test@foo.com"); + ATF_REQUIRE_EQ(tll_length(c5), 1); + ATF_REQUIRE_STREQ(tll_front(c5), "name test@foo.com"); find_email_adr("\"name test@foo.com", &c6); - ATF_REQUIRE_EQ(c6.emailcount, 1); - ATF_REQUIRE_STREQ(c6.emaillist[0], "name test@foo.com"); + ATF_REQUIRE_EQ(tll_length(c6), 1); + ATF_REQUIRE_STREQ(tll_front(c6), "name test@foo.com"); find_email_adr("\"name \\ test@foo.com", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 1); - ATF_REQUIRE_STREQ(c7.emaillist[0], "name test@foo.com"); + ATF_REQUIRE_EQ(tll_length(c7), 1); + ATF_REQUIRE_STREQ(tll_front(c7), "name test@foo.com"); find_email_adr("\"name test@foo.com\\", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 2); - ATF_REQUIRE_STREQ(c7.emaillist[1], "name test@foo.com"); + ATF_REQUIRE_EQ(tll_length(c7), 2); + ATF_REQUIRE_STREQ(tll_back(c7), "name test@foo.com"); find_email_adr("test at foo.com", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 3); - ATF_REQUIRE_STREQ(c7.emaillist[2], "test@foo.com"); + ATF_REQUIRE_EQ(tll_length(c7), 3); + ATF_REQUIRE_STREQ(tll_back(c7), "test@foo.com"); find_email_adr("test atfoo.com", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 4); - ATF_REQUIRE_STREQ(c7.emaillist[3], "test atfoo.com"); + ATF_REQUIRE_EQ(tll_length(c7), 4); + ATF_REQUIRE_STREQ(tll_back(c7), "test atfoo.com"); find_email_adr("test a t foo.com", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 5); - ATF_REQUIRE_STREQ(c7.emaillist[4], "test a t foo.com"); + ATF_REQUIRE_EQ(tll_length(c7), 5); + ATF_REQUIRE_STREQ(tll_back(c7), "test a t foo.com"); find_email_adr("test@foo.com, \"meh\"", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 7); - ATF_REQUIRE_STREQ(c7.emaillist[6], "\"meh\""); + ATF_REQUIRE_EQ(tll_length(c7), 7); + ATF_REQUIRE_STREQ(tll_back(c7), "\"meh\""); find_email_adr("test@foo.com, \"meh\\\"", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 9); - ATF_REQUIRE_STREQ(c7.emaillist[8], "meh "); + ATF_REQUIRE_EQ(tll_length(c7), 9); + ATF_REQUIRE_STREQ(tll_back(c7), "meh "); find_email_adr("", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 9); + ATF_REQUIRE_EQ(tll_length(c7), 9); find_email_adr("\"meh\" , ", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 10); - ATF_REQUIRE_STREQ(c7.emaillist[9], "meh"); + ATF_REQUIRE_EQ(tll_length(c7), 10); + ATF_REQUIRE_STREQ(tll_back(c7), "meh"); find_email_adr("\"meh , ", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 11); - ATF_REQUIRE_STREQ(c7.emaillist[10], "meh "); + ATF_REQUIRE_EQ(tll_length(c7), 11); + ATF_REQUIRE_STREQ(tll_back(c7), "meh "); find_email_adr("\t,", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 11); + ATF_REQUIRE_EQ(tll_length(c7), 11); find_email_adr("\r,", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 11); + ATF_REQUIRE_EQ(tll_length(c7), 11); find_email_adr("\n,", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 11); + ATF_REQUIRE_EQ(tll_length(c7), 11); find_email_adr(", m", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 12); + ATF_REQUIRE_EQ(tll_length(c7), 12); find_email_adr(", \"m", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 13); + ATF_REQUIRE_EQ(tll_length(c7), 13); find_email_adr("bob @ foo.net", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 14); - ATF_REQUIRE_STREQ(c7.emaillist[13], "bob@foo.net"); + ATF_REQUIRE_EQ(tll_length(c7), 14); + ATF_REQUIRE_STREQ(tll_back(c7), "bob@foo.net"); find_email_adr("bob @foo.net", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 15); - ATF_REQUIRE_STREQ(c7.emaillist[14], "bob @foo.net"); + ATF_REQUIRE_EQ(tll_length(c7), 15); + ATF_REQUIRE_STREQ(tll_back(c7), "bob @foo.net"); find_email_adr("bob @foo.net>", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 16); - ATF_REQUIRE_STREQ(c7.emaillist[15], "bob @foo.net>"); + ATF_REQUIRE_EQ(tll_length(c7), 16); + ATF_REQUIRE_STREQ(tll_back(c7), "bob @foo.net>"); find_email_adr(" garbage,", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 17); - ATF_REQUIRE_STREQ(c7.emaillist[16], "bob @foo.net"); + ATF_REQUIRE_EQ(tll_length(c7), 17); + ATF_REQUIRE_STREQ(tll_back(c7), "bob @foo.net"); find_email_adr(" garbage (more garbage) ,", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 18); - ATF_REQUIRE_STREQ(c7.emaillist[17], "bob @foo.net"); + ATF_REQUIRE_EQ(tll_length(c7), 18); + ATF_REQUIRE_STREQ(tll_back(c7), "bob @foo.net"); find_email_adr(" garbage \"more garbage\" ,", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 19); - ATF_REQUIRE_STREQ(c7.emaillist[18], "bob @foo.net"); + ATF_REQUIRE_EQ(tll_length(c7), 19); + ATF_REQUIRE_STREQ(tll_back(c7), "bob @foo.net"); find_email_adr(" garbage \"more garbage \\ ,", &c7); - ATF_REQUIRE_EQ(c7.emailcount, 20); - ATF_REQUIRE_STREQ(c7.emaillist[19], "bob @foo.net"); + ATF_REQUIRE_EQ(tll_length(c7), 20); + ATF_REQUIRE_STREQ(tll_back(c7), "bob @foo.net"); } ATF_TC_BODY(strtoim, tc)