]> diplodocus.org Git - nmh/blobdiff - uip/mhfixmsg.c
Added const to argument of getname().
[nmh] / uip / mhfixmsg.c
index 5db537d37449e228002c7e6505b3f730d75002ea..2d2fde131494cd28d01a322b8d5e6d1762f175ac 100644 (file)
@@ -11,9 +11,6 @@
 #include <h/mhparse.h>
 #include <h/utils.h>
 #include <h/signals.h>
 #include <h/mhparse.h>
 #include <h/utils.h>
 #include <h/signals.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
 #include <fcntl.h>
 #ifdef HAVE_ICONV
 #   include <iconv.h>
 #include <fcntl.h>
 #ifdef HAVE_ICONV
 #   include <iconv.h>
@@ -308,8 +305,7 @@ main (int argc, char **argv) {
             adios (NULL, "out of memory");
         ctp = cts;
 
             adios (NULL, "out of memory");
         ctp = cts;
 
-        if ((ct = parse_mime (file)))
-            *ctp++ = ct;
+        if ((ct = parse_mime (file))) *ctp++ = ct;
     } else {
         /*
          * message(s) are coming from a folder
     } else {
         /*
          * message(s) are coming from a folder
@@ -348,24 +344,14 @@ main (int argc, char **argv) {
                 char *msgnam;
 
                 msgnam = m_name (msgnum);
                 char *msgnam;
 
                 msgnam = m_name (msgnum);
-                if ((ct = parse_mime (msgnam)))
-                    *ctp++ = ct;
+                if ((ct = parse_mime (msgnam))) *ctp++ = ct;
             }
         }
 
             }
         }
 
-        /*
-         * This is a hack.  If we are using an external rmmproc,
-         * then save the current folder to the context file,
-         * so the external rmmproc will remove files from the correct
-         * directory.  This should be moved to folder_delmsgs().
-         */
-        if (rmmproc) {
-            context_replace (pfolder, folder);/* update current folder  */
-            seq_setcur (mp, mp->hghsel);      /* update current message */
-            seq_save (mp);                    /* synchronize sequences  */
-            context_save ();                  /* save the context file  */
-            fflush (stdout);
-        }
+        seq_setcur (mp, mp->hghsel);      /* update current message */
+        seq_save (mp);                    /* synchronize sequences  */
+        context_replace (pfolder, folder);/* update current folder  */
+        context_save ();                  /* save the context file  */
     }
 
     if (*cts) {
     }
 
     if (*cts) {
@@ -469,6 +455,7 @@ mhfixmsgsbr (CT *ctp, const fix_transformations *fx, char *outfile) {
     }
 
     if (modify_inplace) {
     }
 
     if (modify_inplace) {
+        if (status != OK) unlink (outfile);
         free (outfile);
         outfile = NULL;
     }
         free (outfile);
         outfile = NULL;
     }
@@ -529,12 +516,14 @@ fix_boundary (CT *ct, int *message_mods) {
                         char *filename = add ((*ct)->c_file, NULL);
 
                         free_content (*ct);
                         char *filename = add ((*ct)->c_file, NULL);
 
                         free_content (*ct);
-                        *ct = parse_mime (fixed);
-                        (*ct)->c_unlink = 1;
+                        if ((*ct = parse_mime (fixed))) {
+                            (*ct)->c_unlink = 1;
 
 
-                        ++*message_mods;
-                        if (verbosw) {
-                            report (NULL, filename, "fix multipart boundary");
+                            ++*message_mods;
+                            if (verbosw) {
+                                report (NULL, filename,
+                                        "fix multipart boundary");
+                            }
                         }
                         free (filename);
                     } else {
                         }
                         free (filename);
                     } else {
@@ -610,15 +599,18 @@ get_multipart_boundary (CT ct, char **part_boundary) {
 
                 if (cp  &&  cp - buffer >= 2  &&  *--cp == '-'  &&
                     *--cp == '-'  &&  (cp > buffer  &&  *--cp == '\n')) {
 
                 if (cp  &&  cp - buffer >= 2  &&  *--cp == '-'  &&
                     *--cp == '-'  &&  (cp > buffer  &&  *--cp == '\n')) {
+                    status = OK;
                     break;
                 }
                     break;
                 }
-                /* Else the start and end boundaries didn't match, or
-                   the start boundary doesn't begin with "\n--" (or
-                   "--" if at the beginning of buffer).  Keep trying. */
             } else {
             } else {
+                /* The start and end boundaries didn't match, or the
+                   start boundary doesn't begin with "\n--" (or "--"
+                   if at the beginning of buffer).  Keep trying. */
                 status = NOTOK;
             }
         }
                 status = NOTOK;
             }
         }
+    } else {
+       status = NOTOK;
     }
 
     if (status == OK) {
     }
 
     if (status == OK) {
@@ -957,7 +949,11 @@ ensure_text_plain (CT *ct, CT parent, int *message_mods) {
                         free_content (mp_alt);
                         status = NOTOK;
                     }
                         free_content (mp_alt);
                         status = NOTOK;
                     }
+                } else {
+                    status = NOTOK;
                 }
                 }
+            } else {
+                status = NOTOK;
             }
         }
         break;
             }
         }
         break;
@@ -1466,7 +1462,9 @@ decode_text_parts (CT ct, int encoding, int *message_mods) {
                     unlink (ct->c_cefile.ce_file);
                     free (ct->c_cefile.ce_file);
                     ct->c_cefile.ce_file = NULL;
                     unlink (ct->c_cefile.ce_file);
                     free (ct->c_cefile.ce_file);
                     ct->c_cefile.ce_file = NULL;
-                } else if (ct_encoding == CE_8BIT  &&  encoding == CE_7BIT) {
+                    status = NOTOK;
+                } else if (ct->c_encoding == CE_QUOTED &&
+                           ct_encoding == CE_8BIT  &&  encoding == CE_7BIT) {
                     if (verbosw) {
                         report (ct->c_partno, ct->c_file,
                                 "will not decode%s because it is 8bit",
                     if (verbosw) {
                         report (ct->c_partno, ct->c_file,
                                 "will not decode%s because it is 8bit",
@@ -1477,10 +1475,15 @@ decode_text_parts (CT ct, int encoding, int *message_mods) {
                     unlink (ct->c_cefile.ce_file);
                     free (ct->c_cefile.ce_file);
                     ct->c_cefile.ce_file = NULL;
                     unlink (ct->c_cefile.ce_file);
                     free (ct->c_cefile.ce_file);
                     ct->c_cefile.ce_file = NULL;
+                    status = NOTOK;
                 } else {
                 } else {
-                    int enc = ct_encoding == CE_BINARY
-                        ?  CE_BINARY
-                        :  charset_encoding (ct);
+                    int enc;
+                    if (ct_encoding == CE_BINARY)
+                        enc = CE_BINARY;
+                    else if (ct_encoding == CE_8BIT  &&  encoding == CE_7BIT)
+                        enc = CE_QUOTED;
+                    else
+                        enc = charset_encoding (ct);
                     if (set_ce (ct, enc) == OK) {
                         ++*message_mods;
                         if (verbosw) {
                     if (set_ce (ct, enc) == OK) {
                         ++*message_mods;
                         if (verbosw) {
@@ -1829,6 +1832,8 @@ write_content (CT ct, char *input_filename, char *outfile, int modify_inplace,
                 }
 
                 free (infile);
                 }
 
                 free (infile);
+            } else {
+                status = NOTOK;
             }
         } else {
             /* No modifications and didn't need the tmp outfile. */
             }
         } else {
             /* No modifications and didn't need the tmp outfile. */