blob: 284196813be33f7da7c93b5aeed9057418819fb3 [file] [log] [blame]
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001/*
Damien Miller4af51302000-04-16 11:18:38 +10002 *
Damien Miller95def091999-11-25 00:26:21 +11003 * pty.h
Damien Miller4af51302000-04-16 11:18:38 +10004 *
Damien Miller95def091999-11-25 00:26:21 +11005 * Author: Tatu Ylonen <ylo@cs.hut.fi>
Damien Miller4af51302000-04-16 11:18:38 +10006 *
Damien Miller95def091999-11-25 00:26:21 +11007 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
Damien Miller4af51302000-04-16 11:18:38 +10009 *
Damien Miller95def091999-11-25 00:26:21 +110010 * Created: Fri Mar 17 05:03:28 1995 ylo
Damien Miller4af51302000-04-16 11:18:38 +100011 *
Damien Miller95def091999-11-25 00:26:21 +110012 * Functions for allocating a pseudo-terminal and making it the controlling
13 * tty.
14 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100015
Damien Miller6536c7d2000-06-22 21:32:31 +100016/* RCSID("$OpenBSD: pty.h,v 1.7 2000/06/20 01:39:43 markus 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 Miller4af51302000-04-16 11:18:38 +100042void
Damien Miller95def091999-11-25 00:26:21 +110043pty_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 */