projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix burst so it actually complies with RFC 934. This means discarding
[mmh]
/
uip
/
mhbuild.c
diff --git
a/uip/mhbuild.c
b/uip/mhbuild.c
index
2776f7c
..
ad674f4
100644
(file)
--- a/
uip/mhbuild.c
+++ b/
uip/mhbuild.c
@@
-2,8
+2,6
@@
/*
* mhbuild.c -- expand/translate MIME composition files
*
/*
* mhbuild.c -- expand/translate MIME composition files
*
- * $Id$
- *
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
* complete copyright information.
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
* complete copyright information.
@@
-22,10
+20,6
@@
#include <h/mhcachesbr.h>
#include <h/utils.h>
#include <h/mhcachesbr.h>
#include <h/utils.h>
-#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-
static struct swit switches[] = {
#define CHECKSW 0
{ "check", 0 },
static struct swit switches[] = {
#define CHECKSW 0
{ "check", 0 },
@@
-74,7
+68,6
@@
static struct swit switches[] = {
/* mhbuildsbr.c */
/* mhbuildsbr.c */
-extern int checksw;
extern char *tmp; /* directory to place temp files */
/* mhcachesbr.c */
extern char *tmp; /* directory to place temp files */
/* mhcachesbr.c */
@@
-100,18
+93,16
@@
static int unlink_infile = 0;
static char outfile[BUFSIZ];
static int unlink_outfile = 0;
static char outfile[BUFSIZ];
static int unlink_outfile = 0;
-static void unlink_done (int);
+static void unlink_done (int) NORETURN;
/* mhbuildsbr.c */
CT build_mime (char *);
int output_message (CT, char *);
/* mhbuildsbr.c */
CT build_mime (char *);
int output_message (CT, char *);
+int output_message_fp (CT, FILE *, char*);
/* mhlistsbr.c */
int list_all_messages (CT *, int, int, int, int);
/* mhlistsbr.c */
int list_all_messages (CT *, int, int, int, int);
-/* mhmisc.c */
-void set_endian (void);
-
/* mhfree.c */
void free_content (CT);
/* mhfree.c */
void free_content (CT);
@@
-125,7
+116,8
@@
main (int argc, char **argv)
char buffer[BUFSIZ], *compfile = NULL;
char **argp, **arguments;
CT ct, cts[2];
char buffer[BUFSIZ], *compfile = NULL;
char **argp, **arguments;
CT ct, cts[2];
- FILE *fp;
+ FILE *fp = NULL;
+ FILE *fp_out = NULL;
done=unlink_done;
done=unlink_done;
@@
-306,11
+298,8
@@
main (int argc, char **argv)
* Process the composition file from standard input.
*/
if (compfile[0] == '-' && compfile[1] == '\0') {
* Process the composition file from standard input.
*/
if (compfile[0] == '-' && compfile[1] == '\0') {
-
/* copy standard input to temporary file */
/* copy standard input to temporary file */
- strncpy (infile, m_scratch ("", invo_name), sizeof(infile));
- if ((fp = fopen (infile, "w")) == NULL)
- adios (infile, "unable to open");
+ strncpy (infile, m_mktemp(invo_name, NULL, &fp), sizeof(infile));
while (fgets (buffer, BUFSIZ, stdin))
fputs (buffer, fp);
fclose (fp);
while (fgets (buffer, BUFSIZ, stdin))
fputs (buffer, fp);
fclose (fp);
@@
-322,11
+311,12
@@
main (int argc, char **argv)
cts[1] = NULL;
/* output MIME message to this temporary file */
cts[1] = NULL;
/* output MIME message to this temporary file */
- strncpy (outfile, m_scratch ("", invo_name), sizeof(outfile));
+ strncpy (outfile, m_mktemp(invo_name, NULL, &fp_out), sizeof(outfile));
unlink_outfile = 1;
/* output the message */
unlink_outfile = 1;
/* output the message */
- output_message (ct, outfile);
+ output_message_fp (ct, fp_out, outfile);
+ fclose(fp_out);
/* output the temp file to standard output */
if ((fp = fopen (outfile, "r")) == NULL)
/* output the temp file to standard output */
if ((fp = fopen (outfile, "r")) == NULL)
@@
-355,11
+345,13
@@
main (int argc, char **argv)
cts[1] = NULL;
/* output MIME message to this temporary file */
cts[1] = NULL;
/* output MIME message to this temporary file */
- strncpy (outfile, m_scratch (compfile, invo_name), sizeof(outfile));
+ strncpy(outfile, m_mktemp2(compfile, invo_name, NULL, &fp_out),
+ sizeof(outfile));
unlink_outfile = 1;
/* output the message */
unlink_outfile = 1;
/* output the message */
- output_message (ct, outfile);
+ output_message_fp (ct, fp_out, outfile);
+ fclose(fp_out);
/*
* List the message info
/*
* List the message info
@@
-369,12
+361,13
@@
main (int argc, char **argv)
/* Rename composition draft */
snprintf (buffer, sizeof(buffer), "%s.orig", m_backup (compfile));
/* Rename composition draft */
snprintf (buffer, sizeof(buffer), "%s.orig", m_backup (compfile));
- if (rename (compfile, buffer) == NOTOK)
- adios (compfile, "unable to rename %s to", buffer);
+ if (rename (compfile, buffer) == NOTOK) {
+ adios (compfile, "unable to rename comp draft %s to", buffer);
+ }
/* Rename output file to take its place */
if (rename (outfile, compfile) == NOTOK) {
/* Rename output file to take its place */
if (rename (outfile, compfile) == NOTOK) {
- advise (outfile, "unable to rename %s to", compfile);
+ advise (outfile, "unable to rename output %s to", compfile);
rename (buffer, compfile);
done (1);
}
rename (buffer, compfile);
done (1);
}