X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/2fc70e8bf64ead869fce76abb74f04bf1af94923..63621a81d16ab743de6b57d47578a9a2c670ad22:/uip/mhfixmsg.c diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 0bf0437c..2bbb0453 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -11,9 +11,10 @@ #include #include #include -#include "../sbr/m_maildir.h" -#include "../sbr/m_mktemp.h" -#include "../sbr/mime_type.h" +#include "sbr/m_maildir.h" +#include "sbr/m_mktemp.h" +#include "sbr/mime_type.h" +#include "mhmisc.h" #include "mhfree.h" #include "mhoutsbr.h" #include "mhshowsbr.h" @@ -61,16 +62,6 @@ int debugsw; /* Needed by mhparse.c. */ #define quitser pipeser -/* mhparse.c */ -extern int skip_mp_cte_check; /* flag to InitMultiPart */ -extern int suppress_bogus_mp_content_warning; /* flag to InitMultiPart */ -extern int bogus_mp_content; /* flag from InitMultiPart */ -/* flags to/from parse_header_attrs */ -extern int suppress_extraneous_trailing_semicolon_warning; - -/* mhmisc.c */ -void flush_errors (void); - /* * static prototypes */ @@ -87,8 +78,8 @@ typedef struct fix_transformations { char *textcharset; } fix_transformations; -int mhfixmsgsbr (CT *, char *, const fix_transformations *, FILE **, char *, - FILE **); +static int mhfixmsgsbr (CT *, char *, const fix_transformations *, + FILE **, char *, FILE **); static int fix_boundary (CT *, int *); static int copy_input_to_output (const char *, FILE *, const char *, FILE *); static int get_multipart_boundary (CT, char **); @@ -116,7 +107,7 @@ static int should_decode(const char *, const char *, const char *); static int content_encoding (CT, const char **); static int strip_crs (CT, int *); static void update_cte (CT); -static int least_restrictive_encoding (CT); +static int least_restrictive_encoding (CT) PURE; static int less_restrictive (int, int); static int convert_charsets (CT, char *, int *); static int fix_always (CT, int *); @@ -307,12 +298,12 @@ main (int argc, char **argv) { * Read the standard profile setup */ if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) { - readconfig ((struct node **) 0, fp, cp, 0); + readconfig(NULL, fp, cp, 0); fclose (fp); } - suppress_bogus_mp_content_warning = skip_mp_cte_check = 1; - suppress_extraneous_trailing_semicolon_warning = 1; + suppress_bogus_mp_content_warning = skip_mp_cte_check = true; + suppress_extraneous_trailing_semicolon_warning = true; if (! context_find ("path")) { free (path ("./", TFOLDER)); @@ -485,7 +476,10 @@ main (int argc, char **argv) { if (*cts) { for (ctp = cts; *ctp; ++ctp) { - status += mhfixmsgsbr (ctp, maildir, &fx, &infp, outfile, &outfp); + status = + mhfixmsgsbr (ctp, maildir, &fx, &infp, outfile, &outfp) == OK + ? 0 + : 1; free_content (*ctp); if (using_stdin) { @@ -501,7 +495,7 @@ main (int argc, char **argv) { status = 1; } - mh_xfree(maildir); + free(maildir); free (cts); if (fx.fixtypes != NULL) { svector_free (fx.fixtypes); } @@ -512,7 +506,7 @@ main (int argc, char **argv) { free (folder); free (arguments); - done (status); + done (status == OK ? 0 : 1); return NOTOK; } @@ -520,7 +514,7 @@ main (int argc, char **argv) { /* * Apply transformations to one message. */ -int +static int mhfixmsgsbr (CT *ctp, char *maildir, const fix_transformations *fx, FILE **infp, char *outfile, FILE **outfp) { /* Store input filename in case one of the transformations, i.e., @@ -872,7 +866,7 @@ replace_boundary (CT ct, char *file, char *boundary) { fprintf (fpout, "%s:%s%s\n", np, new_ctline, FENDNULL(new_params)); free(new_ctline); - mh_xfree(new_params); + free(new_params); } free (vp); @@ -1120,7 +1114,7 @@ fix_composite_cte (CT ct, int *message_mods) { for (hf = ct->c_first_hf; hf; hf = hf->next) { char *name = hf->name; - for (; *name && isspace ((unsigned char) *name); ++name) { + for (; isspace((unsigned char)*name); ++name) { continue; } @@ -1748,8 +1742,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { boundary_in_content (&new_part->c_cefile.ce_fp, new_part->c_cefile.ce_file, boundary)) == NOTOK) { - free_content (ct); - return NULL; + goto return_null; } } @@ -1760,8 +1753,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { boundary_in_content (&new_part->c_fp, new_part->c_file, boundary)) == NOTOK) { - free_content (ct); - return NULL; + goto return_null; } } @@ -1781,8 +1773,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { if (found_boundary) { inform("giving up trying to find a unique boundary"); - free_content (ct); - return NULL; + goto return_null; } } @@ -1827,6 +1818,11 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { free (boundary); return ct; + +return_null: + free_content(ct); + free(boundary); + return NULL; } @@ -2296,13 +2292,14 @@ strip_crs (CT ct, int *message_mods) { inform("unable to write temporary file %s, continuing...", stripped_content_file); (void) m_unlink (stripped_content_file); + free(stripped_content_file); status = NOTOK; } else { /* Replace the decoded file with the converted one. */ if (ct->c_cefile.ce_file && ct->c_cefile.ce_unlink) (void) m_unlink (ct->c_cefile.ce_file); - mh_xfree(ct->c_cefile.ce_file); + free(ct->c_cefile.ce_file); ct->c_cefile.ce_file = stripped_content_file; ct->c_cefile.ce_unlink = 1; @@ -2716,7 +2713,7 @@ write_content (CT ct, const char *input_filename, char *outfile, FILE *outfp, } } else { inform("unable to remove input file %s, " - "not modifying it, continuing...", infile); + "not modifying it, continuing...", infile); (void) m_unlink (outfile); status = NOTOK; }