Fixed warnings from gcc -Wclobbered by adding volatile qualifiers.
[mmh] / uip / whatnowsbr.c
index 5fcba33..3009e0f 100644 (file)
@@ -2,8 +2,6 @@
 /*
  * whatnowsbr.c -- the WhatNow shell
  *
- * $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.
@@ -411,6 +409,11 @@ WhatNow (int argc, char **argv)
                break;
            }
 
+           if (*(argp+1) == (char *)0) {
+               advise((char *)0, "attach command requires file argument(s).");
+               break;
+           }
+
            /*
             *  Build a command line that causes the user's shell to list the file name
             *  arguments.  This handles and wildcard expansion, tilde expansion, etc.
@@ -634,7 +637,7 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp,
     struct stat st;
 
 #ifdef HAVE_LSTAT
-    int        slinked;
+    int        slinked = 0;
 #if 0
     int oumask;        /* PJS: for setting permissions on symlinks. */
 #endif
@@ -723,13 +726,6 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp,
 
        default:
            if ((status = pidwait (pid, NOTOK))) {
-#ifdef ATTVIBUG
-               if ((cp = r1bindex (*ed, '/'))
-                       && strcmp (cp, "vi") == 0
-                       && (status & 0x00ff) == 0)
-                   status = 0;
-               else {
-#endif
                if (((status & 0xff00) != 0xff00)
                    && (!reedit || (status & 0x00ff))) {
                    if (!use && (status & 0xff00) &&
@@ -741,9 +737,6 @@ editfile (char **ed, char **arg, char *file, int use, struct msgs *mp,
                }
                status = -2;    /* maybe "reedit ? -2 : -1"? */
                break;
-#ifdef ATTVIBUG
-               }
-#endif
            }
 
            reedit++;
@@ -818,7 +811,7 @@ copyf (char *ifile, char *ofile)
  */
 
 static int
-sendfile (char **arg, char *file, int pushsw)
+sendfile (char **arg, char *file, volatile int pushsw)
 {
     pid_t child_id;
     int i, vecp;
@@ -980,6 +973,12 @@ check_draft (char *msgnam)
 # define SASLminc(a)  0
 #endif /* CYRUS_SASL */
 
+#ifndef TLS_SUPPORT
+# define TLSminc(a)  (a)
+#else /* TLS_SUPPORT */
+# define TLSminc(a)   0
+#endif /* TLS_SUPPORT */
+
 static struct swit  sendswitches[] = {
 #define        ALIASW            0
     { "alias aliasfile", 0 },
@@ -1058,13 +1057,15 @@ static struct swit  sendswitches[] = {
 #define SASLMECHSW       37
     { "saslmech", SASLminc(-5) },
 #define USERSW           38
-    { "user", SASLminc(4) },
+    { "user", SASLminc(-4) },
 #define SNDATTACHSW       39
     { "attach file", 6 },
 #define SNDATTACHFORMAT   40
     { "attachformat", 7 },
 #define PORTSW           41
     { "port server-port-name/number", 4 },
+#define TLSSW            42
+    { "tls", TLSminc(-3) },
     { NULL, 0 }
 };
 
@@ -1096,9 +1097,6 @@ sendit (char *sp, char **arg, char *file, int pushed)
 #ifndef        lint
     int        distsw = 0;
 #endif
-#ifdef UCI
-    FILE *fp;
-#endif
 
     /*
      * Make sure these are defined.  In particular, we need
@@ -1146,6 +1144,16 @@ sendit (char *sp, char **arg, char *file, int pushed)
     vec[vecp++] = "-library";
     vec[vecp++] = getcpy (m_maildir (""));
 
+    if ((cp = context_find ("fileproc"))) {
+      vec[vecp++] = "-fileproc";
+      vec[vecp++] = cp;
+    }
+
+    if ((cp = context_find ("mhlproc"))) {
+      vec[vecp++] = "-mhlproc";
+      vec[vecp++] = cp;
+    }
+
     while ((cp = *argp++)) {
        if (*cp == '-') {
            switch (smatch (++cp, sendswitches)) {
@@ -1219,6 +1227,7 @@ sendit (char *sp, char **arg, char *file, int pushed)
                case SOMLSW:
                case SNOOPSW:
                case SASLSW:
+               case TLSSW:
                    vec[vecp++] = --cp;
                    continue;
 
@@ -1288,18 +1297,6 @@ sendit (char *sp, char **arg, char *file, int pushed)
     if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0)
        if ((cp = context_find ("signature")) && *cp)
            m_putenv ("SIGNATURE", cp);
-#ifdef UCI
-       else {
-           snprintf (buf, sizeof(buf), "%s/.signature", mypath);
-           if ((fp = fopen (buf, "r")) != NULL
-               && fgets (buf, sizeof(buf), fp) != NULL) {
-                   fclose (fp);
-                   if (cp = strchr (buf, '\n'))
-                       *cp = 0;
-                   m_putenv ("SIGNATURE", buf);
-           }
-       }
-#endif /* UCI */
 
     if ((annotext = getenv ("mhannotate")) == NULL || *annotext == 0)
        annotext = NULL;
@@ -1315,7 +1312,8 @@ sendit (char *sp, char **arg, char *file, int pushed)
 #endif /* not lint */
            && altmsg) {
        vec[vecp++] = "-dist";
-       distfile = getcpy (m_scratch (altmsg, invo_name));
+       distfile = getcpy (m_mktemp2(altmsg, invo_name, NULL, NULL));
+       unlink(distfile);
        if (link (altmsg, distfile) == NOTOK)
            adios (distfile, "unable to link %s to", altmsg);
     } else {