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.
23 #include <sys/types.h>
29 #include <lib-lib/mem.h>
30 #include <lib-lib/ascii.h>
31 #include <lib-lib/str.h>
32 #include <lib-lib/macros.h>
33 #include <lib-lib/buffer.h>
34 #include <lib-lib/file.h>
35 #include <lib-lib/url.h>
37 #include <lib-mime/mime.h>
39 #include <lib-ui/curses.h>
40 #include <lib-ui/enter.h>
49 #include <imap/imap.h>
50 #include <imap/mx_imap.h>
52 #include <lib-crypt/crypt.h>
54 #define SW (option(OPTMBOXPANE)?SidebarWidth:0)
56 BODY *mutt_new_body (void)
58 BODY *p = p_new(BODY, 1);
60 p->disposition = DISPATTACH;
66 /* Modified by blong to accept a "suggestion" for file name. If
67 * that file exists, then construct one with unique name but
68 * keep any extension. This might fail, I guess.
69 * Renamed to mutt_adv_mktemp so I only have to change where it's
70 * called, and not all possible cases.
72 void mutt_adv_mktemp (const char* dir, char *s, ssize_t l)
74 char buf[_POSIX_PATH_MAX];
75 char tmp[_POSIX_PATH_MAX];
80 m_strcpy(buf, sizeof(buf), m_strisempty(dir) ? NONULL(Tempdir) : dir);
81 mutt_expand_path (buf, sizeof (buf));
83 snprintf (s, l, "%s/muttXXXXXX", buf);
87 m_strcpy(tmp, sizeof(tmp), s);
88 mutt_sanitize_filename (tmp, 1);
89 snprintf (s, l, "%s/%s", buf, tmp);
90 if (lstat (s, &sb) == -1 && errno == ENOENT)
92 if ((period = strrchr (tmp, '.')) != NULL)
94 snprintf (s, l, "%s/%s.XXXXXX", buf, tmp);
99 m_strcpy(s + sl, l - sl, period);
104 /* create a send-mode duplicate from a receive-mode body */
106 int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
108 char tmp[_POSIX_PATH_MAX];
111 PARAMETER *par, **ppar;
117 m_strcpy(tmp, sizeof(tmp), src->filename);
124 mutt_adv_mktemp (NULL, tmp, sizeof (tmp));
125 if (mutt_save_attachment (fp, src, tmp, 0, NULL) == -1)
128 *tgt = mutt_new_body ();
131 memcpy (b, src, sizeof (BODY));
135 b->filename = m_strdup(tmp);
136 b->use_disp = use_disp;
139 if (mutt_is_text_part (b))
142 b->xtype = m_strdup(b->xtype);
143 b->subtype = m_strdup(b->subtype);
144 b->form_name = m_strdup(b->form_name);
145 b->filename = m_strdup(b->filename);
146 b->d_filename = m_strdup(b->d_filename);
147 b->description = m_strdup(b->description);
150 * we don't seem to need the HEADER structure currently.
151 * XXX - this may change in the future
157 /* copy parameters */
158 for (par = b->parameter, ppar = &b->parameter; par;
159 ppar = &(*ppar)->next, par = par->next) {
160 *ppar = parameter_new();
161 (*ppar)->attribute = m_strdup(par->attribute);
162 (*ppar)->value = m_strdup(par->value);
165 mutt_stamp_attachment (b);
171 static void body_wipe(BODY *b)
174 parameter_list_wipe(&b->parameter);
176 if (b->unlink && b->filename) {
177 unlink (b->filename);
180 p_delete(&b->filename);
181 p_delete(&b->content);
183 p_delete(&b->subtype);
184 p_delete(&b->description);
185 p_delete(&b->form_name);
188 /* Don't free twice (b->hdr->content = b->parts) */
189 b->hdr->content = NULL;
190 header_delete(&b->hdr);
194 mutt_free_body(&b->parts);
197 DO_DELETE(BODY, body);
199 void mutt_free_body(BODY **p)
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, ssize_t slen)
254 return _mutt_expand_path (s, slen, 0);
257 char *_mutt_expand_path (char *s, ssize_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 */
326 if ((alias = alias_lookup(s + 1))) {
328 h->env = envelope_new();
329 h->env->from = h->env->to = alias;
330 mutt_default_save (p, sizeof (p), h);
331 h->env->from = h->env->to = NULL;
333 /* Avoid infinite recursion if the resulting folder starts with '@' */
344 m_strcpy(p, sizeof(p), NONULL(Inbox));
351 m_strcpy(p, sizeof(p), NONULL(Outbox));
358 if (*(s + 1) == '!') {
359 m_strcpy(p, sizeof(p), NONULL(LastFolder));
363 m_strcpy(p, sizeof(p), NONULL(Spoolfile));
371 m_strcpy(p, sizeof(p), NONULL(LastFolder));
378 m_strcpy(p, sizeof(p), NONULL(CurrentFolder));
390 if (rx && *p && !recurse) {
391 rx_sanitize_string (q, sizeof (q), p);
392 snprintf (tmp, sizeof (tmp), "%s%s", q, tail);
395 snprintf (tmp, sizeof (tmp), "%s%s", p, tail);
397 m_strcpy(s, slen, tmp);
404 void mutt_set_parameter (const char *attribute, const char *value,
410 mutt_delete_parameter (attribute, p);
414 for (q = *p; q; q = q->next) {
415 if (ascii_strcasecmp (attribute, q->attribute) == 0) {
416 m_strreplace(&q->value, value);
422 q->attribute = m_strdup(attribute);
423 q->value = m_strdup(value);
424 parameter_list_push(p, q);
427 void mutt_delete_parameter (const char *attribute, PARAMETER ** p)
430 if (!ascii_strcasecmp(attribute, (*p)->attribute)) {
431 PARAMETER *q = parameter_list_pop(p);
432 parameter_delete(&q);
440 /* returns 1 if Mutt can't display this type of data, 0 otherwise */
441 int mutt_needs_mailcap (BODY * m)
446 if (!ascii_strcasecmp ("plain", m->subtype) ||
447 !ascii_strcasecmp ("rfc822-headers", m->subtype) ||
448 !ascii_strcasecmp ("enriched", m->subtype))
452 case TYPEAPPLICATION:
453 if (mutt_is_application_pgp (m))
455 if (mutt_is_application_smime (m))
467 int mutt_is_text_part (BODY * b)
470 char *s = b->subtype;
472 if (mutt_is_application_pgp (b))
478 if (t == TYPEMESSAGE) {
479 if (!ascii_strcasecmp ("delivery-status", s))
483 if (t == TYPEAPPLICATION) {
484 if (!ascii_strcasecmp ("pgp-keys", s))
491 /* move all the headers from extra not present in base into base */
492 void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra)
494 /* copies each existing element if necessary, and sets the element
495 * to NULL in the source so that envelope_delete doesn't leave us
496 * with dangling pointers. */
497 #define MOVE_ELEM(h) if (!base->h) { base->h = (*extra)->h; (*extra)->h = NULL; }
498 MOVE_ELEM(return_path);
505 MOVE_ELEM(mail_followup_to);
506 MOVE_ELEM(list_post);
507 MOVE_ELEM(message_id);
508 MOVE_ELEM(supersedes);
511 if (!base->refs_changed) {
512 MOVE_ELEM(references);
514 if (!base->irt_changed) {
515 MOVE_ELEM(in_reply_to);
517 /* real_subj is subordinate to subject */
518 if (!base->subject) {
519 base->subject = (*extra)->subject;
520 base->real_subj = (*extra)->real_subj;
521 (*extra)->subject = NULL;
522 (*extra)->real_subj = NULL;
524 /* spam and user headers should never be hashed, and the new envelope may
525 * have better values. Use new versions regardless. */
526 mutt_buffer_free (&base->spam);
527 string_list_wipe(&base->userhdrs);
532 envelope_delete(extra);
535 void _mutt_mktemp (char *s, const char *src, int line)
538 snprintf (s, _POSIX_PATH_MAX, "%s/madmutt-%s-%d-%d-%d-%x%x", NONULL (Tempdir),
539 NONULL (Hostname), (int) getuid (), (int) getpid (), Counter++,
540 (unsigned int) rand(), (unsigned int) rand());
544 /* collapse the pathname using ~ or = when possible */
545 void mutt_pretty_mailbox (char *s)
551 scheme = url_check_scheme (s);
553 if (scheme == U_IMAP || scheme == U_IMAPS) {
554 imap_pretty_mailbox (s);
558 /* if s is an url, only collapse path component */
559 if (scheme != U_UNKNOWN) {
560 p = strchr (s, ':') + 1;
561 if (!strncmp (p, "//", 2))
562 q = strchr (p + 2, '/');
564 q = strchr (p, '\0');
568 /* first attempt to collapse the pathname */
570 if (*p == '/' && p[1] == '/') {
574 else if (p[0] == '/' && p[1] == '.' && p[2] == '/') {
583 if (m_strncmp(s, Maildir, (len = m_strlen(Maildir))) == 0 &&
586 memmove (s, s + len, m_strlen(s + len) + 1);
588 else if (m_strncmp(s, Homedir, (len = m_strlen(Homedir))) == 0 &&
591 memmove (s, s + len - 1, m_strlen(s + len - 1) + 1);
595 void mutt_pretty_size (char *s, ssize_t len, long n)
598 m_strcpy(s, len, "0K");
599 else if (n < 10189) /* 0.1K - 9.9K */
600 snprintf (s, len, "%3.1fK", (n < 103) ? 0.1 : n / 1024.0);
601 else if (n < 1023949) { /* 10K - 999K */
602 /* 51 is magic which causes 10189/10240 to be rounded up to 10 */
603 snprintf (s, len, "%ldK", (n + 51) / 1024);
605 else if (n < 10433332) /* 1.0M - 9.9M */
606 snprintf (s, len, "%3.1fM", n / 1048576.0);
609 /* (10433332 + 52428) / 1048576 = 10 */
610 snprintf (s, len, "%ldM", (n + 52428) / 1048576);
614 void mutt_expand_file_fmt (char *dest, ssize_t destlen, const char *fmt,
617 char tmp[LONG_STRING];
619 mutt_quote_filename (tmp, sizeof (tmp), src);
620 mutt_expand_fmt (dest, destlen, fmt, tmp);
623 void mutt_expand_fmt (char *dest, ssize_t destlen, const char *fmt,
631 slen = m_strlen(src);
634 for (p = fmt, d = dest; destlen && *p; p++) {
643 m_strcpy(d, destlen + 1, src);
644 d += destlen > slen ? slen : destlen;
645 destlen -= destlen > slen ? slen : destlen;
662 if (!found && destlen > 0) {
663 m_strcat(dest, destlen, " ");
664 m_strcat(dest, destlen, src);
669 /* return 0 on success, -1 on abort, 1 on error */
670 int mutt_check_overwrite (const char *attname, const char *path,
671 char *fname, ssize_t flen, int *append,
675 char tmp[_POSIX_PATH_MAX];
678 m_strcpy(fname, flen, path);
679 if (access (fname, F_OK) != 0)
681 if (stat (fname, &st) != 0)
683 if (S_ISDIR (st.st_mode)) {
685 switch (mutt_multi_choice
686 (_("File is a directory, save under it? [(y)es, (n)o, (a)ll]"),
689 m_strreplace(directory, fname);
704 mutt_yesorno (_("File is a directory, save under it?"),
706 return (rc == M_NO) ? 1 : -1;
708 if (!attname || !attname[0]) {
710 if (mutt_get_field (_("File under directory: "), tmp, sizeof (tmp),
711 M_FILE | M_CLEAR) != 0 || !tmp[0])
713 mutt_concat_path(fname, flen, path, tmp);
716 mutt_concat_path(fname, flen, path, mutt_basename(attname));
719 if (*append == 0 && access (fname, F_OK) == 0) {
720 switch (mutt_multi_choice
721 (_("File exists, (o)verwrite, (a)ppend, or (c)ancel?"), _("oac")))
729 *append = M_SAVE_APPEND;
731 case 1: /* overwrite */
732 *append = M_SAVE_OVERWRITE;
739 void mutt_save_path (char *d, ssize_t dsize, address_t * a)
741 if (a && a->mailbox) {
742 m_strcpy(d, dsize, a->mailbox);
743 if (!option (OPTSAVEADDRESS)) {
746 if ((p = strpbrk (d, "%@")))
755 void mutt_safe_path (char *s, ssize_t l, address_t * a)
759 mutt_save_path (s, l, a);
761 if (*p == '/' || ISSPACE (*p) || !IsPrint ((unsigned char) *p))
765 /* counts how many characters in s can be skipped while none of the
766 * characters of c appears */
767 int mutt_skipchars (const char *s, const char *c)
773 register const char *t = c;
783 return (m_strlen(p));
786 void mutt_FormatString (char *dest, /* output buffer */
787 ssize_t destlen, /* output buffer len */
788 const char *src, /* template string */
789 format_t * callback, /* callback for processing */
790 unsigned long data, /* callback data */
792 { /* callback flags */
793 char prefix[SHORT_STRING], buf[LONG_STRING], *cp, *wptr = dest, ch;
794 char ifstring[SHORT_STRING], elsestring[SHORT_STRING];
795 ssize_t wlen, wid, count, col, len;
798 destlen--; /* save room for the terminal \0 */
799 wlen = (flags & M_FORMAT_ARROWCURSOR && option (OPTARROWCURSOR)) ? 3 : 0;
802 while (*src && wlen < destlen) {
813 flags |= M_FORMAT_OPTIONAL;
817 flags &= ~M_FORMAT_OPTIONAL;
819 /* eat the format string */
822 while (count < ssizeof (prefix) &&
823 (isdigit ((unsigned char) *src) || *src == '.' || *src == '-'))
832 break; /* bad format */
834 ch = *src++; /* save the character to switch on */
836 if (flags & M_FORMAT_OPTIONAL) {
838 break; /* bad format */
841 /* eat the `if' part of the string */
844 while (count < ssizeof (ifstring) && *src && *src != '?'
851 /* eat the `else' part of the string (optional) */
853 src++; /* skip the & */
856 while (count < ssizeof (elsestring) && *src && *src != '?') {
863 break; /* bad format */
865 src++; /* move past the trailing `?' */
868 /* handle generic cases first */
870 /* right justify to EOL */
871 ch = *src++; /* pad char */
872 /* calculate space left on line. if we've already written more data
873 than will fit on the line, ignore the rest of the line */
874 if (DrawFullLine || option (OPTSTATUSONTOP))
875 count = (COLS < destlen ? COLS : destlen);
877 count = ((COLS - SW) < destlen ? (COLS - SW) : destlen);
879 count -= col; /* how many columns left on this line */
880 mutt_FormatString (buf, sizeof (buf), src, callback, data, flags);
883 count -= wid; /* how many chars to pad */
884 memset (wptr, ch, count);
888 if (wid + wlen > destlen)
889 len = destlen - wlen;
892 memcpy (wptr, buf, len);
895 col += mutt_strwidth (buf);
897 break; /* skip rest of input */
899 else if (ch == '|') {
904 if (destlen > wlen) {
905 count = destlen - wlen;
906 memset (wptr, ch, count);
909 break; /* skip rest of input */
915 while (ch == '_' || ch == ':') {
924 /* use callback function to handle this case */
926 callback (buf, sizeof (buf), ch, src, prefix, ifstring, elsestring,
939 if ((len = m_strlen(buf)) + wlen > destlen)
940 len = (destlen - wlen > 0) ? (destlen - wlen) : 0;
942 memcpy (wptr, buf, len);
945 col += mutt_strwidth (buf);
948 else if (*src == '\\') {
977 unsigned int bar = mutt_skipchars (src, "%\\");
978 char *bar2 = p_dupstr(src, bar);
984 col += mutt_strwidth (bar2);
991 if (flags & M_FORMAT_MAKEPRINT) {
992 /* Make sure that the string is printable by changing all non-printable
993 chars to dots, or spaces for non-printable whitespace */
994 for (cp = dest; *cp; cp++)
995 if (!IsPrint (*cp) && !((flags & M_FORMAT_TREE) && (*cp <= M_TREE_MAX)))
996 *cp = isspace ((unsigned char) *cp) ? ' ' : '.';
1001 /* This function allows the user to specify a command to read stdout from in
1002 place of a normal file. If the last character in the string is a pipe (|),
1003 then we assume it is a commmand to run instead of a normal file. */
1004 FILE *mutt_open_read (const char *path, pid_t * thepid)
1006 int len = m_strlen(path);
1009 if (path[len - 1] == '|') {
1010 char *s = m_strdup(path);
1012 /* read from a pipe */
1016 *thepid = mutt_create_filter (s, NULL, &f, NULL);
1019 f = fopen (path, "r");
1028 /* returns 0 if OK to proceed, -1 to abort, 1 to retry */
1029 int mutt_save_confirm (const char *s, struct stat *st)
1031 char tmp[_POSIX_PATH_MAX];
1036 magic = mx_get_magic (s);
1038 if (magic == M_POP) {
1039 mutt_error _("Can't save message to POP mailbox.");
1045 if (magic == M_NNTP) {
1046 mutt_error _("Can't save message to newsserver.");
1052 if (magic > 0 && !mx_access (s, W_OK)) {
1053 if (option (OPTCONFIRMAPPEND) &&
1054 (!TrashPath || (m_strcmp(s, TrashPath) != 0))) {
1055 /* if we're appending to the trash, there's no point in asking */
1056 snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s);
1057 if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
1064 if (stat (s, st) != -1) {
1066 mutt_error (_("%s is not a mailbox!"), s);
1071 if (magic != M_IMAP)
1076 if (errno == ENOENT) {
1077 if (option (OPTCONFIRMCREATE)) {
1078 snprintf (tmp, sizeof (tmp), _("Create %s?"), s);
1079 if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
1092 CLEARLINE (LINES - 1);
1096 void mutt_display_sanitize (char *s)
1104 void mutt_sleep (short s)
1112 /* Decrease a file's modification time by 1 second */
1113 time_t mutt_decrease_mtime (const char *f, struct stat *st)
1115 struct utimbuf utim;
1120 if (stat (f, &_st) == -1)
1125 if ((mtime = st->st_mtime) == time (NULL)) {
1127 utim.actime = mtime;
1128 utim.modtime = mtime;
1135 /* sets mtime of 'to' to mtime of 'from' */
1136 void mutt_set_mtime (const char* from, const char* to) {
1137 struct utimbuf utim;
1140 if (stat (from, &st) != -1) {
1141 utim.actime = st.st_mtime;
1142 utim.modtime = st.st_mtime;
1147 const char *mutt_make_version (int full)
1149 static char vstring[STRING];
1152 snprintf (vstring, sizeof (vstring),
1153 "Madmutt/%s-r%s (based on Mutt 1.5.11)",
1154 MUTT_VERSION, MUTT_REVISION);
1156 snprintf (vstring, sizeof (vstring), "Madmutt/%s-%s",
1157 MUTT_VERSION, MUTT_REVISION);
1161 void mutt_free_spam_list (SPAM_LIST ** list)
1169 *list = (*list)->next;
1171 p_delete(&p->template);
1176 int mutt_match_spam_list (const char *s, SPAM_LIST * l, char *text, int x)
1178 static regmatch_t *pmatch = NULL;
1179 static int nmatch = 0;
1188 for (; l; l = l->next) {
1189 /* If this pattern needs more matches, expand pmatch. */
1190 if (l->nmatch > nmatch) {
1191 p_realloc(&pmatch, l->nmatch);
1195 /* Does this pattern match? */
1196 if (regexec(l->rx->rx, s, l->nmatch, (regmatch_t *)pmatch, (int) 0) == 0)
1198 /* Copy template into text, with substitutions. */
1199 for (p = l->template; *p;) {
1201 n = atoi (++p); /* find pmatch index */
1202 while (isdigit ((unsigned char) *p))
1203 ++p; /* skip subst token */
1204 for (i = pmatch[n].rm_so; (i < pmatch[n].rm_eo) && (tlen < x); i++)
1205 text[tlen++] = s[i];
1208 text[tlen++] = *p++;
1219 int mutt_cmp_header (const HEADER * h1, const HEADER * h2) {
1221 if (h1->received != h2->received ||
1222 h1->date_sent != h2->date_sent ||
1223 h1->content->length != h2->content->length ||
1224 h1->lines != h2->lines ||
1225 h1->zhours != h2->zhours ||
1226 h1->zminutes != h2->zminutes ||
1227 h1->zoccident != h2->zoccident ||
1228 h1->mime != h2->mime ||
1229 !mutt_cmp_env (h1->env, h2->env) ||
1230 !mutt_cmp_body (h1->content, h2->content))
1236 if (h1 == NULL && h2 == NULL)
1243 /* return 1 if address lists are strictly identical */
1244 int mutt_cmp_addr (const address_t * a, const address_t * b)
1247 if (m_strcmp(a->mailbox, b->mailbox) ||
1248 m_strcmp(a->personal, b->personal))
1260 int mutt_cmp_list (const string_list_t * a, const string_list_t * b)
1263 if (m_strcmp(a->data, b->data))
1275 int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2)
1278 if (m_strcmp(e1->message_id, e2->message_id) ||
1279 m_strcmp(e1->subject, e2->subject) ||
1280 !mutt_cmp_list (e1->references, e2->references) ||
1281 !mutt_cmp_addr (e1->from, e2->from) ||
1282 !mutt_cmp_addr (e1->sender, e2->sender) ||
1283 !mutt_cmp_addr (e1->reply_to, e2->reply_to) ||
1284 !mutt_cmp_addr (e1->to, e2->to) ||
1285 !mutt_cmp_addr (e1->cc, e2->cc) ||
1286 !mutt_cmp_addr (e1->return_path, e2->return_path))
1292 if (e1 == NULL && e2 == NULL)
1299 int mutt_cmp_param (const PARAMETER * p1, const PARAMETER * p2)
1302 if (m_strcmp(p1->attribute, p2->attribute) ||
1303 m_strcmp(p1->value, p2->value))
1315 int mutt_cmp_body (const BODY * b1, const BODY * b2)
1317 if (b1->type != b2->type ||
1318 b1->encoding != b2->encoding ||
1319 m_strcmp(b1->subtype, b2->subtype) ||
1320 m_strcmp(b1->description, b2->description) ||
1321 !mutt_cmp_param (b1->parameter, b2->parameter) ||
1322 b1->length != b2->length)