#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)) {
- 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);
+ if ((status = sendaux(vec, vecp, drft, st)) == 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");
}
- break;
-
- default:
+ dup2(dupfd, 0);
+ close(dupfd);
+ } else {
status = DONE;
- 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;
}
char *msgs, *folder;
char buf[BUFSIZ];
char *vec[MAXARGS];
- int vecp;
+ int vecp = 0;
char *cp, *dp;
if (altmsg && (stat(altmsg, &st2) == NOTOK ||
return "message not delivered to anyone";
}
}
-
-
-static void
-armed_done(int status)
-{
- longjmp(env, status ? status : NOTOK);
-
- exit(status);
-}