X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=sendlib.c;h=032078da6d1b04016f7fcd284d27c64d20cfefee;hp=5f713b6e424cfc3d0714190f3c1db40a5546437d;hb=0dbe922d4298aed78dcba64b7c770f315a64505e;hpb=a9533eed32ccd9bae6f6f42980d0478f84dc2551 diff --git a/sendlib.c b/sendlib.c index 5f713b6..032078d 100644 --- a/sendlib.c +++ b/sendlib.c @@ -76,7 +76,7 @@ static char MsgIdPfx = 'A'; static void transform_to_7bit (BODY * a, FILE * fpin); -static void encode_quoted (FGETCONV * fc, FILE * fout, int istext) +static void encode_quoted (fgetconv_t * fc, FILE * fout, int istext) { int c, linelen = 0; char line[77], savechar; @@ -247,7 +247,7 @@ static void b64_putc (char c, FILE * fout) } -static void encode_base64 (FGETCONV * fc, FILE * fout, int istext) +static void encode_base64 (fgetconv_t * fc, FILE * fout, int istext) { int ch, ch1 = EOF; @@ -263,7 +263,7 @@ static void encode_base64 (FGETCONV * fc, FILE * fout, int istext) fputc ('\n', fout); } -static void encode_8bit (FGETCONV * fc, FILE * fout, int istext) +static void encode_8bit (fgetconv_t * fc, FILE * fout, int istext) { int ch; @@ -274,7 +274,6 @@ static void encode_8bit (FGETCONV * fc, FILE * fout, int istext) int mutt_write_mime_header (BODY * a, FILE * f) { - PARAMETER *p; char buffer[STRING]; char *t; char *fn; @@ -285,6 +284,8 @@ int mutt_write_mime_header (BODY * a, FILE * f) fprintf (f, "Content-Type: %s/%s", TYPE (a), a->subtype); if (a->parameter) { + parameter_t *p; + len = 25 + m_strlen(a->subtype); /* approximate len. of content-type */ for (p = a->parameter; p; p = p->next) { @@ -369,15 +370,16 @@ int mutt_write_mime_header (BODY * a, FILE * f) int mutt_write_mime_body (BODY * a, FILE * f) { - char *p, boundary[SHORT_STRING]; + const char *p; + char boundary[SHORT_STRING]; char send_charset[SHORT_STRING]; FILE *fpin; BODY *t; - FGETCONV *fc; + fgetconv_t *fc; if (a->type == TYPEMULTIPART) { /* First, find the boundary to use */ - if (!(p = mutt_get_parameter ("boundary", a->parameter))) { + if (!(p = parameter_getval(a->parameter, "boundary"))) { mutt_error _("No boundary parameter found! [report this error]"); return (-1); @@ -431,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; @@ -598,7 +585,7 @@ static ssize_t convert_file_to (FILE * file, const char *fromcode, ssize_t *score; cd1 = mutt_iconv_open ("UTF-8", fromcode, 0); - if (cd1 == (iconv_t) (-1)) + if (cd1 == MUTT_ICONV_ERROR) return -1; cd = p_new(iconv_t, ncodes); @@ -611,7 +598,7 @@ static ssize_t convert_file_to (FILE * file, const char *fromcode, cd[i] = mutt_iconv_open (tocodes[i], "UTF-8", 0); else /* Special case for conversion to UTF-8 */ - cd[i] = (iconv_t) (-1), score[i] = -1; + cd[i] = MUTT_ICONV_ERROR, score[i] = -1; rewind (file); ibl = 0; @@ -637,7 +624,7 @@ static ssize_t convert_file_to (FILE * file, const char *fromcode, /* Convert from UTF-8 */ for (i = 0; i < ncodes; i++) - if (cd[i] != (iconv_t) (-1) && score[i] != -1) { + if (cd[i] != MUTT_ICONV_ERROR && score[i] != -1) { ub = bufu, ubl = ubl1; ob = bufo, obl = sizeof (bufo); n = my_iconv(cd[i], (ibl || ubl) ? &ub : 0, &ubl, &ob, &obl); @@ -651,7 +638,7 @@ static ssize_t convert_file_to (FILE * file, const char *fromcode, update_content_info (&infos[i], &states[i], bufo, ob - bufo); } } - else if (cd[i] == (iconv_t) (-1) && score[i] == -1) + else if (cd[i] == MUTT_ICONV_ERROR && score[i] == -1) /* Special case for conversion to UTF-8 */ update_content_info (&infos[i], &states[i], bufu, ubl1); @@ -668,13 +655,13 @@ static ssize_t convert_file_to (FILE * file, const char *fromcode, /* Find best score */ ret = -1; for (i = 0; i < ncodes; i++) { - if (cd[i] == (iconv_t) (-1) && score[i] == -1) { + if (cd[i] == MUTT_ICONV_ERROR && score[i] == -1) { /* Special case for conversion to UTF-8 */ *tocode = i; ret = 0; break; } - else if (cd[i] == (iconv_t) (-1) || score[i] == -1) + else if (cd[i] == MUTT_ICONV_ERROR || score[i] == -1) continue; else if (ret == -1 || score[i] < ret) { *tocode = i; @@ -690,7 +677,7 @@ static ssize_t convert_file_to (FILE * file, const char *fromcode, } for (i = 0; i < ncodes; i++) - if (cd[i] != (iconv_t) (-1)) + if (cd[i] != MUTT_ICONV_ERROR) iconv_close (cd[i]); iconv_close (cd1); @@ -819,15 +806,15 @@ CONTENT *mutt_get_content_info (const char *fname, BODY * b) p_clear(&state, 1); if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset)) { - char *chs = mutt_get_parameter ("charset", b->parameter); + const char *chs = parameter_getval(b->parameter, "charset"); char *fchs = b->use_disp ? ((FileCharset && *FileCharset) ? FileCharset : Charset) : Charset; if (Charset && (chs || SendCharset) && convert_file_from_to (fp, fchs, chs ? chs : SendCharset, &fromcode, &tocode, info) != -1) { if (!chs) { - mutt_canonical_charset (chsbuf, sizeof (chsbuf), tocode); - mutt_set_parameter ("charset", chsbuf, &b->parameter); + charset_canonicalize (chsbuf, sizeof (chsbuf), tocode); + parameter_setval(&b->parameter, "charset", chsbuf); } b->file_charset = fromcode; p_delete(&tocode); @@ -844,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 - && !mutt_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; } @@ -1019,7 +1005,7 @@ cleanup: return; } a->length = sb.st_size; - mutt_free_body (&a->parts); + body_list_wipe(&a->parts); a->hdr->content = NULL; } @@ -1127,16 +1113,16 @@ void mutt_stamp_attachment (BODY * a) char *mutt_get_body_charset (char *d, ssize_t dlen, BODY * b) { - char *p = NULL; + const char *p = NULL; if (b && b->type != TYPETEXT) return NULL; if (b) - p = mutt_get_parameter ("charset", b->parameter); + p = parameter_getval(b->parameter, "charset"); if (p) - mutt_canonical_charset (d, dlen, NONULL (p)); + charset_canonicalize (d, dlen, p); else m_strcpy(d, dlen, "us-ascii"); @@ -1151,11 +1137,11 @@ void mutt_update_encoding (BODY * a) char chsbuff[STRING]; /* override noconv when it's us-ascii */ - if (mutt_is_us_ascii (mutt_get_body_charset (chsbuff, sizeof (chsbuff), a))) + if (charset_is_us_ascii (mutt_get_body_charset (chsbuff, sizeof (chsbuff), 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; @@ -1186,7 +1172,7 @@ BODY *mutt_make_message_attach (CONTEXT * ctx, HEADER * hdr, int attach_msg) if ((fp = safe_fopen (buffer, "w+")) == NULL) return NULL; - body = mutt_new_body (); + body = body_new(); body->type = TYPEMESSAGE; body->subtype = m_strdup("rfc822"); body->filename = m_strdup(buffer); @@ -1247,7 +1233,7 @@ BODY *mutt_make_file_attach (const char *path) BODY *att; CONTENT *info; - att = mutt_new_body (); + att = body_new(); att->filename = m_strdup(path); /* Attempt to determine the appropriate content-type based on the filename @@ -1271,7 +1257,7 @@ BODY *mutt_make_file_attach (const char *path) #endif if ((info = mutt_get_content_info (path, att)) == NULL) { - mutt_free_body (&att); + body_list_wipe(&att); return NULL; } @@ -1313,11 +1299,11 @@ BODY *mutt_make_multipart (BODY * b) { BODY *new; - new = mutt_new_body (); + new = body_new(); 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; @@ -1334,7 +1320,7 @@ BODY *mutt_remove_multipart (BODY * b) t = b; b = b->parts; t->parts = NULL; - mutt_free_body (&t); + body_list_wipe(&t); } return b; } @@ -2309,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); } } }