spost: Just a move of some code.
[mmh] / uip / spost.c
index 93283cc..30e283f 100644 (file)
 
 #define MAX_SM_FIELD 1476  /* < largest hdr field sendmail will accept */
 
-struct swit switches[] = {
+static struct swit switches[] = {
 #define VERBSW  0
        { "verbose", 0 },
 #define NVERBSW  1
-       { "noverbose", 0 },
+       { "noverbose", 2 },
 #define WATCSW  2
        { "watch", 0 },
 #define NWATCSW  3
-       { "nowatch", 0 },
+       { "nowatch", 2 },
 #define ALIASW  4
        { "alias aliasfile", 0 },
 #define NALIASW  5
-       { "noalias", 0 },
+       { "noalias", 2 },
 #define VERSIONSW  6
-       { "version", 0 },
+       { "Version", 0 },
 #define HELPSW  7
        { "help", 0 },
 #define DEBUGSW  8
        { "debug", -5 },
 #define DISTSW  9
        { "dist", -4 },  /* interface from dist */
-#define PUSHSW  10  /* fork to sendmail then exit */
-       { "push", -4 },
-#define NPUSHSW  11  /* exec sendmail */
-       { "nopush", -6 },
-#define LIBSW  12
+#define LIBSW  10
        { "library directory", -7 },
        { NULL, 0 }
 };
@@ -113,7 +109,6 @@ static int badmsg = 0;  /* message has bad semantics */
 static int verbose = 0;  /* spell it out */
 static int debug = 0;  /* debugging post */
 static int watch = 0;  /* watch the delivery process */
-static int pushflg = 0;  /* if going to fork to sendmail */
 static int aliasflg = 0;  /* if going to process aliases */
 
 static unsigned msgflags = 0;  /* what we've seen */
@@ -152,9 +147,7 @@ main(int argc, char **argv)
        char *sargv[16], buf[BUFSIZ], name[NAMESZ];
        FILE *in;
 
-#ifdef LOCALE
        setlocale(LC_ALL, "");
-#endif
        invo_name = mhbasename(argv[0]);
 
        /* foil search of user profile/context */
@@ -205,13 +198,6 @@ main(int argc, char **argv)
                                watch = 0;
                                continue;
 
-                       case PUSHSW:
-                               pushflg++;
-                               continue;
-                       case NPUSHSW:
-                               pushflg = 0;
-                               continue;
-
                        case ALIASW:
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(NULL, "missing argument to %s",
@@ -312,17 +298,6 @@ main(int argc, char **argv)
                fcc(tmpfil, fccs);
        }
 
-       argp = sargv;
-       *argp++ = "send-mail";
-       *argp++ = "-m";  /* send to me too */
-       *argp++ = "-t";  /* read msg for recipients */
-       *argp++ = "-i";  /* don't stop on "." */
-       if (watch || verbose) {
-               *argp++ = "-v";
-               pushflg = 0;
-       }
-       *argp = NULL;
-
        if (bccs) {
                process_bccs(tmpfil);
                if (!(msgflags & MVIS)) {
@@ -341,21 +316,15 @@ main(int argc, char **argv)
        }
        unlink(tmpfil);
 
-       if (pushflg) {
-               /* fork to a child to run sendmail */
-               switch (fork()) {
-               case NOTOK:
-                       fprintf(verbose ? stdout : stderr,
-                                       "%s: can't fork to %s\n",
-                                       invo_name, sendmail);
-                       exit(-1);
-               case OK:
-                       /* we're the child .. */
-                       break;
-               default:
-                       exit(0);
-               }
+       argp = sargv;
+       *argp++ = "send-mail";
+       *argp++ = "-m";  /* send to me too */
+       *argp++ = "-t";  /* read msg for recipients */
+       *argp++ = "-i";  /* don't stop on "." */
+       if (watch || verbose) {
+               *argp++ = "-v";
        }
+       *argp = NULL;
        execv(sendmail, sargv);
        adios(sendmail, "can't exec");
        return -1;
@@ -654,12 +623,12 @@ fcc(char *file, char *folders)
                                folders);
                fflush(stdout);
        }
-       if (strlen(fileproc)+strlen(file)+strlen(folders)+100 > sizeof cmd) {
+       if (100+strlen(file)+strlen(folders) > sizeof cmd) {
                adios(NULL, "Too much Fcc data");
        }
        /* hack: read from /dev/null and refile(1) won't question us */
-       snprintf(cmd, sizeof cmd, "</dev/null %s -link -file %s %s",
-                       fileproc, file, folders);
+       snprintf(cmd, sizeof cmd, "</dev/null refile -link -file '%s' %s",
+                       file, folders);
        status = system(cmd);
        if (status == -1) {
                fprintf(stderr, "Skipped %sFcc %s: unable to system().\n",
@@ -694,8 +663,7 @@ process_bccs(char *origmsg)
                fprintf(out, "------------\n");
                fclose(out);
 
-               snprintf(buf, sizeof buf, "send%s %s",
-                               pushflg ? " -push" : "", bccdraft);
+               snprintf(buf, sizeof buf, "send %s", bccdraft);
                if (system(buf) != 0) {
                        admonish(invo_name, "Problems to send Bcc to %s",
                                        mp->m_text);