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