]> diplodocus.org Git - nmh/blobdiff - uip/mhfixmsg.c
Correct first-line comments where filename is wrong.
[nmh] / uip / mhfixmsg.c
index ff3e383a49e1d4885012f451e09ee1de97b6d803..e1057887115a87fa0274811002049213d411c5f1 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * mhfixmsg.c -- rewrite a message with various transformations
+/* mhfixmsg.c -- rewrite a message with various transformations
  *
  * This code is Copyright (c) 2002 and 2013, by the authors of nmh.
  * See the COPYRIGHT file in the root directory of the nmh
@@ -372,7 +371,7 @@ main (int argc, char **argv) {
             set_text_ctparams(ct, fx.decodetypes, fx.lf_line_endings);
             *ctp++ = ct;
         } else {
-            advise (NULL, "unable to parse message from file %s", file);
+            inform("unable to parse message from file %s", file);
             status = NOTOK;
 
             /* If there's an outfile, pass the input message unchanged, so the
@@ -386,7 +385,7 @@ main (int argc, char **argv) {
                 }
 
                 if (copy_input_to_output (file, infp, outfile, outfp) != OK) {
-                    advise (NULL, "unable to copy message to %s, "
+                    inform("unable to copy message to %s, "
                             "it might be lost\n", outfile);
                 }
 
@@ -406,7 +405,7 @@ main (int argc, char **argv) {
         if (! folder) {
             folder = getfolder (1);
         }
-        maildir = m_maildir (folder);
+        maildir = mh_xstrdup(m_maildir (folder));
 
         /* chdir so that error messages, esp. from MIME parser, just
            refer to the message and not its path. */
@@ -442,7 +441,7 @@ main (int argc, char **argv) {
                     set_text_ctparams(ct, fx.decodetypes, fx.lf_line_endings);
                     *ctp++ = ct;
                 } else {
-                    advise (NULL, "unable to parse message %s", msgnam);
+                    inform("unable to parse message %s", msgnam);
                     status = NOTOK;
 
                     /* If there's an outfile, pass the input message
@@ -465,10 +464,8 @@ main (int argc, char **argv) {
 
                         if (copy_input_to_output (input_filename, infp,
                                                   outfile, outfp) != OK) {
-                            advise (NULL,
-                                    "unable to copy message to %s, "
-                                    "it might be lost\n",
-                                    outfile);
+                            inform("unable to copy message to %s, "
+                                "it might be lost\n", outfile);
                         }
 
                         fclose (infp);
@@ -505,6 +502,7 @@ main (int argc, char **argv) {
         status = 1;
     }
 
+    mh_xfree(maildir);
     free (cts);
 
     if (fx.fixtypes != NULL) { svector_free (fx.fixtypes); }
@@ -607,7 +605,7 @@ mhfixmsgsbr (CT *ctp, char *maildir, const fix_transformations *fx,
            to the output. */
         if (copy_input_to_output (input_filename, *infp, outfile,
                                   *outfp) != OK) {
-            advise (NULL, "unable to copy message to %s, it might be lost\n",
+            inform("unable to copy message to %s, it might be lost\n",
                     outfile);
         }
     }
@@ -691,16 +689,16 @@ fix_boundary (CT *ct, int *message_mods) {
                             }
                         } else {
                             *ct = NULL;
-                            advise (NULL, "unable to parse fixed part");
+                            inform("unable to parse fixed part");
                             status = NOTOK;
                         }
                         free (filename);
                     } else {
-                        advise (NULL, "unable to replace broken boundary");
+                        inform("unable to replace broken boundary");
                         status = NOTOK;
                     }
                 } else {
-                    advise (NULL, "unable to create temporary file in %s",
+                    inform("unable to create temporary file in %s",
                             get_temp_dir());
                     status = NOTOK;
                 }
@@ -825,7 +823,7 @@ replace_boundary (CT ct, char *file, char *boundary) {
     int status = OK;
 
     if (ct->c_file == NULL) {
-        advise (NULL, "missing input filename");
+        inform("missing input filename");
         return NOTOK;
     }
 
@@ -897,12 +895,12 @@ replace_boundary (CT ct, char *file, char *boundary) {
 
         case LENERR:
         case FMTERR:
-            advise (NULL, "message format error in component #%d", compnum);
+            inform("message format error in component #%d", compnum);
             status = NOTOK;
             break;
 
         default:
-            advise (NULL, "getfld() returned %d", state);
+            inform("getfld() returned %d", state);
             status = NOTOK;
             break;
         }
@@ -984,7 +982,7 @@ fix_types (CT ct, svector_t fixtypes, int *message_mods) {
                             *cp = '\0';
                             ct_subtype = mh_xstrdup(++cp);
                         } else {
-                            advise (NULL, "missing / in MIME type of %s %s",
+                            inform("missing / in MIME type of %s %s",
                                     ct->c_file, ct->c_partno);
                             free (ct_type);
                             return NOTOK;
@@ -999,7 +997,7 @@ fix_types (CT ct, svector_t fixtypes, int *message_mods) {
                         ct->c_ctinfo.ci_subtype = ct_subtype;
                         if (! replace_substring (&ct->c_ctline, type,
                                                  ct_type_subtype)) {
-                            advise (NULL, "did not find %s in %s",
+                            inform("did not find %s in %s",
                                     type, ct->c_ctline);
                         }
 
@@ -1017,7 +1015,7 @@ fix_types (CT ct, svector_t fixtypes, int *message_mods) {
                                     }
                                     break;
                                 } else {
-                                    advise (NULL, "did not find %s in %s",
+                                    inform("did not find %s in %s",
                                             type, hf->value);
                                 }
                             }
@@ -1336,9 +1334,8 @@ ensure_text_plain (CT *ct, CT parent, int *message_mods, int replacetextplain) {
                         parent->c_ctinfo.ci_subtype = mh_xstrdup("alternative");
                         if (! replace_substring (&parent->c_ctline, "/related",
                                                  "/alternative")) {
-                            advise (NULL,
-                                    "did not find multipart/related in %s",
-                                    parent->c_ctline);
+                            inform("did not find multipart/related in %s",
+                                parent->c_ctline);
                         }
 
                         /* Update Content-Type header field. */
@@ -1358,7 +1355,7 @@ ensure_text_plain (CT *ct, CT parent, int *message_mods, int replacetextplain) {
                                     remove_parameter (hf->value, "type");
                                     break;
                                 } else {
-                                    advise (NULL, "did not find multipart/"
+                                    inform("did not find multipart/"
                                                   "related in header %s",
                                             hf->value);
                                 }
@@ -1492,7 +1489,7 @@ build_text_plain_part (CT encoded_part) {
 
         /* This m_mktemp2() call closes the temp file. */
         if ((tempfile = m_mktemp2 (NULL, invo_name, NULL, NULL)) == NULL) {
-            advise (NULL, "unable to create temporary file in %s",
+            inform("unable to create temporary file in %s",
                     get_temp_dir());
         } else {
             tmp_plain_file = mh_xstrdup (tempfile);
@@ -1630,7 +1627,7 @@ decode_part (CT ct) {
     (void) m_unlink (tmp_decoded);
     free (tmp_decoded);
     if (fclose (file)) {
-        admonish (NULL, "unable to close temporary file %s", tempfile);
+        inform("unable to close temporary file %s, continuing...", tempfile);
     }
 
     return status;
@@ -1657,14 +1654,14 @@ reformat_part (CT ct, char *file, char *type, char *subtype, int c_type) {
     /* Check for invo_name-format-type/subtype. */
     if ((cf = context_find_by_type ("format", type, subtype)) == NULL) {
         if (verbosw) {
-            advise (NULL, "Don't know how to convert %s, there is no "
+            inform("Don't know how to convert %s, there is no "
                     "%s-format-%s/%s profile entry",
                     ct->c_file, invo_name, type, subtype);
         }
         return NOTOK;
     }
     if (strchr (cf, '>')) {
-        advise (NULL, "'>' prohibited in \"%s\",\nplease fix your "
+        inform("'>' prohibited in \"%s\",\nplease fix your "
                 "%s-format-%s/%s profile entry", cf, invo_name, type,
                 subtype ? subtype : "");
 
@@ -1789,7 +1786,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
         }
 
         if (found_boundary) {
-            advise (NULL, "giving up trying to find a unique boundary");
+            inform("giving up trying to find a unique boundary");
             free_content (ct);
             return NULL;
         }
@@ -2303,7 +2300,7 @@ strip_crs (CT ct, int *message_mods) {
                 }
 
                 if (close (fd)) {
-                    admonish (NULL, "unable to write temporary file %s",
+                    inform("unable to write temporary file %s, continuing...",
                               stripped_content_file);
                     (void) m_unlink (stripped_content_file);
                     status = NOTOK;
@@ -2589,7 +2586,7 @@ static int
 fix_filename_param (char *name, char *value, PM *first_pm, PM *last_pm) {
     int fixed = 0;
 
-    if (HasPrefix(value, "=?") && HasSuffix(value, "?=")) {
+    if (has_prefix(value, "=?") && has_suffix(value, "?=")) {
         /* Looks like an RFC 2047 encoded parameter. */
         char decoded[PATH_MAX + 1];
 
@@ -2598,7 +2595,7 @@ fix_filename_param (char *name, char *value, PM *first_pm, PM *last_pm) {
             replace_param (first_pm, last_pm, name, decoded, 0);
             fixed = 1;
         } else {
-            advise (NULL, "failed to decode %s parameter %s", name, value);
+            inform("failed to decode %s parameter %s", name, value);
         }
     }
 
@@ -2663,7 +2660,7 @@ fix_filename_encoding (CT ct) {
                 free((void *)new_params); /* Cast away const.  Sigh. */
                 free((void *)params);
             } else {
-                advise (NULL, "did not find semicolon in %s:%s\n",
+                inform("did not find semicolon in %s:%s\n",
                         hf->name, hf->value);
             }
         }
@@ -2718,15 +2715,15 @@ write_content (CT ct, const char *input_filename, char *outfile, FILE *outfp,
                                expand filename to absolute path. */
                             int file = ct->c_file  &&  ct->c_file[0] == '/';
 
-                            admonish (NULL, "unable to rename %s %s to %s",
+                            inform("unable to rename %s %s to %s, continuing...",
                                       file ? "file" : "message", outfile,
                                       infile);
                             status = NOTOK;
                         }
                     }
                 } else {
-                    admonish (NULL, "unable to remove input file %s, "
-                              "not modifying it", infile);
+                    inform("unable to remove input file %s, "
+                       "not modifying it, continuing...", infile);
                     (void) m_unlink (outfile);
                     status = NOTOK;
                 }