blob: af6c279d7cf749e87203cbdf06dd7ae6f6225ad9 [file] [log] [blame]
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001/*
Damien Miller95def091999-11-25 00:26:21 +11002 *
3 * pty.h
4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
9 *
10 * Created: Fri Mar 17 05:03:28 1995 ylo
11 *
12 * Functions for allocating a pseudo-terminal and making it the controlling
13 * tty.
14 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100015
Damien Millerb38eff82000-04-01 11:09:21 +100016/* RCSID("$Id: pty.h,v 1.7 2000/04/01 01:09:25 damien Exp $"); */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100017
18#ifndef PTY_H
19#define PTY_H
20
Damien Miller5428f641999-11-25 11:54:57 +110021/*
22 * Allocates and opens a pty. Returns 0 if no pty could be allocated, or
23 * nonzero if a pty was successfully allocated. On success, open file
24 * descriptors for the pty and tty sides and the name of the tty side are
25 * returned (the buffer must be able to hold at least 64 characters).
26 */
Damien Miller037a0dc1999-12-07 15:38:31 +110027int pty_allocate(int *ptyfd, int *ttyfd, char *ttyname, int ttynamelen);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100028
Damien Miller5428f641999-11-25 11:54:57 +110029/*
30 * Releases the tty. Its ownership is returned to root, and permissions to
31 * 0666.
32 */
Damien Miller95def091999-11-25 00:26:21 +110033void pty_release(const char *ttyname);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100034
Damien Miller5428f641999-11-25 11:54:57 +110035/*
36 * Makes the tty the processes controlling tty and sets it to sane modes.
37 * This may need to reopen the tty to get rid of possible eavesdroppers.
38 */
Damien Miller95def091999-11-25 00:26:21 +110039void pty_make_controlling_tty(int *ttyfd, const char *ttyname);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100040
41/* Changes the window size associated with the pty. */
Damien Miller95def091999-11-25 00:26:21 +110042void
43pty_change_window_size(int ptyfd, int row, int col,
44 int xpixel, int ypixel);
Damien Millerd4a8b7e1999-10-27 13:42:43 +100045
Damien Millerc7d8dbb2000-03-02 23:30:53 +110046void pty_setowner(struct passwd *pw, const char *ttyname);
47
Damien Miller95def091999-11-25 00:26:21 +110048#endif /* PTY_H */