X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=handler.c;h=c72ddfccb38147e2ef907ce002603735eb2a2fb2;hp=5d9af6ddc8b914ca2df703cde69102a008376666;hb=f3cbb9f51357972f6e74244494236a41dc4d84cd;hpb=2a2f2f9a5bad73c883b7f9c9b4166d932b6aaf37 diff --git a/handler.c b/handler.c index 5d9af6d..c72ddfc 100644 --- a/handler.c +++ b/handler.c @@ -7,28 +7,15 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include #include #include #include +#include + #include "mutt.h" #include "recvattach.h" #include "handler.h" @@ -152,7 +139,7 @@ static void qp_decode_line (char *dest, char *src, ssize_t * l, int last) * */ -void mutt_decode_quoted (STATE * s, long len, int istext, iconv_t cd) +static void mutt_decode_quoted (STATE * s, long len, int istext, iconv_t cd) { char line[STRING]; char decline[2 * STRING]; @@ -283,14 +270,14 @@ void mutt_decode_base64 (STATE * s, long len, int istext, iconv_t cd) state_reset_prefix (s); } -unsigned char decode_byte (char ch) +static unsigned char decode_byte (char ch) { if (ch == 96) return 0; return ch - 32; } -void mutt_decode_uuencoded (STATE * s, long len, int istext, iconv_t cd) +static void mutt_decode_uuencoded (STATE * s, long len, int istext, iconv_t cd) { char tmps[SHORT_STRING]; char linelen, c, l, out; @@ -496,7 +483,7 @@ static void enriched_flush (struct enriched_state *stte, int wrap) stte->line_max = stte->line_used; p_realloc(&stte->line, stte->line_max + 1); } - strcat (stte->line, stte->buffer); /* __STRCAT_CHECKED__ */ + m_strcat(stte->line, stte->line_max + 1, stte->buffer); stte->line_len += stte->word_len; stte->word_len = 0; stte->buff_used = 0; @@ -644,7 +631,7 @@ static void enriched_set_flags (const char *tag, struct enriched_state *stte) } } -int text_enriched_handler (BODY * a, STATE * s) +static int text_enriched_handler (BODY * a, STATE * s) { enum { TEXT, LANGLE, TAG, BOGUS_TAG, NEWLINE, ST_EOF, DONE @@ -781,7 +768,7 @@ static int alternative_handler (BODY * a, STATE * s) mustfree = 1; fstat (fileno (s->fpin), &st); - b = mutt_new_body (); + b = body_new(); b->length = (long) st.st_size; b->parts = mutt_parse_multipart(s->fpin, parameter_getval(a->parameter, "boundary"), @@ -903,7 +890,7 @@ static int alternative_handler (BODY * a, STATE * s) } if (mustfree) - mutt_free_body (&a); + body_list_wipe(&a); return (rc); } @@ -920,7 +907,7 @@ static int message_handler (BODY * a, STATE * s) if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || a->encoding == ENCUUENCODED) { fstat (fileno (s->fpin), &st); - b = mutt_new_body (); + b = body_new(); b->length = (long) st.st_size; b->parts = mutt_parse_messageRFC822 (s->fpin, b); } @@ -944,7 +931,7 @@ static int message_handler (BODY * a, STATE * s) if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || a->encoding == ENCUUENCODED) - mutt_free_body (&b); + body_list_wipe(&b); return (rc); } @@ -995,7 +982,7 @@ static int multipart_handler (BODY * a, STATE * s) if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || a->encoding == ENCUUENCODED) { fstat (fileno (s->fpin), &st); - b = mutt_new_body (); + b = body_new(); b->length = (long) st.st_size; b->parts = mutt_parse_multipart(s->fpin, parameter_getval(a->parameter, "boundary"), @@ -1045,7 +1032,7 @@ static int multipart_handler (BODY * a, STATE * s) if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || a->encoding == ENCUUENCODED) - mutt_free_body (&b); + body_list_wipe(&b); return (rc); } @@ -1096,7 +1083,7 @@ static int autoview_handler (BODY * a, STATE * s) mutt_copy_bytes (s->fpin, fpin, a->length); if (!piped) { - safe_fclose (&fpin); + m_fclose(&fpin); thepid = mutt_create_filter (command, NULL, &fpout, &fperr); } else { @@ -1153,12 +1140,12 @@ static int autoview_handler (BODY * a, STATE * s) } bail: - safe_fclose (&fpout); - safe_fclose (&fperr); + m_fclose(&fpout); + m_fclose(&fperr); mutt_wait_filter (thepid); if (piped) - safe_fclose (&fpin); + m_fclose(&fpin); else mutt_unlink (tempfile); @@ -1263,12 +1250,11 @@ void mutt_decode_attachment (BODY * b, STATE * s) if (s->flags & M_CHARCONV) { const char *charset = parameter_getval(b->parameter, "charset"); - if (!option (OPTSTRICTMIME) && !charset) + if (!charset) charset = charset_getfirst(AssumedCharset); if (charset && Charset) cd = mutt_iconv_open (Charset, charset, M_ICONV_HOOK_FROM); - } - else { + } else { if (b->file_charset) cd = mutt_iconv_open (Charset, b->file_charset, M_ICONV_HOOK_FROM); } @@ -1401,10 +1387,9 @@ int mutt_body_handler (BODY * b, STATE * s) if (!plaintext) { /* decode to a tempfile, saving the original destination */ fp = s->fpout; - mutt_mktemp (tempfile); - if ((s->fpout = safe_fopen (tempfile, "w")) == NULL) { + s->fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + if (!s->fpout) { mutt_error _("Unable to open temporary file!"); - goto bail; } /* decoding the attachment changes the size and offset, so save a copy @@ -1420,16 +1405,16 @@ int mutt_body_handler (BODY * b, STATE * s) s->prefix = NULL; decode = 1; - } - else + } else { b->type = TYPETEXT; + } mutt_decode_attachment (b, s); if (decode) { b->length = ftello (s->fpout); b->offset = 0; - fclose (s->fpout); + m_fclose(&s->fpout); /* restore final destination and substitute the tempfile for input */ s->fpout = fp; @@ -1453,7 +1438,7 @@ int mutt_body_handler (BODY * b, STATE * s) b->offset = tmpoffset; /* restore the original source stream */ - fclose (s->fpin); + m_fclose(&s->fpin); s->fpin = fp; } }