* Generally useful tty stuff.
static char *SccsId
= "@(#)tty.c 1.1 %G%";
static int c_erase
; /* Current erase char */
static int c_kill
; /* Current kill char */
static int ttyset
; /* We must now do erase/kill */
* Read all relevant header fields.
if (gtty(fileno(stdin
), &ttybuf
) < 0) {
c_erase
= ttybuf
.sg_erase
;
for (s
= SIGINT
; s
<= SIGQUIT
; s
++)
if ((savesigs
[s
-SIGINT
] = signal(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
);
ttybuf
.sg_erase
= c_erase
;
stty(fileno(stdin
), &ttybuf
);
for (s
= SIGINT
; s
<= SIGQUIT
; s
++)
signal(s
, savesigs
[s
-SIGINT
]);
* Read up a header from standard input.
* The source string has the preliminary contents to
fputs(pr
, stdout
); fflush(stdout
);
if (src
!= NOSTR
&& strlen(src
) > BUFSIZ
- 2) {
printf("too long to edit\n");
for (cp
= src
; c
= *cp
; cp
++) {
if (c
== c_erase
|| c
== c_kill
) {
cp2
= fgets(cp
, BUFSIZ
- (cp
- canonb
), stdin
);
canonb
[strlen(canonb
) - 1] = '\0';
if (cp2
== NOSTR
|| *cp2
== '\0')
return(strlen(canonb
) > 0 ? savestr(canonb
) : NOSTR
);