* Generally useful tty stuff.
static char *SccsId
= "@(#)tty.c 2.3 %G%";
static int c_erase
; /* Current erase char */
static int c_kill
; /* Current kill char */
static int hadcont
; /* Saw continue signal */
static jmp_buf rewrite
; /* Place to go when continued */
static int ttyset
; /* We must now do erase/kill */
* Read all relevant header fields.
int ttycont(), signull();
savecont
= sigset(SIGCONT
, signull
);
if (gtty(fileno(stdin
), &ttybuf
) < 0) {
c_erase
= ttybuf
.sg_erase
;
for (s
= SIGINT
; s
<= SIGQUIT
; s
++)
if ((savesigs
[s
-SIGINT
] = sigset(s
, SIG_IGN
)) == SIG_DFL
)
if (!ttyset
&& hp
->h_to
!= NOSTR
)
ttyset
++, stty(fileno(stdin
), &ttybuf
);
hp
->h_to
= readtty("To: ", hp
->h_to
);
if (!ttyset
&& hp
->h_subject
!= NOSTR
)
ttyset
++, stty(fileno(stdin
), &ttybuf
);
hp
->h_subject
= readtty("Subject: ", hp
->h_subject
);
if (hp
->h_subject
!= NOSTR
)
if (!ttyset
&& hp
->h_cc
!= NOSTR
)
ttyset
++, stty(fileno(stdin
), &ttybuf
);
hp
->h_cc
= readtty("Cc: ", hp
->h_cc
);
if (!ttyset
&& hp
->h_bcc
!= NOSTR
)
ttyset
++, stty(fileno(stdin
), &ttybuf
);
hp
->h_bcc
= readtty("Bcc: ", hp
->h_bcc
);
sigset(SIGCONT
, savecont
);
ttybuf
.sg_erase
= c_erase
;
stty(fileno(stdin
), &ttybuf
);
for (s
= SIGINT
; s
<= SIGQUIT
; s
++)
sigset(s
, savesigs
[s
-SIGINT
]);
* Read up a header from standard input.
* The source string has the preliminary contents to
if (src
!= NOSTR
&& strlen(src
) > BUFSIZ
- 2) {
printf("too long to edit\n");
cp
= src
== NOSTR
? "" : src
;
if (c
== c_erase
|| c
== c_kill
) {
while (cp2
< canonb
+ BUFSIZ
)
sigset(SIGCONT
, ttycont
);
while (cp2
< canonb
+ BUFSIZ
) {
if (c
== EOF
|| c
== '\n')
sigset(SIGCONT
, signull
);
if (c
== EOF
&& ferror(stdin
) && hadcont
) {
cp
= strlen(canonb
) > 0 ? canonb
: NOSTR
;
if (cp
== NOSTR
|| *cp
== '\0')
return(strlen(canonb
) > 0 ? savestr(canonb
) : NOSTR
);
* Null routine to satisfy
* silly system bug that denies us holding SIGCONT