Andreas Krennmair:
[apps/madmutt.git] / hdrline.c
1 /*
2  * Copyright (C) 1996-2000,2002 Michael R. Elkins <me@mutt.org>
3  * 
4  *     This program is free software; you can redistribute it and/or modify
5  *     it under the terms of the GNU General Public License as published by
6  *     the Free Software Foundation; either version 2 of the License, or
7  *     (at your option) any later version.
8  * 
9  *     This program is distributed in the hope that it will be useful,
10  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *     GNU General Public License for more details.
13  * 
14  *     You should have received a copy of the GNU General Public License
15  *     along with this program; if not, write to the Free Software
16  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17  */
18
19 #if HAVE_CONFIG_H
20 # include "config.h"
21 #endif
22
23 #include "mutt.h"
24 #include "mutt_curses.h"
25 #include "sort.h"
26 #include "charset.h"
27 #include "mutt_crypt.h"
28 #include "mutt_idna.h"
29
30 #include <ctype.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <locale.h>
34
35 int mutt_is_mail_list (ADDRESS * addr)
36 {
37   if (!mutt_match_rx_list (addr->mailbox, UnMailLists))
38     return mutt_match_rx_list (addr->mailbox, MailLists);
39   return 0;
40 }
41
42 int mutt_is_subscribed_list (ADDRESS * addr)
43 {
44   if (!mutt_match_rx_list (addr->mailbox, UnMailLists)
45       && !mutt_match_rx_list (addr->mailbox, UnSubscribedLists))
46     return mutt_match_rx_list (addr->mailbox, SubscribedLists);
47   return 0;
48 }
49
50 /* Search for a mailing list in the list of addresses pointed to by adr.
51  * If one is found, print pfx and the name of the list into buf, then
52  * return 1.  Otherwise, simply return 0.
53  */
54 static int
55 check_for_mailing_list (ADDRESS * adr, char *pfx, char *buf, int buflen)
56 {
57   for (; adr; adr = adr->next) {
58     if (mutt_is_subscribed_list (adr)) {
59       if (pfx && buf && buflen)
60         snprintf (buf, buflen, "%s%s", pfx, mutt_get_name (adr));
61       return 1;
62     }
63   }
64   return 0;
65 }
66
67 /* Search for a mailing list in the list of addresses pointed to by adr.
68  * If one is found, print the address of the list into buf, then return 1.
69  * Otherwise, simply return 0.
70  */
71 static int check_for_mailing_list_addr (ADDRESS * adr, char *buf, int buflen)
72 {
73   for (; adr; adr = adr->next) {
74     if (mutt_is_subscribed_list (adr)) {
75       if (buf && buflen)
76         snprintf (buf, buflen, "%s", adr->mailbox);
77       return 1;
78     }
79   }
80   return 0;
81 }
82
83
84 static int first_mailing_list (char *buf, size_t buflen, ADDRESS * a)
85 {
86   for (; a; a = a->next) {
87     if (mutt_is_subscribed_list (a)) {
88       mutt_save_path (buf, buflen, a);
89       return 1;
90     }
91   }
92   return 0;
93 }
94
95 static void make_from (ENVELOPE * hdr, char *buf, size_t len, int do_lists)
96 {
97   int me;
98
99   me = mutt_addr_is_user (hdr->from);
100
101   if (do_lists || me) {
102     if (check_for_mailing_list (hdr->to, "To ", buf, len))
103       return;
104     if (check_for_mailing_list (hdr->cc, "Cc ", buf, len))
105       return;
106   }
107
108   if (me && hdr->to)
109     snprintf (buf, len, "To %s", mutt_get_name (hdr->to));
110   else if (me && hdr->cc)
111     snprintf (buf, len, "Cc %s", mutt_get_name (hdr->cc));
112   else if (hdr->from)
113     strfcpy (buf, mutt_get_name (hdr->from), len);
114   else
115     *buf = 0;
116 }
117
118 static void make_from_addr (ENVELOPE * hdr, char *buf, size_t len,
119                             int do_lists)
120 {
121   int me;
122
123   me = mutt_addr_is_user (hdr->from);
124
125   if (do_lists || me) {
126     if (check_for_mailing_list_addr (hdr->to, buf, len))
127       return;
128     if (check_for_mailing_list_addr (hdr->cc, buf, len))
129       return;
130   }
131
132   if (me && hdr->to)
133     snprintf (buf, len, "%s", hdr->to->mailbox);
134   else if (me && hdr->cc)
135     snprintf (buf, len, "%s", hdr->cc->mailbox);
136   else if (hdr->from)
137     strfcpy (buf, hdr->from->mailbox, len);
138   else
139     *buf = 0;
140 }
141
142 static int user_in_addr (ADDRESS * a)
143 {
144   for (; a; a = a->next)
145     if (mutt_addr_is_user (a))
146       return 1;
147   return 0;
148 }
149
150 /* Return values:
151  * 0: user is not in list
152  * 1: user is unique recipient
153  * 2: user is in the TO list
154  * 3: user is in the CC list
155  * 4: user is originator
156  * 5: sent to a subscribed mailinglist
157  */
158 int mutt_user_is_recipient (HEADER * h)
159 {
160   ENVELOPE *env = h->env;
161
162   if (!h->recip_valid) {
163     h->recip_valid = 1;
164
165     if (mutt_addr_is_user (env->from))
166       h->recipient = 4;
167     else if (user_in_addr (env->to)) {
168       if (env->to->next || env->cc)
169         h->recipient = 2;       /* non-unique recipient */
170       else
171         h->recipient = 1;       /* unique recipient */
172     }
173     else if (user_in_addr (env->cc))
174       h->recipient = 3;
175     else if (check_for_mailing_list (env->to, NULL, NULL, 0))
176       h->recipient = 5;
177     else if (check_for_mailing_list (env->cc, NULL, NULL, 0))
178       h->recipient = 5;
179     else
180       h->recipient = 0;
181   }
182
183   return h->recipient;
184 }
185
186 /* %a = address of author
187  * %A = reply-to address (if present; otherwise: address of author
188  * %b = filename of the originating folder
189  * %B = the list to which the letter was sent
190  * %c = size of message in bytes
191  * %C = current message number
192  * %d = date and time of message using $date_format and sender's timezone
193  * %D = date and time of message using $date_format and local timezone
194  * %e = current message number in thread
195  * %E = number of messages in current thread
196  * %f = entire from line
197  * %F = like %n, unless from self
198  * %g = newsgroup name (if compiled with nntp support)
199  * %i = message-id
200  * %I = initials of author
201  * %l = number of lines in the message
202  * %L = like %F, except `lists' are displayed first
203  * %m = number of messages in the mailbox
204  * %n = name of author
205  * %N = score
206  * %O = like %L, except using address instead of name
207  * %s = subject
208  * %S = short message status (e.g., N/O/D/!/r/-)
209  * %t = `to:' field (recipients)
210  * %T = $to_chars
211  * %u = user (login) name of author
212  * %v = first name of author, unless from self
213  * %W = where user is (organization)
214  * %y = `x-label:' field (if present)
215  * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
216  * %Z = status flags    */
217
218 struct hdr_format_info {
219   CONTEXT *ctx;
220   HEADER *hdr;
221 };
222
223 static const char *hdr_format_str (char *dest,
224                                    size_t destlen,
225                                    char op,
226                                    const char *src,
227                                    const char *prefix,
228                                    const char *ifstring,
229                                    const char *elsestring,
230                                    unsigned long data, format_flag flags)
231 {
232   struct hdr_format_info *hfi = (struct hdr_format_info *) data;
233   HEADER *hdr, *htmp;
234   CONTEXT *ctx;
235   char fmt[SHORT_STRING], buf2[SHORT_STRING], ch, *p;
236   int do_locales, i;
237   int optional = (flags & M_FORMAT_OPTIONAL);
238   int threads = ((Sort & SORT_MASK) == SORT_THREADS);
239   int is_index = (flags & M_FORMAT_INDEX);
240
241 #define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1)
242 #define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2)
243   size_t len;
244
245   hdr = hfi->hdr;
246   ctx = hfi->ctx;
247
248   dest[0] = 0;
249   switch (op) {
250   case 'A':
251     if (hdr->env->reply_to && hdr->env->reply_to->mailbox) {
252       mutt_format_s (dest, destlen, prefix,
253                      mutt_addr_for_display (hdr->env->reply_to));
254       break;
255     }
256     /* fall through if 'A' returns nothing */
257
258   case 'a':
259     if (hdr->env->from && hdr->env->from->mailbox) {
260       mutt_format_s (dest, destlen, prefix,
261                      mutt_addr_for_display (hdr->env->from));
262     }
263     else
264       dest[0] = '\0';
265     break;
266
267   case 'B':
268     if (!first_mailing_list (dest, destlen, hdr->env->to) &&
269         !first_mailing_list (dest, destlen, hdr->env->cc))
270       dest[0] = 0;
271     if (dest[0]) {
272       strfcpy (buf2, dest, sizeof (buf2));
273       mutt_format_s (dest, destlen, prefix, buf2);
274       break;
275     }
276     /* fall through if 'B' returns nothing */
277
278   case 'b':
279     if (ctx) {
280       if ((p = strrchr (ctx->path, '/')))
281         strfcpy (dest, p + 1, destlen);
282       else
283         strfcpy (dest, ctx->path, destlen);
284     }
285     else
286       strfcpy (dest, "(null)", destlen);
287     strfcpy (buf2, dest, sizeof (buf2));
288     mutt_format_s (dest, destlen, prefix, buf2);
289     break;
290
291   case 'c':
292     mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length);
293     mutt_format_s (dest, destlen, prefix, buf2);
294     break;
295
296   case 'C':
297     snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
298     snprintf (dest, destlen, fmt, hdr->msgno + 1);
299     break;
300
301   case 'd':
302   case 'D':
303   case '{':
304   case '[':
305   case '(':
306   case '<':
307
308     /* preprocess $date_format to handle %Z */
309     {
310       const char *cp;
311       struct tm *tm;
312       time_t T;
313
314       p = dest;
315
316       cp = (op == 'd' || op == 'D') ? (NONULL (DateFmt)) : src;
317       if (*cp == '!') {
318         do_locales = 0;
319         cp++;
320       }
321       else
322         do_locales = 1;
323
324       len = destlen - 1;
325       while (len > 0 && (((op == 'd' || op == 'D') && *cp) ||
326                          (op == '{' && *cp != '}') ||
327                          (op == '[' && *cp != ']') ||
328                          (op == '(' && *cp != ')') ||
329                          (op == '<' && *cp != '>'))) {
330         if (*cp == '%') {
331           cp++;
332           if ((*cp == 'Z' || *cp == 'z') && (op == 'd' || op == '{')) {
333             if (len >= 5) {
334               sprintf (p, "%c%02u%02u", hdr->zoccident ? '-' : '+',
335                        hdr->zhours, hdr->zminutes);
336               p += 5;
337               len -= 5;
338             }
339             else
340               break;            /* not enough space left */
341           }
342           else {
343             if (len >= 2) {
344               *p++ = '%';
345               *p++ = *cp;
346               len -= 2;
347             }
348             else
349               break;            /* not enough space */
350           }
351           cp++;
352         }
353         else {
354           *p++ = *cp++;
355           len--;
356         }
357       }
358       *p = 0;
359
360       if (do_locales && Locale)
361         setlocale (LC_TIME, Locale);
362
363       if (op == '[' || op == 'D')
364         tm = localtime (&hdr->date_sent);
365       else if (op == '(')
366         tm = localtime (&hdr->received);
367       else if (op == '<') {
368         T = time (NULL);
369         tm = localtime (&T);
370       }
371       else {
372         /* restore sender's time zone */
373         T = hdr->date_sent;
374         if (hdr->zoccident)
375           T -= (hdr->zhours * 3600 + hdr->zminutes * 60);
376         else
377           T += (hdr->zhours * 3600 + hdr->zminutes * 60);
378         tm = gmtime (&T);
379       }
380
381       strftime (buf2, sizeof (buf2), dest, tm);
382
383       if (do_locales)
384         setlocale (LC_TIME, "C");
385
386       mutt_format_s (dest, destlen, prefix, buf2);
387       if (len > 0 && op != 'd' && op != 'D')    /* Skip ending op */
388         src = cp + 1;
389     }
390     break;
391
392   case 'e':
393     snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
394     snprintf (dest, destlen, fmt, mutt_messages_in_thread (ctx, hdr, 1));
395     break;
396
397   case 'E':
398     if (!optional) {
399       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
400       snprintf (dest, destlen, fmt, mutt_messages_in_thread (ctx, hdr, 0));
401     }
402     else if (mutt_messages_in_thread (ctx, hdr, 0) <= 1)
403       optional = 0;
404     break;
405
406   case 'f':
407     buf2[0] = 0;
408     rfc822_write_address (buf2, sizeof (buf2), hdr->env->from, 1);
409     mutt_format_s (dest, destlen, prefix, buf2);
410     break;
411
412   case 'F':
413     if (!optional) {
414       make_from (hdr->env, buf2, sizeof (buf2), 0);
415       mutt_format_s (dest, destlen, prefix, buf2);
416     }
417     else if (mutt_addr_is_user (hdr->env->from))
418       optional = 0;
419     break;
420
421 #ifdef USE_NNTP
422   case 'g':
423     mutt_format_s (dest, destlen, prefix,
424                    hdr->env->newsgroups ? hdr->env->newsgroups : "");
425     break;
426 #endif
427
428   case 'H':
429     /* (Hormel) spam score */
430     if (optional)
431       optional = hdr->env->spam ? 1 : 0;
432
433     if (hdr->env->spam)
434       mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->spam->data));
435     else
436       mutt_format_s (dest, destlen, prefix, "");
437
438     break;
439
440   case 'i':
441     mutt_format_s (dest, destlen, prefix,
442                    hdr->env->message_id ? hdr->env->message_id : "<no.id>");
443     break;
444
445   case 'I':
446     {
447       int iflag = FALSE;
448       int j = 0;
449
450       for (i = 0; hdr->env->from && hdr->env->from->personal &&
451            hdr->env->from->personal[i] && j < SHORT_STRING - 1; i++) {
452         if (isalpha ((int) hdr->env->from->personal[i])) {
453           if (!iflag) {
454             buf2[j++] = hdr->env->from->personal[i];
455             iflag = TRUE;
456           }
457         }
458         else
459           iflag = FALSE;
460       }
461
462       buf2[j] = '\0';
463     }
464     mutt_format_s (dest, destlen, prefix, buf2);
465     break;
466
467   case 'l':
468     if (!optional) {
469       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
470       snprintf (dest, destlen, fmt, (int) hdr->lines);
471     }
472     else if (hdr->lines <= 0)
473       optional = 0;
474     break;
475
476   case 'L':
477     if (!optional) {
478       make_from (hdr->env, buf2, sizeof (buf2), 1);
479       mutt_format_s (dest, destlen, prefix, buf2);
480     }
481     else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) &&
482              !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0)) {
483       optional = 0;
484     }
485     break;
486
487   case 'm':
488     if (ctx) {
489       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
490       snprintf (dest, destlen, fmt, ctx->msgcount);
491     }
492     else
493       strfcpy (dest, "(null)", destlen);
494     break;
495
496   case 'n':
497     mutt_format_s (dest, destlen, prefix, mutt_get_name (hdr->env->from));
498     break;
499
500   case 'N':
501     if (!optional) {
502       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
503       snprintf (dest, destlen, fmt, hdr->score);
504     }
505     else {
506       if (hdr->score == 0)
507         optional = 0;
508     }
509     break;
510
511   case 'O':
512     if (!optional) {
513       make_from_addr (hdr->env, buf2, sizeof (buf2), 1);
514       if (!option (OPTSAVEADDRESS) && (p = strpbrk (buf2, "%@")))
515         *p = 0;
516       mutt_format_s (dest, destlen, prefix, buf2);
517     }
518     else if (!check_for_mailing_list_addr (hdr->env->to, NULL, 0) &&
519              !check_for_mailing_list_addr (hdr->env->cc, NULL, 0)) {
520       optional = 0;
521     }
522     break;
523
524   case 'M':
525     snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
526     if (!optional) {
527       if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1)
528         snprintf (dest, destlen, fmt, hdr->num_hidden);
529       else if (is_index && threads)
530         mutt_format_s (dest, destlen, prefix, " ");
531       else
532         *dest = '\0';
533     }
534     else {
535       if (!(threads && is_index && hdr->collapsed && hdr->num_hidden > 1))
536         optional = 0;
537     }
538     break;
539
540   case 's':
541
542     if (flags & M_FORMAT_TREE && !hdr->collapsed) {
543       if (flags & M_FORMAT_FORCESUBJ) {
544         mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject));
545         snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
546         mutt_format_s_tree (dest, destlen, prefix, buf2);
547       }
548       else
549         mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
550     }
551     else
552       mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject));
553     break;
554
555   case 'S':
556     if (hdr->deleted)
557       ch = 'D';
558     else if (hdr->attach_del)
559       ch = 'd';
560     else if (hdr->tagged)
561       ch = '*';
562     else if (hdr->flagged)
563       ch = '!';
564     else if (hdr->replied)
565       ch = 'r';
566     else if (hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno))
567       ch = '-';
568     else if (hdr->old)
569       ch = 'O';
570     else
571       ch = 'N';
572
573     /* FOO - this is probably unsafe, but we are not likely to have such
574        a short string passed into this routine */
575     *dest = ch;
576     *(dest + 1) = 0;
577     break;
578
579   case 't':
580     buf2[0] = 0;
581     if (!check_for_mailing_list (hdr->env->to, "To ", buf2, sizeof (buf2)) &&
582         !check_for_mailing_list (hdr->env->cc, "Cc ", buf2, sizeof (buf2))) {
583       if (hdr->env->to)
584         snprintf (buf2, sizeof (buf2), "To %s", mutt_get_name (hdr->env->to));
585       else if (hdr->env->cc)
586         snprintf (buf2, sizeof (buf2), "Cc %s", mutt_get_name (hdr->env->cc));
587     }
588     mutt_format_s (dest, destlen, prefix, buf2);
589     break;
590
591   case 'T':
592     snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
593     snprintf (dest, destlen, fmt,
594               (Tochars
595                && ((i = mutt_user_is_recipient (hdr))) <
596                mutt_strlen (Tochars)) ? Tochars[i] : ' ');
597     break;
598
599   case 'u':
600     if (hdr->env->from && hdr->env->from->mailbox) {
601       strfcpy (buf2, mutt_addr_for_display (hdr->env->from), sizeof (buf2));
602       if ((p = strpbrk (buf2, "%@")))
603         *p = 0;
604     }
605     else
606       buf2[0] = 0;
607     mutt_format_s (dest, destlen, prefix, buf2);
608     break;
609
610   case 'v':
611     if (mutt_addr_is_user (hdr->env->from)) {
612       if (hdr->env->to)
613         mutt_format_s (buf2, sizeof (buf2), prefix,
614                        mutt_get_name (hdr->env->to));
615       else if (hdr->env->cc)
616         mutt_format_s (buf2, sizeof (buf2), prefix,
617                        mutt_get_name (hdr->env->cc));
618       else
619         *buf2 = 0;
620     }
621     else
622       mutt_format_s (buf2, sizeof (buf2), prefix,
623                      mutt_get_name (hdr->env->from));
624     if ((p = strpbrk (buf2, " %@")))
625       *p = 0;
626     mutt_format_s (dest, destlen, prefix, buf2);
627     break;
628
629   case 'W':
630     if (!optional)
631       mutt_format_s (dest, destlen, prefix,
632                      hdr->env->organization ? hdr->env->organization : "");
633     else if (!hdr->env->organization)
634       optional = 0;
635     break;
636
637   case 'Z':
638
639     ch = ' ';
640
641     if (WithCrypto && hdr->security & GOODSIGN)
642       ch = 'S';
643     else if (WithCrypto && hdr->security & ENCRYPT)
644       ch = 'P';
645     else if (WithCrypto && hdr->security & SIGN)
646       ch = 's';
647     else if ((WithCrypto & APPLICATION_PGP) && hdr->security & PGPKEY)
648       ch = 'K';
649
650     snprintf (buf2, sizeof (buf2),
651               "%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' :
652                                              ((hdr->read
653                                                && (ctx
654                                                    && ctx->msgnotreadyet !=
655                                                    hdr->msgno))
656                                               ? (hdr->
657                                                  replied ? 'r' : ' ') : (hdr->
658                                                                          old ?
659                                                                          'O' :
660                                                                          'N')))),
661               hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch),
662               hdr->tagged ? '*' : (hdr->
663                                    flagged ? '!' : (Tochars
664                                                     &&
665                                                     ((i =
666                                                       mutt_user_is_recipient
667                                                       (hdr)) <
668                                                      mutt_strlen (Tochars)) ?
669                                                     Tochars[i] : ' ')));
670     mutt_format_s (dest, destlen, prefix, buf2);
671     break;
672
673   case 'y':
674     if (optional)
675       optional = hdr->env->x_label ? 1 : 0;
676
677     mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
678     break;
679
680   case 'Y':
681     if (hdr->env->x_label) {
682       i = 1;                    /* reduce reuse recycle */
683       htmp = NULL;
684       if (flags & M_FORMAT_TREE
685           && (hdr->thread->prev && hdr->thread->prev->message
686               && hdr->thread->prev->message->env->x_label))
687         htmp = hdr->thread->prev->message;
688       else if (flags & M_FORMAT_TREE
689                && (hdr->thread->parent && hdr->thread->parent->message
690                    && hdr->thread->parent->message->env->x_label))
691         htmp = hdr->thread->parent->message;
692       if (htmp && mutt_strcasecmp (hdr->env->x_label,
693                                    htmp->env->x_label) == 0)
694         i = 0;
695     }
696     else
697       i = 0;
698
699     if (optional)
700       optional = i;
701
702     if (i)
703       mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
704     else
705       mutt_format_s (dest, destlen, prefix, "");
706
707     break;
708
709   default:
710     snprintf (dest, destlen, "%%%s%c", prefix, op);
711     break;
712   }
713
714   if (optional)
715     mutt_FormatString (dest, destlen, ifstring, hdr_format_str,
716                        (unsigned long) hfi, flags);
717   else if (flags & M_FORMAT_OPTIONAL)
718     mutt_FormatString (dest, destlen, elsestring, hdr_format_str,
719                        (unsigned long) hfi, flags);
720
721   return (src);
722 #undef THREAD_NEW
723 #undef THREAD_OLD
724 }
725
726 void
727 _mutt_make_string (char *dest, size_t destlen, const char *s, CONTEXT * ctx,
728                    HEADER * hdr, format_flag flags)
729 {
730   struct hdr_format_info hfi;
731
732   hfi.hdr = hdr;
733   hfi.ctx = ctx;
734
735   mutt_FormatString (dest, destlen, s, hdr_format_str, (unsigned long) &hfi,
736                      flags);
737 }