]> diplodocus.org Git - nmh/commitdiff
Add die(fmt, ...). Equivalent to adios(NULL, fmt, ...).
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 27 Aug 2017 10:34:50 +0000 (11:34 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 27 Aug 2017 10:34:50 +0000 (11:34 +0100)
Avoids the noise of the `NULL' first parameter that's used in over 70%
of adios() calls.  Removes the possibility of it being omitted and `fmt'
being used instead.  `die' is already in use in nmh's shell scripts.
Had to rename post.c's existing die() to avoid it clashing.

h/prototypes.h
sbr/error.c
uip/post.c

index 92ed8ef..0b40c0d 100644 (file)
@@ -18,6 +18,7 @@ struct msgs_array;
 void add_profile_entry (const char *, const char *);
 void inform(char *fmt, ...) CHECK_PRINTF(1, 2);
 void adios (const char *, const char *, ...) CHECK_PRINTF(2, 3) NORETURN;
+void die(const char *, ...) CHECK_PRINTF(1, 2) NORETURN;
 void admonish (char *, char *, ...) CHECK_PRINTF(2, 3);
 void advertise (const char *, char *, const char *, va_list) CHECK_PRINTF(3, 0);
 void advise (const char *, const char *, ...) CHECK_PRINTF(2, 3);
index 96c89f5..5a5808c 100644 (file)
@@ -58,6 +58,21 @@ adios (const char *what, const char *fmt, ...)
 }
 
 
+/* die is the same as adios(), but without the what as that's commonly
+ * NULL. */
+void NORETURN
+die(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    advertise(NULL, NULL, fmt, ap);
+    va_end(ap);
+    done(1);
+    abort();
+}
+
+
 /* admonish calls advertise() with a tail indicating the program
  * continues.
  * Thus "[invo_name: ]fmt[[ what]: errno], continuing...\n" results. */
index 1117061..a02b071 100644 (file)
@@ -306,7 +306,7 @@ static void sigon (void);
 static void sigoff (void);
 static void p_refile (char *);
 static void fcc (char *, char *);
-static void die (char *, char *, ...) CHECK_PRINTF(2, 3);
+static void fatal (char *, char *, ...) CHECK_PRINTF(2, 3);
 static void post (char *, int, int, int, char *, int, char *);
 static void do_text (char *file, int fd);
 static void do_an_address (struct mailname *, int);
@@ -1606,12 +1606,12 @@ static void
 chkadr (void)
 {
     if (badadr && unkadr)
-       die (NULL, "%d address%s unparsable, %d addressee%s undeliverable",
+       fatal (NULL, "%d address%s unparsable, %d addressee%s undeliverable",
                badadr, PLURALS(badadr), unkadr, PLURALS(badadr));
     if (badadr)
-       die (NULL, "%d address%s unparsable", badadr, PLURALS(badadr));
+       fatal (NULL, "%d address%s unparsable", badadr, PLURALS(badadr));
     if (unkadr)
-       die (NULL, "%d addressee%s undeliverable", unkadr, PLURALS(unkadr));
+       fatal (NULL, "%d addressee%s undeliverable", unkadr, PLURALS(unkadr));
 }
 
 
@@ -1652,7 +1652,7 @@ do_addresses (int bccque, int talk)
     chkadr ();
 
     if (rp_isbad (retval = sm_waend ()))
-       die (NULL, "problem ending addresses; %s", rp_string (retval));
+       fatal (NULL, "problem ending addresses; %s", rp_string (retval));
 }
 
 
@@ -1718,7 +1718,7 @@ post (char *file, int bccque, int talk, int eai, char *envelope,
         int eightbit = 0;
 
         if (fd == NOTOK) {
-          die (file, "unable to re-open");
+          fatal (file, "unable to re-open");
         }
 
         if (msgflags & MMIM  &&  cte != UNKNOWN) {
@@ -1728,7 +1728,7 @@ post (char *file, int bccque, int talk, int eai, char *envelope,
         } else {
             if (scan_input (fd, &eightbit) == NOTOK) {
                 close (fd);
-                die (file, "problem reading from");
+                fatal (file, "problem reading from");
             }
         }
 
@@ -1737,7 +1737,7 @@ post (char *file, int bccque, int talk, int eai, char *envelope,
                                        oauth_flag ? auth_svc : NULL, tlsflag))
                || rp_isbad (retval = sm_winit (envelope, eai, eightbit))) {
            close (fd);
-           die (NULL, "problem initializing server; %s", rp_string (retval));
+           fatal (NULL, "problem initializing server; %s", rp_string (retval));
        }
 
         do_addresses (bccque, talk && verbose);
@@ -1780,7 +1780,7 @@ verify_all_addresses (int talk, int eai, char *envelope, int oauth_flag,
                                        verbose, snoop, sasl, saslmech, user,
                                        oauth_flag ? auth_svc : NULL, tlsflag))
                || rp_isbad (retval = sm_winit (envelope, eai, eightbit))) {
-           die (NULL, "problem initializing server; %s", rp_string (retval));
+           fatal (NULL, "problem initializing server; %s", rp_string (retval));
        }
     }
 
@@ -1870,7 +1870,7 @@ do_an_address (struct mailname *lp, int talk)
        default: 
            if (!talk)
                fprintf (stderr, "  %s: ", addr);
-           die (NULL, "unexpected response; %s", rp_string (retval));
+           fatal (NULL, "unexpected response; %s", rp_string (retval));
     }
 
     fflush (stdout);
@@ -1887,11 +1887,11 @@ do_text (char *file, int fd)
 
     while ((state = read (fd, buf, sizeof(buf))) > 0) {
        if (rp_isbad (retval = sm_wtxt (buf, state)))
-           die (NULL, "problem writing text; %s\n", rp_string (retval));
+           fatal (NULL, "problem writing text; %s\n", rp_string (retval));
     }
 
     if (state == NOTOK)
-       die (file, "problem reading from");
+       fatal (file, "problem reading from");
 
     switch (retval = sm_wtend ()) {
        case RP_OK: 
@@ -1899,11 +1899,11 @@ do_text (char *file, int fd)
 
        case RP_NO: 
        case RP_NDEL: 
-           die (NULL, "posting failed; %s", rp_string (retval));
+           fatal (NULL, "posting failed; %s", rp_string (retval));
            break;
 
        default: 
-           die (NULL, "unexpected response; %s", rp_string (retval));
+           fatal (NULL, "unexpected response; %s", rp_string (retval));
     }
 }
 
@@ -2037,7 +2037,7 @@ fcc (char *file, char *folder)
  */
 
 static void
-die (char *what, char *fmt, ...)
+fatal (char *what, char *fmt, ...)
 {
     int err;
     va_list ap;