tty_name = _getpty (pty, O_RDWR, 0622, 0); if (tty_name == 0) return 1; strcpy (ttydev, tty_name); return 0;
tty_name = _getpty (pty, O_RDWR, 0622, 0); if (tty_name == 0) return 1; strcpy (ttydev, tty_name); return 0; #elif defined(__convex__) char *pty_name, *getpty();  while ((pty_name = getpty()) != NULL) { if ((*pty = open (pty_name, O_RDWR)) >= 0) { strcpy(ptydev, pty_name); strcpy(ttydev, pty_name); ttydev[5] = 't'; return 0; }
get_pty (int *pty){#if defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS))    int tty;    return (openpty(pty, &tty, ttydev, NULL, NULL));#elif (defined(SYSV) && defined(i386) && !defined(SVR4)) || defined(__QNXNTO__)        /*	  The order of this code is *important*.  On SYSV/386 we want to open	  a /dev/ttyp? first if at all possible.  If none are available, then	  we'll try to open a /dev/pts??? device.	  The reason for this is because /dev/ttyp? works correctly, where	  as /dev/pts??? devices have a number of bugs, (won't update	  screen correcly, will hang -- it more or less works, but you	  really don't want to use it).	  Most importantly, for boxes of this nature, one of the major	  "features" is that you can emulate a 8086 by spawning off a UNIX	  program on 80386/80486 in v86 mode.  In other words, you can spawn	  off multiple MS-DOS environments.  On ISC the program that does	  this is named "vpix."  The catcher is that "vpix" will *not* work	  with a /dev/pts??? device, will only work with a /dev/ttyp? device.	  Since we can open either a /dev/ttyp? or a /dev/pts??? device,	  the flag "IsPts" is set here so that we know which type of	  device we're dealing with in routine spawn().  That's the reason	  for the "if (IsPts)" statement in spawn(); we have two different	  device types which need to be handled differently.	  */        if (pty_search(pty) == 0)	    return 0;#elif defined(USE_USG_PTYS)#ifdef __GLIBC__ /* if __GLIBC__ and USE_USG_PTYS, we know glibc >= 2.1 */	/* GNU libc 2 allows us to abstract away from having to know the	   master pty device name. */	if ((*pty = getpt()) < 0) {	    return 1;	}	strcpy(ttydev, ptsname(*pty));#else	if ((*pty = open ("/dev/ptmx", O_RDWR)) < 0) {	    return 1;	}#endif#if defined(SVR4) || defined(SCO325) || (defined(i386) && defined(SYSV))	strcpy(ttydev, ptsname(*pty));#if defined (SYSV) && defined(i386) && !defined(SVR4)	IsPts = True;#endif#endif	return 0;#elif defined(AIXV3)	if ((*pty = open ("/dev/ptc", O_RDWR)) < 0) {	    return 1;	}	strcpy(ttydev, ttyname(*pty));	return 0;#elif defined(__sgi) && (OSMAJORVERSION >= 4)	{	    char    *tty_name;	    tty_name = _getpty (pty, O_RDWR, 0622, 0);	    if (tty_name == 0)		return 1;	    strcpy (ttydev, tty_name);	    return 0;	}#elif defined(__convex__)        {	    char *pty_name, *getpty();	    while ((pty_name = getpty()) != NULL) {		if ((*pty = open (pty_name, O_RDWR)) >= 0) {		    strcpy(ptydev, pty_name);		    strcpy(ttydev, pty_name);		    ttydev[5] = 't';		    return 0;		}	    }	    return 1;	}#elif defined(USE_GET_PSEUDOTTY)	return ((*pty = getpseudotty (&ttydev, &ptydev)) >= 0 ? 0 : 1);#elif (defined(__sgi) && (OSMAJORVERSION < 4)) || (defined(umips) && defined (SYSTYPE_SYSV))	struct stat fstat_buf;	*pty = open ("/dev/ptc", O_RDWR);	if (*pty < 0 || (fstat (*pty, &fstat_buf)) < 0) {	  return(1);	}	sprintf (ttydev, "/dev/ttyq%d", minor(fstat_buf.st_rdev));#ifndef __sgi	sprintf (ptydev, "/dev/ptyq%d", minor(fstat_buf.st_rdev));	if ((*tty = open (ttydev, O_RDWR)) < 0) {	  close (*pty);	  return(1);	}#endif /* !__sgi */	/* got one! */	return(0);#else /* __sgi or umips */#ifdef __hpux	/*	 * Use the clone device if it works, otherwise use pty_search logic.	 */	if ((*pty = open("/dev/ptym/clone", O_RDWR)) >= 0) {		strcpy(ttydev, ptsname(*pty));		return(0);	}#endif	return pty_search(pty);#endif}