]>
git.saurik.com Git - apple/network_cmds.git/blob - telnet.tproj/utilities.c
295729785c047c38e63b78a86dc752a7d882e172
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Copyright (c) 1988, 1993
26 * The Regents of the University of California. All rights reserved.
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
31 * 1. Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * 3. All advertising materials mentioning features or use of this software
37 * must display the following acknowledgement:
38 * This product includes software developed by the University of
39 * California, Berkeley and its contributors.
40 * 4. Neither the name of the University nor the names of its contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
44 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
45 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 static char sccsid
[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95";
64 #include <arpa/telnet.h>
65 #include <sys/types.h>
80 FILE *NetTrace
= 0; /* Not in bss, since needs to stay */
86 * Upcase (in place) the argument.
91 register char *argument
;
95 while ((c
= *argument
) != 0) {
97 *argument
= toupper(c
);
106 * Compensate for differences in 4.2 and 4.3 systems.
110 SetSockOpt(fd
, level
, option
, yesno
)
111 int fd
, level
, option
, yesno
;
114 return setsockopt(fd
, level
, option
,
115 (char *)&yesno
, sizeof yesno
);
117 if (yesno
== 0) { /* Can't do that in 4.2! */
118 fprintf(stderr
, "Error: attempt to turn off an option 0x%x.\n",
122 return setsockopt(fd
, level
, option
, 0, 0);
127 * The following are routines used to print out debugging information.
130 unsigned char NetTraceFile
[256] = "(standard output)";
136 if (NetTrace
&& NetTrace
!= stdout
)
138 if (file
&& (strcmp(file
, "-") != 0)) {
139 NetTrace
= fopen(file
, "w");
141 strcpy((char *)NetTraceFile
, file
);
144 fprintf(stderr
, "Cannot open %s.\n", file
);
147 strcpy((char *)NetTraceFile
, "(standard output)");
151 Dump(direction
, buffer
, length
)
153 unsigned char *buffer
;
156 # define BYTES_PER_LINE 32
157 # define min(x,y) ((x<y)? x:y)
158 unsigned char *pThis
;
166 fprintf(NetTrace
, "%c 0x%x\t", direction
, offset
);
169 buffer
= buffer
+ min(length
, BYTES_PER_LINE
/2);
170 while (pThis
< buffer
) {
171 fprintf(NetTrace
, "%c%.2x",
172 (((*pThis
)&0xff) == 0xff) ? '*' : ' ',
176 length
-= BYTES_PER_LINE
/2;
177 offset
+= BYTES_PER_LINE
/2;
179 buffer
= buffer
+ min(length
, BYTES_PER_LINE
);
180 while (pThis
< buffer
) {
181 fprintf(NetTrace
, "%.2x", (*pThis
)&0xff);
184 length
-= BYTES_PER_LINE
;
185 offset
+= BYTES_PER_LINE
;
187 if (NetTrace
== stdout
) {
188 fprintf(NetTrace
, "\r\n");
190 fprintf(NetTrace
, "\n");
196 /* find next unique line */
203 printoption(direction
, cmd
, option
)
210 if (TELCMD_OK(option
))
211 fprintf(NetTrace
, "%s IAC %s", direction
, TELCMD(option
));
213 fprintf(NetTrace
, "%s IAC %d", direction
, option
);
216 fmt
= (cmd
== WILL
) ? "WILL" : (cmd
== WONT
) ? "WONT" :
217 (cmd
== DO
) ? "DO" : (cmd
== DONT
) ? "DONT" : 0;
219 fprintf(NetTrace
, "%s %s ", direction
, fmt
);
220 if (TELOPT_OK(option
))
221 fprintf(NetTrace
, "%s", TELOPT(option
));
222 else if (option
== TELOPT_EXOPL
)
223 fprintf(NetTrace
, "EXOPL");
225 fprintf(NetTrace
, "%d", option
);
227 fprintf(NetTrace
, "%s %d %d", direction
, cmd
, option
);
229 if (NetTrace
== stdout
) {
230 fprintf(NetTrace
, "\r\n");
233 fprintf(NetTrace
, "\n");
242 extern char will_wont_resp
[], do_dont_resp
[];
244 for (i
= 0; i
< 256; i
++) {
245 if (do_dont_resp
[i
]) {
247 printf("resp DO_DONT %s: %d\n", TELOPT(i
), do_dont_resp
[i
]);
248 else if (TELCMD_OK(i
))
249 printf("resp DO_DONT %s: %d\n", TELCMD(i
), do_dont_resp
[i
]);
251 printf("resp DO_DONT %d: %d\n", i
,
253 if (my_want_state_is_do(i
)) {
255 printf("want DO %s\n", TELOPT(i
));
256 else if (TELCMD_OK(i
))
257 printf("want DO %s\n", TELCMD(i
));
259 printf("want DO %d\n", i
);
262 printf("want DONT %s\n", TELOPT(i
));
263 else if (TELCMD_OK(i
))
264 printf("want DONT %s\n", TELCMD(i
));
266 printf("want DONT %d\n", i
);
269 if (my_state_is_do(i
)) {
271 printf(" DO %s\n", TELOPT(i
));
272 else if (TELCMD_OK(i
))
273 printf(" DO %s\n", TELCMD(i
));
275 printf(" DO %d\n", i
);
278 if (will_wont_resp
[i
]) {
280 printf("resp WILL_WONT %s: %d\n", TELOPT(i
), will_wont_resp
[i
]);
281 else if (TELCMD_OK(i
))
282 printf("resp WILL_WONT %s: %d\n", TELCMD(i
), will_wont_resp
[i
]);
284 printf("resp WILL_WONT %d: %d\n",
285 i
, will_wont_resp
[i
]);
286 if (my_want_state_is_will(i
)) {
288 printf("want WILL %s\n", TELOPT(i
));
289 else if (TELCMD_OK(i
))
290 printf("want WILL %s\n", TELCMD(i
));
292 printf("want WILL %d\n", i
);
295 printf("want WONT %s\n", TELOPT(i
));
296 else if (TELCMD_OK(i
))
297 printf("want WONT %s\n", TELCMD(i
));
299 printf("want WONT %d\n", i
);
302 if (my_state_is_will(i
)) {
304 printf(" WILL %s\n", TELOPT(i
));
305 else if (TELCMD_OK(i
))
306 printf(" WILL %s\n", TELCMD(i
));
308 printf(" WILL %d\n", i
);
316 printsub(direction
, pointer
, length
)
317 char direction
; /* '<' or '>' */
318 unsigned char *pointer
; /* where suboption data sits */
319 int length
; /* length of suboption data */
323 extern int want_status_response
;
325 if (showoptions
|| direction
== 0 ||
326 (want_status_response
&& (pointer
[0] == TELOPT_STATUS
))) {
328 fprintf(NetTrace
, "%s IAC SB ",
329 (direction
== '<')? "RCVD":"SENT");
333 i
= pointer
[length
-2];
334 j
= pointer
[length
-1];
336 if (i
!= IAC
|| j
!= SE
) {
337 fprintf(NetTrace
, "(terminated by ");
339 fprintf(NetTrace
, "%s ", TELOPT(i
));
340 else if (TELCMD_OK(i
))
341 fprintf(NetTrace
, "%s ", TELCMD(i
));
343 fprintf(NetTrace
, "%d ", i
);
345 fprintf(NetTrace
, "%s", TELOPT(j
));
346 else if (TELCMD_OK(j
))
347 fprintf(NetTrace
, "%s", TELCMD(j
));
349 fprintf(NetTrace
, "%d", j
);
350 fprintf(NetTrace
, ", not IAC SE!) ");
356 fprintf(NetTrace
, "(Empty suboption??\?)");
357 if (NetTrace
== stdout
)
361 switch (pointer
[0]) {
363 fprintf(NetTrace
, "TERMINAL-TYPE ");
364 switch (pointer
[1]) {
366 fprintf(NetTrace
, "IS \"%.*s\"", length
-2, (char *)pointer
+2);
369 fprintf(NetTrace
, "SEND");
373 "- unknown qualifier %d (0x%x).",
374 pointer
[1], pointer
[1]);
378 fprintf(NetTrace
, "TERMINAL-SPEED");
380 fprintf(NetTrace
, " (empty suboption??\?)");
383 switch (pointer
[1]) {
385 fprintf(NetTrace
, " IS ");
386 fprintf(NetTrace
, "%.*s", length
-2, (char *)pointer
+2);
390 fprintf(NetTrace
, " SEND");
392 fprintf(NetTrace
, " %d (unknown)", pointer
[1]);
393 for (i
= 2; i
< length
; i
++)
394 fprintf(NetTrace
, " ?%d?", pointer
[i
]);
400 fprintf(NetTrace
, "TOGGLE-FLOW-CONTROL");
402 fprintf(NetTrace
, " (empty suboption??\?)");
405 switch (pointer
[1]) {
407 fprintf(NetTrace
, " OFF"); break;
409 fprintf(NetTrace
, " ON"); break;
410 case LFLOW_RESTART_ANY
:
411 fprintf(NetTrace
, " RESTART-ANY"); break;
412 case LFLOW_RESTART_XON
:
413 fprintf(NetTrace
, " RESTART-XON"); break;
415 fprintf(NetTrace
, " %d (unknown)", pointer
[1]);
417 for (i
= 2; i
< length
; i
++)
418 fprintf(NetTrace
, " ?%d?", pointer
[i
]);
422 fprintf(NetTrace
, "NAWS");
424 fprintf(NetTrace
, " (empty suboption??\?)");
428 fprintf(NetTrace
, " ?%d?", pointer
[1]);
431 fprintf(NetTrace
, " %d %d (%d)",
432 pointer
[1], pointer
[2],
433 (int)((((unsigned int)pointer
[1])<<8)|((unsigned int)pointer
[2])));
435 fprintf(NetTrace
, " ?%d?", pointer
[3]);
438 fprintf(NetTrace
, " %d %d (%d)",
439 pointer
[3], pointer
[4],
440 (int)((((unsigned int)pointer
[3])<<8)|((unsigned int)pointer
[4])));
441 for (i
= 5; i
< length
; i
++)
442 fprintf(NetTrace
, " ?%d?", pointer
[i
]);
445 #if defined(AUTHENTICATION)
446 case TELOPT_AUTHENTICATION
:
447 fprintf(NetTrace
, "AUTHENTICATION");
449 fprintf(NetTrace
, " (empty suboption??\?)");
452 switch (pointer
[1]) {
455 fprintf(NetTrace
, " %s ", (pointer
[1] == TELQUAL_IS
) ?
457 if (AUTHTYPE_NAME_OK(pointer
[2]))
458 fprintf(NetTrace
, "%s ", AUTHTYPE_NAME(pointer
[2]));
460 fprintf(NetTrace
, "%d ", pointer
[2]);
462 fprintf(NetTrace
, "(partial suboption??\?)");
465 fprintf(NetTrace
, "%s|%s",
466 ((pointer
[3] & AUTH_WHO_MASK
) == AUTH_WHO_CLIENT
) ?
468 ((pointer
[3] & AUTH_HOW_MASK
) == AUTH_HOW_MUTUAL
) ?
469 "MUTUAL" : "ONE-WAY");
471 auth_printsub(&pointer
[1], length
- 1, buf
, sizeof(buf
));
472 fprintf(NetTrace
, "%s", buf
);
477 fprintf(NetTrace
, " SEND ");
479 if (AUTHTYPE_NAME_OK(pointer
[i
]))
480 fprintf(NetTrace
, "%s ", AUTHTYPE_NAME(pointer
[i
]));
482 fprintf(NetTrace
, "%d ", pointer
[i
]);
484 fprintf(NetTrace
, "(partial suboption??\?)");
487 fprintf(NetTrace
, "%s|%s ",
488 ((pointer
[i
] & AUTH_WHO_MASK
) == AUTH_WHO_CLIENT
) ?
490 ((pointer
[i
] & AUTH_HOW_MASK
) == AUTH_HOW_MUTUAL
) ?
491 "MUTUAL" : "ONE-WAY");
498 fprintf(NetTrace
, " NAME \"");
500 putc(pointer
[i
++], NetTrace
);
505 for (i
= 2; i
< length
; i
++)
506 fprintf(NetTrace
, " ?%d?", pointer
[i
]);
514 fprintf(NetTrace
, "ENCRYPT");
516 fprintf(NetTrace
, " (empty suboption??\?)");
519 switch (pointer
[1]) {
521 fprintf(NetTrace
, " START");
525 fprintf(NetTrace
, " END");
528 case ENCRYPT_REQSTART
:
529 fprintf(NetTrace
, " REQUEST-START");
533 fprintf(NetTrace
, " REQUEST-END");
538 fprintf(NetTrace
, " %s ", (pointer
[1] == ENCRYPT_IS
) ?
541 fprintf(NetTrace
, " (partial suboption??\?)");
544 if (ENCTYPE_NAME_OK(pointer
[2]))
545 fprintf(NetTrace
, "%s ", ENCTYPE_NAME(pointer
[2]));
547 fprintf(NetTrace
, " %d (unknown)", pointer
[2]);
549 encrypt_printsub(&pointer
[1], length
- 1, buf
, sizeof(buf
));
550 fprintf(NetTrace
, "%s", buf
);
553 case ENCRYPT_SUPPORT
:
555 fprintf(NetTrace
, " SUPPORT ");
557 if (ENCTYPE_NAME_OK(pointer
[i
]))
558 fprintf(NetTrace
, "%s ", ENCTYPE_NAME(pointer
[i
]));
560 fprintf(NetTrace
, "%d ", pointer
[i
]);
565 case ENCRYPT_ENC_KEYID
:
566 fprintf(NetTrace
, " ENC_KEYID ");
569 case ENCRYPT_DEC_KEYID
:
570 fprintf(NetTrace
, " DEC_KEYID ");
574 fprintf(NetTrace
, " %d (unknown)", pointer
[1]);
576 for (i
= 2; i
< length
; i
++)
577 fprintf(NetTrace
, " %d", pointer
[i
]);
581 #endif /* ENCRYPTION */
583 case TELOPT_LINEMODE
:
584 fprintf(NetTrace
, "LINEMODE ");
586 fprintf(NetTrace
, " (empty suboption??\?)");
589 switch (pointer
[1]) {
591 fprintf(NetTrace
, "WILL ");
594 fprintf(NetTrace
, "WONT ");
597 fprintf(NetTrace
, "DO ");
600 fprintf(NetTrace
, "DONT ");
603 fprintf(NetTrace
, "(no option??\?)");
606 switch (pointer
[2]) {
608 fprintf(NetTrace
, "Forward Mask");
609 for (i
= 3; i
< length
; i
++)
610 fprintf(NetTrace
, " %x", pointer
[i
]);
613 fprintf(NetTrace
, "%d (unknown)", pointer
[2]);
614 for (i
= 3; i
< length
; i
++)
615 fprintf(NetTrace
, " %d", pointer
[i
]);
621 fprintf(NetTrace
, "SLC");
622 for (i
= 2; i
< length
- 2; i
+= 3) {
623 if (SLC_NAME_OK(pointer
[i
+SLC_FUNC
]))
624 fprintf(NetTrace
, " %s", SLC_NAME(pointer
[i
+SLC_FUNC
]));
626 fprintf(NetTrace
, " %d", pointer
[i
+SLC_FUNC
]);
627 switch (pointer
[i
+SLC_FLAGS
]&SLC_LEVELBITS
) {
629 fprintf(NetTrace
, " NOSUPPORT"); break;
631 fprintf(NetTrace
, " CANTCHANGE"); break;
633 fprintf(NetTrace
, " VARIABLE"); break;
635 fprintf(NetTrace
, " DEFAULT"); break;
637 fprintf(NetTrace
, "%s%s%s",
638 pointer
[i
+SLC_FLAGS
]&SLC_ACK
? "|ACK" : "",
639 pointer
[i
+SLC_FLAGS
]&SLC_FLUSHIN
? "|FLUSHIN" : "",
640 pointer
[i
+SLC_FLAGS
]&SLC_FLUSHOUT
? "|FLUSHOUT" : "");
641 if (pointer
[i
+SLC_FLAGS
]& ~(SLC_ACK
|SLC_FLUSHIN
|
642 SLC_FLUSHOUT
| SLC_LEVELBITS
))
643 fprintf(NetTrace
, "(0x%x)", pointer
[i
+SLC_FLAGS
]);
644 fprintf(NetTrace
, " %d;", pointer
[i
+SLC_VALUE
]);
645 if ((pointer
[i
+SLC_VALUE
] == IAC
) &&
646 (pointer
[i
+SLC_VALUE
+1] == IAC
))
649 for (; i
< length
; i
++)
650 fprintf(NetTrace
, " ?%d?", pointer
[i
]);
654 fprintf(NetTrace
, "MODE ");
656 fprintf(NetTrace
, "(no mode??\?)");
661 sprintf(tbuf
, "%s%s%s%s%s",
662 pointer
[2]&MODE_EDIT
? "|EDIT" : "",
663 pointer
[2]&MODE_TRAPSIG
? "|TRAPSIG" : "",
664 pointer
[2]&MODE_SOFT_TAB
? "|SOFT_TAB" : "",
665 pointer
[2]&MODE_LIT_ECHO
? "|LIT_ECHO" : "",
666 pointer
[2]&MODE_ACK
? "|ACK" : "");
667 fprintf(NetTrace
, "%s", tbuf
[1] ? &tbuf
[1] : "0");
669 if (pointer
[2]&~(MODE_MASK
))
670 fprintf(NetTrace
, " (0x%x)", pointer
[2]);
671 for (i
= 3; i
< length
; i
++)
672 fprintf(NetTrace
, " ?0x%x?", pointer
[i
]);
675 fprintf(NetTrace
, "%d (unknown)", pointer
[1]);
676 for (i
= 2; i
< length
; i
++)
677 fprintf(NetTrace
, " %d", pointer
[i
]);
681 case TELOPT_STATUS
: {
685 fprintf(NetTrace
, "STATUS");
687 switch (pointer
[1]) {
689 if (pointer
[1] == TELQUAL_SEND
)
690 fprintf(NetTrace
, " SEND");
692 fprintf(NetTrace
, " %d (unknown)", pointer
[1]);
693 for (i
= 2; i
< length
; i
++)
694 fprintf(NetTrace
, " ?%d?", pointer
[i
]);
697 if (--want_status_response
< 0)
698 want_status_response
= 0;
699 if (NetTrace
== stdout
)
700 fprintf(NetTrace
, " IS\r\n");
702 fprintf(NetTrace
, " IS\n");
704 for (i
= 2; i
< length
; i
++) {
706 case DO
: cp
= "DO"; goto common2
;
707 case DONT
: cp
= "DONT"; goto common2
;
708 case WILL
: cp
= "WILL"; goto common2
;
709 case WONT
: cp
= "WONT"; goto common2
;
712 if (TELOPT_OK((int)pointer
[i
]))
713 fprintf(NetTrace
, " %s %s", cp
, TELOPT(pointer
[i
]));
715 fprintf(NetTrace
, " %s %d", cp
, pointer
[i
]);
717 if (NetTrace
== stdout
)
718 fprintf(NetTrace
, "\r\n");
720 fprintf(NetTrace
, "\n");
724 fprintf(NetTrace
, " SB ");
728 if (pointer
[j
] == SE
) {
731 if (pointer
[j
+1] == SE
)
736 pointer
[k
++] = pointer
[j
++];
738 printsub(0, &pointer
[i
], k
- i
);
740 fprintf(NetTrace
, " SE");
745 if (NetTrace
== stdout
)
746 fprintf(NetTrace
, "\r\n");
748 fprintf(NetTrace
, "\n");
753 fprintf(NetTrace
, " %d", pointer
[i
]);
762 case TELOPT_XDISPLOC
:
763 fprintf(NetTrace
, "X-DISPLAY-LOCATION ");
764 switch (pointer
[1]) {
766 fprintf(NetTrace
, "IS \"%.*s\"", length
-2, (char *)pointer
+2);
769 fprintf(NetTrace
, "SEND");
772 fprintf(NetTrace
, "- unknown qualifier %d (0x%x).",
773 pointer
[1], pointer
[1]);
777 case TELOPT_NEW_ENVIRON
:
778 fprintf(NetTrace
, "NEW-ENVIRON ");
781 case TELOPT_OLD_ENVIRON
:
782 fprintf(NetTrace
, "OLD-ENVIRON");
785 switch (pointer
[1]) {
787 fprintf(NetTrace
, "IS ");
790 fprintf(NetTrace
, "SEND ");
793 fprintf(NetTrace
, "INFO ");
796 register int noquote
= 2;
797 #if defined(ENV_HACK) && defined(OLD_ENVIRON)
798 extern int old_env_var
, old_env_value
;
800 for (i
= 2; i
< length
; i
++ ) {
801 switch (pointer
[i
]) {
804 /* case NEW_ENV_OVAR: */
805 if (pointer
[0] == TELOPT_OLD_ENVIRON
) {
807 if (old_env_var
== OLD_ENV_VALUE
)
808 fprintf(NetTrace
, "\" (VALUE) " + noquote
);
811 fprintf(NetTrace
, "\" VAR " + noquote
);
813 #endif /* OLD_ENVIRON */
814 fprintf(NetTrace
, "\" VALUE " + noquote
);
820 /* case OLD_ENV_VALUE: */
821 if (pointer
[0] == TELOPT_OLD_ENVIRON
) {
823 if (old_env_value
== OLD_ENV_VAR
)
824 fprintf(NetTrace
, "\" (VAR) " + noquote
);
827 fprintf(NetTrace
, "\" VALUE " + noquote
);
829 #endif /* OLD_ENVIRON */
830 fprintf(NetTrace
, "\" VAR " + noquote
);
835 fprintf(NetTrace
, "\" ESC " + noquote
);
840 fprintf(NetTrace
, "\" USERVAR " + noquote
);
846 if (isprint(pointer
[i
]) && pointer
[i
] != '"') {
851 putc(pointer
[i
], NetTrace
);
853 fprintf(NetTrace
, "\" %03o " + noquote
,
868 if (TELOPT_OK(pointer
[0]))
869 fprintf(NetTrace
, "%s (unknown)", TELOPT(pointer
[0]));
871 fprintf(NetTrace
, "%d (unknown)", pointer
[0]);
872 for (i
= 1; i
< length
; i
++)
873 fprintf(NetTrace
, " %d", pointer
[i
]);
877 if (NetTrace
== stdout
)
878 fprintf(NetTrace
, "\r\n");
880 fprintf(NetTrace
, "\n");
882 if (NetTrace
== stdout
)
887 /* EmptyTerminal - called to make sure that the terminal buffer is empty.
888 * Note that we consider the buffer to run all the
889 * way to the kernel (thus the select).
895 #if defined(unix) || defined(__APPLE__)
899 #endif /* defined(unix) || defined(__APPLE__) */
901 if (TTYBYTES() == 0) {
902 #if defined(unix) || defined(__APPLE__)
904 (void) select(tout
+1, (fd_set
*) 0, &o
, (fd_set
*) 0,
905 (struct timeval
*) 0); /* wait for TTLOWAT */
906 #endif /* defined(unix) || defined(__APPLE__) */
910 #if defined(unix) || defined(__APPLE__)
912 (void) select(tout
+1, (fd_set
*) 0, &o
, (fd_set
*) 0,
913 (struct timeval
*) 0); /* wait for TTLOWAT */
914 #endif /* defined(unix) || defined(__APPLE__) */
927 #else /* defined(TN3270) */
929 (void)telrcv(); /* Process any incoming data */
931 } while (ring_full_count(&netiring
)); /* While there is any */
932 #endif /* defined(TN3270) */
940 #endif /* defined(TN3270) */
942 EmptyTerminal(); /* Flush the path to the tty */
955 ExitString(string
, returnCode
)
960 fwrite(string
, 1, strlen(string
), stderr
);