forw: convert system() to execprog(); fix buffer check
[mmh] / uip / send.c
index adb2039..c2c9f17 100644 (file)
@@ -24,8 +24,7 @@
 #include <time.h>
 
 int debugsw = 0;  /* global */
-int verbosesw = 0;
-char *altmsg   = NULL;
+char *altmsg = NULL;
 char *annotext = NULL;
 char *distfile = NULL;
 
@@ -118,9 +117,7 @@ main(int argc, char **argv)
                                debugsw++;
                                /* fall */
                        case VERBSW:
-                               verbosesw += 2;
                        case NVERBSW:
-                               verbosesw--;
                                vec[vecp++] = --cp;
                                continue;
                        }
@@ -448,8 +445,8 @@ attach(char *draft_file_name)
        fclose(composition_file);
 
        /* We're ready to roll! */
-       sprintf(buf, "mhbuild %s", composition_file_name);
-       if (system(buf) != 0) {
+       if (execprogl("mhbuild", "mhbuild", composition_file_name,
+                       (char *)NULL) != 0) {
                /* some problem */
                clean_up_temporary_files();
                return (NOTOK);
@@ -469,6 +466,7 @@ signandenc(char *draft_file_name)
        char buf[BUFSIZ];
        int dosign = 0;
        int doenc = 0;
+       int ret;
 
        if (!(draft_file = fopen(draft_file_name, "r"))) {
                adios(NULL, "can't open draft file `%s'.", draft_file_name);
@@ -495,9 +493,14 @@ signandenc(char *draft_file_name)
        strcpy(composition_file_name, draft_file_name);
 
        /* We're ready to roll! */
-       sprintf(buf, "mhsign -m%s '%s'", doenc ? " -e" : "",
-                       draft_file_name);
-       if (system(buf) != 0) {
+       if (doenc) {
+               ret = execprogl("mhsign", "mhsign", "-m", "-e",
+                               draft_file_name, (char *)NULL);
+       } else {
+               ret = execprogl("mhsign", "mhsign", "-m",
+                               draft_file_name, (char *)NULL);
+       }
+       if (ret != 0) {
                /* some problem */
                return (NOTOK);
        }
@@ -647,12 +650,9 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
                        if (annotext) {
                                anno(st);
                        }
-               }
-               else {
+               } else {
+                       /* spost failed */
                        advise(NULL, "%s", strexit(status));
-                       if (verbosesw <= 0) {
-                               advise(NULL, "Try using -v to get better output");
-                       }
                        if (distfile) {
                                unlink(drft);
                                if (rename(backup, drft) == NOTOK) {
@@ -716,13 +716,13 @@ strexit(int status)
                return "spost or sendmail killed by signal";
        }
        if (!WIFEXITED(status)) {
-               return "sendmail stopt for unknown reasen, message not deliverd to anyone";
+               return "message not delivered to anyone";
        }
        switch (WEXITSTATUS(status)) {
-               case EX_TEMPFAIL:
-                       return "Temporary error, maby the MTA hase queued the Mail";
-               default:
-                       return "sendmail stopt for unknown reasen, message not deliverd to anyone";
+       case EX_TEMPFAIL:
+               return "Temporary error, maybe the MTA has queued the message";
+       default:
+               return "message not delivered to anyone";
        }
 }