move more things in the lib-mime
[apps/madmutt.git] / muttlib.c
index d607b4f..f7449df 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
 
 #define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
 
-BODY *mutt_new_body (void)
-{
-  BODY *p = p_new(BODY, 1);
-
-  p->disposition = DISPATTACH;
-  p->use_disp = 1;
-  return (p);
-}
-
-
 /* Modified by blong to accept a "suggestion" for file name.  If
  * that file exists, then construct one with unique name but 
  * keep any extension.  This might fail, I guess.
@@ -108,7 +98,7 @@ int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
   char tmp[_POSIX_PATH_MAX];
   BODY *b;
 
-  PARAMETER *par, **ppar;
+  parameter_t *par, **ppar;
 
   short use_disp;
 
@@ -125,7 +115,7 @@ int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
   if (mutt_save_attachment (fp, src, tmp, 0, NULL) == -1)
     return -1;
 
-  *tgt = mutt_new_body ();
+  *tgt = body_new();
   b = *tgt;
 
   memcpy (b, src, sizeof (BODY));
@@ -167,53 +157,6 @@ int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
   return 0;
 }
 
-
-
-void mutt_free_body (BODY ** p)
-{
-  BODY *a = *p, *b;
-
-  while (a) {
-    b = a;
-    a = a->next;
-
-    if (b->parameter)
-      parameter_list_wipe(&b->parameter);
-    if (b->unlink && b->filename) {
-      unlink (b->filename);
-    }
-
-    p_delete(&b->filename);
-    p_delete(&b->content);
-    p_delete(&b->xtype);
-    p_delete(&b->subtype);
-    p_delete(&b->description);
-    p_delete(&b->form_name);
-
-    if (b->hdr) {
-      /* Don't free twice (b->hdr->content = b->parts) */
-      b->hdr->content = NULL;
-      header_delete(&b->hdr);
-    }
-
-    if (b->parts)
-      mutt_free_body (&b->parts);
-
-    p_delete(&b);
-  }
-
-  *p = 0;
-}
-
-HEADER *mutt_dup_header (HEADER * h)
-{
-  HEADER *hnew;
-
-  hnew = header_new();
-  memcpy (hnew, h, sizeof (HEADER));
-  return hnew;
-}
-
 /* returns true if the header contained in "s" is in list "t" */
 int mutt_matches_ignore (const char *s, string_list_t * t)
 {
@@ -400,104 +343,6 @@ char *_mutt_expand_path (char *s, ssize_t slen, int rx)
   return (s);
 }
 
-char *mutt_get_parameter (const char *s, PARAMETER * p)
-{
-    while (p) {
-        if (!ascii_strcasecmp(s, p->attribute))
-            return (p->value);
-        p = p->next;
-    }
-
-    return NULL;
-}
-
-void mutt_set_parameter (const char *attribute, const char *value,
-                         PARAMETER ** p)
-{
-    PARAMETER *q;
-
-    if (!value) {
-        mutt_delete_parameter (attribute, p);
-        return;
-    }
-
-    for (q = *p; q; q = q->next) {
-        if (ascii_strcasecmp (attribute, q->attribute) == 0) {
-            m_strreplace(&q->value, value);
-            return;
-        }
-    }
-
-    q = parameter_new();
-    q->attribute = m_strdup(attribute);
-    q->value = m_strdup(value);
-    parameter_list_push(p, q);
-}
-
-void mutt_delete_parameter (const char *attribute, PARAMETER ** p)
-{
-    while (*p) {
-        if (!ascii_strcasecmp(attribute, (*p)->attribute)) {
-            PARAMETER *q = parameter_list_pop(p);
-            parameter_delete(&q);
-            return;
-        }
-
-        p = &(*p)->next;
-    }
-}
-
-/* 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 (mutt_is_application_pgp (m))
-      return 0;
-    if (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 (mutt_is_application_pgp (b))
-    return 0;
-
-  if (t == TYPETEXT)
-    return 1;
-
-  if (t == TYPEMESSAGE) {
-    if (!ascii_strcasecmp ("delivery-status", s))
-      return 1;
-  }
-
-  if (t == TYPEAPPLICATION) {
-    if (!ascii_strcasecmp ("pgp-keys", s))
-      return 1;
-  }
-
-  return 0;
-}
-
 /* move all the headers from extra not present in base into base */
 void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra)
 {
@@ -1306,29 +1151,13 @@ int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2)
   }
 }
 
-int mutt_cmp_param (const PARAMETER * p1, const PARAMETER * p2)
-{
-  while (p1 && p2) {
-    if (m_strcmp(p1->attribute, p2->attribute) ||
-        m_strcmp(p1->value, p2->value))
-      return (0);
-
-    p1 = p1->next;
-    p2 = p2->next;
-  }
-  if (p1 || p2)
-    return (0);
-
-  return (1);
-}
-
 int mutt_cmp_body (const BODY * b1, const BODY * b2)
 {
   if (b1->type != b2->type ||
       b1->encoding != b2->encoding ||
       m_strcmp(b1->subtype, b2->subtype) ||
       m_strcmp(b1->description, b2->description) ||
-      !mutt_cmp_param (b1->parameter, b2->parameter) ||
+      !parameter_equal(b1->parameter, b2->parameter) ||
       b1->length != b2->length)
     return (0);
   return (1);