#define _PATH_DEVPTMX "/dev/ptmx"
-int openpty (int *amaster, int *aslave, char *name, struct termios *termp,
+int openpty (int *aptmx, int *apts, char *name, struct termios *termp,
struct winsize *winp)
{
char buf[PATH_MAX];
- int master, slave;
+ int ptmx, pts;
- master = open(_PATH_DEVPTMX, O_RDWR);
- if (master == -1)
+ ptmx = open(_PATH_DEVPTMX, O_RDWR);
+ if (ptmx == -1)
return -1;
- if (grantpt(master))
+ if (grantpt(ptmx))
goto fail;
- if (unlockpt(master))
+ if (unlockpt(ptmx))
goto fail;
- if (ptsname_r(master, buf, sizeof buf))
+ if (ptsname_r(ptmx, buf, sizeof buf))
goto fail;
- slave = open(buf, O_RDWR | O_NOCTTY);
- if (slave == -1)
+ pts = open(buf, O_RDWR | O_NOCTTY);
+ if (pts == -1)
goto fail;
/* XXX Should we ignore errors here? */
if (termp)
- tcsetattr(slave, TCSAFLUSH, termp);
+ tcsetattr(pts, TCSAFLUSH, termp);
if (winp)
- ioctl(slave, TIOCSWINSZ, winp);
+ ioctl(pts, TIOCSWINSZ, winp);
- *amaster = master;
- *aslave = slave;
+ *aptmx = ptmx;
+ *apts = pts;
if (name != NULL)
strcpy(name, buf);
return 0;
fail:
- close(master);
+ close(ptmx);
return -1;
}
#include <termios.h>
#include <sys/ioctl.h>
-/* Create pseudo tty master slave pair with NAME and set terminal
- attributes according to TERMP and WINP and return handles for both
- ends in AMASTER and ASLAVE. */
-extern int openpty (int *__amaster, int *__aslave, char *__name,
+/*
+ * Create pseudo tty ptmx pts pair with @__name and set terminal
+ * attributes according to @__termp and @__winp and return handles for both
+ * ends in @__aptmx and @__apts.
+ */
+extern int openpty (int *__aptmx, int *__apts, char *__name,
const struct termios *__termp,
const struct winsize *__winp);