2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
24 #include <sys/types.h>
27 #include <lib-lib/mem.h>
28 #include <lib-lib/ascii.h>
29 #include <lib-lib/str.h>
30 #include <lib-lib/macros.h>
31 #include <lib-lib/buffer.h>
32 #include <lib-lib/file.h>
33 #include <lib-lib/debug.h>
34 #include <lib-lib/url.h>
36 #include <lib-mime/mime.h>
38 #include <lib-ui/curses.h>
39 #include <lib-ui/enter.h>
47 #include <imap/imap.h>
48 #include <imap/mx_imap.h>
50 #include <lib-crypt/crypt.h>
52 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
54 BODY *mutt_new_body (void)
56 BODY *p = p_new(BODY, 1);
58 p->disposition = DISPATTACH;
64 /* Modified by blong to accept a "suggestion" for file name. If
65 * that file exists, then construct one with unique name but
66 * keep any extension. This might fail, I guess.
67 * Renamed to mutt_adv_mktemp so I only have to change where it's
68 * called, and not all possible cases.
70 void mutt_adv_mktemp (const char* dir, char *s, size_t l)
72 char buf[_POSIX_PATH_MAX];
73 char tmp[_POSIX_PATH_MAX];
78 m_strcpy(buf, sizeof(buf), m_strisempty(dir) ? NONULL(Tempdir) : dir);
79 mutt_expand_path (buf, sizeof (buf));
81 snprintf (s, l, "%s/muttXXXXXX", buf);
85 m_strcpy(tmp, sizeof(tmp), s);
86 mutt_sanitize_filename (tmp, 1);
87 snprintf (s, l, "%s/%s", buf, tmp);
88 if (lstat (s, &sb) == -1 && errno == ENOENT)
90 if ((period = strrchr (tmp, '.')) != NULL)
92 snprintf (s, l, "%s/%s.XXXXXX", buf, tmp);
97 m_strcpy(s + sl, l - sl, period);
102 /* create a send-mode duplicate from a receive-mode body */
104 int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
106 char tmp[_POSIX_PATH_MAX];
109 PARAMETER *par, **ppar;
115 m_strcpy(tmp, sizeof(tmp), src->filename);
122 mutt_adv_mktemp (NULL, tmp, sizeof (tmp));
123 if (mutt_save_attachment (fp, src, tmp, 0, NULL) == -1)
126 *tgt = mutt_new_body ();
129 memcpy (b, src, sizeof (BODY));
133 b->filename = m_strdup(tmp);
134 b->use_disp = use_disp;
137 if (mutt_is_text_part (b))
140 b->xtype = m_strdup(b->xtype);
141 b->subtype = m_strdup(b->subtype);
142 b->form_name = m_strdup(b->form_name);
143 b->filename = m_strdup(b->filename);
144 b->d_filename = m_strdup(b->d_filename);
145 b->description = m_strdup(b->description);
148 * we don't seem to need the HEADER structure currently.
149 * XXX - this may change in the future
155 /* copy parameters */
156 for (par = b->parameter, ppar = &b->parameter; par;
157 ppar = &(*ppar)->next, par = par->next) {
158 *ppar = parameter_new();
159 (*ppar)->attribute = m_strdup(par->attribute);
160 (*ppar)->value = m_strdup(par->value);
163 mutt_stamp_attachment (b);
170 void mutt_free_body (BODY ** p)
179 parameter_list_wipe(&b->parameter);
180 if (b->unlink && b->filename) {
181 debug_print (1, ("unlinking %s.\n", b->filename));
182 unlink (b->filename);
184 else if (b->filename)
185 debug_print (1, ("not unlinking %s.\n", b->filename));
187 p_delete(&b->filename);
188 p_delete(&b->content);
190 p_delete(&b->subtype);
191 p_delete(&b->description);
192 p_delete(&b->form_name);
195 /* Don't free twice (b->hdr->content = b->parts) */
196 b->hdr->content = NULL;
197 header_delete(&b->hdr);
201 mutt_free_body (&b->parts);
209 HEADER *mutt_dup_header (HEADER * h)
214 memcpy (hnew, h, sizeof (HEADER));
218 /* returns true if the header contained in "s" is in list "t" */
219 int mutt_matches_ignore (const char *s, string_list_t * t)
221 for (; t; t = t->next) {
222 if (!ascii_strncasecmp (s, t->data, m_strlen(t->data))
229 /* prepend the path part of *path to *lnk */
230 void mutt_expand_link (char *newpath, const char *path, const char *lnk)
232 const char *lb = NULL;
235 /* lnk is full path */
237 m_strcpy(newpath, _POSIX_PATH_MAX, lnk);
241 if ((lb = strrchr (path, '/')) == NULL) {
243 m_strcpy(newpath, _POSIX_PATH_MAX, lnk);
248 memcpy (newpath, path, len);
249 m_strcpy(newpath + len, _POSIX_PATH_MAX - len, lnk);
252 char *mutt_expand_path (char *s, size_t slen)
254 return _mutt_expand_path (s, slen, 0);
257 char *_mutt_expand_path (char *s, size_t slen, int rx)
259 char p[_POSIX_PATH_MAX] = "";
260 char q[_POSIX_PATH_MAX] = "";
261 char tmp[_POSIX_PATH_MAX];
264 const char *tail = "";
274 if (*(s + 1) == '/' || *(s + 1) == 0) {
275 m_strcpy(p, sizeof(p), NONULL(Homedir));
281 if ((t = strchr (s + 1, '/')))
284 if ((pw = getpwnam (s + 1))) {
285 m_strcpy(p, sizeof(p), pw->pw_dir);
294 /* user not found! */
307 /* if folder = imap[s]://host/: don't append slash */
308 if (imap_is_magic (NONULL (Maildir), NULL) == M_IMAP &&
309 Maildir[m_strlen(Maildir) - 1] == '/')
310 m_strcpy(p, sizeof(p), NONULL(Maildir));
312 snprintf (p, sizeof (p), "%s/", NONULL (Maildir));
318 /* elm compatibility, @ expands alias to user name */
325 if ((alias = alias_lookup(Aliases, s + 1))) {
327 h->env = envelope_new();
328 h->env->from = h->env->to = alias;
329 mutt_default_save (p, sizeof (p), h);
330 h->env->from = h->env->to = NULL;
332 /* Avoid infinite recursion if the resulting folder starts with '@' */
343 m_strcpy(p, sizeof(p), NONULL(Inbox));
350 m_strcpy(p, sizeof(p), NONULL(Outbox));
357 if (*(s + 1) == '!') {
358 m_strcpy(p, sizeof(p), NONULL(LastFolder));
362 m_strcpy(p, sizeof(p), NONULL(Spoolfile));
370 m_strcpy(p, sizeof(p), NONULL(LastFolder));
377 m_strcpy(p, sizeof(p), NONULL(CurrentFolder));
389 if (rx && *p && !recurse) {
390 rx_sanitize_string (q, sizeof (q), p);
391 snprintf (tmp, sizeof (tmp), "%s%s", q, tail);
394 snprintf (tmp, sizeof (tmp), "%s%s", p, tail);
396 m_strcpy(s, slen, tmp);
403 char *mutt_get_parameter (const char *s, PARAMETER * p)
405 for (; p; p = p->next)
406 if (ascii_strcasecmp (s, p->attribute) == 0)
412 void mutt_set_parameter (const char *attribute, const char *value,
418 mutt_delete_parameter (attribute, p);
422 for (q = *p; q; q = q->next) {
423 if (ascii_strcasecmp (attribute, q->attribute) == 0) {
424 m_strreplace(&q->value, value);
430 q->attribute = m_strdup(attribute);
431 q->value = m_strdup(value);
436 void mutt_delete_parameter (const char *attribute, PARAMETER ** p)
440 for (q = *p; q; p = &q->next, q = q->next) {
441 if (ascii_strcasecmp (attribute, q->attribute) == 0) {
444 parameter_list_wipe(&q);
450 /* returns 1 if Mutt can't display this type of data, 0 otherwise */
451 int mutt_needs_mailcap (BODY * m)
456 if (!ascii_strcasecmp ("plain", m->subtype) ||
457 !ascii_strcasecmp ("rfc822-headers", m->subtype) ||
458 !ascii_strcasecmp ("enriched", m->subtype))
462 case TYPEAPPLICATION:
463 if (mutt_is_application_pgp (m))
465 if (mutt_is_application_smime (m))
477 int mutt_is_text_part (BODY * b)
480 char *s = b->subtype;
482 if (mutt_is_application_pgp (b))
488 if (t == TYPEMESSAGE) {
489 if (!ascii_strcasecmp ("delivery-status", s))
493 if (t == TYPEAPPLICATION) {
494 if (!ascii_strcasecmp ("pgp-keys", s))
501 /* move all the headers from extra not present in base into base */
502 void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra)
504 /* copies each existing element if necessary, and sets the element
505 * to NULL in the source so that envelope_delete doesn't leave us
506 * with dangling pointers. */
507 #define MOVE_ELEM(h) if (!base->h) { base->h = (*extra)->h; (*extra)->h = NULL; }
508 MOVE_ELEM(return_path);
515 MOVE_ELEM(mail_followup_to);
516 MOVE_ELEM(list_post);
517 MOVE_ELEM(message_id);
518 MOVE_ELEM(supersedes);
521 if (!base->refs_changed) {
522 MOVE_ELEM(references);
524 if (!base->irt_changed) {
525 MOVE_ELEM(in_reply_to);
527 /* real_subj is subordinate to subject */
528 if (!base->subject) {
529 base->subject = (*extra)->subject;
530 base->real_subj = (*extra)->real_subj;
531 (*extra)->subject = NULL;
532 (*extra)->real_subj = NULL;
534 /* spam and user headers should never be hashed, and the new envelope may
535 * have better values. Use new versions regardless. */
536 mutt_buffer_free (&base->spam);
537 string_list_wipe(&base->userhdrs);
542 envelope_delete(extra);
545 void _mutt_mktemp (char *s, const char *src, int line)
548 snprintf (s, _POSIX_PATH_MAX, "%s/madmutt-%s-%d-%d-%d-%x%x", NONULL (Tempdir),
549 NONULL (Hostname), (int) getuid (), (int) getpid (), Counter++,
550 (unsigned int) rand(), (unsigned int) rand());
551 debug_print (1, ("%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
555 /* collapse the pathname using ~ or = when possible */
556 void mutt_pretty_mailbox (char *s)
562 scheme = url_check_scheme (s);
564 if (scheme == U_IMAP || scheme == U_IMAPS) {
565 imap_pretty_mailbox (s);
569 /* if s is an url, only collapse path component */
570 if (scheme != U_UNKNOWN) {
571 p = strchr (s, ':') + 1;
572 if (!strncmp (p, "//", 2))
573 q = strchr (p + 2, '/');
575 q = strchr (p, '\0');
579 /* first attempt to collapse the pathname */
581 if (*p == '/' && p[1] == '/') {
585 else if (p[0] == '/' && p[1] == '.' && p[2] == '/') {
594 if (m_strncmp(s, Maildir, (len = m_strlen(Maildir))) == 0 &&
597 memmove (s, s + len, m_strlen(s + len) + 1);
599 else if (m_strncmp(s, Homedir, (len = m_strlen(Homedir))) == 0 &&
602 memmove (s, s + len - 1, m_strlen(s + len - 1) + 1);
606 void mutt_pretty_size (char *s, size_t len, long n)
609 m_strcpy(s, len, "0K");
610 else if (n < 10189) /* 0.1K - 9.9K */
611 snprintf (s, len, "%3.1fK", (n < 103) ? 0.1 : n / 1024.0);
612 else if (n < 1023949) { /* 10K - 999K */
613 /* 51 is magic which causes 10189/10240 to be rounded up to 10 */
614 snprintf (s, len, "%ldK", (n + 51) / 1024);
616 else if (n < 10433332) /* 1.0M - 9.9M */
617 snprintf (s, len, "%3.1fM", n / 1048576.0);
620 /* (10433332 + 52428) / 1048576 = 10 */
621 snprintf (s, len, "%ldM", (n + 52428) / 1048576);
625 void mutt_expand_file_fmt (char *dest, size_t destlen, const char *fmt,
628 char tmp[LONG_STRING];
630 mutt_quote_filename (tmp, sizeof (tmp), src);
631 mutt_expand_fmt (dest, destlen, fmt, tmp);
634 void mutt_expand_fmt (char *dest, size_t destlen, const char *fmt,
642 slen = m_strlen(src);
645 for (p = fmt, d = dest; destlen && *p; p++) {
654 m_strcpy(d, destlen + 1, src);
655 d += destlen > slen ? slen : destlen;
656 destlen -= destlen > slen ? slen : destlen;
673 if (!found && destlen > 0) {
674 m_strcat(dest, destlen, " ");
675 m_strcat(dest, destlen, src);
680 /* return 0 on success, -1 on abort, 1 on error */
681 int mutt_check_overwrite (const char *attname, const char *path,
682 char *fname, size_t flen, int *append,
686 char tmp[_POSIX_PATH_MAX];
689 m_strcpy(fname, flen, path);
690 if (access (fname, F_OK) != 0)
692 if (stat (fname, &st) != 0)
694 if (S_ISDIR (st.st_mode)) {
696 switch (mutt_multi_choice
697 (_("File is a directory, save under it? [(y)es, (n)o, (a)ll]"),
700 m_strreplace(directory, fname);
715 mutt_yesorno (_("File is a directory, save under it?"),
717 return (rc == M_NO) ? 1 : -1;
719 if (!attname || !attname[0]) {
721 if (mutt_get_field (_("File under directory: "), tmp, sizeof (tmp),
722 M_FILE | M_CLEAR) != 0 || !tmp[0])
724 mutt_concat_path(fname, flen, path, tmp);
727 mutt_concat_path(fname, flen, path, mutt_basename(attname));
730 if (*append == 0 && access (fname, F_OK) == 0) {
731 switch (mutt_multi_choice
732 (_("File exists, (o)verwrite, (a)ppend, or (c)ancel?"), _("oac")))
740 *append = M_SAVE_APPEND;
742 case 1: /* overwrite */
743 *append = M_SAVE_OVERWRITE;
750 void mutt_save_path (char *d, size_t dsize, address_t * a)
752 if (a && a->mailbox) {
753 m_strcpy(d, dsize, a->mailbox);
754 if (!option (OPTSAVEADDRESS)) {
757 if ((p = strpbrk (d, "%@")))
766 void mutt_safe_path (char *s, size_t l, address_t * a)
770 mutt_save_path (s, l, a);
772 if (*p == '/' || ISSPACE (*p) || !IsPrint ((unsigned char) *p))
776 /* counts how many characters in s can be skipped while none of the
777 * characters of c appears */
778 int mutt_skipchars (const char *s, const char *c)
784 register const char *t = c;
794 return (m_strlen(p));
797 void mutt_FormatString (char *dest, /* output buffer */
798 ssize_t destlen, /* output buffer len */
799 const char *src, /* template string */
800 format_t * callback, /* callback for processing */
801 unsigned long data, /* callback data */
803 { /* callback flags */
804 char prefix[SHORT_STRING], buf[LONG_STRING], *cp, *wptr = dest, ch;
805 char ifstring[SHORT_STRING], elsestring[SHORT_STRING];
806 ssize_t wlen, wid, count, col, len;
809 destlen--; /* save room for the terminal \0 */
810 wlen = (flags & M_FORMAT_ARROWCURSOR && option (OPTARROWCURSOR)) ? 3 : 0;
813 while (*src && wlen < destlen) {
824 flags |= M_FORMAT_OPTIONAL;
828 flags &= ~M_FORMAT_OPTIONAL;
830 /* eat the format string */
833 while (count < ssizeof (prefix) &&
834 (isdigit ((unsigned char) *src) || *src == '.' || *src == '-'))
843 break; /* bad format */
845 ch = *src++; /* save the character to switch on */
847 if (flags & M_FORMAT_OPTIONAL) {
849 break; /* bad format */
852 /* eat the `if' part of the string */
855 while (count < ssizeof (ifstring) && *src && *src != '?'
862 /* eat the `else' part of the string (optional) */
864 src++; /* skip the & */
867 while (count < ssizeof (elsestring) && *src && *src != '?') {
874 break; /* bad format */
876 src++; /* move past the trailing `?' */
879 /* handle generic cases first */
881 /* right justify to EOL */
882 ch = *src++; /* pad char */
883 /* calculate space left on line. if we've already written more data
884 than will fit on the line, ignore the rest of the line */
885 if (DrawFullLine || option (OPTSTATUSONTOP))
886 count = (COLS < destlen ? COLS : destlen);
888 count = ((COLS - SW) < destlen ? (COLS - SW) : destlen);
890 count -= col; /* how many columns left on this line */
891 mutt_FormatString (buf, sizeof (buf), src, callback, data, flags);
894 count -= wid; /* how many chars to pad */
895 memset (wptr, ch, count);
899 if (wid + wlen > destlen)
900 len = destlen - wlen;
903 memcpy (wptr, buf, len);
906 col += mutt_strwidth (buf);
908 break; /* skip rest of input */
910 else if (ch == '|') {
915 if (destlen > wlen) {
916 count = destlen - wlen;
917 memset (wptr, ch, count);
920 break; /* skip rest of input */
926 while (ch == '_' || ch == ':') {
935 /* use callback function to handle this case */
937 callback (buf, sizeof (buf), ch, src, prefix, ifstring, elsestring,
950 if ((len = m_strlen(buf)) + wlen > destlen)
951 len = (destlen - wlen > 0) ? (destlen - wlen) : 0;
953 memcpy (wptr, buf, len);
956 col += mutt_strwidth (buf);
959 else if (*src == '\\') {
988 unsigned int bar = mutt_skipchars (src, "%\\");
989 char *bar2 = p_dupstr(src, bar);
995 col += mutt_strwidth (bar2);
1002 if (flags & M_FORMAT_MAKEPRINT) {
1003 /* Make sure that the string is printable by changing all non-printable
1004 chars to dots, or spaces for non-printable whitespace */
1005 for (cp = dest; *cp; cp++)
1006 if (!IsPrint (*cp) && !((flags & M_FORMAT_TREE) && (*cp <= M_TREE_MAX)))
1007 *cp = isspace ((unsigned char) *cp) ? ' ' : '.';
1012 /* This function allows the user to specify a command to read stdout from in
1013 place of a normal file. If the last character in the string is a pipe (|),
1014 then we assume it is a commmand to run instead of a normal file. */
1015 FILE *mutt_open_read (const char *path, pid_t * thepid)
1017 int len = m_strlen(path);
1020 if (path[len - 1] == '|') {
1021 char *s = m_strdup(path);
1023 /* read from a pipe */
1027 *thepid = mutt_create_filter (s, NULL, &f, NULL);
1030 f = fopen (path, "r");
1039 /* returns 0 if OK to proceed, -1 to abort, 1 to retry */
1040 int mutt_save_confirm (const char *s, struct stat *st)
1042 char tmp[_POSIX_PATH_MAX];
1047 magic = mx_get_magic (s);
1049 if (magic == M_POP) {
1050 mutt_error _("Can't save message to POP mailbox.");
1056 if (magic == M_NNTP) {
1057 mutt_error _("Can't save message to newsserver.");
1063 if (magic > 0 && !mx_access (s, W_OK)) {
1064 if (option (OPTCONFIRMAPPEND) &&
1065 (!TrashPath || (m_strcmp(s, TrashPath) != 0))) {
1066 /* if we're appending to the trash, there's no point in asking */
1067 snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s);
1068 if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
1075 if (stat (s, st) != -1) {
1077 mutt_error (_("%s is not a mailbox!"), s);
1082 if (magic != M_IMAP)
1087 if (errno == ENOENT) {
1088 if (option (OPTCONFIRMCREATE)) {
1089 snprintf (tmp, sizeof (tmp), _("Create %s?"), s);
1090 if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
1103 CLEARLINE (LINES - 1);
1107 void mutt_display_sanitize (char *s)
1115 void mutt_sleep (short s)
1123 /* Decrease a file's modification time by 1 second */
1124 time_t mutt_decrease_mtime (const char *f, struct stat *st)
1126 struct utimbuf utim;
1131 if (stat (f, &_st) == -1)
1136 if ((mtime = st->st_mtime) == time (NULL)) {
1138 utim.actime = mtime;
1139 utim.modtime = mtime;
1146 /* sets mtime of 'to' to mtime of 'from' */
1147 void mutt_set_mtime (const char* from, const char* to) {
1148 struct utimbuf utim;
1151 if (stat (from, &st) != -1) {
1152 utim.actime = st.st_mtime;
1153 utim.modtime = st.st_mtime;
1158 const char *mutt_make_version (int full)
1160 static char vstring[STRING];
1163 snprintf (vstring, sizeof (vstring),
1164 "Madmutt/%s-r%s (based on Mutt 1.5.11)",
1165 MUTT_VERSION, MUTT_REVISION);
1167 snprintf (vstring, sizeof (vstring), "Madmutt/%s-%s",
1168 MUTT_VERSION, MUTT_REVISION);
1172 void mutt_free_spam_list (SPAM_LIST ** list)
1180 *list = (*list)->next;
1182 p_delete(&p->template);
1187 int mutt_match_spam_list (const char *s, SPAM_LIST * l, char *text, int x)
1189 static regmatch_t *pmatch = NULL;
1190 static int nmatch = 0;
1199 for (; l; l = l->next) {
1200 /* If this pattern needs more matches, expand pmatch. */
1201 if (l->nmatch > nmatch) {
1202 p_realloc(&pmatch, l->nmatch);
1206 /* Does this pattern match? */
1208 (l->rx->rx, s, (size_t) l->nmatch, (regmatch_t *) pmatch,
1210 debug_print (5, ("%s matches %s\n%d subst", s, l->rx->pattern, l->rx->rx->re_nsub));
1212 /* Copy template into text, with substitutions. */
1213 for (p = l->template; *p;) {
1215 n = atoi (++p); /* find pmatch index */
1216 while (isdigit ((unsigned char) *p))
1217 ++p; /* skip subst token */
1218 for (i = pmatch[n].rm_so; (i < pmatch[n].rm_eo) && (tlen < x); i++)
1219 text[tlen++] = s[i];
1222 text[tlen++] = *p++;
1226 debug_print (5, ("\"%s\"\n", text));
1234 int mutt_cmp_header (const HEADER * h1, const HEADER * h2) {
1236 if (h1->received != h2->received ||
1237 h1->date_sent != h2->date_sent ||
1238 h1->content->length != h2->content->length ||
1239 h1->lines != h2->lines ||
1240 h1->zhours != h2->zhours ||
1241 h1->zminutes != h2->zminutes ||
1242 h1->zoccident != h2->zoccident ||
1243 h1->mime != h2->mime ||
1244 !mutt_cmp_env (h1->env, h2->env) ||
1245 !mutt_cmp_body (h1->content, h2->content))
1251 if (h1 == NULL && h2 == NULL)
1258 /* return 1 if address lists are strictly identical */
1259 int mutt_cmp_addr (const address_t * a, const address_t * b)
1262 if (m_strcmp(a->mailbox, b->mailbox) ||
1263 m_strcmp(a->personal, b->personal))
1275 int mutt_cmp_list (const string_list_t * a, const string_list_t * b)
1278 if (m_strcmp(a->data, b->data))
1290 int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2)
1293 if (m_strcmp(e1->message_id, e2->message_id) ||
1294 m_strcmp(e1->subject, e2->subject) ||
1295 !mutt_cmp_list (e1->references, e2->references) ||
1296 !mutt_cmp_addr (e1->from, e2->from) ||
1297 !mutt_cmp_addr (e1->sender, e2->sender) ||
1298 !mutt_cmp_addr (e1->reply_to, e2->reply_to) ||
1299 !mutt_cmp_addr (e1->to, e2->to) ||
1300 !mutt_cmp_addr (e1->cc, e2->cc) ||
1301 !mutt_cmp_addr (e1->return_path, e2->return_path))
1307 if (e1 == NULL && e2 == NULL)
1314 int mutt_cmp_param (const PARAMETER * p1, const PARAMETER * p2)
1317 if (m_strcmp(p1->attribute, p2->attribute) ||
1318 m_strcmp(p1->value, p2->value))
1330 int mutt_cmp_body (const BODY * b1, const BODY * b2)
1332 if (b1->type != b2->type ||
1333 b1->encoding != b2->encoding ||
1334 m_strcmp(b1->subtype, b2->subtype) ||
1335 m_strcmp(b1->description, b2->description) ||
1336 !mutt_cmp_param (b1->parameter, b2->parameter) ||
1337 b1->length != b2->length)