]>
git.saurik.com Git - apple/network_cmds.git/blob - telnet.tproj/sys_bsd.c
2 * Copyright (c) 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/cdefs.h>
39 __FBSDID("$FreeBSD: src/crypto/telnet/telnet/sys_bsd.c,v 1.2.8.4 2002/04/13 10:59:08 markm Exp $");
43 #define __unused __attribute__((__unused__))
47 static const char sccsid
[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95";
51 * The following routines try to encapsulate what is system dependent
52 * (at least between 4.x and dos) which is used in telnet.c.
55 #include <sys/types.h>
56 #include <sys/socket.h>
62 #include <arpa/telnet.h>
71 tout
, /* Output file descriptor */
72 tin
, /* Input file descriptor */
76 struct tchars otc
= { 0 }, ntc
= { 0 };
77 struct ltchars oltc
= { 0 }, nltc
= { 0 };
78 struct sgttyb ottyb
= { 0 }, nttyb
= { 0 };
80 # define cfgetispeed(ptr) (ptr)->sg_ispeed
81 # define cfgetospeed(ptr) (ptr)->sg_ospeed
84 #else /* USE_TERMIO */
85 struct termio old_tc
= { 0, 0, 0, 0, {}, 0, 0 };
89 # define TCSANOW TCSETS
90 # define TCSADRAIN TCSETSW
91 # define tcgetattr(f, t) ioctl(f, TCGETS, (char *)t)
94 # define TCSANOW TCSETA
95 # define TCSADRAIN TCSETAW
96 # define tcgetattr(f, t) ioctl(f, TCGETA, (char *)t)
98 # define TCSANOW TIOCSETA
99 # define TCSADRAIN TIOCSETAW
100 # define tcgetattr(f, t) ioctl(f, TIOCGETA, (char *)t)
103 # define tcsetattr(f, a, t) ioctl(f, a, (char *)t)
104 # define cfgetospeed(ptr) ((ptr)->c_cflag&CBAUD)
106 # define cfgetispeed(ptr) (((ptr)->c_cflag&CIBAUD) >> IBSHIFT)
108 # define cfgetispeed(ptr) cfgetospeed(ptr)
110 # endif /* TCSANOW */
112 # define TIOCFLUSH TC_PX_DRAIN
114 #endif /* USE_TERMIO */
116 static fd_set
*ibitsp
, *obitsp
, *xbitsp
;
120 static SIG_FUNC_RET
intr(int);
123 static SIG_FUNC_RET
intr2(int);
126 static SIG_FUNC_RET
susp(int);
129 static SIG_FUNC_RET
ayt(int);
135 tout
= fileno(stdout
);
141 TerminalWrite(char *buf
, int n
)
143 return write(tout
, buf
, n
);
147 TerminalRead(char *buf
, int n
)
149 return read(tin
, buf
, n
);
157 TerminalAutoFlush(void)
162 ioctl(0, TIOCLGET
, (char *)&flush
);
163 return !(flush
&LNOFLSH
); /* if LNOFLSH, no autoflush */
169 #ifdef KLUDGELINEMODE
170 extern int kludgelinemode
;
173 * TerminalSpecialChars()
175 * Look at an input character to see if it is a special character
176 * and decide what to do.
180 * 0 Don't add this character.
181 * 1 Do add this character
185 TerminalSpecialChars(int c
)
187 if (c
== termIntChar
) {
190 } else if (c
== termQuitChar
) {
191 #ifdef KLUDGELINEMODE
198 } else if (c
== termEofChar
) {
199 if (my_want_state_is_will(TELOPT_LINEMODE
)) {
204 } else if (c
== termSuspChar
) {
207 } else if (c
== termFlushChar
) {
208 xmitAO(); /* Transmit Abort Output */
210 } else if (!MODE_LOCAL_CHARS(globalmode
)) {
211 if (c
== termKillChar
) {
214 } else if (c
== termEraseChar
) {
215 xmitEC(); /* Transmit Erase Character */
224 * Flush output to the terminal
228 TerminalFlushOutput(void)
231 (void) ioctl(fileno(stdout
), TIOCFLUSH
, (char *) 0);
233 (void) ioctl(fileno(stdout
), TCFLSH
, (char *) 0);
238 TerminalSaveState(void)
241 ioctl(0, TIOCGETP
, (char *)&ottyb
);
242 ioctl(0, TIOCGETC
, (char *)&otc
);
243 ioctl(0, TIOCGLTC
, (char *)&oltc
);
244 ioctl(0, TIOCLGET
, (char *)&olmode
);
250 #else /* USE_TERMIO */
251 tcgetattr(0, &old_tc
);
256 termFlushChar
= CONTROL('O');
259 termWerasChar
= CONTROL('W');
262 termRprntChar
= CONTROL('R');
265 termLiteralNextChar
= CONTROL('V');
268 termStartChar
= CONTROL('Q');
271 termStopChar
= CONTROL('S');
274 termAytChar
= CONTROL('T');
276 #endif /* USE_TERMIO */
283 case SLC_IP
: return(&termIntChar
);
284 case SLC_ABORT
: return(&termQuitChar
);
285 case SLC_EOF
: return(&termEofChar
);
286 case SLC_EC
: return(&termEraseChar
);
287 case SLC_EL
: return(&termKillChar
);
288 case SLC_XON
: return(&termStartChar
);
289 case SLC_XOFF
: return(&termStopChar
);
290 case SLC_FORW1
: return(&termForw1Char
);
292 case SLC_FORW2
: return(&termForw2Char
);
294 case SLC_AO
: return(&termFlushChar
);
297 case SLC_SUSP
: return(&termSuspChar
);
300 case SLC_EW
: return(&termWerasChar
);
303 case SLC_RP
: return(&termRprntChar
);
306 case SLC_LNEXT
: return(&termLiteralNextChar
);
309 case SLC_AYT
: return(&termAytChar
);
322 TerminalDefaultChars(void)
327 nttyb
.sg_kill
= ottyb
.sg_kill
;
328 nttyb
.sg_erase
= ottyb
.sg_erase
;
329 #else /* USE_TERMIO */
330 memcpy(new_tc
.c_cc
, old_tc
.c_cc
, sizeof(old_tc
.c_cc
));
332 termFlushChar
= CONTROL('O');
335 termWerasChar
= CONTROL('W');
338 termRprntChar
= CONTROL('R');
341 termLiteralNextChar
= CONTROL('V');
344 termStartChar
= CONTROL('Q');
347 termStopChar
= CONTROL('S');
350 termAytChar
= CONTROL('T');
352 #endif /* USE_TERMIO */
356 * TerminalNewMode - set up terminal to a specific mode.
357 * MODE_ECHO: do local terminal echo
358 * MODE_FLOW: do local flow control
359 * MODE_TRAPSIG: do local mapping to TELNET IAC sequences
360 * MODE_EDIT: do local line editing
363 * MODE_ECHO|MODE_EDIT|MODE_FLOW|MODE_TRAPSIG
367 * local signal mapping
371 * Both Linemode and Single Character mode:
374 * local/no signal mapping
378 TerminalNewMode(int f
)
380 static int prevmode
= 0;
386 #else /* USE_TERMIO */
387 struct termio tmp_tc
;
388 #endif /* USE_TERMIO */
393 globalmode
= f
&~MODE_FORCE
;
398 * Write any outstanding data before switching modes
399 * ttyflush() returns 0 only when there is no more data
400 * left to write out, it returns -1 if it couldn't do
401 * anything at all, otherwise it returns 1 + the number
402 * of characters left to write.
404 * We would really like ask the kernel to wait for the output
405 * to drain, like we can do with the TCSADRAIN, but we don't have
406 * that option. The only ioctl that waits for the output to
407 * drain, TIOCSETP, also flushes the input queue, which is NOT
408 * what we want (TIOCSETP is like TCSADFLUSH).
411 old
= ttyflush(SYNCHing
|flushout
);
412 if (old
< 0 || old
> 1) {
414 tcgetattr(tin
, &tmp_tc
);
415 #endif /* USE_TERMIO */
418 * Wait for data to drain, then flush again.
421 tcsetattr(tin
, TCSADRAIN
, &tmp_tc
);
422 #endif /* USE_TERMIO */
423 old
= ttyflush(SYNCHing
|flushout
);
424 } while (old
< 0 || old
> 1);
428 prevmode
= f
&~MODE_FORCE
;
442 tmp_tc
.c_lflag
|= ECHO
;
443 tmp_tc
.c_oflag
|= ONLCR
;
445 tmp_tc
.c_iflag
|= ICRNL
;
449 sb
.sg_flags
&= ~ECHO
;
451 tmp_tc
.c_lflag
&= ~ECHO
;
452 tmp_tc
.c_oflag
&= ~ONLCR
;
456 if ((f
&MODE_FLOW
) == 0) {
458 tc
.t_startc
= _POSIX_VDISABLE
;
459 tc
.t_stopc
= _POSIX_VDISABLE
;
461 tmp_tc
.c_iflag
&= ~(IXOFF
|IXON
); /* Leave the IXANY bit alone */
463 if (restartany
< 0) {
464 tmp_tc
.c_iflag
|= IXOFF
|IXON
; /* Leave the IXANY bit alone */
465 } else if (restartany
> 0) {
466 tmp_tc
.c_iflag
|= IXOFF
|IXON
|IXANY
;
468 tmp_tc
.c_iflag
|= IXOFF
|IXON
;
469 tmp_tc
.c_iflag
&= ~IXANY
;
474 if ((f
&MODE_TRAPSIG
) == 0) {
476 tc
.t_intrc
= _POSIX_VDISABLE
;
477 tc
.t_quitc
= _POSIX_VDISABLE
;
478 tc
.t_eofc
= _POSIX_VDISABLE
;
479 ltc
.t_suspc
= _POSIX_VDISABLE
;
480 ltc
.t_dsuspc
= _POSIX_VDISABLE
;
482 tmp_tc
.c_lflag
&= ~ISIG
;
487 tmp_tc
.c_lflag
|= ISIG
;
494 sb
.sg_flags
&= ~CBREAK
;
495 sb
.sg_flags
|= CRMOD
;
497 tmp_tc
.c_lflag
|= ICANON
;
501 sb
.sg_flags
|= CBREAK
;
503 sb
.sg_flags
|= CRMOD
;
505 sb
.sg_flags
&= ~CRMOD
;
507 tmp_tc
.c_lflag
&= ~ICANON
;
508 tmp_tc
.c_iflag
&= ~ICRNL
;
509 tmp_tc
.c_cc
[VMIN
] = 1;
510 tmp_tc
.c_cc
[VTIME
] = 0;
514 if ((f
&(MODE_EDIT
|MODE_TRAPSIG
)) == 0) {
516 ltc
.t_lnextc
= _POSIX_VDISABLE
;
519 tmp_tc
.c_cc
[VLNEXT
] = (cc_t
)(_POSIX_VDISABLE
);
524 if (f
&MODE_SOFT_TAB
) {
526 sb
.sg_flags
|= XTABS
;
529 tmp_tc
.c_oflag
|= OXTABS
;
532 tmp_tc
.c_oflag
&= ~TABDLY
;
533 tmp_tc
.c_oflag
|= TAB3
;
538 sb
.sg_flags
&= ~XTABS
;
541 tmp_tc
.c_oflag
&= ~OXTABS
;
544 tmp_tc
.c_oflag
&= ~TABDLY
;
549 if (f
&MODE_LIT_ECHO
) {
554 tmp_tc
.c_lflag
&= ~ECHOCTL
;
562 tmp_tc
.c_lflag
|= ECHOCTL
;
582 tmp_tc
.c_iflag
&= ~ISTRIP
;
584 tmp_tc
.c_iflag
|= ISTRIP
;
585 if (f
& MODE_OUTBIN
) {
586 tmp_tc
.c_cflag
&= ~(CSIZE
|PARENB
);
587 tmp_tc
.c_cflag
|= CS8
;
588 tmp_tc
.c_oflag
&= ~OPOST
;
590 tmp_tc
.c_cflag
&= ~(CSIZE
|PARENB
);
591 tmp_tc
.c_cflag
|= old_tc
.c_cflag
& (CSIZE
|PARENB
);
592 tmp_tc
.c_oflag
|= OPOST
;
600 (void) signal(SIGINT
, intr
);
603 (void) signal(SIGQUIT
, intr2
);
606 (void) signal(SIGTSTP
, susp
);
609 (void) signal(SIGINFO
, ayt
);
611 #if defined(USE_TERMIO) && defined(NOKERNINFO)
612 tmp_tc
.c_lflag
|= NOKERNINFO
;
615 * We don't want to process ^Y here. It's just another
616 * character that we'll pass on to the back end. It has
617 * to process it because it will be processed when the
618 * user attempts to read it, not when we send it.
621 ltc
.t_dsuspc
= _POSIX_VDISABLE
;
624 tmp_tc
.c_cc
[VDSUSP
] = (cc_t
)(_POSIX_VDISABLE
);
629 * If the VEOL character is already set, then use VEOL2,
630 * otherwise use VEOL.
632 esc
= (rlogin
!= _POSIX_VDISABLE
) ? rlogin
: escape
;
633 if ((tmp_tc
.c_cc
[VEOL
] != esc
)
635 && (tmp_tc
.c_cc
[VEOL2
] != esc
)
638 if (tmp_tc
.c_cc
[VEOL
] == (cc_t
)(_POSIX_VDISABLE
))
639 tmp_tc
.c_cc
[VEOL
] = esc
;
641 else if (tmp_tc
.c_cc
[VEOL2
] == (cc_t
)(_POSIX_VDISABLE
))
642 tmp_tc
.c_cc
[VEOL2
] = esc
;
646 if (tc
.t_brkc
== (cc_t
)(_POSIX_VDISABLE
))
651 (void) signal(SIGINFO
, (void (*)(int))ayt_status
);
654 (void) signal(SIGINT
, SIG_DFL
);
657 (void) signal(SIGQUIT
, SIG_DFL
);
660 (void) signal(SIGTSTP
, SIG_DFL
);
662 (void) sigsetmask(sigblock(0) & ~(1<<(SIGTSTP
-1)));
664 (void) sigrelse(SIGTSTP
);
677 ioctl(tin
, TIOCLSET
, (char *)&lmode
);
678 ioctl(tin
, TIOCSLTC
, (char *)<c
);
679 ioctl(tin
, TIOCSETC
, (char *)&tc
);
680 ioctl(tin
, TIOCSETN
, (char *)&sb
);
682 if (tcsetattr(tin
, TCSADRAIN
, &tmp_tc
) < 0)
683 tcsetattr(tin
, TCSANOW
, &tmp_tc
);
686 ioctl(tin
, FIONBIO
, (char *)&onoff
);
687 ioctl(tout
, FIONBIO
, (char *)&onoff
);
692 * Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD).
708 # define B19200 B14400
712 #define B28800 B19200
716 # define B38400 B28800
720 #define B57600 B38400
724 #define B76800 B57600
728 #define B115200 B76800
732 #define B230400 B115200
737 * This code assumes that the values B0, B50, B75...
738 * are in ascending order. They do not have to be
745 { 0, B0
}, { 50, B50
}, { 75, B75
},
746 { 110, B110
}, { 134, B134
}, { 150, B150
},
747 { 200, B200
}, { 300, B300
}, { 600, B600
},
748 { 1200, B1200
}, { 1800, B1800
}, { 2400, B2400
},
749 { 4800, B4800
}, { 7200, B7200
}, { 9600, B9600
},
750 { 14400, B14400
}, { 19200, B19200
}, { 28800, B28800
},
751 { 38400, B38400
}, { 57600, B57600
}, { 115200, B115200
},
752 { 230400, B230400
}, { -1, B230400
}
754 #endif /* DECODE_BAUD */
757 TerminalSpeeds(long *ispeed
, long *ospeed
)
760 struct termspeeds
*tp
;
761 #endif /* DECODE_BAUD */
764 out
= cfgetospeed(&old_tc
);
765 in
= cfgetispeed(&old_tc
);
771 while ((tp
->speed
!= -1) && (tp
->value
< in
))
776 while ((tp
->speed
!= -1) && (tp
->value
< out
))
779 #else /* DECODE_BAUD */
782 #endif /* DECODE_BAUD */
786 TerminalWindowSize(long *rows
, long *cols
)
791 if (ioctl(fileno(stdin
), TIOCGWINSZ
, (char *)&ws
) >= 0) {
796 #endif /* TIOCGWINSZ */
807 NetNonblockingIO(int fd
, int onoff
)
809 ioctl(fd
, FIONBIO
, (char *)&onoff
);
814 * Various signal handling routines.
819 deadpeer(int sig __unused
)
822 longjmp(peerdied
, -1);
827 intr(int sig __unused
)
834 longjmp(toplevel
, -1);
839 intr2(int sig __unused
)
842 #ifdef KLUDGELINEMODE
855 susp(int sig __unused
)
857 if ((rlogin
!= _POSIX_VDISABLE
) && rlogin_susp())
867 sendwin(int sig __unused
)
878 ayt(int sig __unused
)
889 sys_telnet_init(void)
891 (void) signal(SIGINT
, intr
);
892 (void) signal(SIGQUIT
, intr2
);
893 (void) signal(SIGPIPE
, deadpeer
);
895 (void) signal(SIGWINCH
, sendwin
);
898 (void) signal(SIGTSTP
, susp
);
901 (void) signal(SIGINFO
, ayt
);
906 NetNonblockingIO(net
, 1);
908 #if defined(SO_OOBINLINE)
909 if (SetSockOpt(net
, SOL_SOCKET
, SO_OOBINLINE
, 1) == -1) {
910 perror("SetSockOpt");
912 #endif /* defined(SO_OOBINLINE) */
918 * This routine tries to fill up/empty our various rings.
920 * The parameter specifies whether this is a poll operation,
921 * or a block-until-something-happens operation.
923 * The return value is 1 if something happened, 0 if not.
927 process_rings(int netin
, int netout
, int netex
, int ttyin
, int ttyout
, int poll
)
931 static struct timeval TimeValue
= { 0, 0 };
935 if ((netout
|| netin
|| netex
) && net
> maxfd
)
938 if (ttyout
&& tout
> maxfd
)
940 if (ttyin
&& tin
> maxfd
)
942 tmp
= howmany(maxfd
+1, NFDBITS
) * sizeof(fd_mask
);
952 if ((ibitsp
= (fd_set
*)malloc(fdsn
)) == NULL
)
954 if ((obitsp
= (fd_set
*)malloc(fdsn
)) == NULL
)
956 if ((xbitsp
= (fd_set
*)malloc(fdsn
)) == NULL
)
958 memset(ibitsp
, 0, fdsn
);
959 memset(obitsp
, 0, fdsn
);
960 memset(xbitsp
, 0, fdsn
);
966 FD_SET(tout
, obitsp
);
973 if ((c
= select(maxfd
+ 1, ibitsp
, obitsp
, xbitsp
,
974 (poll
== 0)? (struct timeval
*)0 : &TimeValue
)) < 0) {
977 * we can get EINTR if we are in line mode,
978 * and the user does an escape (TSTP), or
979 * some other signal generator.
981 if (errno
== EINTR
) {
984 /* I don't like this, does it ever happen? */
985 printf("sleep(5) from telnet, after select: %s\r\n", strerror(errno
));
994 if (FD_ISSET(net
, xbitsp
)) {
997 (void) ttyflush(1); /* flush already enqueued data */
1001 * Something to read from the network...
1003 if (FD_ISSET(net
, ibitsp
)) {
1006 FD_CLR(net
, ibitsp
);
1007 canread
= ring_empty_consecutive(&netiring
);
1008 #if !defined(SO_OOBINLINE)
1010 * In 4.2 (and some early 4.3) systems, the
1011 * OOB indication and data handling in the kernel
1012 * is such that if two separate TCP Urgent requests
1013 * come in, one byte of TCP data will be overlaid.
1014 * This is fatal for Telnet, but we try to live
1017 * In addition, in 4.2 (and...), a special protocol
1018 * is needed to pick up the TCP Urgent data in
1019 * the correct sequence.
1021 * What we do is: if we think we are in urgent
1022 * mode, we look to see if we are "at the mark".
1023 * If we are, we do an OOB receive. If we run
1024 * this twice, we will do the OOB receive twice,
1025 * but the second will fail, since the second
1026 * time we were "at the mark", but there wasn't
1027 * any data there (the kernel doesn't reset
1028 * "at the mark" until we do a normal read).
1029 * Once we've read the OOB data, we go ahead
1030 * and do normal reads.
1032 * There is also another problem, which is that
1033 * since the OOB byte we read doesn't put us
1034 * out of OOB state, and since that byte is most
1035 * likely the TELNET DM (data mark), we would
1036 * stay in the TELNET SYNCH (SYNCHing) state.
1037 * So, clocks to the rescue. If we've "just"
1038 * received a DM, then we test for the
1039 * presence of OOB data when the receive OOB
1040 * fails (and AFTER we did the normal mode read
1041 * to clear "at the mark").
1045 static int bogus_oob
= 0, first
= 1;
1047 ioctl(net
, SIOCATMARK
, (char *)&atmark
);
1049 c
= recv(net
, netiring
.supply
, canread
, MSG_OOB
);
1050 if ((c
== -1) && (errno
== EINVAL
)) {
1051 c
= recv(net
, netiring
.supply
, canread
, 0);
1052 if (clocks
.didnetreceive
< clocks
.gotDM
) {
1053 SYNCHing
= stilloob(net
);
1055 } else if (first
&& c
> 0) {
1057 * Bogosity check. Systems based on 4.2BSD
1058 * do not return an error if you do a second
1059 * recv(MSG_OOB). So, we do one. If it
1060 * succeeds and returns exactly the same
1061 * data, then assume that we are running
1062 * on a broken system and set the bogus_oob
1063 * flag. (If the data was different, then
1064 * we probably got some valid new data, so
1065 * increment the count...)
1068 i
= recv(net
, netiring
.supply
+ c
, canread
- c
, MSG_OOB
);
1070 memcmp(netiring
.supply
, netiring
.supply
+ c
, i
) == 0) {
1079 if (bogus_oob
&& c
> 0) {
1082 * Bogosity. We have to do the read
1083 * to clear the atmark to get out of
1086 i
= read(net
, netiring
.supply
+ c
, canread
- c
);
1091 c
= recv(net
, netiring
.supply
, canread
, 0);
1094 c
= recv(net
, netiring
.supply
, canread
, 0);
1096 settimer(didnetreceive
);
1097 #else /* !defined(SO_OOBINLINE) */
1098 c
= recv(net
, (char *)netiring
.supply
, canread
, 0);
1099 #endif /* !defined(SO_OOBINLINE) */
1100 if (c
< 0 && errno
== EWOULDBLOCK
) {
1102 } else if (c
<= 0) {
1106 Dump('<', netiring
.supply
, c
);
1109 ring_supplied(&netiring
, c
);
1114 * Something to read from the tty...
1116 if (FD_ISSET(tin
, ibitsp
)) {
1117 FD_CLR(tin
, ibitsp
);
1118 c
= TerminalRead(ttyiring
.supply
, ring_empty_consecutive(&ttyiring
));
1119 if (c
< 0 && errno
== EIO
)
1121 if (c
< 0 && errno
== EWOULDBLOCK
) {
1124 /* EOF detection for line mode!!!! */
1125 if ((c
== 0) && MODE_LOCAL_CHARS(globalmode
) && isatty(tin
)) {
1126 /* must be an EOF... */
1127 *ttyiring
.supply
= termEofChar
;
1134 Dump('<', ttyiring
.supply
, c
);
1136 ring_supplied(&ttyiring
, c
);
1138 returnValue
= 1; /* did something useful */
1141 if (FD_ISSET(net
, obitsp
)) {
1142 FD_CLR(net
, obitsp
);
1143 returnValue
|= netflush();
1145 if (FD_ISSET(tout
, obitsp
)) {
1146 FD_CLR(tout
, obitsp
);
1147 returnValue
|= (ttyflush(SYNCHing
|flushout
) > 0);