386BSD 0.1 development
[unix-history] / usr / src / libexec / telnetd / slc.c
index b23654a..6cdc286 100644 (file)
@@ -2,11 +2,37 @@
  * Copyright (c) 1989 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1989 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[] = "@(#)slc.c      5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)slc.c      5.7 (Berkeley) 3/1/91";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -26,6 +52,7 @@ static unsigned char  slcbuf[NSLC*6]; /* buffer for slc negotiation */
  *
  * Write out the current special characters to the client.
  */
  *
  * Write out the current special characters to the client.
  */
+       void
 send_slc()
 {
        register int i;
 send_slc()
 {
        register int i;
@@ -49,6 +76,7 @@ send_slc()
  *
  * Set pty special characters to all the defaults.
  */
  *
  * Set pty special characters to all the defaults.
  */
+       void
 default_slc()
 {
        register int i;
 default_slc()
 {
        register int i;
@@ -66,13 +94,14 @@ default_slc()
        slcchange = 1;
 
 }  /* end of default_slc */
        slcchange = 1;
 
 }  /* end of default_slc */
-#endif LINEMODE
+#endif /* LINEMODE */
 
 /*
  * get_slc_defaults
  *
  * Initialize the slc mapping table.
  */
 
 /*
  * get_slc_defaults
  *
  * Initialize the slc mapping table.
  */
+       void
 get_slc_defaults()
 {
        register int i;
 get_slc_defaults()
 {
        register int i;
@@ -94,15 +123,16 @@ get_slc_defaults()
  *
  * Add an slc triplet to the slc buffer.
  */
  *
  * Add an slc triplet to the slc buffer.
  */
+       void
 add_slc(func, flag, val)
 add_slc(func, flag, val)
-       register unsigned char func, flag;
-       cc_t val;
+       register char func, flag;
+       register cc_t val;
 {
 
 {
 
-       if ((*slcptr++ = func) == 0xff)
+       if ((*slcptr++ = (unsigned char)func) == 0xff)
                *slcptr++ = 0xff;
 
                *slcptr++ = 0xff;
 
-       if ((*slcptr++ = flag) == 0xff)
+       if ((*slcptr++ = (unsigned char)flag) == 0xff)
                *slcptr++ = 0xff;
 
        if ((*slcptr++ = (unsigned char)val) == 0xff)
                *slcptr++ = 0xff;
 
        if ((*slcptr++ = (unsigned char)val) == 0xff)
@@ -118,6 +148,7 @@ add_slc(func, flag, val)
  * The parameter getit is non-zero if it is necessary to grab a copy
  * of the terminal control structures.
  */
  * The parameter getit is non-zero if it is necessary to grab a copy
  * of the terminal control structures.
  */
+       void
 start_slc(getit)
        register int getit;
 {
 start_slc(getit)
        register int getit;
 {
@@ -125,7 +156,8 @@ start_slc(getit)
        slcchange = 0;
        if (getit)
                init_termbuf();
        slcchange = 0;
        if (getit)
                init_termbuf();
-       (void) sprintf(slcbuf, "%c%c%c%c", IAC, SB, TELOPT_LINEMODE, LM_SLC);
+       (void) sprintf((char *)slcbuf, "%c%c%c%c",
+                                       IAC, SB, TELOPT_LINEMODE, LM_SLC);
        slcptr = slcbuf + 4;
 
 }  /* end of start_slc */
        slcptr = slcbuf + 4;
 
 }  /* end of start_slc */
@@ -135,8 +167,9 @@ start_slc(getit)
  *
  * Finish up the slc negotiation.  If something to send, then send it.
  */
  *
  * Finish up the slc negotiation.  If something to send, then send it.
  */
+       int
 end_slc(bufp)
 end_slc(bufp)
-register unsigned char **bufp;
+       register unsigned char **bufp;
 {
        register int len;
        void netflush();
 {
        register int len;
        void netflush();
@@ -156,7 +189,7 @@ register unsigned char **bufp;
         * request very soon.
         */
        if (def_slcbuf && (terminit() == 0)) {
         * request very soon.
         */
        if (def_slcbuf && (terminit() == 0)) {
-               return;
+               return(0);
        }
 
        if (slcptr > (slcbuf + 4)) {
        }
 
        if (slcptr > (slcbuf + 4)) {
@@ -164,13 +197,14 @@ register unsigned char **bufp;
                        *bufp = &slcbuf[4];
                        return(slcptr - slcbuf - 4);
                } else {
                        *bufp = &slcbuf[4];
                        return(slcptr - slcbuf - 4);
                } else {
-                       (void) sprintf(slcptr, "%c%c", IAC, SE);
+                       (void) sprintf((char *)slcptr, "%c%c", IAC, SE);
                        slcptr += 2;
                        len = slcptr - slcbuf;
                        writenet(slcbuf, len);
                        netflush();  /* force it out immediately */
                }
        }
                        slcptr += 2;
                        len = slcptr - slcbuf;
                        writenet(slcbuf, len);
                        netflush();  /* force it out immediately */
                }
        }
+       return (0);
 
 }  /* end of end_slc */
 
 
 }  /* end of end_slc */
 
@@ -179,9 +213,10 @@ register unsigned char **bufp;
  *
  * Figure out what to do about the client's slc
  */
  *
  * Figure out what to do about the client's slc
  */
+       void
 process_slc(func, flag, val)
        register unsigned char func, flag;
 process_slc(func, flag, val)
        register unsigned char func, flag;
-       cc_t val;
+       register cc_t val;
 {
        register int hislevel, mylevel, ack;
 
 {
        register int hislevel, mylevel, ack;
 
@@ -201,9 +236,9 @@ process_slc(func, flag, val)
        if (func == 0) {
                if ((flag = flag & SLC_LEVELBITS) == SLC_DEFAULT) {
                        default_slc();
        if (func == 0) {
                if ((flag = flag & SLC_LEVELBITS) == SLC_DEFAULT) {
                        default_slc();
-                       send_slc(1);
+                       send_slc();
                } else if (flag == SLC_VARIABLE) {
                } else if (flag == SLC_VARIABLE) {
-                       send_slc(0);
+                       send_slc();
                }
                return;
        }
                }
                return;
        }
@@ -244,9 +279,10 @@ process_slc(func, flag, val)
  * Process a request to change one of our special characters.
  * Compare client's request with what we are capable of supporting.
  */
  * Process a request to change one of our special characters.
  * Compare client's request with what we are capable of supporting.
  */
+       void
 change_slc(func, flag, val)
 change_slc(func, flag, val)
-       register unsigned char func, flag;
-       cc_t val;
+       register char func, flag;
+       register cc_t val;
 {
        register int hislevel, mylevel;
        
 {
        register int hislevel, mylevel;
        
@@ -354,6 +390,7 @@ cc_t oldeofc = '\004';
  * likely to have changed.  If a local change occurs, kick the support level
  * and flags up to the defaults.
  */
  * likely to have changed.  If a local change occurs, kick the support level
  * and flags up to the defaults.
  */
+       void
 check_slc()
 {
        register int i;
 check_slc()
 {
        register int i;
@@ -397,14 +434,14 @@ check_slc()
  *
  * ptr points to the beginning of the buffer, len is the length.
  */
  *
  * ptr points to the beginning of the buffer, len is the length.
  */
+       void
 do_opt_slc(ptr, len)
 do_opt_slc(ptr, len)
-register char *ptr;
-register int len;
+       register unsigned char *ptr;
+       register int len;
 {
        register unsigned char func, flag;
        cc_t val;
 {
        register unsigned char func, flag;
        cc_t val;
-       register char *end = (char *)(ptr + len);
-       char *malloc();
+       register unsigned char *end = ptr + len;
 
        if (terminit()) {  /* go ahead */
                while (ptr < end) {
 
        if (terminit()) {  /* go ahead */
                while (ptr < end) {
@@ -438,12 +475,13 @@ register int len;
  *
  * Do slc stuff that was deferred.
  */
  *
  * Do slc stuff that was deferred.
  */
+       void
 deferslc()
 {
        if (def_slcbuf) {
                start_slc(1);
                do_opt_slc(def_slcbuf, def_slclen);
 deferslc()
 {
        if (def_slcbuf) {
                start_slc(1);
                do_opt_slc(def_slcbuf, def_slclen);
-               end_slc(0);
+               (void) end_slc(0);
                free(def_slcbuf);
                def_slcbuf = (unsigned char *)0;
                def_slclen = 0;
                free(def_slcbuf);
                def_slcbuf = (unsigned char *)0;
                def_slclen = 0;