3 * sendsbr.c -- routines to help WhatNow/Send along
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
11 #include <h/signals.h>
12 #include <h/m_setjmp.h>
19 #ifdef HAVE_SYS_TIME_H
20 # include <sys/time.h>
24 int debugsw = 0; /* global */
32 char *altmsg = NULL; /* .. */
33 char *annotext = NULL;
34 char *distfile = NULL;
38 static char body_file_name[MAXPATHLEN + 1]; /* name of temporary file for body content */
39 static char composition_file_name[MAXPATHLEN + 1]; /* name of mhbuild composition temporary file */
40 static int field_size; /* size of header field buffer */
41 static char *field; /* header field buffer */
42 static FILE *draft_file; /* draft file pointer */
43 static FILE *body_file; /* body file pointer */
44 static FILE *composition_file; /* composition file pointer */
49 int sendsbr (char **, int, char *, struct stat *, int, char *, int);
50 char *getusername (void);
55 static void armed_done (int) NORETURN;
56 static void alert (char *, int);
57 static int tmp_fd (void);
58 static void anno (int, struct stat *);
59 static void annoaux (int);
60 static int splitmsg (char **, int, char *, struct stat *, int);
61 static int sendaux (char **, int, char *, struct stat *);
63 static int attach(char *, char *, int);
64 static void clean_up_temporary_files(void);
65 static int get_line(void);
66 static void make_mime_composition_file_entry(char *, int);
70 * Entry point into (back-end) routines to send message.
74 sendsbr (char **vec, int vecp, char *drft, struct stat *st, int rename_drft, char *attachment_header_field_name, int attachformat)
77 char buffer[BUFSIZ], file[BUFSIZ];
79 char *original_draft; /* name of original draft file */
80 char *p; /* string pointer for building file name */
83 * Save the original name of the draft file. The name of the draft file is changed
84 * to a temporary file containing the built MIME message if there are attachments.
85 * We need the original name so that it can be renamed after the message is sent.
88 original_draft = drft;
91 * There might be attachments if a header field name for attachments is supplied.
92 * Convert the draft to a MIME message. Use the mhbuild composition file for the
93 * draft if there was a successful conversion because that now contains the MIME
94 * message. A nice side effect of this is that it leaves the original draft file
95 * untouched so that it can be retrieved and modified if desired.
98 if (attachment_header_field_name != (char *)0) {
99 switch (attach(attachment_header_field_name, drft, attachformat)) {
101 drft = composition_file_name;
113 switch (m_setjmp (env)) {
116 * If given -push and -unique (which is undocumented), then
117 * rename the draft file. I'm not quite sure why.
119 if (pushsw && unique) {
120 char *cp = m_mktemp2(drft, invo_name, NULL, NULL);
122 adios ("sendsbr", "unable to create temporary file");
124 if (rename (drft, strncpy(file, cp, sizeof(file))) == NOTOK)
125 adios (file, "unable to rename %s to", drft);
130 * Check if we need to split the message into
131 * multiple messages of type "message/partial".
133 if (splitsw >= 0 && !distfile && stat (drft, &sts) != NOTOK
134 && sts.st_size >= CPERMSG) {
135 status = splitmsg (vec, vecp, drft, st, splitsw) ? NOTOK : OK;
137 status = sendaux (vec, vecp, drft, st) ? NOTOK : OK;
140 /* rename the original draft */
141 if (rename_drft && status == OK &&
142 rename (original_draft, strncpy (buffer, m_backup (original_draft), sizeof(buffer))) == NOTOK)
143 advise (buffer, "unable to rename %s to", drft);
156 * Get rid of any temporary files that we created for attachments. Also get rid of
157 * the renamed composition file that mhbuild leaves as a turd. It looks confusing,
158 * but we use the body file name to help build the renamed composition file name.
161 if (drft == composition_file_name) {
162 clean_up_temporary_files();
164 if (strlen(composition_file_name) >= sizeof (composition_file_name) - 6)
165 advise((char *)0, "unable to remove original composition file.");
168 if ((p = strrchr(composition_file_name, '/')) == (char *)0)
169 p = composition_file_name;
173 (void)strcpy(body_file_name, p);
175 (void)strcpy(p, body_file_name);
176 (void)strcat(p, ".orig");
178 (void)unlink(composition_file_name);
186 attach(char *attachment_header_field_name, char *draft_file_name,
189 char buf[MAXPATHLEN + 6]; /* miscellaneous buffer */
190 int c; /* current character for body copy */
191 int has_attachment; /* draft has at least one attachment */
192 int has_body; /* draft has a message body */
193 int length; /* length of attachment header field name */
194 char *p; /* miscellaneous string pointer */
195 FILE *fp; /* pointer for mhn.defaults */
198 * Open up the draft file.
201 if ((draft_file = fopen(draft_file_name, "r")) == (FILE *)0)
202 adios((char *)0, "can't open draft file `%s'.", draft_file_name);
205 * Allocate a buffer to hold the header components as they're read in.
206 * This buffer might need to be quite large, so we grow it as needed.
209 field = (char *)mh_xmalloc(field_size = 256);
212 * Scan the draft file for a header field name that matches the -attach
213 * argument. The existence of one indicates that the draft has attachments.
214 * Bail out if there are no attachments because we're done. Read to the
215 * end of the headers even if we have no attachments.
218 length = strlen(attachment_header_field_name);
222 while (get_line() != EOF && *field != '\0' && *field != '-')
223 if (strncasecmp(field, attachment_header_field_name, length) == 0 && field[length] == ':')
226 if (has_attachment == 0)
230 * We have at least one attachment. Look for at least one non-blank line
231 * in the body of the message which indicates content in the body.
236 while (get_line() != EOF) {
237 for (p = field; *p != '\0'; p++) {
238 if (*p != ' ' && *p != '\t') {
249 * Make names for the temporary files.
252 (void)strncpy(body_file_name,
253 m_mktemp(m_maildir(invo_name), NULL, NULL),
254 sizeof (body_file_name));
255 (void)strncpy(composition_file_name,
256 m_mktemp(m_maildir(invo_name), NULL, NULL),
257 sizeof (composition_file_name));
260 body_file = fopen(body_file_name, "w");
262 composition_file = fopen(composition_file_name, "w");
264 if ((has_body && body_file == (FILE *)0) || composition_file == (FILE *)0) {
265 clean_up_temporary_files();
266 adios((char *)0, "unable to open all of the temporary files.");
270 * Start at the beginning of the draft file. Copy all non-attachment header fields
271 * to the temporary composition file. Then add the dashed line separator.
276 while (get_line() != EOF && *field != '\0' && *field != '-')
277 if (strncasecmp(field, attachment_header_field_name, length) != 0 || field[length] != ':')
278 (void)fprintf(composition_file, "%s\n", field);
280 (void)fputs("--------\n", composition_file);
283 * Copy the message body to a temporary file.
287 while ((c = getc(draft_file)) != EOF)
290 (void)fclose(body_file);
294 * Add a mhbuild MIME composition file line for the body if there was one.
298 make_mime_composition_file_entry(body_file_name, attachformat);
301 * Now, go back to the beginning of the draft file and look for header fields
302 * that specify attachments. Add a mhbuild MIME composition file for each.
305 if ((fp = fopen (p = etcpath ("mhn.defaults"), "r"))) {
306 readconfig ((struct node **) NULL, fp, p, 0);
312 while (get_line() != EOF && *field != '\0' && *field != '-') {
313 if (strncasecmp(field, attachment_header_field_name, length) == 0 && field[length] == ':') {
314 for (p = field + length + 1; *p == ' ' || *p == '\t'; p++)
317 make_mime_composition_file_entry(p, attachformat);
321 (void)fclose(composition_file);
324 * We're ready to roll! Run mhbuild on the composition file. Note that mhbuild
325 * is in the context as buildmimeproc.
328 (void)sprintf(buf, "%s %s", buildmimeproc, composition_file_name);
330 if (system(buf) != 0) {
331 clean_up_temporary_files();
339 clean_up_temporary_files(void)
341 (void)unlink(body_file_name);
342 (void)unlink(composition_file_name);
350 int c; /* current character */
351 int n; /* number of bytes in buffer */
352 char *p; /* buffer pointer */
355 * Get a line from the input file, growing the field buffer as needed. We do this
356 * so that we can fit an entire line in the buffer making it easy to do a string
357 * comparison on both the field name and the field body which might be a long path
361 for (n = 0, p = field; (c = getc(draft_file)) != EOF; *p++ = c) {
362 if (c == '\n' && (c = getc(draft_file)) != ' ' && c != '\t') {
363 (void)ungetc(c, draft_file);
368 if (++n >= field_size - 1) {
369 field = (char *)mh_xrealloc((void *)field, field_size += 256);
376 * NUL-terminate the field..
385 make_mime_composition_file_entry(char *file_name, int attachformat)
387 int binary; /* binary character found flag */
388 int c; /* current character */
389 char cmd[MAXPATHLEN + 6]; /* file command buffer */
390 char *content_type; /* mime content type */
391 FILE *fp; /* content and pipe file pointer */
392 struct node *np; /* context scan node pointer */
393 char *p; /* miscellaneous string pointer */
394 struct stat st; /* file status buffer */
396 content_type = (char *)0;
399 * Check the file name for a suffix. Scan the context for that suffix on a
400 * mhshow-suffix- entry. We use these entries to be compatible with mhnshow,
401 * and there's no reason to make the user specify each suffix twice. Context
402 * entries of the form "mhshow-suffix-contenttype" in the name have the suffix
403 * in the field, including the dot.
406 if ((p = strrchr(file_name, '.')) != (char *)0) {
407 for (np = m_defs; np; np = np->n_next) {
408 if (strncasecmp(np->n_name, "mhshow-suffix-", 14) == 0 && mh_strcasecmp(p, np->n_field) == 0) {
409 content_type = np->n_name + 14;
416 * No content type was found, either because there was no matching entry in the
417 * context or because the file name has no suffix. Open the file and check for
418 * non-ASCII characters. Choose the content type based on this check.
421 if (content_type == (char *)0) {
422 if ((fp = fopen(file_name, "r")) == (FILE *)0) {
423 clean_up_temporary_files();
424 adios((char *)0, "unable to access file \"%s\"", file_name);
429 while ((c = getc(fp)) != EOF) {
430 if (c > 127 || c < 0) {
438 content_type = binary ? "application/octet-stream" : "text/plain";
442 * Make sure that the attachment file exists and is readable. Append a mhbuild
443 * directive to the draft file. This starts with the content type. Append a
444 * file name attribute and a private x-unix-mode attribute. Also append a
445 * description obtained (if possible) by running the "file" command on the file.
448 if (stat(file_name, &st) == -1 || access(file_name, R_OK) != 0) {
449 clean_up_temporary_files();
450 adios((char *)0, "unable to access file \"%s\"", file_name);
453 switch (attachformat) {
455 /* Insert name, file mode, and Content-Id. */
456 (void)fprintf(composition_file, "#%s; name=\"%s\"; x-unix-mode=0%.3ho",
457 content_type, ((p = strrchr(file_name, '/')) == (char *)0) ? file_name : p + 1, (unsigned short)(st.st_mode & 0777));
459 if (strlen(file_name) > MAXPATHLEN) {
460 clean_up_temporary_files();
461 adios((char *)0, "attachment file name `%s' too long.", file_name);
464 (void)sprintf(cmd, "file '%s'", file_name);
466 if ((fp = popen(cmd, "r")) != (FILE *)0 && fgets(cmd, sizeof (cmd), fp) != (char *)0) {
467 *strchr(cmd, '\n') = '\0';
470 * The output of the "file" command is of the form
474 * Strip off the "file:" and subsequent white space.
477 for (p = cmd; *p != '\0'; p++) {
479 for (p++; *p != '\0'; p++) {
488 /* Insert Content-Description. */
489 (void)fprintf(composition_file, " [ %s ]", p);
496 if (stringdex (m_maildir(invo_name), file_name) == 0) {
497 /* Content had been placed by send into a temp file.
498 Don't generate Content-Disposition header, because
499 it confuses Microsoft Outlook, Build 10.0.6626, at
501 (void) fprintf (composition_file, "#%s <>", content_type);
503 /* Suppress Content-Id, insert simple Content-Disposition
504 and Content-Description with filename. */
505 (void) fprintf (composition_file,
506 "#%1$s; name=\"%2$s\" <> [%2$s]{attachment}",
508 ((p = strrchr(file_name, '/')) == (char *)0) ? file_name : p + 1);
513 if (stringdex (m_maildir(invo_name), file_name) == 0) {
514 /* Content had been placed by send into a temp file.
515 Don't generate Content-Disposition header, because
516 it confuses Microsoft Outlook, Build 10.0.6626, at
518 (void) fprintf (composition_file, "#%s <>", content_type);
520 /* Suppress Content-Id, insert Content-Disposition with
521 modification date and Content-Description wtih filename. */
522 (void) fprintf (composition_file,
523 "#%1$s; name=\"%2$s\" <>[%2$s]{attachment; modification-date=\"%3$s\"}",
525 ((p = strrchr(file_name, '/')) == (char *)0) ? file_name : p + 1,
526 dtime (&st.st_mtime, 0));
531 adios ((char *)0, "unsupported attachformat %d", attachformat);
535 * Finish up with the file name.
538 (void)fprintf(composition_file, " %s\n", file_name);
544 * Split large message into several messages of
545 * type "message/partial" and send them.
549 splitmsg (char **vec, int vecp, char *drft, struct stat *st, int delay)
551 int compnum, nparts, partno, state, status;
554 char *cp, *dp, buffer[BUFSIZ], msgid[BUFSIZ];
555 char subject[BUFSIZ];
556 char name[NAMESZ], partnum[BUFSIZ];
559 if ((in = fopen (drft, "r")) == NULL)
560 adios (drft, "unable to open for reading");
566 * Scan through the message and examine the various header fields,
567 * as well as locate the beginning of the message body.
569 for (compnum = 1, state = FLD;;) {
570 switch (state = m_getfld (state, name, buffer, sizeof(buffer), in)) {
577 * This header field is discarded.
579 if (!mh_strcasecmp (name, "Message-ID")) {
580 while (state == FLDPLUS)
581 state = m_getfld (state, name, buffer, sizeof(buffer), in);
582 } else if (uprf (name, XXX_FIELD_PRF)
583 || !mh_strcasecmp (name, VRSN_FIELD)
584 || !mh_strcasecmp (name, "Subject")
585 || !mh_strcasecmp (name, "Encrypted")) {
587 * These header fields are copied to the enclosed
588 * header of the first message in the collection
589 * of message/partials. For the "Subject" header
590 * field, we also record it, so that a modified
591 * version of it, can be copied to the header
592 * of each messsage/partial in the collection.
594 if (!mh_strcasecmp (name, "Subject")) {
597 strncpy (subject, buffer, BUFSIZ);
598 sublen = strlen (subject);
599 if (sublen > 0 && subject[sublen - 1] == '\n')
600 subject[sublen - 1] = '\0';
603 dp = add (concat (name, ":", buffer, NULL), dp);
604 while (state == FLDPLUS) {
605 state = m_getfld (state, name, buffer, sizeof(buffer), in);
606 dp = add (buffer, dp);
610 * These header fields are copied to the header of
611 * each message/partial in the collection.
613 cp = add (concat (name, ":", buffer, NULL), cp);
614 while (state == FLDPLUS) {
615 state = m_getfld (state, name, buffer, sizeof(buffer), in);
616 cp = add (buffer, cp);
620 if (state != FLDEOF) {
621 start = ftell (in) + 1;
633 adios (NULL, "message format error in component #%d", compnum);
636 adios (NULL, "getfld () returned %d", state);
642 adios (NULL, "headers missing from draft");
646 while (fgets (buffer, sizeof(buffer) - 1, in)) {
649 if ((pos += (len = strlen (buffer))) > CPERMSG) {
655 /* Only one part, nothing to split */
662 return sendaux (vec, vecp, drft, st);
666 printf ("Sending as %d Partial Messages\n", nparts);
671 vec[vecp++] = "-partno";
672 vec[vecp++] = partnum;
674 vec[vecp++] = "-queued";
677 snprintf (msgid, sizeof(msgid), "<%d.%ld@%s>",
678 (int) getpid(), (long) clock, LocalName(1));
680 fseek (in, start, SEEK_SET);
681 for (partno = 1; partno <= nparts; partno++) {
685 char *cp = m_mktemp2(drft, invo_name, NULL, &out);
687 adios (drft, "unable to create temporary file for");
689 strncpy(tmpdrf, cp, sizeof(tmpdrf));
690 chmod (tmpdrf, 0600);
693 * Output the header fields
696 fprintf (out, "Subject: %s (part %d of %d)\n", subject, partno, nparts);
697 fprintf (out, "%s: %s\n", VRSN_FIELD, VRSN_VALUE);
698 fprintf (out, "%s: message/partial; id=\"%s\";\n", TYPE_FIELD, msgid);
699 fprintf (out, "\tnumber=%d; total=%d\n", partno, nparts);
700 fprintf (out, "%s: part %d of %d\n\n", DESCR_FIELD, partno, nparts);
703 * If this is the first in the collection, output the
704 * header fields we are encapsulating at the beginning
705 * of the body of the first message.
710 fprintf (out, "Message-ID: %s\n", msgid);
718 if (!fgets (buffer, sizeof(buffer) - 1, in)) {
719 if (partno == nparts)
721 adios (NULL, "premature eof");
724 if ((pos += (len = strlen (buffer))) > CPERMSG) {
725 fseek (in, -len, SEEK_CUR);
733 adios (tmpdrf, "error writing to");
737 if (!pushsw && verbsw) {
742 /* Pause here, if a delay is specified */
743 if (delay > 0 && 1 < partno && partno <= nparts) {
745 printf ("pausing %d seconds before sending part %d...\n",
749 sleep ((unsigned int) delay);
752 snprintf (partnum, sizeof(partnum), "%d", partno);
753 status = sendaux (vec, vecp, tmpdrf, st);
759 * This is so sendaux will only annotate
760 * the altmsg the first time it is called.
769 fclose (in); /* close the draft */
775 * Annotate original message, and
776 * call `postproc' to send message.
780 sendaux (char **vec, int vecp, char *drft, struct stat *st)
783 int i, status, fd, fd2;
784 char backup[BUFSIZ], buf[BUFSIZ];
786 fd = pushsw ? tmp_fd () : NOTOK;
791 if ((fd2 = tmp_fd ()) != NOTOK) {
792 vec[vecp++] = "-idanno";
793 snprintf (buf, sizeof(buf), "%d", fd2);
796 admonish (NULL, "unable to create file for annotation list");
799 if (distfile && distout (drft, distfile, backup) == NOTOK)
803 for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
808 /* oops -- fork error */
809 adios ("fork", "unable to");
810 break; /* NOT REACHED */
814 * child process -- send it
816 * If fd is ok, then we are pushing and fd points to temp
817 * file, so capture anything on stdout and stderr there.
820 dup2 (fd, fileno (stdout));
821 dup2 (fd, fileno (stderr));
824 execvp (postproc, vec);
825 fprintf (stderr, "unable to exec ");
828 break; /* NOT REACHED */
832 * parent process -- wait for it
834 if ((status = pidwait(child_id, NOTOK)) == OK) {
835 if (annotext && fd2 != NOTOK)
839 * If postproc failed, and we have good fd (which means
840 * we pushed), then mail error message (and possibly the
841 * draft) back to the user.
847 advise (NULL, "message not delivered to anyone");
849 if (annotext && fd2 != NOTOK)
853 if (rename (backup, drft) == NOTOK)
854 advise (drft, "unable to rename %s to", backup);
865 * Mail error notification (and possibly a copy of the
866 * message) back to the user, using the mailproc
870 alert (char *file, int out)
876 for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
881 /* oops -- fork error */
882 advise ("fork", "unable to");
885 /* child process -- send it */
886 SIGNAL (SIGHUP, SIG_IGN);
887 SIGNAL (SIGINT, SIG_IGN);
888 SIGNAL (SIGQUIT, SIG_IGN);
889 SIGNAL (SIGTERM, SIG_IGN);
891 if ((in = open (file, O_RDONLY)) == NOTOK) {
892 admonish (file, "unable to re-open");
894 lseek (out, (off_t) 0, SEEK_END);
895 strncpy (buf, "\nMessage not delivered to anyone.\n", sizeof(buf));
896 write (out, buf, strlen (buf));
897 strncpy (buf, "\n------- Unsent Draft\n\n", sizeof(buf));
898 write (out, buf, strlen (buf));
899 cpydgst (in, out, file, "temporary file");
901 strncpy (buf, "\n------- End of Unsent Draft\n", sizeof(buf));
902 write (out, buf, strlen (buf));
903 if (rename (file, strncpy (buf, m_backup (file), sizeof(buf))) == NOTOK)
904 admonish (buf, "unable to rename %s to", file);
907 lseek (out, (off_t) 0, SEEK_SET);
908 dup2 (out, fileno (stdin));
910 /* create subject for error notification */
911 snprintf (buf, sizeof(buf), "send failed on %s",
912 forwsw ? "enclosed draft" : file);
914 execlp (mailproc, r1bindex (mailproc, '/'), getusername (),
915 "-subject", buf, NULL);
916 fprintf (stderr, "unable to exec ");
920 default: /* no waiting... */
932 tfile = m_mktemp2(NULL, invo_name, &fd, NULL);
933 if (tfile == NULL) return NOTOK;
937 advise (NULL, "temporary file %s selected", tfile);
939 if (unlink (tfile) == NOTOK)
940 advise (tfile, "unable to remove");
947 anno (int fd, struct stat *st)
951 static char *cwd = NULL;
955 (stat (altmsg, &st2) == NOTOK
956 || st->st_mtime != st2.st_mtime
957 || st->st_dev != st2.st_dev
958 || st->st_ino != st2.st_ino)) {
960 admonish (NULL, "$mhaltmsg mismatch");
964 child_id = debugsw ? NOTOK : fork ();
966 case NOTOK: /* oops */
969 "unable to fork, so doing annotations by hand...");
971 cwd = getcpy (pwd ());
974 /* block a few signals */
976 sigaddset (&set, SIGHUP);
977 sigaddset (&set, SIGINT);
978 sigaddset (&set, SIGQUIT);
979 sigaddset (&set, SIGTERM);
980 sigprocmask (SIG_BLOCK, &set, &oset);
986 /* reset the signal mask */
987 sigprocmask (SIG_SETMASK, &oset, &set);
992 default: /* no waiting... */
1002 int fd2, fd3, msgnum;
1003 char *cp, *folder, *maildir;
1004 char buffer[BUFSIZ], **ap;
1008 if ((folder = getenv ("mhfolder")) == NULL || *folder == 0) {
1010 admonish (NULL, "$mhfolder not set");
1013 maildir = m_maildir (folder);
1014 if (chdir (maildir) == NOTOK) {
1016 admonish (maildir, "unable to change directory to");
1019 if (!(mp = folder_read (folder))) {
1021 admonish (NULL, "unable to read folder %s", folder);
1025 /* check for empty folder */
1026 if (mp->nummsg == 0) {
1028 admonish (NULL, "no messages in %s", folder);
1032 if ((cp = getenv ("mhmessages")) == NULL || *cp == 0) {
1034 admonish (NULL, "$mhmessages not set");
1037 if (!debugsw /* MOBY HACK... */
1039 && (fd3 = open ("/dev/null", O_RDWR)) != NOTOK
1040 && (fd2 = dup (fileno (stderr))) != NOTOK) {
1041 dup2 (fd3, fileno (stderr));
1046 for (ap = brkstring (cp = getcpy (cp), " ", NULL); *ap; ap++)
1047 m_convert (mp, *ap);
1050 dup2 (fd2, fileno (stderr));
1051 if (mp->numsel == 0) {
1053 admonish (NULL, "no messages to annotate");
1057 lseek (fd, (off_t) 0, SEEK_SET);
1058 if ((fp = fdopen (fd, "r")) == NULL) {
1060 admonish (NULL, "unable to fdopen annotation list");
1064 while (fgets (buffer, sizeof(buffer), fp) != NULL)
1065 cp = add (buffer, cp);
1069 advise (NULL, "annotate%s with %s: \"%s\"",
1070 inplace ? " inplace" : "", annotext, cp);
1071 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
1072 if (is_selected(mp, msgnum)) {
1074 advise (NULL, "annotate message %d", msgnum);
1075 annotate (m_name (msgnum), annotext, cp, inplace, 1, -2, 0);
1082 folder_free (mp); /* free folder/message structure */
1087 armed_done (int status)
1089 longjmp (env, status ? status : NOTOK);