]> diplodocus.org Git - nmh/blobdiff - uip/sendsbr.c
sbr: Replace some ints that are only ever 0 or 1 with bool.
[nmh] / uip / sendsbr.c
index 4106010078cca75bf449494ddeeb84d112b3c0df..cc00e0ce32e24fa958fe8f92a6639501faa98ca9 100644 (file)
 #ifdef OAUTH_SUPPORT
 #include <h/oauth.h>
 #endif
-#include "../sbr/m_maildir.h"
-#include "../sbr/m_mktemp.h"
-#include "../sbr/message_id.h"
+#include "h/done.h"
+#include "sbr/m_maildir.h"
+#include "sbr/m_mktemp.h"
+#include "sbr/message_id.h"
 
 #ifdef OAUTH_SUPPORT
 static int setup_oauth_params(char *[], int *, const char *, const char **);
@@ -100,7 +101,7 @@ sendsbr (char **vec, int vecp, char *program, char *draft, struct stat *st,
        execvp(buildprogram, buildvec);
        fprintf(stderr, "unable to exec ");
        perror(buildmimeproc);
-       _exit(-1);
+       _exit(1);
        break;
 
     default:
@@ -109,7 +110,7 @@ sendsbr (char **vec, int vecp, char *program, char *draft, struct stat *st,
        break;
     }
 
-    done=armed_done;
+    set_done(armed_done);
     switch (setjmp (env)) {
     case OK:
        /*
@@ -119,8 +120,7 @@ sendsbr (char **vec, int vecp, char *program, char *draft, struct stat *st,
        if (pushsw && unique) {
            char *cp = m_mktemp2(drft, invo_name, NULL, NULL);
            if (cp == NULL) {
-               adios(NULL, "unable to create temporary file in %s",
-                     get_temp_dir());
+               die("unable to create temporary file");
            }
            if (rename (drft, strncpy(file, cp, sizeof(file))) == NOTOK)
                adios (file, "unable to rename %s to", drft);
@@ -135,10 +135,10 @@ sendsbr (char **vec, int vecp, char *program, char *draft, struct stat *st,
 #ifdef OAUTH_SUPPORT
                const char *errmsg;
                if (setup_oauth_params(vec, nvecsp, auth_svc, &errmsg) != OK) {
-                        adios(NULL, "%s", errmsg);
+                        die("%s", errmsg);
                }
 #else
-                adios(NULL, "send built without OAUTH_SUPPORT, "
+                die("send built without OAUTH_SUPPORT, "
                       "so auth_svc %s is not supported", auth_svc);
 #endif /* OAUTH_SUPPORT */
        }
@@ -175,7 +175,7 @@ sendsbr (char **vec, int vecp, char *program, char *draft, struct stat *st,
        break;
     }
 
-    done=exit;
+    set_done(exit);
     if (distfile)
        (void) m_unlink (distfile);
 
@@ -276,17 +276,17 @@ splitmsg (char **vec, int vecp, char *program, char *drft,
 
           case LENERR:
           case FMTERR:
-               adios (NULL, "message format error in component #%d", compnum);
+               die("message format error in component #%d", compnum);
 
           default:
-               adios (NULL, "getfld () returned %d", state);
+               die("getfld () returned %d", state);
        }
 
        break;
     }
     m_getfld_state_destroy (&gstate);
     if (cp == NULL)
-       adios (NULL, "headers missing from draft");
+       die("headers missing from draft");
 
     nparts = 1;
     pos = start;
@@ -302,7 +302,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft,
     /* Only one part, nothing to split */
     if (nparts == 1) {
        free (cp);
-        mh_xfree(dp);
+        free(dp);
 
        fclose (in);
        return sendaux (vec, vecp, program, drft, st);
@@ -329,8 +329,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft,
 
        char *cp = m_mktemp2(drft, invo_name, NULL, &out);
         if (cp == NULL) {
-           adios(NULL, "unable to create temporary file in %s",
-                 get_temp_dir());
+           die("unable to create temporary file");
         }
        strncpy(tmpdrf, cp, sizeof(tmpdrf));
 
@@ -363,7 +362,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft,
            if (!fgets (buffer, sizeof buffer, in)) {
                if (partno == nparts)
                    break;
-               adios (NULL, "premature eof");
+               die("premature eof");
            }
 
            if ((pos += (len = strlen (buffer))) > CPERMSG) {
@@ -408,7 +407,7 @@ splitmsg (char **vec, int vecp, char *program, char *drft,
     }
 
     free (cp);
-    mh_xfree(dp);
+    free(dp);
 
     fclose (in);       /* close the draft */
     return status;
@@ -424,7 +423,7 @@ static int
 sendaux (char **vec, int vecp, char *program, char *drft, struct stat *st)
 {
     pid_t child_id;
-    int i, status, fd, fd2;
+    int status, fd, fd2;
     char backup[BUFSIZ], buf[BUFSIZ];
 
     fd = pushsw ? tmp_fd () : NOTOK;
@@ -445,9 +444,7 @@ sendaux (char **vec, int vecp, char *program, char *drft, struct stat *st)
        done (1);
     vec[vecp] = NULL;
 
-    for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
-       sleep (5);
-
+    child_id = fork();
     switch (child_id) {
     case -1:
        /* oops -- fork error */
@@ -469,7 +466,7 @@ sendaux (char **vec, int vecp, char *program, char *drft, struct stat *st)
        execvp (program, vec);
        fprintf (stderr, "unable to exec ");
        perror (postproc);
-       _exit (-1);
+       _exit(1);
 
     default:
        /*
@@ -514,14 +511,12 @@ static void
 alert (char *file, int out)
 {
     pid_t child_id;
-    int i, in, argp;
+    int in, argp;
     char buf[BUFSIZ];
     char *program;
     char **arglist;
 
-    for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
-       sleep (5);
-
+    child_id = fork();
     switch (child_id) {
        case NOTOK:
            /* oops -- fork error */
@@ -574,7 +569,7 @@ alert (char *file, int out)
            execvp (program, arglist);
            fprintf (stderr, "unable to exec ");
            perror (mailproc);
-           _exit (-1);
+           _exit(1);
 
        default:                /* no waiting... */
            break;
@@ -768,12 +763,12 @@ handle_sendfrom(char **vec, int *vecp, char *draft, const char *auth_svc) {
             if (strcmp(*vp, "xoauth2") == 0) {
 #ifdef OAUTH_SUPPORT
                 if (setup_oauth_params(vec, vecp, auth_svc, &message) != OK) {
-                    adios(NULL, "%s", message);
+                    die("%s", message);
                 }
                 break;
 #else
                 NMH_UNUSED(auth_svc);
-                adios(NULL, "send built without OAUTH_SUPPORT, "
+                die("send built without OAUTH_SUPPORT, "
                       "so -saslmech xoauth2 is not supported");
 #endif /* OAUTH_SUPPORT */
             }
@@ -821,13 +816,13 @@ setup_oauth_params(char *vec[], int *vecp, const char *auth_svc,
         if (saslmech  &&  ! strcasecmp(saslmech, "xoauth2")) {
            if (! mh_oauth_get_service_info(auth_svc, &svc, errbuf,
                                            sizeof(errbuf)))
-               adios(NULL, "Unable to retrieve oauth profile entries: %s",
+               die("Unable to retrieve oauth profile entries: %s",
                      errbuf);
 
            vec[(*vecp)++] = mh_xstrdup("-authservice");
            vec[(*vecp)++] = mh_xstrdup(auth_svc);
            vec[(*vecp)++] = mh_xstrdup("-oauthcredfile");
-           vec[(*vecp)++] = mh_xstrdup(mh_oauth_cred_fn(auth_svc));
+           vec[(*vecp)++] = mh_oauth_cred_fn(auth_svc);
            vec[(*vecp)++] = mh_xstrdup("-oauthclientid");
            vec[(*vecp)++] = getcpy(svc.client_id);
            vec[(*vecp)++] = mh_xstrdup("-oauthclientsecret");