GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
KPty Class Reference

Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY, utmp registration and setting various terminal attributes. More...

#include "kpty.h"

Collaboration diagram for KPty:
Collaboration graph
[legend]

Public Member Functions

 KPty ()
 Constructor.
 KPty (int masterFd, int slaveFd)
 ~KPty ()
 Destructor:
void close ()
 Close the pty master/slave pair.
void closeSlave ()
 Close the pty slave descriptor.
int masterFd () const
bool open ()
 Create a pty master/slave pair.
bool setEcho (bool echo)
 Set whether the pty should echo input.
bool setWinSize (int lines, int columns)
 Change the logical (screen) size of the pty.
int slaveFd () const
bool tcGetAttr (struct::termios *ttmode) const
 Wrapper around tcgetattr(3).
bool tcSetAttr (struct::termios *ttmode)
 Wrapper around tcsetattr(3) with mode TCSANOW.
const charttyName () const

Protected Member Functions

 KPty (KPtyPrivate *d)

Protected Attributes

KPtyPrivate *const d_ptr

Detailed Description

Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY, utmp registration and setting various terminal attributes.

Definition at line 35 of file kpty.h.

Constructor & Destructor Documentation

KPty::KPty ( )

Constructor.

Definition at line 184 of file kpty.cpp.

KPty::KPty ( int  masterFd,
int  slaveFd 
)

Definition at line 189 of file kpty.cpp.

KPty::~KPty ( )

Destructor:

If the pty is still open, it will be closed. Note, however, that an utmp registration is not undone.

Definition at line 200 of file kpty.cpp.

References close(), and d_ptr.

KPty::KPty ( KPtyPrivate d)
protected

Definition at line 194 of file kpty.cpp.

References d_ptr, and KPtyPrivate::q_ptr.

Member Function Documentation

void KPty::close ( void  )

Close the pty master/slave pair.

Definition at line 396 of file kpty.cpp.

References closeSlave(), d, and stat().

Referenced by closeSlave(), open(), and ~KPty().

void KPty::closeSlave ( )

Close the pty slave descriptor.

When creating the pty, KPty also opens the slave and keeps it open. Consequently the master will never receive an EOF notification. Usually this is the desired behavior, as a closed pty slave can be reopened any time - unlike a pipe or socket. However, in some cases pipe-alike behavior might be desired.

After this function was called, slaveFd() and setCTty() cannot be used.

Definition at line 386 of file kpty.cpp.

References close(), and d.

Referenced by close().

int KPty::masterFd ( ) const
Returns
the file descriptor of the master pty

This function should be called only while the pty is open.

Definition at line 472 of file kpty.cpp.

References d.

Referenced by TerminalModel::sendData(), and TerminalModel::TerminalModel().

bool KPty::open ( )

Create a pty master/slave pair.

Returns
true if a pty pair was successfully opened

Definition at line 206 of file kpty.cpp.

References close(), d, PATH_MAX, stat(), tcGetAttr(), tcSetAttr(), and TTY_GROUP.

Referenced by QUnixTerminalImpl::initialize().

bool KPty::setEcho ( bool  echo)

Set whether the pty should echo input.

Echo is on by default. If the output of automatically fed (non-interactive) PTY clients needs to be parsed, disabling echo often makes it much simpler.

This function can be used only while the PTY is open.

Parameters
echotrue if input should be echoed.
Returns
true on success, false otherwise

Definition at line 453 of file kpty.cpp.

References ECHO, tcGetAttr(), and tcSetAttr().

bool KPty::setWinSize ( int  lines,
int  columns 
)

Change the logical (screen) size of the pty.

The default is 24 lines by 80 columns.

This function can be used only while the PTY is open.

Parameters
linesthe number of rows
columnsthe number of columns
Returns
true on success, false otherwise

Definition at line 442 of file kpty.cpp.

References d.

Referenced by TerminalModel::updateTerminalSize().

int KPty::slaveFd ( ) const
Returns
the file descriptor of the slave pty

This function should be called only while the pty slave is open.

Definition at line 479 of file kpty.cpp.

References d.

Referenced by QUnixTerminalImpl::connectToPty().

bool KPty::tcGetAttr ( struct::termios *  ttmode) const

Wrapper around tcgetattr(3).

This function can be used only while the PTY is open. You will need an #include <termios.h> to do anything useful with it.

Parameters
ttmodea pointer to a termios structure. Note: when declaring ttmode, struct ::termios must be used - without the '::' some version of HP-UX thinks, this declares the struct in your class, in your method.
Returns
true on success, false otherwise

Definition at line 428 of file kpty.cpp.

References _tcgetattr, and d.

Referenced by open(), and setEcho().

bool KPty::tcSetAttr ( struct::termios *  ttmode)

Wrapper around tcsetattr(3) with mode TCSANOW.

This function can be used only while the PTY is open.

Parameters
ttmodea pointer to a termios structure.
Returns
true on success, false otherwise. Note that success means that at least one attribute could be set.

Definition at line 435 of file kpty.cpp.

References _tcsetattr, and d.

Referenced by open(), and setEcho().

const char * KPty::ttyName ( ) const
Returns
the name of the slave pty device.

This function should be called only while the pty is open.

Definition at line 465 of file kpty.cpp.

References d.

Member Data Documentation

KPtyPrivate* const KPty::d_ptr
protected

Definition at line 162 of file kpty.h.

Referenced by KPty(), and ~KPty().


The documentation for this class was generated from the following files: