Telnet AUTHENTICATION option
[unix-history] / usr / src / usr.bin / telnet / network.c
index 7759cc7..1601417 100644 (file)
@@ -2,21 +2,11 @@
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)network.c  1.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)network.c  5.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -33,13 +23,14 @@ static char sccsid[] = "@(#)network.c       1.13 (Berkeley) %G%";
 #include "externs.h"
 #include "fdset.h"
 
 #include "externs.h"
 #include "fdset.h"
 
-Ring   netoring, netiring;
-char   netobuf[2*BUFSIZ], netibuf[BUFSIZ];
+Ring           netoring, netiring;
+unsigned char  netobuf[2*BUFSIZ], netibuf[BUFSIZ];
 
 /*
  * Initialize internal network data structures.
  */
 
 
 /*
  * Initialize internal network data structures.
  */
 
+    void
 init_network()
 {
     if (ring_init(&netoring, netobuf, sizeof netobuf) != 1) {
 init_network()
 {
     if (ring_init(&netoring, netobuf, sizeof netobuf) != 1) {
@@ -57,7 +48,7 @@ init_network()
  * Telnet "synch" processing).
  */
 
  * Telnet "synch" processing).
  */
 
-int
+    int
 stilloob()
 {
     static struct timeval timeout = { 0 };
 stilloob()
 {
     static struct timeval timeout = { 0 };
@@ -73,6 +64,7 @@ stilloob()
     if (value < 0) {
        perror("select");
        (void) quit();
     if (value < 0) {
        perror("select");
        (void) quit();
+       /* NOTREACHED */
     }
     if (FD_ISSET(net, &excepts)) {
        return 1;
     }
     if (FD_ISSET(net, &excepts)) {
        return 1;
@@ -88,7 +80,7 @@ stilloob()
  *     Sets "neturg" to the current location.
  */
 
  *     Sets "neturg" to the current location.
  */
 
-void
+    void
 setneturg()
 {
     ring_mark(&netoring);
 setneturg()
 {
     ring_mark(&netoring);
@@ -105,11 +97,15 @@ setneturg()
  */
 
 
  */
 
 
-int
+    int
 netflush()
 {
     register int n, n1;
 
 netflush()
 {
     register int n, n1;
 
+#if    defined(ENCRYPT)
+    if (encrypt_output)
+       ring_encrypt(&netoring, encrypt_output);
+#endif
     if ((n1 = n = ring_full_consecutive(&netoring)) > 0) {
        if (!ring_at_mark(&netoring)) {
            n = send(net, netoring.consume, n, 0);      /* normal write */
     if ((n1 = n = ring_full_consecutive(&netoring)) > 0) {
        if (!ring_at_mark(&netoring)) {
            n = send(net, netoring.consume, n, 0);      /* normal write */
@@ -129,7 +125,7 @@ netflush()
        if (errno != ENOBUFS && errno != EWOULDBLOCK) {
            setcommandmode();
            perror(hostname);
        if (errno != ENOBUFS && errno != EWOULDBLOCK) {
            setcommandmode();
            perror(hostname);
-           NetClose(net);
+           (void)NetClose(net);
            ring_clear_mark(&netoring);
            longjmp(peerdied, -1);
            /*NOTREACHED*/
            ring_clear_mark(&netoring);
            longjmp(peerdied, -1);
            /*NOTREACHED*/