move all the parameter related functions into the lib-mime.
[apps/madmutt.git] / sendlib.c
index 0178db0..fbe8814 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -284,7 +284,7 @@ int mutt_write_mime_header (BODY * a, FILE * f)
   fprintf (f, "Content-Type: %s/%s", TYPE (a), a->subtype);
 
   if (a->parameter) {
-    PARAMETER *p;
+    parameter_t *p;
 
     len = 25 + m_strlen(a->subtype);        /* approximate len. of content-type */
 
@@ -433,21 +433,6 @@ int mutt_write_mime_body (BODY * a, FILE * f)
 
 #undef write_as_text_part
 
-#define BOUNDARYLEN 16
-void mutt_generate_boundary (PARAMETER ** parm)
-{
-  char rs[BOUNDARYLEN + 1];
-  char *p = rs;
-  int i;
-
-  rs[BOUNDARYLEN] = 0;
-  for (i = 0; i < BOUNDARYLEN; i++)
-    *p++ = __m_b64chars[lrand48() % sizeof(__m_b64chars)];
-  *p = 0;
-
-  mutt_set_parameter ("boundary", rs, parm);
-}
-
 typedef struct {
   int from;
   int whitespace;
@@ -829,7 +814,7 @@ CONTENT *mutt_get_content_info (const char *fname, BODY * b)
                               &fromcode, &tocode, info) != -1) {
       if (!chs) {
         charset_canonicalize (chsbuf, sizeof (chsbuf), tocode);
-        mutt_set_parameter ("charset", chsbuf, &b->parameter);
+        parameter_setval(&b->parameter, "charset", chsbuf);
       }
       b->file_charset = fromcode;
       p_delete(&tocode);
@@ -846,10 +831,9 @@ CONTENT *mutt_get_content_info (const char *fname, BODY * b)
   safe_fclose (&fp);
 
   if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
-    mutt_set_parameter ("charset", (!info->hibin ? "us-ascii" :
-                                    Charset
-                                    && !charset_is_us_ascii (Charset) ? Charset :
-                                    "unknown-8bit"), &b->parameter);
+    parameter_setval(&b->parameter, "charset",
+                     (!info->hibin ? "us-ascii"
+                      : Charset && !charset_is_us_ascii(Charset) ? Charset : "unknown-8bit"));
 
   return info;
 }
@@ -1157,7 +1141,7 @@ void mutt_update_encoding (BODY * a)
     a->noconv = 0;
 
   if (!a->force_charset && !a->noconv)
-    mutt_delete_parameter ("charset", &a->parameter);
+    parameter_delval(&a->parameter, "charset");
 
   if ((info = mutt_get_content_info (a->filename, a)) == NULL)
     return;
@@ -1319,7 +1303,7 @@ BODY *mutt_make_multipart (BODY * b)
   new->type = TYPEMULTIPART;
   new->subtype = m_strdup("mixed");
   new->encoding = get_toplevel_encoding (b);
-  mutt_generate_boundary (&new->parameter);
+  parameter_set_boundary(&new->parameter);
   new->use_disp = 0;
   new->disposition = DISPINLINE;
   new->parts = b;
@@ -2311,10 +2295,7 @@ static void set_noconv_flags (BODY * b, short flag)
     if (b->type == TYPEMESSAGE || b->type == TYPEMULTIPART)
       set_noconv_flags (b->parts, flag);
     else if (b->type == TYPETEXT && b->noconv) {
-      if (flag)
-        mutt_set_parameter ("x-mutt-noconv", "yes", &b->parameter);
-      else
-        mutt_delete_parameter ("x-mutt-noconv", &b->parameter);
+      parameter_setval(&b->parameter, "x-mutt-noconv", flag ? "yes" : NULL);
     }
   }
 }