BSD 4_4_Lite2 release
[unix-history] / usr / src / libexec / telnetd / state.c
index 9376540..4ee8bea 100644 (file)
@@ -2,11 +2,37 @@
  * Copyright (c) 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
  * Copyright (c) 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)state.c    8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)state.c    8.5 (Berkeley) 5/30/95";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -340,7 +366,7 @@ gotiac:                     switch (c) {
                char    xbuf2[BUFSIZ];
                register char *cp;
                int n = pfrontp - opfrontp, oc;
                char    xbuf2[BUFSIZ];
                register char *cp;
                int n = pfrontp - opfrontp, oc;
-               bcopy(opfrontp, xptyobuf, n);
+               memmove(xptyobuf, opfrontp, n);
                pfrontp = opfrontp;
                pfrontp += term_input(xptyobuf, pfrontp, n, BUFSIZ+NETSLOP,
                                        xbuf2, &oc, BUFSIZ);
                pfrontp = opfrontp;
                pfrontp += term_input(xptyobuf, pfrontp, n, BUFSIZ+NETSLOP,
                                        xbuf2, &oc, BUFSIZ);
@@ -362,7 +388,7 @@ gotiac:                     switch (c) {
  * All state defaults are negative, and resp defaults to 0.
  *
  * When initiating a request to change state to new_state:
  * All state defaults are negative, and resp defaults to 0.
  *
  * When initiating a request to change state to new_state:
- * 
+ *
  * if ((want_resp == 0 && new_state == my_state) || want_state == new_state) {
  *     do nothing;
  * } else {
  * if ((want_resp == 0 && new_state == my_state) || want_state == new_state) {
  *     do nothing;
  * } else {
@@ -690,7 +716,6 @@ wontoption(option)
                         */
                        if (lmodetype != REAL_LINEMODE)
                                break;
                         */
                        if (lmodetype != REAL_LINEMODE)
                                break;
-                       lmodetype = KLUDGE_LINEMODE;
 # endif        /* KLUDGELINEMODE */
                        clientstat(TELOPT_LINEMODE, WONT, 0);
                        break;
 # endif        /* KLUDGELINEMODE */
                        clientstat(TELOPT_LINEMODE, WONT, 0);
                        break;
@@ -1494,8 +1519,8 @@ doclientstat()
        clientstat(TELOPT_LINEMODE, WILL, 0);
 }
 
        clientstat(TELOPT_LINEMODE, WILL, 0);
 }
 
-#define        ADD(c)   *ncp++ = c;
-#define        ADD_DATA(c) { *ncp++ = c; if (c == SE) *ncp++ = c; }
+#define        ADD(c)   *ncp++ = c
+#define        ADD_DATA(c) { *ncp++ = c; if (c == SE || c == IAC) *ncp++ = c; }
        void
 send_status()
 {
        void
 send_status()
 {
@@ -1524,14 +1549,10 @@ send_status()
                if (my_want_state_is_will(i)) {
                        ADD(WILL);
                        ADD_DATA(i);
                if (my_want_state_is_will(i)) {
                        ADD(WILL);
                        ADD_DATA(i);
-                       if (i == IAC)
-                               ADD(IAC);
                }
                if (his_want_state_is_will(i)) {
                        ADD(DO);
                        ADD_DATA(i);
                }
                if (his_want_state_is_will(i)) {
                        ADD(DO);
                        ADD_DATA(i);
-                       if (i == IAC)
-                               ADD(IAC);
                }
        }
 
                }
        }
 
@@ -1546,15 +1567,14 @@ send_status()
                ADD(SE);
 
                if (restartany >= 0) {
                ADD(SE);
 
                if (restartany >= 0) {
-                       ADD(SB)
+                       ADD(SB);
                        ADD(TELOPT_LFLOW);
                        if (restartany) {
                                ADD(LFLOW_RESTART_ANY);
                        } else {
                                ADD(LFLOW_RESTART_XON);
                        }
                        ADD(TELOPT_LFLOW);
                        if (restartany) {
                                ADD(LFLOW_RESTART_ANY);
                        } else {
                                ADD(LFLOW_RESTART_XON);
                        }
-                       ADD(SE)
-                       ADD(SB);
+                       ADD(SE);
                }
        }
 
                }
        }
 
@@ -1567,8 +1587,6 @@ send_status()
                ADD(TELOPT_LINEMODE);
                ADD(LM_MODE);
                ADD_DATA(editmode);
                ADD(TELOPT_LINEMODE);
                ADD(LM_MODE);
                ADD_DATA(editmode);
-               if (editmode == IAC)
-                       ADD(IAC);
                ADD(SE);
 
                ADD(SB);
                ADD(SE);
 
                ADD(SB);