Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/usr.bin/window Pull up revision 1.6 (requested by simonb):



details:   https://anonhg.NetBSD.org/src/rev/4ccc9af71454
branches:  netbsd-1-6
changeset: 527615:4ccc9af71454
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu May 30 08:32:08 2002 +0000

description:
Pull up revision 1.6 (requested by simonb):
Use openpty() to deal with the new pty naming scheme.
--

diffstat:

 usr.bin/window/wwpty.c |  51 ++++++++++++-------------------------------------
 1 files changed, 13 insertions(+), 38 deletions(-)

diffs (79 lines):

diff -r ee03ac3a3ba0 -r 4ccc9af71454 usr.bin/window/wwpty.c
--- a/usr.bin/window/wwpty.c    Thu May 30 08:31:57 2002 +0000
+++ b/usr.bin/window/wwpty.c    Thu May 30 08:32:08 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wwpty.c,v 1.5 1997/11/21 08:49:12 mrg Exp $    */
+/*     $NetBSD: wwpty.c,v 1.5.12.1 2002/05/30 08:32:08 lukem Exp $     */
 
 /*
  * Copyright (c) 1983, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)wwpty.c    8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: wwpty.c,v 1.5 1997/11/21 08:49:12 mrg Exp $");
+__RCSID("$NetBSD: wwpty.c,v 1.5.12.1 2002/05/30 08:32:08 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -49,49 +49,24 @@
 #include <sys/ioctl.h>
 #endif
 #include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
+#include <util.h>
 #include "ww.h"
 
 int
 wwgetpty(w)
        struct ww *w;
 {
-       char c, *p;
-       int tty;
        int on = 1;
-#define PTY "/dev/XtyXX"
-#define _PT    5
-#define _PQRS  8
-#define _0_9   9
+       int result, tty;
 
-       (void) strcpy(w->ww_ttyname, PTY);
-       for (c = 'p'; c <= 'u'; c++) {
-               w->ww_ttyname[_PT] = 'p';
-               w->ww_ttyname[_PQRS] = c;
-               w->ww_ttyname[_0_9] = '0';
-               if (access(w->ww_ttyname, 0) < 0)
-                       break;
-               for (p = "0123456789abcdef"; *p; p++) {
-                       w->ww_ttyname[_PT] = 'p';
-                       w->ww_ttyname[_0_9] = *p;
-                       if ((w->ww_pty = open(w->ww_ttyname, 2)) < 0)
-                               continue;
-                       w->ww_ttyname[_PT] = 't';
-                       if ((tty = open(w->ww_ttyname, 2)) < 0) {
-                               (void) close(w->ww_pty);
-                               continue;
-                       }
-                       (void) close(tty);
-                       if (ioctl(w->ww_pty, TIOCPKT, (char *)&on) < 0) {
-                               (void) close(w->ww_pty);
-                               continue;
-                       }
-                       (void) fcntl(w->ww_pty, F_SETFD, 1);
-                       return 0;
-               }
+       result = openpty(&w->ww_pty, &tty, w->ww_ttyname, NULL, NULL);
+       if (result < 0) {
+               w->ww_pty = -1;
+               wwerrno = WWE_NOPTY;
+               return -1;
+       } else {
+               (void) ioctl(w->ww_pty, TIOCPKT, (char *)&on);
+               (void) fcntl(w->ww_pty, F_SETFD, 1);
+               return 0;
        }
-       w->ww_pty = -1;
-       wwerrno = WWE_NOPTY;
-       return -1;
 }



Home | Main Index | Thread Index | Old Index