- q = mutt_new_parameter ();
- q->attribute = str_dup (attribute);
- q->value = str_dup (value);
- q->next = *p;
- *p = q;
-}
-
-void mutt_delete_parameter (const char *attribute, PARAMETER ** p)
-{
- PARAMETER *q;
-
- for (q = *p; q; p = &q->next, q = q->next) {
- if (ascii_strcasecmp (attribute, q->attribute) == 0) {
- *p = q->next;
- q->next = NULL;
- mutt_free_parameter (&q);
- return;
- }
- }
-}
-
-/* returns 1 if Mutt can't display this type of data, 0 otherwise */
-int mutt_needs_mailcap (BODY * m)
-{
- switch (m->type) {
- case TYPETEXT:
-
- if (!ascii_strcasecmp ("plain", m->subtype) ||
- !ascii_strcasecmp ("rfc822-headers", m->subtype) ||
- !ascii_strcasecmp ("enriched", m->subtype))
- return 0;
- break;
-
- case TYPEAPPLICATION:
- if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (m))
- return 0;
- if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime (m))
- return 0;
- break;
-
- case TYPEMULTIPART:
- case TYPEMESSAGE:
- return 0;
- }
-
- return 1;
-}
-
-int mutt_is_text_part (BODY * b)
-{
- int t = b->type;
- char *s = b->subtype;
-
- if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b))
- return 0;
-
- if (t == TYPETEXT)
- return 1;
-
- if (t == TYPEMESSAGE) {
- if (!ascii_strcasecmp ("delivery-status", s))
- return 1;
- }
-
- if ((WithCrypto & APPLICATION_PGP) && t == TYPEAPPLICATION) {
- if (!ascii_strcasecmp ("pgp-keys", s))
- return 1;
- }
-
- return 0;
-}
-
-void mutt_free_envelope (ENVELOPE ** p)
-{
- if (!*p)
- return;
- rfc822_free_address (&(*p)->return_path);
- rfc822_free_address (&(*p)->from);
- rfc822_free_address (&(*p)->to);
- rfc822_free_address (&(*p)->cc);
- rfc822_free_address (&(*p)->bcc);
- rfc822_free_address (&(*p)->sender);
- rfc822_free_address (&(*p)->reply_to);
- rfc822_free_address (&(*p)->mail_followup_to);
-
- p_delete(&(*p)->list_post);
- p_delete(&(*p)->subject);
- /* real_subj is just an offset to subject and shouldn't be freed */
- p_delete(&(*p)->message_id);
- p_delete(&(*p)->supersedes);
- p_delete(&(*p)->date);
- p_delete(&(*p)->x_label);
- p_delete(&(*p)->organization);
-#ifdef USE_NNTP
- p_delete(&(*p)->newsgroups);
- p_delete(&(*p)->xref);
- p_delete(&(*p)->followup_to);
- p_delete(&(*p)->x_comment_to);
-#endif
-
- mutt_buffer_free (&(*p)->spam);
- mutt_free_list (&(*p)->references);
- mutt_free_list (&(*p)->in_reply_to);
- mutt_free_list (&(*p)->userhdrs);
- p_delete(p);
-}
-
-/* move all the headers from extra not present in base into base */
-void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra)
-{
- /* copies each existing element if necessary, and sets the element
- * to NULL in the source so that mutt_free_envelope doesn't leave us
- * with dangling pointers. */
-#define MOVE_ELEM(h) if (!base->h) { base->h = (*extra)->h; (*extra)->h = NULL; }
- MOVE_ELEM(return_path);
- MOVE_ELEM(from);
- MOVE_ELEM(to);
- MOVE_ELEM(cc);
- MOVE_ELEM(bcc);
- MOVE_ELEM(sender);
- MOVE_ELEM(reply_to);
- MOVE_ELEM(mail_followup_to);
- MOVE_ELEM(list_post);
- MOVE_ELEM(message_id);
- MOVE_ELEM(supersedes);
- MOVE_ELEM(date);
- MOVE_ELEM(x_label);
- if (!base->refs_changed) {
- MOVE_ELEM(references);
- }
- if (!base->irt_changed) {
- MOVE_ELEM(in_reply_to);
- }
- /* real_subj is subordinate to subject */
- if (!base->subject) {
- base->subject = (*extra)->subject;
- base->real_subj = (*extra)->real_subj;
- (*extra)->subject = NULL;
- (*extra)->real_subj = NULL;
- }
- /* spam and user headers should never be hashed, and the new envelope may
- * have better values. Use new versions regardless. */
- mutt_buffer_free (&base->spam);
- mutt_free_list (&base->userhdrs);
- MOVE_ELEM(spam);
- MOVE_ELEM(userhdrs);
-#undef MOVE_ELEM
-
- mutt_free_envelope(extra);
-}
-
-void _mutt_mktemp (char *s, const char *src, int line)
-{
-
- snprintf (s, _POSIX_PATH_MAX, "%s/muttng-%s-%d-%d-%d-%x%x", NONULL (Tempdir),
- NONULL (Hostname), (int) getuid (), (int) getpid (), Counter++,
- (unsigned int) rand(), (unsigned int) rand());
- debug_print (1, ("%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
- unlink (s);
-}
-
-void mutt_free_alias (ALIAS ** p)
-{
- ALIAS *t;
-
- while (*p) {
- t = *p;
- *p = (*p)->next;
- p_delete(&t->name);
- rfc822_free_address (&t->addr);
- p_delete(&t);
- }