Fix compilation warnings in recvcmd.c
[apps/madmutt.git] / copy.c
diff --git a/copy.c b/copy.c
index 2d205de..97b73c0 100644 (file)
--- a/copy.c
+++ b/copy.c
 # include "config.h"
 #endif
 
+#include <lib-lib/macros.h>
 #include <lib-lib/mem.h>
 #include <lib-lib/str.h>
+#include <lib-lib/file.h>
+#include <lib-lib/ascii.h>
+
+#include <lib-mime/mime.h>
 
 #include "mutt.h"
-#include "ascii.h"
 #include "handler.h"
 #include "mx.h"
 #include "copy.h"
-#include "rfc2047.h"
-#include "mime.h"
-#include "mutt_crypt.h"
+#include <lib-crypt/crypt.h>
 #include "mutt_idna.h"
 
 #include "lib/debug.h"
@@ -75,7 +77,7 @@ mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end,
       /* Is it the begining of a header? */
       if (nl && buf[0] != ' ' && buf[0] != '\t') {
         ignore = 1;
-        if (!from && str_ncmp ("From ", buf, 5) == 0) {
+        if (!from && m_strncmp("From ", buf, 5) == 0) {
           if ((flags & CH_FROM) == 0)
             continue;
           from = 1;
@@ -165,7 +167,7 @@ mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end,
 
       ignore = 1;
       this_is_from = 0;
-      if (!from && str_ncmp ("From ", buf, 5) == 0) {
+      if (!from && m_strncmp("From ", buf, 5) == 0) {
         if ((flags & CH_FROM) == 0)
           continue;
         this_is_from = from = 1;
@@ -353,7 +355,7 @@ mutt_copy_header (FILE * in, HEADER * h, FILE * out, int flags,
     fputs ("Content-Type: text/plain; charset=", out);
     mutt_canonical_charset (chsbuf, sizeof (chsbuf),
                             Charset ? Charset : "us-ascii");
-    rfc822_cat (buffer, sizeof (buffer), chsbuf, MimeSpecials);
+    rfc822_strcpy(buffer, sizeof(buffer), chsbuf, MimeSpecials);
     fputs (buffer, out);
     fputc ('\n', out);
 
@@ -442,7 +444,7 @@ mutt_copy_header (FILE * in, HEADER * h, FILE * out, int flags,
   }
 
   if (flags & CH_UPDATE_LEN && (flags & CH_NOLEN) == 0) {
-    fprintf (out, "Content-Length: %zd\n", h->content->length);
+    fprintf (out, "Content-Length: %lld\n", h->content->length);
     if (h->lines != 0 || h->content->length == 0)
       fprintf (out, "Lines: %d\n", h->lines);
   }
@@ -519,7 +521,7 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body,
 
   if (flags & M_CM_PREFIX) {
     if (option (OPTTEXTFLOWED))
-      strfcpy (prefix, ">", sizeof (prefix));
+      m_strcpy(prefix, sizeof(prefix), ">");
     else
       _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context,
                          hdr, 0);
@@ -546,7 +548,7 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body,
       if (mutt_copy_header (fpin, hdr, fpout,
                             chflags | CH_NOLEN | CH_NONEWLINE, NULL))
         return -1;
-      fprintf (fpout, "Content-Length: %zd\n", new_length);
+      fprintf (fpout, "Content-Length: %lld\n", new_length);
       if (new_lines <= 0)
         new_lines = 0;
       else
@@ -603,7 +605,7 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body,
 
   if (flags & M_CM_DECODE) {
     /* now make a text/plain version of the message */
-    memset (&s, 0, sizeof (STATE));
+    p_clear(&s, 1);
     s.fpin = fpin;
     s.fpout = fpout;
     if (flags & M_CM_PREFIX)
@@ -619,26 +621,23 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body,
     if (flags & M_CM_REPLYING)
       s.flags |= M_REPLYING;
 
-    if (WithCrypto && flags & M_CM_VERIFY)
+    if (flags & M_CM_VERIFY)
       s.flags |= M_VERIFY;
 
     rc = mutt_body_handler (body, &s);
   }
-  else if (WithCrypto
-           && (flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT)) {
+  else if ((flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT)) {
     BODY *cur;
     FILE *fp;
 
-    if ((WithCrypto & APPLICATION_PGP)
-        && (flags & M_CM_DECODE_PGP) && (hdr->security & APPLICATION_PGP) &&
+    if ((flags & M_CM_DECODE_PGP) && (hdr->security & APPLICATION_PGP) &&
         hdr->content->type == TYPEMULTIPART) {
       if (crypt_pgp_decrypt_mime (fpin, &fp, hdr->content, &cur))
         return (-1);
       fputs ("MIME-Version: 1.0\n", fpout);
     }
 
-    if ((WithCrypto & APPLICATION_SMIME)
-        && (flags & M_CM_DECODE_SMIME) && (hdr->security & APPLICATION_SMIME)
+    if ((flags & M_CM_DECODE_SMIME) && (hdr->security & APPLICATION_SMIME)
         && hdr->content->type == TYPEAPPLICATION) {
       if (crypt_smime_decrypt_mime (fpin, &fp, hdr->content, &cur))
         return (-1);
@@ -716,7 +715,7 @@ mutt_copy_message (FILE * fpout, CONTEXT * src, HEADER * hdr, int flags,
  */
 
 int
-_mutt_append_message (CONTEXT * dest, FILE * fpin, CONTEXT * src,
+_mutt_append_message (CONTEXT * dest, FILE * fpin, CONTEXT * src __attribute__ ((unused)),
                       HEADER * hdr, BODY * body, int flags, int chflags) {
   char buf[STRING];
   MESSAGE *msg;
@@ -775,7 +774,7 @@ static int copy_delete_attach (BODY * b, FILE * fpin, FILE * fpout,
       if (part->deleted) {
         fprintf (fpout,
                  "Content-Type: message/external-body; access-type=x-mutt-deleted;\n"
-                 "\texpiration=%s; length=%zd\n"
+                 "\texpiration=%s; length=%lld\n"
                  "\n", date + 5, part->length);
         if (ferror (fpout))
           return -1;
@@ -810,7 +809,7 @@ static int copy_delete_attach (BODY * b, FILE * fpin, FILE * fpout,
  * XXX - fix that. 
  */
 
-static void format_address_header (char **h, ADDRESS * a)
+static void format_address_header (char **h, address_t * a)
 {
   char buf[HUGE_STRING];
   char cbuf[STRING];
@@ -824,7 +823,7 @@ static void format_address_header (char **h, ADDRESS * a)
 
   p_realloc(h, buflen);
   for (count = 0; a; a = a->next, count++) {
-    ADDRESS *tmp = a->next;
+    address_t *tmp = a->next;
 
     a->next = NULL;
     *buf = *cbuf = *c2buf = '\0';
@@ -865,7 +864,7 @@ static int address_header_decode (char **h)
   char *s = *h;
   int l;
 
-  ADDRESS *a = NULL;
+  address_t *a = NULL;
 
   switch (tolower ((unsigned char) *s)) {
   case 'r':
@@ -937,7 +936,7 @@ static int address_header_decode (char **h)
 
   format_address_header (h, a);
 
-  rfc822_free_address (&a);
+  address_delete (&a);
 
   p_delete(&s);
   return 1;