[bug #4302] errno is not always an extern int
[mmh] / uip / send.c
index bf689f0..514f073 100644 (file)
@@ -3,6 +3,10 @@
  * send.c -- send a composed message
  *
  * $Id$
  * send.c -- send a composed message
  *
  * $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/mh.h>
@@ -98,6 +102,8 @@ static struct swit switches[] = {
     { "saslmech", SASLminc(-5) },
 #define USERSW                39
     { "user", SASLminc(-4) },
     { "saslmech", SASLminc(-5) },
 #define USERSW                39
     { "user", SASLminc(-4) },
+#define ATTACHSW              40
+    { "attach", 6 },
     { NULL, 0 }
 };
 
     { NULL, 0 }
 };
 
@@ -123,7 +129,6 @@ extern char *altmsg;                /*  .. */
 extern char *annotext;
 extern char *distfile;
 
 extern char *annotext;
 extern char *distfile;
 
-extern int   errno;
 
 int
 main (int argc, char **argv)
 
 int
 main (int argc, char **argv)
@@ -136,6 +141,7 @@ main (int argc, char **argv)
     char *msgs[MAXARGS], *vec[MAXARGS];
     struct msgs *mp;
     struct stat st;
     char *msgs[MAXARGS], *vec[MAXARGS];
     struct msgs *mp;
     struct stat st;
+    char       *attach = (char *)0;    /* header field name for attachments */
 #ifdef UCI
     FILE *fp;
 #endif /* UCI */
 #ifdef UCI
     FILE *fp;
 #endif /* UCI */
@@ -269,6 +275,11 @@ main (int argc, char **argv)
                        adios (NULL, "missing argument to %s", argp[-2]);
                    vec[vecp++] = cp;
                    continue;
                        adios (NULL, "missing argument to %s", argp[-2]);
                    vec[vecp++] = cp;
                    continue;
+               
+               case ATTACHSW:
+                   if (!(attach = *argp++) || *attach == '-')
+                       adios (NULL, "missing argument to %s", argp[-2]);
+                   continue;
            }
        } else {
            msgs[msgp++] = cp;
            }
        } else {
            msgs[msgp++] = cp;
@@ -432,7 +443,7 @@ go_to_it:
     closefds (3);
 
     for (msgnum = 0; msgnum < msgp; msgnum++) {
     closefds (3);
 
     for (msgnum = 0; msgnum < msgp; msgnum++) {
-       switch (sendsbr (vec, vecp, msgs[msgnum], &st, 1)) {
+       switch (sendsbr (vec, vecp, msgs[msgnum], &st, 1, attach)) {
            case DONE: 
                done (++status);
            case NOTOK: 
            case DONE: 
                done (++status);
            case NOTOK: