Mercurial > gftp.yaz
diff lib/pty.c @ 515:cb78cf311d23
2004-7-26 Brian Masney <masneyb@gftp.org>
* lib/pty.c - give the grantpt pty implementation more priority over
using openpty()
author | masneyb |
---|---|
date | Mon, 26 Jul 2004 09:51:07 +0000 |
parents | 656a0b3d1403 |
children | fbb5a02beddb |
line wrap: on
line diff
--- a/lib/pty.c Sun Jul 25 15:48:25 2004 +0000 +++ b/lib/pty.c Mon Jul 26 09:51:07 2004 +0000 @@ -60,49 +60,6 @@ return (new_fds); } -#elif HAVE_OPENPTY - -#ifdef HAVE_PTY_H -#include <pty.h> -#include <utmp.h> /* for login_tty */ -#elif HAVE_LIBUTIL_H -#include <libutil.h> -#include <utmp.h> /* for login_tty */ -#else -extern int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize * winp); -extern int login_tty(int fd); -#endif - -char * -gftp_get_pty_impl (void) -{ - return ("openpty"); -} - - -static int -_gftp_ptym_open (char *pts_name, size_t len, int *fds) -{ - int fdm; - - if (openpty (&fdm, fds, pts_name, NULL, NULL) < 0) - return (GFTP_ERETRYABLE); - - ioctl (*fds, TIOCSCTTY, NULL); - - return (fdm); -} - - -static int -_gftp_ptys_open (int fdm, int fds, char *pts_name) -{ - if (login_tty (fds) < 0) - return (GFTP_EFATAL); - - return (fds); -} - #elif HAVE_GRANTPT #include <stropts.h> @@ -169,7 +126,50 @@ return (new_fds); } -#else /* !HAVE_GRANTPT */ +#elif HAVE_OPENPTY + +#ifdef HAVE_PTY_H +#include <pty.h> +#include <utmp.h> /* for login_tty */ +#elif HAVE_LIBUTIL_H +#include <libutil.h> +#include <utmp.h> /* for login_tty */ +#else +extern int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize * winp); +extern int login_tty(int fd); +#endif + +char * +gftp_get_pty_impl (void) +{ + return ("openpty"); +} + + +static int +_gftp_ptym_open (char *pts_name, size_t len, int *fds) +{ + int fdm; + + if (openpty (&fdm, fds, pts_name, NULL, NULL) < 0) + return (GFTP_ERETRYABLE); + + ioctl (*fds, TIOCSCTTY, NULL); + + return (fdm); +} + + +static int +_gftp_ptys_open (int fdm, int fds, char *pts_name) +{ + if (login_tty (fds) < 0) + return (GFTP_EFATAL); + + return (fds); +} + +#else /* Fall back to *BSD... */