2efa1efb9065337f8fbd8c3477453b5c72600b87
[apps/madmutt.git] / alias.cpkg
1 /*
2  *  This program is free software; you can redistribute it and/or modify
3  *  it under the terms of the GNU General Public License as published by
4  *  the Free Software Foundation; either version 2 of the License, or (at
5  *  your option) any later version.
6  *
7  *  This program is distributed in the hope that it will be useful, but
8  *  WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  *  General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
15  *  MA 02110-1301, USA.
16  *
17  *  Copyright © 2006 Pierre Habouzit
18  */
19 /*
20  * Copyright notice from original mutt:
21  * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
22  *
23  * This file is part of mutt-ng, see http://www.muttng.org/.
24  * It's licensed under the GNU General Public License,
25  * please see the file GPL in the top level source directory.
26  */
27
28 #include <lib-lib/lib-lib.h>
29
30 #include <lib-sys/unix.h>
31
32 #include <lib-ui/curses.h>
33 #include <lib-ui/enter.h>
34 #include <lib-ui/menu.h>
35
36 #include "alias.h"
37 #include "mutt_idna.h"
38 #include "sort.h"
39 @import  "lib-lua/base.cpkg"
40
41 static rx_t *Alternates = NULL, *UnAlternates = NULL;
42 rx_t *MailLists = NULL, *UnMailLists = NULL;
43 rx_t *SubscribedLists = NULL, *UnSubscribedLists = NULL;
44
45 @package MAlias {
46     /*
47      ** .pp
48      ** Specifies the format of the data displayed for the ``alias'' menu. The
49      ** following \fTprintf(3)\fP-style sequences are available:
50      ** .pp
51      ** .dl
52      ** .dt %a .dd alias name
53      ** .dt %f .dd flags - currently, a "d" for an alias marked for deletion
54      ** .dt %n .dd index number
55      ** .dt %r .dd address which alias expands to
56      ** .dt %t .dd character which indicates if the alias is tagged for inclusion
57      ** .de
58      */
59     string_t alias_format = m_strdup("%4n %2f %t %-10a   %r");
60     /*
61      ** .pp
62      ** The default file in which to save aliases created by the
63      ** ``$create-alias'' function.
64      ** .pp
65      ** \fBNote:\fP Madmutt will not automatically source this file; you must
66      ** explicitly use the ``$source'' command for it to be executed.
67      */
68     path_t alias_file = m_strdup("~/.madmutt/aliases");
69
70     /*
71      ** .pp
72      ** Specifies the filename of your signature, which is appended to all
73      ** outgoing messages.   If the filename ends with a pipe (``\fT|\fP''), it is
74      ** assumed that filename is a shell command and input should be read from
75      ** its stdout.
76      */
77     path_t signature = m_strdup("~/.signature");
78
79     /*
80      ** .pp
81      ** This specifies the file into which your outgoing messages should be
82      ** appended.  (This is meant as the primary method for saving a copy of
83      ** your messages, but another way to do this is using the ``$my_hdr''
84      ** command to create a \fTBcc:\fP header field with your email address in it.)
85      ** .pp
86      ** The value of \fI$$record\fP is overridden by the ``$$force_name'' and
87      ** ``$$save_name'' variables, and the ``$fcc-hook'' command.
88      */
89     path_t record = NULL;
90
91     void alternates(rx_t rx) {
92         rx_list_remove(&UnAlternates, rx);
93         rx_list_add(&Alternates, rx);
94         RETURN();
95     };
96     void unalternates(rx_t rx) {
97         rx_list_remove(&Alternates, rx);
98         rx_list_add(&UnAlternates, rx);
99         RETURN();
100     };
101
102     void lists(rx_t rx) {
103         rx_list_remove(&UnMailLists, rx);
104         rx_list_add(&MailLists, rx);
105         RETURN();
106     };
107     void unlists(rx_t rx) {
108         rx_list_remove(&MailLists, rx);
109         rx_list_remove(&SubscribedLists, rx);
110         rx_list_add(&UnMailLists, rx);
111         RETURN();
112     };
113
114     void subscribe(rx_t rx) {
115         rx_list_remove(&UnMailLists, rx);
116         rx_list_remove(&UnSubscribedLists, rx);
117         rx_list_add(&MailLists, rx);
118         rx_list_add(&SubscribedLists, rx_dup(rx));
119         RETURN();
120     };
121     void unsubscribe(rx_t rx) {
122         rx_list_remove(&SubscribedLists, rx);
123         rx_list_add(&UnSubscribedLists, rx);
124         RETURN();
125     };
126 };
127
128 alias_t *Aliases;
129
130 #define RSORT(x) (SortAlias & SORT_REVERSE) ? -x : x
131
132 static struct mapping_t AliasHelp[] = {
133     {N_("Exit"), OP_EXIT},
134     {N_("Del"), OP_DELETE},
135     {N_("Undel"), OP_UNDELETE},
136     {N_("Select"), OP_GENERIC_SELECT_ENTRY},
137     {N_("Help"), OP_HELP},
138     {NULL, OP_NULL}
139 };
140
141 static void mutt_alias_menu(char *, size_t, alias_t *);
142
143 const address_t *alias_lookup(const char *s)
144 {
145     alias_t *list;
146
147     for (list = Aliases; list; list = list->next) {
148         if (!m_strcasecmp(s, list->name))
149             return list->addr;
150     }
151
152     return NULL;
153 }
154
155 /* This routine looks to see if the user has an alias defined for the given
156    address.                                                                 */
157 const address_t *alias_reverse_lookup(const address_t *a)
158 {
159     alias_t *list;
160
161     if (!a || !a->mailbox)
162         return NULL;
163
164     for (list = Aliases; list; list = list->next) {
165         address_t *ap;
166
167         /* cycle through all addresses if this is a group alias */
168         for (ap = list->addr; ap; ap = ap->next) {
169             if (!ap->group && ap->mailbox
170             &&  !ascii_strcasecmp(ap->mailbox, a->mailbox))
171                 return ap;
172         }
173     }
174
175     return NULL;
176 }
177
178 static int string_is_address(const char *str, const char *u, const char *d)
179 {
180     char buf[LONG_STRING];
181     snprintf(buf, sizeof (buf), "%s@%s", NONULL(u), NONULL(d));
182     return !ascii_strcasecmp(str, buf);
183 }
184
185 /* returns TRUE if the given address belongs to the user. */
186 int mutt_addr_is_user(address_t *addr)
187 {
188     /* NULL address is assumed to be the user. */
189     if (!addr)
190         return 1;
191
192     if (!addr->mailbox)
193         return 0;
194
195     if (!ascii_strcasecmp(addr->mailbox, MCore.username)
196     ||  string_is_address(addr->mailbox, MCore.username, MCore.shorthost)
197     ||  string_is_address(addr->mailbox, MCore.username, mutt_fqdn(0))
198     ||  string_is_address(addr->mailbox, MCore.username, mutt_fqdn(1))
199     ||  (From && !ascii_strcasecmp(From->mailbox, addr->mailbox)))
200     {
201         return 1;
202     }
203
204     return rx_list_match(Alternates, addr->mailbox)
205         && !rx_list_match(UnAlternates, addr->mailbox);
206 }
207
208 address_t *mutt_get_address(ENVELOPE *env, const char **pfxp)
209 {
210 #define RETURN(s, adr)  do { if (pfxp) *pfxp = s; return adr; } while (0)
211
212     if (mutt_addr_is_user(env->from)) {
213         if (env->to && !mutt_is_mail_list(env->to)) {
214             RETURN("To", env->to);
215         } else {
216             RETURN("Cc", env->cc);
217         }
218     } else {
219         if (env->reply_to && !mutt_is_mail_list(env->reply_to)) {
220             RETURN("Reply-To", env->reply_to);
221         } else {
222             RETURN("From", env->from);
223         }
224     }
225
226 #undef RETURN
227 }
228
229 /* Only characters which are non-special to both the RFC 822 and the mutt
230    configuration parser are permitted.                                      */
231 static int alias_sanitize(const char *s, char *d)
232 {
233     int rv = 0;
234
235     while (*s) {
236         if (isalnum((unsigned char)(*s)) || strchr("-_+=.", *s)) {
237             if (d)
238                 *d++ = *s;
239         } else {
240             if (!d)
241                 return -1;
242             *d++ = '_';
243             rv = -1;
244         }
245         s++;
246     }
247
248     if (d)
249         *d = '\0';
250     return rv;
251 }
252
253 /* 
254  * if someone has an address like
255  *      From: Michael `/bin/rm -f ~` Elkins <me@mutt.org>
256  * and the user creates an alias for this, Mutt could wind up executing
257  * the backtics because it writes aliases like
258  *      alias me Michael `/bin/rm -f ~` Elkins <me@mutt.org>
259  * To avoid this problem, use a backslash (\) to quote any backtics.  We also
260  * need to quote backslashes as well, since you could defeat the above by
261  * doing
262  *      From: Michael \`/bin/rm -f ~\` Elkins <me@mutt.org>
263  * since that would get aliased as
264  *      alias me Michael \\`/bin/rm -f ~\\` Elkins <me@mutt.org>
265  * which still gets evaluated because the double backslash is not a quote.
266  * 
267  * Additionally, we need to quote ' and " characters - otherwise, mutt will
268  * interpret them on the wrong parsing step.
269  * 
270  * $ wants to be quoted since it may indicate the start of an environment
271  * variable.
272  */
273 static void write_safe_address(FILE *fp, const char *s)
274 {
275     while (*s) {
276         if (strchr("\\`'\"$", *s)) {
277             fputc('\\', fp);
278         }
279         fputc(*s++, fp);
280     }
281     fputc('\n', fp);
282 }
283
284 void mutt_create_alias(ENVELOPE *cur, address_t *iadr)
285 {
286     char buf[LONG_STRING], prompt[STRING];
287     address_t *adr = iadr;
288     alias_t *new;
289     FILE *rc;
290
291     if (cur) {
292         adr = mutt_get_address(cur, NULL);
293     }
294
295     if (adr && adr->mailbox) {
296         const char *p = m_strchrnul(adr->mailbox, '@');
297         m_strncpy(buf, sizeof(buf), adr->mailbox, p - adr->mailbox);
298     } else {
299         buf[0] = '\0';
300     }
301
302     /* Don't suggest a bad alias name in the event of a strange local part. */
303     alias_sanitize(buf, buf);
304
305     /* add a new alias */
306     if (mutt_get_field(_("Alias as: "), buf, sizeof(buf), 0) || !buf[0])
307         return;
308
309     /* check to see if the user already has an alias defined */
310     if (alias_lookup(buf)) {
311         mutt_error _("You already have an alias defined with that name!");
312         return;
313     }
314
315     alias_sanitize(buf, buf);
316     new = alias_new();
317     new->name = m_strdup(buf);
318
319     mutt_addrlist_to_local(adr);
320     if (adr) {
321         m_strcpy(buf, sizeof(buf), adr->mailbox);
322     } else {
323         buf[0] = 0;
324     }
325
326     mutt_addrlist_to_idna(adr, NULL);
327
328     do {
329         char *err = NULL;
330
331         if (mutt_get_field(_("Address: "), buf, sizeof(buf), 0) || !buf[0]) {
332             alias_list_wipe(&new);
333             return;
334         }
335
336         new->addr = rfc822_parse_adrlist(new->addr, buf);
337         if (!new->addr)
338             BEEP();
339
340         if (mutt_addrlist_to_idna(new->addr, &err)) {
341             mutt_error(_("Error: '%s' is a bad IDN."), err);
342             p_delete(&err);
343             mutt_sleep(1);
344             continue;
345         }
346     } while (!new->addr);
347
348     if (adr && adr->personal && !mutt_is_mail_list(adr)) {
349         m_strcpy(buf, sizeof(buf), adr->personal);
350     } else {
351         buf[0] = '\0';
352     }
353
354     if (mutt_get_field(_("Personal name: "), buf, sizeof(buf), 0)) {
355         alias_list_wipe(&new);
356         return;
357     }
358     new->addr->personal = m_strdup(buf);
359
360     buf[0] = '\0';
361     rfc822_addrcat(buf, sizeof(buf), new->addr, 1);
362     snprintf(prompt, sizeof(prompt), _("[%s = %s] Accept?"), new->name, buf);
363     if (mutt_yesorno(prompt, M_YES) != M_YES) {
364         alias_list_wipe(&new);
365         return;
366     }
367
368     alias_list_push(&Aliases, new);
369
370     m_strcpy(buf, sizeof(buf), NONULL(MAlias.alias_file));
371     if (mutt_get_field(_("Save to file: "), buf, sizeof(buf), M_FILE)) {
372         return;
373     }
374
375     mutt_expand_path(buf, sizeof(buf));
376     rc = safe_fopen (buf, "a");
377
378     if (rc) {
379         if (alias_sanitize(new->name, NULL)) {
380             mutt_quote_filename(buf, sizeof(buf), new->name);
381             fprintf(rc, "alias %s ", buf);
382         } else {
383             fprintf(rc, "alias %s ", new->name);
384         }
385
386         buf[0] = '\0';
387         rfc822_addrcat(buf, sizeof(buf), new->addr, 0);
388         write_safe_address(rc, buf);
389         m_fclose(&rc);
390         mutt_message _("Alias added.");
391     } else {
392         mutt_perror(buf);
393     }
394 }
395
396 static address_t *mutt_expand_aliases_r(address_t *a, string_list_t **expn)
397 {
398     address_t *pop, *head = NULL;
399     address_t **last = &head;
400
401     while ((pop = address_list_pop(&a))) {
402         if (!pop->group && !pop->personal
403         &&  pop->mailbox && !strchr(pop->mailbox, '@'))
404         {
405             const address_t *t = alias_lookup(pop->mailbox);
406
407             if (t) {
408                 string_list_t *u;
409
410                 for (u = *expn; u; u = u->next) {
411                     if (!m_strcmp(pop->mailbox, u->data)) { /* alias already found */
412                         address_list_wipe(&pop);
413                         continue;
414                     }
415                 }
416
417                 /* save the fact we saw it */
418                 u = string_item_new();
419                 u->data = m_strdup(pop->mailbox);
420                 u->next = *expn;
421                 *expn = u;
422                 address_list_wipe(&pop);
423
424                 /* recurse */
425                 last  = address_list_last(last);
426                 *last = mutt_expand_aliases_r(address_list_dup(t), expn);
427                 continue;
428             } else {
429                 struct passwd *pw = getpwnam(pop->mailbox);
430
431                 if (pw) {
432                     char namebuf[STRING];
433                     mutt_gecos_name(namebuf, sizeof(namebuf), pw, MCore.gecos_mask);
434                     m_strreplace(&pop->personal, namebuf);
435                 }
436             }
437         }
438
439         last = address_list_append(last, pop);
440     }
441
442     if (MCore.use_domain) {
443         /* now qualify all local addresses */
444         rfc822_qualify(head, mutt_fqdn(1));
445     }
446
447     return head;
448 }
449
450 address_t *mutt_expand_aliases(address_t *a)
451 {
452     address_t *t;
453     string_list_t *expn = NULL;            /* previously expanded aliases to avoid loops */
454
455     t = mutt_expand_aliases_r(a, &expn);
456     string_list_wipe(&expn);
457     address_list_uniq(t);
458     return t;
459 }
460
461 void mutt_expand_aliases_env(ENVELOPE *env)
462 {
463     env->from = mutt_expand_aliases(env->from);
464     env->to = mutt_expand_aliases(env->to);
465     env->cc = mutt_expand_aliases(env->cc);
466     env->bcc = mutt_expand_aliases(env->bcc);
467     env->reply_to = mutt_expand_aliases(env->reply_to);
468     env->mail_followup_to = mutt_expand_aliases(env->mail_followup_to);
469 }
470
471 /************* READ MARK *********************/
472
473 /* alias_complete() -- alias completion routine
474  *
475  * given a partial alias, this routine attempts to fill in the alias
476  * from the alias list as much as possible. if given empty search string
477  * or found nothing, present all aliases
478  */
479 int mutt_alias_complete (char *s, size_t buflen)
480 {
481   alias_t *a = Aliases;
482   alias_t *a_list = NULL, *a_cur = NULL;
483   char bestname[HUGE_STRING];
484   int i;
485
486 #define min(a,b)        ((a<b)?a:b)
487
488   if (s[0] != 0) {              /* avoid empty string as strstr argument */
489     p_clear(bestname, countof(bestname));
490
491     while (a) {
492       if (a->name && strstr (a->name, s) == a->name) {
493         if (!bestname[0])       /* init */
494           m_strcpy(bestname, MIN(m_strlen(a->name) + 1, ssizeof(bestname)),
495                    a->name);
496         else {
497           for (i = 0; a->name[i] && a->name[i] == bestname[i]; i++);
498           bestname[i] = 0;
499         }
500       }
501       a = a->next;
502     }
503
504     if (bestname[0] != 0) {
505       if (m_strcmp(bestname, s) != 0) {
506         /* we are adding something to the completion */
507         m_strcpy(s, m_strlen(bestname) + 1, bestname);
508         return 1;
509       }
510
511       /* build alias list and show it */
512
513       a = Aliases;
514       while (a) {
515         if (a->name && (strstr (a->name, s) == a->name)) {
516           if (!a_list)          /* init */
517             a_cur = a_list = alias_new();
518           else {
519             a_cur->next = alias_new();
520             a_cur = a_cur->next;
521           }
522           *a_cur = *a;
523           a_cur->next = NULL;
524         }
525         a = a->next;
526       }
527     }
528   }
529
530   bestname[0] = 0;
531   mutt_alias_menu (bestname, sizeof (bestname), a_list ? a_list : Aliases);
532   if (bestname[0] != 0)
533     m_strcpy(s, buflen, bestname);
534
535   /* free the alias list */
536   while (a_list) {
537     a_cur = a_list;
538     a_list = a_list->next;
539     p_delete(&a_cur);
540   }
541
542   /* remove any aliases marked for deletion */
543   a_list = NULL;
544   for (a_cur = Aliases; a_cur;) {
545     if (a_cur->del) {
546       if (a_list)
547         a_list->next = a_cur->next;
548       else
549         Aliases = a_cur->next;
550
551       a_cur->next = NULL;
552       alias_list_wipe(&a_cur);
553
554       if (a_list)
555         a_cur = a_list;
556       else
557         a_cur = Aliases;
558     }
559     else {
560       a_list = a_cur;
561       a_cur = a_cur->next;
562     }
563   }
564
565   return 0;
566 }
567
568 static const char *
569 alias_format_str(char *dest, ssize_t destlen, char op, const char *src,
570                  const char *fmt, const char *ifstr __attribute__ ((unused)),
571                  const char *elstr __attribute__ ((unused)),
572                  anytype data, format_flag flags __attribute__ ((unused)))
573 {
574   char tmp[STRING], adr[STRING];
575   alias_t *alias = data.ptr;
576
577   switch (op) {
578   case 'f':
579     m_strputc(dest, destlen, alias->del ? 'D' : ' ');
580     break;
581   case 'a':
582     mutt_format_s(dest, destlen, fmt, alias->name);
583     break;
584   case 'r':
585     adr[0] = '\0';
586     rfc822_addrcat(adr, sizeof(adr), alias->addr, 1);
587     snprintf(tmp, sizeof(tmp), "%%%ss", fmt);
588     snprintf(dest, destlen, tmp, adr);
589     break;
590   case 'n':
591     snprintf(tmp, sizeof(tmp), "%%%sd", fmt);
592     snprintf(dest, destlen, tmp, alias->num + 1);
593     break;
594   case 't':
595     m_strputc(dest, destlen, alias->tagged ? '*' : ' ');
596     break;
597   }
598
599   return src;
600 }
601
602 static void alias_entry(char *s, ssize_t slen, MUTTMENU *m, int num)
603 {
604     m_strformat(s, slen, COLS - SW, MAlias.alias_format, alias_format_str,
605                 ((alias_t **)m->data)[num],
606                 option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
607 }
608
609 static int alias_tag (MUTTMENU * menu, int n, int m)
610 {
611   alias_t *cur = ((alias_t **) menu->data)[n];
612   int ot = cur->tagged;
613
614   cur->tagged = (m >= 0 ? m : !cur->tagged);
615
616   return cur->tagged - ot;
617 }
618
619 static int alias_SortAlias (const void *a, const void *b)
620 {
621   alias_t *pa = *(alias_t **) a;
622   alias_t *pb = *(alias_t **) b;
623   int r = m_strcasecmp(pa->name, pb->name);
624
625   return (RSORT (r));
626 }
627
628 static int alias_SortAddress (const void *a, const void *b)
629 {
630   address_t *pa = (*(alias_t **) a)->addr;
631   address_t *pb = (*(alias_t **) b)->addr;
632   int r;
633
634   if (pa == pb)
635     r = 0;
636   else if (pa == NULL)
637     r = -1;
638   else if (pb == NULL)
639     r = 1;
640   else if (pa->personal) {
641     if (pb->personal)
642       r = m_strcasecmp(pa->personal, pb->personal);
643     else
644       r = 1;
645   }
646   else if (pb->personal)
647     r = -1;
648   else
649     r = ascii_strcasecmp (pa->mailbox, pb->mailbox);
650   return (RSORT (r));
651 }
652
653 void mutt_alias_menu (char *buf, size_t buflen, alias_t * aliases)
654 {
655   alias_t *aliasp;
656   MUTTMENU *menu;
657   alias_t **AliasTable = NULL;
658   int t = -1;
659   int i, done = 0;
660   int op;
661   char helpstr[STRING];
662
663   int omax;
664
665   if (!aliases) {
666     mutt_error _("You have no aliases!");
667
668     return;
669   }
670
671   /* tell whoever called me to redraw the screen when I return */
672   set_option (OPTNEEDREDRAW);
673
674   menu = mutt_new_menu ();
675   menu->make_entry = alias_entry;
676   menu->tag = alias_tag;
677   menu->menu = MENU_ALIAS;
678   menu->title = _("Aliases");
679   menu->help = mutt_compile_help(helpstr, sizeof(helpstr),
680                                  MENU_ALIAS, AliasHelp);
681
682 new_aliases:
683
684   omax = menu->max;
685
686   /* count the number of aliases */
687   for (aliasp = aliases; aliasp; aliasp = aliasp->next) {
688     aliasp->del = 0;
689     aliasp->tagged = 0;
690     menu->max++;
691   }
692
693   p_realloc(&AliasTable, menu->max);
694   menu->data = AliasTable;
695
696   for (i = omax, aliasp = aliases; aliasp; aliasp = aliasp->next, i++) {
697     AliasTable[i] = aliasp;
698     aliases = aliasp;
699   }
700
701   if ((SortAlias & SORT_MASK) != SORT_ORDER) {
702     qsort (AliasTable, i, sizeof (alias_t *),
703            (SortAlias & SORT_MASK) ==
704            SORT_ADDRESS ? alias_SortAddress : alias_SortAlias);
705   }
706
707   for (i = 0; i < menu->max; i++)
708     AliasTable[i]->num = i;
709
710   while (!done) {
711     if (aliases->next) {
712       menu->redraw |= REDRAW_FULL;
713       aliases = aliases->next;
714       goto new_aliases;
715     }
716
717     switch ((op = mutt_menuLoop (menu))) {
718     case OP_DELETE:
719     case OP_UNDELETE:
720       if (menu->tagprefix) {
721         for (i = 0; i < menu->max; i++)
722           if (AliasTable[i]->tagged)
723             AliasTable[i]->del = (op == OP_DELETE) ? 1 : 0;
724         menu->redraw |= REDRAW_INDEX;
725       }
726       else {
727         AliasTable[menu->current]->del = (op == OP_DELETE) ? 1 : 0;
728         menu->redraw |= REDRAW_CURRENT;
729         if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
730           menu->current++;
731           menu->redraw |= REDRAW_INDEX;
732         }
733       }
734       break;
735     case OP_GENERIC_SELECT_ENTRY:
736       t = menu->current;
737     case OP_EXIT:
738       done = 1;
739       break;
740     }
741   }
742
743   for (i = 0; i < menu->max; i++) {
744     if (AliasTable[i]->tagged) {
745       mutt_addrlist_to_local (AliasTable[i]->addr);
746       rfc822_addrcat(buf, buflen, AliasTable[i]->addr, 0);
747       t = -1;
748     }
749   }
750
751   if (t != -1) {
752     mutt_addrlist_to_local (AliasTable[t]->addr);
753     rfc822_addrcat(buf, buflen, AliasTable[t]->addr, 0);
754   }
755
756   mutt_menuDestroy (&menu);
757   p_delete(&AliasTable);
758 }
759
760 /* vim:set ft=c: */