new copyright notice
[unix-history] / usr / src / lib / libcurses / setterm.c
index 2ff70d5..3fd496f 100644 (file)
@@ -1,7 +1,17 @@
+/*
+ * Copyright (c) 1981 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)setterm.c  5.8 (Berkeley) %G%";
+#endif /* not lint */
+
 /*
  * Terminal initialization routines.
  *
 /*
  * Terminal initialization routines.
  *
- * @(#)setterm.c       1.17 (Berkeley) %G%
  */
 
 # include      "curses.ext"
  */
 
 # include      "curses.ext"
@@ -22,8 +32,9 @@ static char   *_PC,
                        &SO, &SR, &TA, &TE, &TI, &UC, &UE, &UP, &US,
                        &VB, &VS, &VE, &AL_PARM, &DL_PARM, &UP_PARM,
                        &DOWN_PARM, &LEFT_PARM, &RIGHT_PARM,
                        &SO, &SR, &TA, &TE, &TI, &UC, &UE, &UP, &US,
                        &VB, &VS, &VE, &AL_PARM, &DL_PARM, &UP_PARM,
                        &DOWN_PARM, &LEFT_PARM, &RIGHT_PARM,
-               },
-               *tgoto();
+               };
+
+extern char    *tgoto();
 
 char           _tspace[2048];          /* Space for capability strings */
 
 
 char           _tspace[2048];          /* Space for capability strings */
 
@@ -40,10 +51,10 @@ short       ospeed = -1;
 
 gettmode() {
 
 
 gettmode() {
 
-       if (gtty(_tty_ch, &_tty) < 0)
+       if (ioctl(_tty_ch, TIOCGETP, &_tty) < 0)
                return;
        savetty();
                return;
        savetty();
-       if (stty(_tty_ch, &_tty) < 0)
+       if (ioctl(_tty_ch, TIOCSETP, &_tty) < 0)
                _tty.sg_flags = _res_flg;
        ospeed = _tty.sg_ospeed;
        _res_flg = _tty.sg_flags;
                _tty.sg_flags = _res_flg;
        ospeed = _tty.sg_ospeed;
        _res_flg = _tty.sg_flags;
@@ -51,7 +62,7 @@ gettmode() {
        GT = ((_tty.sg_flags & XTABS) == 0);
        NONL = ((_tty.sg_flags & CRMOD) == 0);
        _tty.sg_flags &= ~XTABS;
        GT = ((_tty.sg_flags & XTABS) == 0);
        NONL = ((_tty.sg_flags & CRMOD) == 0);
        _tty.sg_flags &= ~XTABS;
-       stty(_tty_ch, &_tty);
+       ioctl(_tty_ch, TIOCSETP, &_tty);
 # ifdef DEBUG
        fprintf(outf, "GETTMODE: UPPERCASE = %s\n", UPPERCASE ? "TRUE":"FALSE");
        fprintf(outf, "GETTMODE: GT = %s\n", GT ? "TRUE" : "FALSE");
 # ifdef DEBUG
        fprintf(outf, "GETTMODE: UPPERCASE = %s\n", UPPERCASE ? "TRUE":"FALSE");
        fprintf(outf, "GETTMODE: GT = %s\n", GT ? "TRUE" : "FALSE");
@@ -125,7 +136,14 @@ reg char   *type; {
 
        PC = _PC ? _PC[0] : FALSE;
        aoftspace = _tspace;
 
        PC = _PC ? _PC[0] : FALSE;
        aoftspace = _tspace;
-       strcpy(ttytype, longname(genbuf, type));
+       {
+               /* xtype should be the same size as genbuf for longname(). */
+               static char xtype[1024];
+
+               (void)strcpy(xtype,type);
+               strncpy(ttytype, longname(genbuf, xtype), sizeof(ttytype) - 1);
+       }
+       ttytype[sizeof(ttytype) - 1] = '\0';
        if (unknown)
                return ERR;
        return OK;
        if (unknown)
                return ERR;
        return OK;