Here's a better test of Resent-From: in test-rcvdist: use the user's
[mmh] / uip / mhoutsbr.c
index 5ed9b97..8324991 100644 (file)
@@ -3,7 +3,9 @@
  * mhoutsbr.c -- routines to output MIME messages
  *            -- given a Content structure
  *
- * $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.
  */
 
 #include <h/mh.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 
-#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
 
-
-extern int errno;
 extern int ebcdicsw;
 
 static char ebcdicsafe[0x100] = {
@@ -67,7 +64,7 @@ static char nib2b64[0x40+1] =
  * prototypes
  */
 int output_message (CT, char *);
-int writeBase64aux (FILE *, FILE *);
+int output_message_fp (CT, FILE *, char *);
 
 /*
  * static prototypes
@@ -87,27 +84,33 @@ static int writeBase64 (CT, FILE *);
  */
 
 int
-output_message (CT ct, char *file)
+output_message_fp (CT ct, FILE *fp, char *file)
 {
-    FILE *fp;
-
-    if ((fp = fopen (file, "w")) == NULL) {
-       advise (file, "unable to open for writing");
-       return NOTOK;
-    }
-
     if (output_content (ct, fp) == NOTOK)
        return NOTOK;
 
     if (fflush (fp)) {
-       advise (file, "error writing to");
+       advise ((file?file:"<FILE*>"), "error writing to");
        return NOTOK;
     }
-    fclose (fp);
-
     return OK;
 }
 
+int
+output_message (CT ct, char *file)
+{
+    FILE *fp;
+    int status;
+
+    if ((fp = fopen (file, "w")) == NULL) {
+       advise (file, "unable to open for writing");
+       return NOTOK;
+    }
+    status = output_message_fp(ct, fp, file);
+    fclose(fp);
+    return status;
+}
+
 
 /*
  * Output a Content structure to a file.
@@ -260,7 +263,7 @@ writeExternalBody (CT ct, FILE *out)
 
            case 'N':
                for (ap = ci2->ci_attrs, ep = ci2->ci_values; *ap; ap++, ep++)
-                   if (!strcasecmp (*ap, "name")) {
+                   if (!mh_strcasecmp (*ap, "name")) {
                        fprintf (out, "%s", *ep);
                        break;
                    }
@@ -426,7 +429,7 @@ writeBase64 (CT ct, FILE *out)
 int
 writeBase64aux (FILE *in, FILE *out)
 {
-    int        cc, n;
+    unsigned int cc, n;
     char inbuf[3];
 
     n = BPERLIN;