--- xview-3.2p1.4-18c/lib/libxview/ttysw/tty_init.c 2005-04-08 11:39:49.000000000 +0200 +++ xview-3.2p1.4-18c-unix98ptys/lib/libxview/ttysw/tty_init.c 2005-04-08 12:20:15.000000000 +0200 @@ -27,6 +27,10 @@ #include #endif +#ifdef _XOPEN_SOURCE +#include +#endif + #include /* for XV* defines and termios */ #ifdef XV_USE_SVR4_PTYS @@ -731,6 +735,18 @@ int tmpfd; int pty = 0, tty = 0; int on = 1; + +#ifdef _XOPEN_SOURCE + /* info: pty master, tty slave, Ttysw->tty_name is char[20] */ + if (((pty=getpt())<0)||(grantpt(pty)<0)||(unlockpt(pty)<0)) { + (void) fprintf(stderr, XV_MSG("Error: getpt/grantpt/unlockpt failed\n")); + return XV_ERROR; } + if ((ptsname(pty)==NULL)||(strncpy(ttysw->tty_name,ptsname(pty),19)==NULL)) { + (void) fprintf(stderr, XV_MSG("Error: ptsname/strncpy failed\n")); + return XV_ERROR; } + if ((tty=open(ttysw->tty_name,O_RDWR))<0) { + return XV_ERROR; } +#else #ifdef __CYGWIN__ openpty(&pty, &tty, ttysw->tty_name, NULL, NULL); #else @@ -949,6 +965,7 @@ #endif /* SVR4 */ #endif /* cygwin */ +#endif /* _XOPEN_SOURCE */ if (ttysw_restoreparms(tty)) (void) putenv(WE_TTYPARMS_E);