Nico Golde:
[apps/madmutt.git] / handler.c
index 8ddee8c..a6a085c 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1,19 +1,10 @@
 /*
+ * Copyright notice from original mutt:
  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
- * 
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- * 
- *     This program is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License
- *     along with this program; if not, write to the Free Software
- *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
  */
 
 #if HAVE_CONFIG_H
 #include "mutt_crypt.h"
 #include "lib.h"
 
+#include "lib/mem.h"
+#include "lib/intl.h"
+#include "lib/str.h"
+#include "lib/debug.h"
 
 #define BUFI_SIZE 1000
 #define BUFO_SIZE 2000
@@ -247,7 +242,7 @@ void mutt_decode_quoted (STATE * s, long len, int istext, iconv_t cd)
     if (fgets (line, MIN ((ssize_t) sizeof (line), len + 1), s->fpin) == NULL)
       break;
 
-    linelen = strlen (line);
+    linelen = mutt_strlen (line);
     len -= linelen;
 
     /*
@@ -293,8 +288,7 @@ void mutt_decode_base64 (STATE * s, long len, int istext, iconv_t cd)
         buf[i++] = ch;
     }
     if (i != 4) {
-      dprint (2, (debugfile, "%s:%d [mutt_decode_base64()]: "
-                  "didn't get a multiple of 4 chars.\n", __FILE__, __LINE__));
+      debug_print (2, ("didn't get a multiple of 4 chars.\n"));
       break;
     }
 
@@ -376,14 +370,14 @@ void mutt_decode_uuencoded (STATE * s, long len, int istext, iconv_t cd)
     if ((fgets (tmps, sizeof (tmps), s->fpin)) == NULL)
       return;
     len -= mutt_strlen (tmps);
-    if ((!mutt_strncmp (tmps, "begin", 5)) && ISSPACE (tmps[5]))
+    if ((!safe_strncmp (tmps, "begin", 5)) && ISSPACE (tmps[5]))
       break;
   }
   while (len > 0) {
     if ((fgets (tmps, sizeof (tmps), s->fpin)) == NULL)
       return;
     len -= mutt_strlen (tmps);
-    if (!mutt_strncmp (tmps, "end", 3))
+    if (!safe_strncmp (tmps, "end", 3))
       break;
     pt = tmps;
     linelen = decode_byte (*pt);
@@ -877,7 +871,7 @@ static void flowed_stuff (STATE * s, char *cont, int level)
   }
   else if ((!(s->flags & M_PRINTING)) && ((*cont == ' ') || (*cont == '>')
                                           || (!level
-                                              && !mutt_strncmp (cont, "From ",
+                                              && !safe_strncmp (cont, "From ",
                                                                 5))))
     state_putc (' ', s);
 }
@@ -949,7 +943,7 @@ static void text_plain_flowed_handler (BODY * a, STATE * s)
   fprintf (stderr, "flowed_max = %d\n", flowed_max);
 
   while (bytes > 0 && fgets (line, sizeof (line), s->fpin)) {
-    bytes -= strlen (line);
+    bytes -= mutt_strlen (line);
     tail = NULL;
 
     last_full = full;
@@ -979,7 +973,7 @@ static void text_plain_flowed_handler (BODY * a, STATE * s)
        */
 
       full = 0;
-      l = strlen (t + 1);
+      l = mutt_strlen (t + 1);
       t[0] = ' ';
       t[1] = '\0';
 
@@ -1132,7 +1126,7 @@ static void print_flowed_line (char *line, STATE * s, int ql)
 {
   int width;
   char *pos, *oldpos;
-  int len = strlen (line);
+  int len = mutt_strlen (line);
   int i;
 
   if (MaxLineLength > 0) {
@@ -1156,7 +1150,7 @@ static void print_flowed_line (char *line, STATE * s, int ql)
 
   /* fprintf(stderr,"print_flowed_line will print `%s' with ql = %d\n",line,ql); */
 
-  if (strlen (line) == 0) {
+  if (mutt_strlen (line) == 0) {
     if (option (OPTQUOTEEMPTY)) {
       if (s->prefix)
         state_puts(s->prefix,s);
@@ -1239,24 +1233,24 @@ static void text_plain_flowed_handler (BODY * a, STATE * s)
   while (bytes > 0 && fgets (buf, sizeof (buf), s->fpin)) {
 
     /* fprintf(stderr,"read `%s'",buf); */
-    bytes -= strlen (buf);
+    bytes -= mutt_strlen (buf);
 
     newql = get_quote_level (buf);
 
     if ((t = strrchr (buf, '\n')) || (t = strrchr (buf, '\r'))) {
       *t = '\0';
-      if (strlen (curline) > 0 && curline[strlen (curline) - 1] == ' '
+      if (mutt_strlen (curline) > 0 && curline[mutt_strlen (curline) - 1] == ' '
           && newql == quotelevel
           && strcmp (curline + quotelevel, "-- ") != 0) {
         if (buf[newql] == ' ')
-          curline[strlen (curline) - 1] = '\0';
+          curline[mutt_strlen (curline) - 1] = '\0';
 
-        curline = realloc (curline, curline_len + strlen (buf));
+        curline = realloc (curline, curline_len + mutt_strlen (buf));
         if (curline_len == 1)
           *curline = '\0';
-        curline_len += strlen (buf);
+        curline_len += mutt_strlen (buf);
         safe_strncat (curline, curline_len, buf + newql,
-                      strlen (buf + newql));
+                      mutt_strlen (buf + newql));
       }
       else {
         if (first_line) {
@@ -1267,11 +1261,11 @@ static void text_plain_flowed_handler (BODY * a, STATE * s)
         }
         FREE (&curline);
         curline_len = 1;
-        curline = realloc (curline, curline_len + strlen (buf));
+        curline = realloc (curline, curline_len + mutt_strlen (buf));
         if (curline_len == 1)
           *curline = '\0';
-        curline_len += strlen (buf);
-        safe_strncat (curline, curline_len, buf, strlen (buf));
+        curline_len += mutt_strlen (buf);
+        safe_strncat (curline, curline_len, buf, mutt_strlen (buf));
         quotelevel = newql;
       }
     }
@@ -1632,7 +1626,7 @@ void autoview_handler (BODY * a, STATE * s)
     }
 
     if (thepid < 0) {
-      mutt_perror _("Can't create filter");
+      mutt_perror (_("Can't create filter"));
 
       if (s->flags & M_DISPLAY) {
         state_mark_attach (s);
@@ -1884,7 +1878,7 @@ void mutt_body_handler (BODY * b, STATE * s)
         handler = mutt_signed_handler;
     }
     else if ((WithCrypto & APPLICATION_PGP)
-             && mutt_strcasecmp ("encrypted", b->subtype) == 0) {
+             && safe_strcasecmp ("encrypted", b->subtype) == 0) {
       p = mutt_get_parameter ("protocol", b->parameter);
 
       if (!p)