static char *ignores[MAXARGS];
static jmp_buf env;
-static jmp_buf mhlenv;
-
-static FILE *(*mhl_action) () = (FILE *(*) ()) 0;
-
/*
** Redefine a couple of functions.
** These are undefined later in the code.
*/
-#define adios mhladios
-#define done mhldone
/*
** prototypes
static void putstr(char *);
static void putch(char);
static void intrser(int);
-static void mhladios(char *, char *, ...);
-static void mhldone(int);
int sc_width(void); /* from termsbr.c */
switch (smatch(++cp, switches)) {
case AMBIGSW:
ambigsw(cp, switches);
- done(1);
+ exit(1);
case UNKWNSW:
adios(NULL, "-%s unknown\n", cp);
case HELPSW:
snprintf(buf, sizeof(buf), "%s [switches] [files ...]", invo_name);
print_help(buf, switches, 1);
- done(1);
+ exit(0);
case VERSIONSW:
print_version(invo_name);
- done(1);
+ exit(0);
case FORMSW:
if (!(form = *argp++) || *form == '-')
switch (setjmp(env)) {
case OK:
if (fname) {
- fp = mhl_action ? (*mhl_action) (fname) :
- fopen(fname, "r");
+ fp = fopen(fname, "r");
if (fp == NULL) {
advise(fname, "unable to open");
exitstat++;
/* FALL THROUGH! */
default:
SIGNAL(SIGINT, SIG_IGN);
- if (mhl_action == NULL && fp != stdin)
+ if (fp != stdin)
fclose(fp);
if (holder.c_text) {
free(holder.c_text);
putchar('\n');
longjmp(env, DONE);
}
-
-
-#undef adios
-#undef done
-
-static void
-mhladios(char *what, char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- advertise(what, NULL, fmt, ap);
- va_end(ap);
- mhldone(1);
-}
-
-
-static void
-mhldone(int status)
-{
- exitstat = status;
- if (mhl_action)
- longjmp(mhlenv, DONE);
- else
- done(exitstat);
-}
static int listsw = -1;
-static void putzero_done(int) NORETURN;
+static void putzero_done();
int
main(int argc, char **argv)
struct msgs *mp;
register FILE *fp;
- done=putzero_done;
+ atexit(putzero_done);
setlocale(LC_ALL, "");
invo_name = mhbasename(argv[0]);
case AMBIGSW:
ambigsw(cp, switches);
listsw = 0; /* HACK */
- done(1);
+ exit(1);
case UNKWNSW:
adios(NULL, "-%s unknown", cp);
snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
print_help(buf, switches, 1);
listsw = 0; /* HACK */
- done(1);
+ exit(0);
case VERSIONSW:
print_version(invo_name);
listsw = 0; /* HACK */
- done(1);
+ exit(0);
case CCSW:
case DATESW:
adios(NULL, "too many sequences (more than %d) specified", NUMATTRS);
if (!seq_nameok(cp))
- done(1);
+ exit(1);
seqs[seqp++] = cp;
continue;
/* parse all the message ranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < msgs.size; msgnum++)
if (!m_convert(mp, msgs.msgs[msgnum]))
- done(1);
+ exit(1);
seq_setprev(mp); /* set the previous-sequence */
/*
folder);
if (!pcompile(vec, NULL))
- done(1);
+ exit(1);
lo = mp->lowsel;
hi = mp->hghsel;
*/
for (seqp = 0; seqs[seqp]; seqp++)
if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw))
- done(1);
+ exit(1);
/*
** Print total matched if not printing each matched message number.
seq_save(mp); /* synchronize message sequences */
context_save(); /* save the context file */
folder_free(mp); /* free folder/message structure */
- done(0);
- return 1;
+ listsw = 0; /* HACK */
+ return 0;
}
static void
-putzero_done(int status)
+putzero_done()
{
- if (listsw && status && !isatty(fileno(stdout)))
+ if (listsw && !isatty(fileno(stdout)))
printf("0\n");
- exit(status);
}
#include <errno.h>
#include <signal.h>
#include <h/signals.h>
-#include <setjmp.h>
#include <h/mime.h>
#include <h/tws.h>
#include <h/utils.h>
char *annotext = NULL;
char *distfile = NULL;
-static jmp_buf env;
-
/* name of temp file for body content */
static char body_file_name[MAXPATHLEN + 1];
/* name of mhbuild composition temporary file */
** static prototypes
*/
static int sendsbr(char **, int, char *, struct stat *);
-static void armed_done(int) NORETURN;
static void anno(struct stat *);
static int sendaux(char **, int, char *, struct stat *);
static int attach(char *);
switch (smatch(++cp, switches)) {
case AMBIGSW:
ambigsw(cp, switches);
- done(1);
+ exit(1);
case UNKWNSW:
adios(NULL, "-%s unknown\n", cp);
"%s [file] [switches]",
invo_name);
print_help(buf, switches, 1);
- done(1);
+ exit(0);
case VERSIONSW:
print_version(invo_name);
- done(1);
+ exit(0);
case DEBUGSW:
debugsw++;
/* parse all the msgranges/sequences and set SELECTED */
for (msgnum = 0; msgnum < nmsgs; msgnum++) {
if (!m_convert(mp, msgs[msgnum])) {
- done(1);
+ exit(1);
}
}
seq_setprev(mp);
for (n = 0; n < nfiles; n++) {
switch (sendsbr(vec, vecp, files[n], &st)) {
case DONE:
- done(++status);
+ exit(++status);
case NOTOK:
status++; /* fall */
case OK:
}
context_save();
- done(status);
- return 1;
+ return status;
}
break;
}
- done=armed_done;
- switch (setjmp(env)) {
+ switch (sendaux(vec, vecp, drft, st)) {
case OK:
- status = sendaux(vec, vecp, drft, st) ? NOTOK : OK;
- if (status == OK) {
- /* move original draft to +trash folder */
- /* temporary close stdin, for refile not to ask */
- dupfd = dup(0);
- close(0);
- if (execprogl("refile", "refile", "-file",
- original_draft, "+trash",
- (char *)NULL) != 0) {
- advise(NULL, "unable to trash the draft");
- }
- dup2(dupfd, 0);
- close(dupfd);
+ /* move original draft to +trash folder */
+ /* temporary close stdin, for refile not to ask */
+ dupfd = dup(0);
+ close(0);
+ if (execprogl("refile", "refile", "-file",
+ original_draft, "+trash",
+ (char *)NULL) != 0) {
+ advise(NULL, "unable to trash the draft");
}
+ dup2(dupfd, 0);
+ close(dupfd);
break;
default:
break;
}
- done=exit;
if (distfile) {
unlink(distfile);
}
vec[vecp++] = drft;
if (distfile && distout(drft, distfile, backup) == NOTOK) {
- done(1);
+ return DONE;
}
vec[vecp] = NULL;
switch (child_id = fork()) {
case -1:
/* oops -- fork error */
- adios("fork", "unable to");
- break; /* NOT REACHED */
+ advise("fork", "unable to");
+ return DONE;
case 0:
/* child process -- send it */
}
- return status;
+ return status ? NOTOK : status;
}
return "message not delivered to anyone";
}
}
-
-
-static void
-armed_done(int status)
-{
- longjmp(env, status ? status : NOTOK);
-
- exit(status);
-}