diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1998-11-18 22:56:57 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1998-11-18 22:56:57 +0000 |
commit | b226bc2cc5db75b72c08042b95977c28b9ef2322 (patch) | |
tree | e6a594d7eca4356caee700156546ebd26c508433 /sendlib.c | |
parent | 98df548e97d14a9f6ba75e7c4cea7cbfbf389cef (diff) |
This patch simplifies the generation of content type parameters
significantly by introducing a funciton mutt_set_parameter().
Additionally, we re-use code from parse.c for parsing user-input
content type headers on the compose screen.
Diffstat (limited to 'sendlib.c')
-rw-r--r-- | sendlib.c | 33 |
1 files changed, 10 insertions, 23 deletions
@@ -535,16 +535,18 @@ int mutt_write_mime_body (BODY *a, FILE *f) } #define BOUNDARYLEN 16 -char *mutt_generate_boundary (void) +void mutt_generate_boundary (PARAMETER **parm) { - char *rs = (char *)safe_malloc (BOUNDARYLEN + 1); + char rs[BOUNDARYLEN + 1]; char *p = rs; int i; rs[BOUNDARYLEN] = 0; - for (i=0;i<BOUNDARYLEN;i++) *p++ = B64Chars[LRAND() % sizeof (B64Chars)]; + for (i=0;i<BOUNDARYLEN;i++) + *p++ = B64Chars[LRAND() % sizeof (B64Chars)]; *p = 0; - return (rs); + + mutt_set_parameter ("boundary", rs, parm); } /* analyze the contents of a file to determine which MIME encoding to use */ @@ -935,19 +937,7 @@ void mutt_update_encoding (BODY *a) mutt_stamp_attachment(a); if (a->type == TYPETEXT) - { - /* make sure the charset is valid */ - if (a->parameter) - safe_free ((void **) &a->parameter->value); - else - { - a->parameter = mutt_new_parameter (); - a->parameter->attribute = safe_strdup ("charset"); - } - a->parameter->value = safe_strdup (set_text_charset (info)); - } - - + mutt_set_parameter ("charset", set_text_charset (info), &a->parameter); #ifdef _PGPPATH /* save the info in case this message is signed. we will want to do Q-P @@ -1077,9 +1067,8 @@ BODY *mutt_make_file_attach (const char *path) */ att->type = TYPETEXT; att->subtype = safe_strdup ("plain"); - att->parameter = mutt_new_parameter (); - att->parameter->attribute = safe_strdup ("charset"); - att->parameter->value = safe_strdup (set_text_charset (info)); + + mutt_set_parameter("charset", set_text_charset(info), &att->parameter); } else { @@ -1131,9 +1120,7 @@ BODY *mutt_make_multipart (BODY *b) new->type = TYPEMULTIPART; new->subtype = safe_strdup ("mixed"); new->encoding = get_toplevel_encoding (b); - new->parameter = mutt_new_parameter (); - new->parameter->attribute = safe_strdup ("boundary"); - new->parameter->value = mutt_generate_boundary (); + mutt_generate_boundary(&new->parameter); new->use_disp = 0; new->parts = b; |