X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=handler.c;h=27bfb08ba53f13b3cd89c7e92ec7e232f60a45ed;hp=cc0a3c1184e433ec28aa766acf929119ad629c41;hb=7d29626ce4e1fa932c6349c7253e6f774df069fc;hpb=7b392ef7b50798f9eb3e7c869e634c5fef0092d1 diff --git a/handler.c b/handler.c index cc0a3c1..27bfb08 100644 --- a/handler.c +++ b/handler.c @@ -270,16 +270,14 @@ void mutt_decode_base64 (STATE * s, long len, int istext, iconv_t cd) state_reset_prefix (s); } -static unsigned char decode_byte (char ch) +static unsigned char decode_byte(int ch) { - if (ch == 96) - return 0; - return ch - 32; + return ch == 96 ? 0 : ch - 32; } static void mutt_decode_uuencoded (STATE * s, long len, int istext, iconv_t cd) { - char tmps[SHORT_STRING]; + char tmps[STRING]; char linelen, c, l, out; char *pt; char bufi[BUFI_SIZE]; @@ -302,13 +300,13 @@ static void mutt_decode_uuencoded (STATE * s, long len, int istext, iconv_t cd) if (!m_strncmp(tmps, "end", 3)) break; pt = tmps; - linelen = decode_byte (*pt); + linelen = decode_byte(*pt); pt++; for (c = 0; c < linelen;) { for (l = 2; l <= 6; l += 2) { - out = decode_byte (*pt) << l; + out = decode_byte(*pt) << l; pt++; - out |= (decode_byte (*pt) >> (6 - l)); + out |= (decode_byte(*pt) >> (6 - l)); bufi[k++] = out; c++; if (c == linelen) @@ -340,22 +338,21 @@ static struct { const char *tag_name; int index; } EnrichedTags[] = { - { - "param", RICH_PARAM}, { - "bold", RICH_BOLD}, { - "italic", RICH_ITALIC}, { - "underline", RICH_UNDERLINE}, { - "nofill", RICH_NOFILL}, { - "excerpt", RICH_EXCERPT}, { - "indent", RICH_INDENT}, { - "indentright", RICH_INDENT_RIGHT}, { - "center", RICH_CENTER}, { - "flushleft", RICH_FLUSHLEFT}, { - "flushright", RICH_FLUSHRIGHT}, { - "flushboth", RICH_FLUSHLEFT}, { - "color", RICH_COLOR}, { - "x-color", RICH_COLOR}, { - NULL, -1} + {"param", RICH_PARAM}, + {"bold", RICH_BOLD}, + {"italic", RICH_ITALIC}, + {"underline", RICH_UNDERLINE}, + {"nofill", RICH_NOFILL}, + {"excerpt", RICH_EXCERPT}, + {"indent", RICH_INDENT}, + {"indentright", RICH_INDENT_RIGHT}, + {"center", RICH_CENTER}, + {"flushleft", RICH_FLUSHLEFT}, + {"flushright", RICH_FLUSHRIGHT}, + {"flushboth", RICH_FLUSHLEFT}, + {"color", RICH_COLOR}, + {"x-color", RICH_COLOR}, + {NULL, -1} }; struct enriched_state { @@ -483,7 +480,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; @@ -541,8 +538,7 @@ static void enriched_putc (int c, struct enriched_state *stte) else { stte->buffer[stte->buff_used++] = c; } - } - else { + } else { stte->buffer[stte->buff_used++] = c; } stte->word_len++; @@ -1083,10 +1079,9 @@ 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 { + } else { unlink (tempfile); fflush (fpin); rewind (fpin); @@ -1124,8 +1119,7 @@ static int autoview_handler (BODY * a, STATE * s) state_puts (buffer, s); } } - } - else { + } else { mutt_copy_stream (fpout, s->fpout); /* Check for stderr messages */ if (fgets (buffer, sizeof (buffer), fperr)) { @@ -1140,12 +1134,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); @@ -1219,8 +1213,7 @@ static int external_body_handler (BODY * b, STATE * s) (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE, NULL); } - } - else { + } else { if (s->flags & M_DISPLAY) { state_mark_attach (s); state_printf (s, @@ -1250,12 +1243,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); } @@ -1330,7 +1322,7 @@ int mutt_body_handler (BODY * b, STATE * s) plaintext = 1; } else if (b->type == TYPEMESSAGE) { - if (mutt_is_message_type (b->type, b->subtype)) + if (mutt_is_message_type (b)) handler = message_handler; else if (!ascii_strcasecmp ("delivery-status", b->subtype)) plaintext = 1; @@ -1377,11 +1369,10 @@ int mutt_body_handler (BODY * b, STATE * s) fseeko (s->fpin, b->offset, 0); /* see if we need to decode this part before processing it */ - if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE || b->encoding == ENCUUENCODED || plaintext || mutt_is_text_part (b)) { /* text subtypes may - * require character - * set conversion even - * with 8bit encoding. - */ + if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE + || b->encoding == ENCUUENCODED || plaintext || mutt_is_text_part (b)) { + /* text subtypes may require character set conversion even with 8bit + encoding. */ int origType = b->type; char *savePrefix = NULL; @@ -1415,7 +1406,7 @@ int mutt_body_handler (BODY * b, STATE * 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; @@ -1439,7 +1430,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; } }