1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ Lexical processing of commands.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2013 Steffen "Daode" Nurpmeso <sdaoden@users.sf.net>.
8 * Copyright (c) 1980, 1993
9 * The Regents of the University of California. All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 static int _reset_on_stop
; /* do a reset() if stopped */
51 static sighandler_type _oldpipe
;
53 /* Update mailname (if *name* != NULL) and displayname */
54 static void _update_mailname(char const *name
);
55 #ifdef HAVE_MBLEN /* TODO unite __narrow_{pre,suf}fix() into one function! */
56 SINLINE
size_t __narrow_prefix(char const *cp
, size_t maxl
);
57 SINLINE
size_t __narrow_suffix(char const *cp
, size_t cpl
, size_t maxl
);
60 static const struct cmd
*lex(char *Word
);
61 static void stop(int s
);
62 static void hangup(int s
);
66 __narrow_prefix(char const *cp
, size_t maxl
)
71 for (err
= ok
= i
= 0; i
< maxl
;) {
72 int ml
= mblen(cp
, maxl
- i
);
73 if (ml
< 0) { /* XXX _narrow_prefix(): mblen() error; action? */
91 __narrow_suffix(char const *cp
, size_t cpl
, size_t maxl
)
96 for (err
= ok
= i
= 0; cpl
> maxl
|| err
;) {
97 int ml
= mblen(cp
, cpl
);
98 if (ml
< 0) { /* XXX _narrow_suffix(): mblen() error; action? */
115 #endif /* HAVE_MBLEN */
118 _update_mailname(char const *name
)
120 char tbuf
[MAXPATHLEN
], *mailp
, *dispp
;
123 /* Don't realpath(3) if it's only an update request */
126 enum protocol p
= which_protocol(name
);
127 if (p
== PROTO_FILE
|| p
== PROTO_MAILDIR
) {
128 if (realpath(name
, mailname
) == NULL
) {
129 fprintf(stderr
, tr(151,
130 "Can't canonicalize `%s'\n"), name
);
135 (void)n_strlcpy(mailname
, name
, MAXPATHLEN
);
141 /* Don't display an absolute path but "+FOLDER" if under *folder* */
142 if (getfold(tbuf
, sizeof tbuf
)) {
144 if (i
< sizeof(tbuf
) - 1)
146 if (strncmp(tbuf
, mailp
, i
) == 0) {
152 /* We want to see the name of the folder .. on the screen */
154 if (i
< sizeof(displayname
) - 1)
155 memcpy(dispp
, mailp
, i
+ 1);
157 /* Avoid disrupting multibyte sequences (if possible) */
159 j
= sizeof(displayname
) / 3 - 1;
160 i
-= sizeof(displayname
) - (1/* + */ + 3) - j
;
162 j
= __narrow_prefix(mailp
, sizeof(displayname
) / 3);
163 i
= j
+ __narrow_suffix(mailp
+ j
, i
- j
,
164 sizeof(displayname
) - (1/* + */ + 3 + 1) - j
);
166 (void)snprintf(dispp
, sizeof(displayname
), "%.*s...%s",
167 (int)j
, mailp
, mailp
+ i
);
175 * Set up editing on the given file name.
176 * If the first character of name is %, we are considered to be
177 * editing the file, otherwise we are reading our mail which has
178 * signficance for mbox and so forth.
180 * newmail: Check for new mail in the current folder only.
183 setfile(char const *name
, int newmail
)
186 int i
, compressed
= 0;
189 char const *who
= name
[1] ? name
+ 1 : myname
;
196 isedit
= (*name
!= '%' && ((sh
= get_shortcut(name
)) == NULL
||
197 *sh
->sh_long
!= '%'));
198 if ((name
= expand(name
)) == NULL
)
201 switch (which_protocol(name
)) {
205 return (maildir_setfile(name
, newmail
, isedit
));
209 return (pop3_setfile(name
, newmail
, isedit
));
215 if (mb
.mb_type
== MB_CACHE
)
218 return imap_setfile(name
, newmail
, isedit
);
221 fprintf(stderr
, tr(217, "Cannot handle protocol: %s\n"), name
);
225 if ((ibuf
= Zopen(name
, "r", &compressed
)) == NULL
) {
226 if ((!isedit
&& errno
== ENOENT
) || newmail
) {
235 if (fstat(fileno(ibuf
), &stb
) < 0) {
243 if (S_ISDIR(stb
.st_mode
)) {
250 } else if (S_ISREG(stb
.st_mode
)) {
262 * Looks like all will be well. We must now relinquish our
263 * hold on the current set of stuff. Must hold signals
264 * while we are reading the new file, else we will ruin
265 * the message[] data structure.
269 if (shudclob
&& !newmail
)
273 if (!newmail
&& mb
.mb_sock
.s_fd
>= 0)
275 #endif /* HAVE_SOCKETS */
278 * Copy the messages into /tmp
282 flp
.l_type
= F_RDLCK
;
284 flp
.l_whence
= SEEK_SET
;
286 mb
.mb_type
= MB_FILE
;
287 mb
.mb_perm
= (options
& OPT_R_FLAG
) ? 0 : MB_DELE
|MB_EDIT
;
288 mb
.mb_compressed
= compressed
;
290 if (compressed
& 0200)
293 if ((i
= open(name
, O_WRONLY
)) < 0)
313 if (!edit
&& fcntl(fileno(ibuf
), F_SETLKW
, &flp
) < 0) {
314 perror("Unable to lock mailbox");
318 } else /* newmail */{
319 fseek(mb
.mb_otf
, 0L, SEEK_END
);
320 fseek(ibuf
, mailsize
, SEEK_SET
);
322 omsgCount
= msgCount
;
324 if (!edit
&& fcntl(fileno(ibuf
), F_SETLKW
, &flp
) < 0)
327 mailsize
= fsize(ibuf
);
328 if (newmail
&& (size_t)mailsize
<= offset
) {
332 setptr(ibuf
, offset
);
334 if (newmail
&& mb
.mb_sorted
) {
342 if ((!edit
|| newmail
) && msgCount
== 0) {
345 if (value("emptystart") == NULL
)
346 nomail
: fprintf(stderr
, catgets(catd
, CATSET
, 88,
347 "No mail for %s\n"), who
);
352 newmailinfo(omsgCount
);
358 newmailinfo(int omsgCount
)
363 for (i
= 0; i
< omsgCount
; i
++)
364 message
[i
].m_flag
&= ~MNEWEST
;
365 if (msgCount
> omsgCount
) {
366 for (i
= omsgCount
; i
< msgCount
; i
++)
367 message
[i
].m_flag
|= MNEWEST
;
368 printf(tr(158, "New mail has arrived.\n"));
369 if (msgCount
- omsgCount
== 1)
370 printf(tr(214, "Loaded 1 new message.\n"));
372 printf(tr(215, "Loaded %d new messages.\n"),
373 msgCount
- omsgCount
);
375 printf(tr(224, "Loaded %d messages.\n"), msgCount
);
376 callhook(mailname
, 1);
378 if (value("header")) {
380 if (mb
.mb_type
== MB_IMAP
)
381 imap_getheaders(omsgCount
+1, msgCount
);
383 time_current_update(&time_current
, FAL0
);
384 while (++omsgCount
<= msgCount
)
385 if (visible(&message
[omsgCount
-1]))
386 printhead(omsgCount
, stdout
, 0);
392 * Interpret user commands one by one. If standard input is not a tty,
399 char *linebuf
= NULL
, *av
, *nv
;
406 if (safe_signal(SIGINT
, SIG_IGN
) != SIG_IGN
)
407 safe_signal(SIGINT
, onintr
);
408 if (safe_signal(SIGHUP
, SIG_IGN
) != SIG_IGN
)
409 safe_signal(SIGHUP
, hangup
);
410 /* TODO We do a lot of redundant signal handling, especially
411 * TODO with the line editor(s); try to merge this */
412 safe_signal(SIGTSTP
, stop
);
413 safe_signal(SIGTTOU
, stop
);
414 safe_signal(SIGTTIN
, stop
);
416 _oldpipe
= safe_signal(SIGPIPE
, SIG_IGN
);
417 safe_signal(SIGPIPE
, _oldpipe
);
422 handlerstacktop
= NULL
;
424 * Print the prompt, if needed. Clear out
425 * string space, and flush the output.
427 if (! sourcing
&& (options
& OPT_INTERACTIVE
)) {
428 av
= (av
= value("autoinc")) ? savestr(av
) : NULL
;
429 nv
= (nv
= value("newmail")) ? savestr(nv
) : NULL
;
430 if ((options
& OPT_TTYIN
) &&
431 (av
!= NULL
|| nv
!= NULL
||
432 mb
.mb_type
== MB_IMAP
)) {
435 n
= (av
&& strcmp(av
, "noimap") &&
436 strcmp(av
, "nopoll")) |
437 (nv
&& strcmp(nv
, "noimap") &&
438 strcmp(nv
, "nopoll"));
442 if ((mb
.mb_type
== MB_FILE
&&
443 stat(mailname
, &st
) == 0 &&
444 st
.st_size
> mailsize
) ||
446 (mb
.mb_type
== MB_IMAP
&&
447 imap_newmail(n
) > x
) ||
449 (mb
.mb_type
== MB_MAILDIR
&&
451 int odot
= dot
- &message
[0];
452 bool_t odid
= did_print_dot
;
454 setfile(mailname
, 1);
455 if (mb
.mb_type
!= MB_IMAP
) {
456 dot
= &message
[odot
];
457 did_print_dot
= odid
;
467 /* TODO Note: this buffer may contain a password
468 * TODO We should redefine the code flow which has
470 if ((nv
= termios_state
.ts_linebuf
) != NULL
) {
471 termios_state
.ts_linebuf
= NULL
;
472 termios_state
.ts_linesize
= 0;
473 free(nv
); /* TODO pool give-back */
475 /* TODO Due to expand-on-tab of our line editor the
476 * TODO buffer may grow */
477 if (linesize
> LINESIZE
* 3) {
478 free(linebuf
); /* TODO pool! but what? */
485 * Read a line of commands from the current input
486 * and handle end of file specially.
488 n
= readline_input(LNED_LF_ESC
| LNED_HIST_ADD
, NULL
,
489 &linebuf
, &linesize
);
499 if ((options
& OPT_INTERACTIVE
) &&
500 value("ignoreeof") && ++eofloop
< 25) {
501 printf(tr(89, "Use `quit' to quit.\n"));
509 if (execute(linebuf
, 0, n
))
511 if (exit_status
!= EXIT_OK
&& (options
& OPT_BATCH_FLAG
) &&
512 boption("batch-exit-on-error"))
523 * Execute a single command.
524 * Command functions return 0 for success, 1 for error, and -1
525 * for abort. A 1 or -1 aborts a load or source. A -1 aborts
526 * the interactive command loop.
527 * Contxt is non-zero if called while composing mail.
530 execute(char *linebuf
, int contxt
, size_t linesize
)
532 char _wordbuf
[2], *arglist
[MAXARGC
], *cp
, *word
;
533 struct cmd
const *com
= (struct cmd
*)NULL
;
534 int muvec
[2], c
, e
= 1;
536 /* Strip the white space away from the beginning of the command */
537 for (cp
= linebuf
; whitechar(*cp
); ++cp
)
540 /* Ignore comments */
544 /* Handle ! differently to get the correct lexical conventions */
547 fprintf(stderr
, tr(90, "Can't `!' while sourcing\n"));
554 /* Isolate the actual command; since it may not necessarily be
555 * separated from the arguments (as in `p1') we need to duplicate it to
556 * be able to create a NUL terminated version.
557 * We must be aware of special one letter commands here */
567 while (*cp
&& strchr(" \t0123456789$^.:/-+*'\",;(`",
572 c
= (int)(cp
- arglist
[0]);
574 word
= (c
<= 1) ? _wordbuf
: salloc(c
+ 1);
575 memcpy(word
, arglist
[0], c
);
578 /* Look up the command; if not found, bitch.
579 * Normally, a blank command would map to the first command in the
580 * table; while sourcing, however, we ignore blank lines to eliminate
582 if (sourcing
&& *word
== '\0')
586 if (com
== NULL
|| com
->c_func
== &ccmdnotsupp
) {
587 fprintf(stderr
, tr(91, "Unknown command: `%s'\n"), word
);
596 * See if we should execute the command -- if a conditional
597 * we always execute it, otherwise, check the state of cond.
599 if ((com
->c_argtype
& F
) == 0) {
600 if ((cond
== CRCV
&& (options
& OPT_SENDMODE
)) ||
601 (cond
== CSEND
&& ! (options
& OPT_SENDMODE
)) ||
602 (cond
== CTERM
&& ! (options
& OPT_TTYIN
)) ||
603 (cond
== CNONTERM
&& (options
& OPT_TTYIN
)))
608 * Process the arguments to the command, depending
609 * on the type he expects. Default to an error.
610 * If we are sourcing an interactive command, it's
613 if ((options
& OPT_SENDMODE
) && (com
->c_argtype
& M
) == 0) {
614 fprintf(stderr
, tr(92,
615 "May not execute `%s' while sending\n"),
619 if (sourcing
&& com
->c_argtype
& I
) {
620 fprintf(stderr
, tr(93,
621 "May not execute `%s' while sourcing\n"),
625 if ((mb
.mb_perm
& MB_DELE
) == 0 && com
->c_argtype
& W
) {
626 fprintf(stderr
, tr(94, "May not execute `%s' -- "
627 "message file is read only\n"),
631 if (contxt
&& com
->c_argtype
& R
) {
632 fprintf(stderr
, tr(95,
633 "Cannot recursively invoke `%s'\n"), com
->c_name
);
636 if (mb
.mb_type
== MB_VOID
&& com
->c_argtype
& A
) {
637 fprintf(stderr
, tr(257,
638 "Cannot execute `%s' without active mailbox\n"),
643 switch (com
->c_argtype
& ~(F
|P
|I
|M
|T
|W
|R
|A
)) {
645 /* Message list defaulting to nearest forward legal message */
648 if ((c
= getmsglist(cp
, _msgvec
, com
->c_msgflag
)) < 0)
651 *_msgvec
= first(com
->c_msgflag
, com
->c_msgmask
);
657 printf(tr(97, "No applicable messages\n"));
660 e
= (*com
->c_func
)(_msgvec
);
664 /* Message list with no defaults, but no error if none exist */
667 fprintf(stderr
, tr(96,
668 "Illegal use of `message list'\n"));
671 if ((c
= getmsglist(cp
, _msgvec
, com
->c_msgflag
)) < 0)
673 e
= (*com
->c_func
)(_msgvec
);
677 /* Just the straight string, with leading blanks removed */
678 while (whitechar(*cp
))
680 e
= (*com
->c_func
)(cp
);
685 /* A vector of strings, in shell style */
686 if ((c
= getrawlist(cp
, linesize
, arglist
,
687 sizeof arglist
/ sizeof *arglist
,
688 (com
->c_argtype
&~(F
|P
|I
|M
|T
|W
|R
|A
)) == ECHOLIST
)
691 if (c
< com
->c_minargs
) {
692 fprintf(stderr
, tr(99,
693 "`%s' requires at least %d arg(s)\n"),
694 com
->c_name
, com
->c_minargs
);
697 if (c
> com
->c_maxargs
) {
698 fprintf(stderr
, tr(100,
699 "`%s' takes no more than %d arg(s)\n"),
700 com
->c_name
, com
->c_maxargs
);
703 e
= (*com
->c_func
)(arglist
);
707 /* Just the constant zero, for exiting, eg. */
708 e
= (*com
->c_func
)(0);
712 panic(tr(101, "Unknown argument type"));
716 /* Exit the current source file on error */
717 if ((exec_last_comm_error
= (e
!= 0))) {
726 if (com
== (struct cmd
*)NULL
)
728 if (boption("autoprint") && com
->c_argtype
& P
)
730 muvec
[0] = dot
- &message
[0] + 1;
734 if (! sourcing
&& ! inhook
&& (com
->c_argtype
& T
) == 0)
741 * Set the size of the message vector used to construct argument
742 * lists to message list functions.
750 _msgvec
= (int*)scalloc(sz
+ 1, sizeof *_msgvec
);
754 * Find the correct command in the command table corresponding
755 * to the passed command "word"
758 static const struct cmd
*
761 extern const struct cmd cmdtab
[];
762 const struct cmd
*cp
;
764 for (cp
= &cmdtab
[0]; cp
->c_name
!= NULL
; cp
++)
765 if (is_prefix(Word
, cp
->c_name
))
771 * The following gets called on receipt of an interrupt. This is
772 * to abort printout of a command, mainly.
773 * Dispatching here when command() is inactive crashes rcv.
774 * Close all open files except 0, 1, 2, and the temporary.
775 * Also, unstack all source files.
778 static int inithdr
; /* am printing startup headers */
784 if (handlerstacktop
!= NULL
) {
788 safe_signal(SIGINT
, onintr
);
803 fprintf(stderr
, catgets(catd
, CATSET
, 102, "Interrupt\n"));
804 safe_signal(SIGPIPE
, _oldpipe
);
809 * When we wake up after ^Z, reprint the prompt.
814 sighandler_type old_action
= safe_signal(s
, SIG_DFL
);
819 sigprocmask(SIG_UNBLOCK
, &nset
, (sigset_t
*)NULL
);
821 sigprocmask(SIG_BLOCK
, &nset
, (sigset_t
*)NULL
);
822 safe_signal(s
, old_action
);
823 if (_reset_on_stop
) {
830 * Branch here on hangup signal and simulate "exit".
842 * Announce the presence of the current Mail version,
843 * give the message count, and print a header listing.
846 announce(int printheaders
)
850 mdot
= newfileinfo();
853 dot
= &message
[mdot
- 1];
854 if (printheaders
&& msgCount
> 0 && value("header") != NULL
) {
862 * Announce information about the file we are editing.
863 * Return a likely place to set dot.
869 int u
, n
, mdot
, d
, s
, hidden
, moved
;
871 if (mb
.mb_type
== MB_VOID
)
874 s
= d
= hidden
= moved
=0;
875 for (mp
= &message
[0], n
= 0, u
= 0; mp
< &message
[msgCount
]; mp
++) {
876 if (mp
->m_flag
& MNEW
)
878 if ((mp
->m_flag
& MREAD
) == 0)
880 if ((mp
->m_flag
& (MDELETED
|MSAVED
)) == (MDELETED
|MSAVED
))
882 if ((mp
->m_flag
& (MDELETED
|MSAVED
)) == MDELETED
)
884 if ((mp
->m_flag
& (MDELETED
|MSAVED
)) == MSAVED
)
886 if (mp
->m_flag
& MHIDDEN
)
889 _update_mailname(NULL
);
890 printf(tr(103, "\"%s\": "), displayname
);
892 printf(tr(104, "1 message"));
894 printf(tr(105, "%d messages"), msgCount
);
896 printf(tr(106, " %d new"), n
);
898 printf(tr(107, " %d unread"), u
);
900 printf(tr(108, " %d deleted"), d
);
902 printf(tr(109, " %d saved"), s
);
904 printf(tr(136, " %d moved"), moved
);
906 printf(tr(139, " %d hidden"), hidden
);
907 if (mb
.mb_type
== MB_CACHE
)
908 printf(" [Disconnected]");
909 else if (mb
.mb_perm
== 0)
910 printf(tr(110, " [Read only]"));
921 enum mflag avoid
= MHIDDEN
|MDELETED
;
924 if (value("autothread"))
926 else if ((cp
= value("autosort")) != NULL
) {
928 mb
.mb_sorted
= sstrdup(cp
);
932 if (mb
.mb_type
== MB_VOID
)
935 for (mp
= &message
[0]; mp
< &message
[msgCount
]; mp
++)
936 if ((mp
->m_flag
& (MNEWEST
|avoid
)) == MNEWEST
)
938 if (!newmail
|| mp
>= &message
[msgCount
]) {
939 for (mp
= mb
.mb_threaded
? threadroot
: &message
[0];
941 mp
!= NULL
: mp
< &message
[msgCount
];
943 mp
= next_in_thread(mp
) : mp
++)
944 if ((mp
->m_flag
& (MNEW
|avoid
)) == MNEW
)
947 if (mb
.mb_threaded
? mp
== NULL
: mp
>= &message
[msgCount
])
948 for (mp
= mb
.mb_threaded
? threadroot
: &message
[0];
949 mb
.mb_threaded
? mp
!= NULL
:
950 mp
< &message
[msgCount
];
951 mb
.mb_threaded
? mp
= next_in_thread(mp
) : mp
++)
952 if (mp
->m_flag
& MFLAGGED
)
954 if (mb
.mb_threaded
? mp
== NULL
: mp
>= &message
[msgCount
])
955 for (mp
= mb
.mb_threaded
? threadroot
: &message
[0];
956 mb
.mb_threaded
? mp
!= NULL
:
957 mp
< &message
[msgCount
];
958 mb
.mb_threaded
? mp
= next_in_thread(mp
) : mp
++)
959 if ((mp
->m_flag
& (MREAD
|avoid
)) == 0)
961 if (mb
.mb_threaded
? mp
!= NULL
: mp
< &message
[msgCount
])
962 mdot
= mp
- &message
[0] + 1;
963 else if (value("showlast")) {
964 if (mb
.mb_threaded
) {
965 for (mp
= this_in_thread(threadroot
, -1); mp
;
966 mp
= prev_in_thread(mp
))
967 if ((mp
->m_flag
& avoid
) == 0)
969 mdot
= mp
? mp
- &message
[0] + 1 : msgCount
;
971 for (mp
= &message
[msgCount
-1]; mp
>= &message
[0]; mp
--)
972 if ((mp
->m_flag
& avoid
) == 0)
974 mdot
= mp
>= &message
[0] ? mp
-&message
[0]+1 : msgCount
;
976 } else if (mb
.mb_threaded
) {
977 for (mp
= threadroot
; mp
; mp
= next_in_thread(mp
))
978 if ((mp
->m_flag
& avoid
) == 0)
980 mdot
= mp
? mp
- &message
[0] + 1 : 1;
982 for (mp
= &message
[0]; mp
< &message
[msgCount
]; mp
++)
983 if ((mp
->m_flag
& avoid
) == 0)
985 mdot
= mp
< &message
[msgCount
] ? mp
-&message
[0]+1 : 1;
991 * Print the current version number.
999 printf(catgets(catd
, CATSET
, 111, "Version %s\n"), version
);
1004 initbox(const char *name
)
1009 if (mb
.mb_type
!= MB_VOID
)
1010 (void)n_strlcpy(prevfile
, mailname
, MAXPATHLEN
);
1011 _update_mailname(name
!= mailname
? name
: NULL
);
1012 if ((mb
.mb_otf
= Ftemp(&tempMesg
, "tmpbox", "w", 0600, 0)) == NULL
) {
1013 perror(tr(87, "temporary mail message file"));
1016 (void)fcntl(fileno(mb
.mb_otf
), F_SETFD
, FD_CLOEXEC
);
1017 if ((mb
.mb_itf
= safe_fopen(tempMesg
, "r", &dummy
)) == NULL
) {
1018 perror(tr(87, "temporary mail message file"));
1021 (void)fcntl(fileno(mb
.mb_itf
), F_SETFD
, FD_CLOEXEC
);
1031 if (mb
.mb_sorted
!= NULL
) {
1033 mb
.mb_sorted
= NULL
;
1036 mb
.mb_flags
= MB_NOFLAGS
;
1040 did_print_dot
= FAL0
;