Back to index

lightning-sunbird  0.9+nobinonly
ptystream.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is lineterm.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Ramalingam Saravanan.
00018  * Portions created by the Initial Developer are Copyright (C) 1999
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 /* ptystream.h: pseudo-TTY stream header
00038  * (used by ltermPrivate.h)
00039  */
00040 
00041 #ifndef _PTYSTREAM_H
00042 
00043 #define _PTYSTREAM_H   1
00044 
00045 #ifdef  __cplusplus
00046 extern "C" {
00047 #endif
00048 
00049 #define PTYNAMELEN 10         /* Length of PTY/TTY device name: /dev/pty?? */
00050 
00051 struct ptys {                 /* PTY structure */
00052 
00053   int ptyFD;                  /* PTY file descriptor (bi-directional) */
00054   int errpipeFD;              /* stderr pipe file descriptor (-1, if none) */
00055 
00056   long pid;                   /* PTY child PID */
00057 
00058   int debug;                  /* Debugging flag */
00059 
00060   char ptydev[PTYNAMELEN+1];  /* PTY (master) name */
00061   char ttydev[PTYNAMELEN+1];  /* TTY (slave) name */
00062 };
00063 
00064 /* creates a new pseudo-TTY (PTY) and also a new process attached to
00065  * it to execute the command line contained in array ARGV.
00066  * The PTY details are stored in the PTY structure PTYP.
00067  * ROWS, COLS contain the initial no. of rows/columns.
00068  * X_PIXELS, Y_PIXELS contain the initial screen size in pixels
00069  * (may be set to zero if screen size is unknown).
00070  * ERRFD is the file descriptor to which the STDERR output of the
00071  * child process is directed.
00072  * If ERRFD == -1, then the STDERR output is redirected to STDOUT.
00073  * If ERRFD == -2, then a new pipe is created and STDERR is redirected
00074  * through it.
00075  * If NOBLOCK is true, enable non-blocking I/O on PTY.
00076  * If NOECHO is true, tty echoing is turned off.
00077  * If NOEXPORT is true, then the current environment is not exported
00078  * to the new process.
00079  * If DEBUG_LTERM is true, debugging messages are printed to STDERR.
00080  * Returns 0 on success and -1 on error.
00081  */
00082 int pty_create(struct ptys *ptyp, char *const argv[],
00083                int rows, int cols, int x_pixels, int y_pixels,
00084                int errfd, int noblock, int noecho, int noexport, int debug);
00085 
00086 /* resizes a PTY; if ptyp is null, resizes file desciptor 0,
00087  * returning 0 on success and -1 on error.
00088  */
00089 int pty_resize(struct ptys *ptyp, int rows, int cols,
00090                                   int xpix, int ypix);
00091 
00092 /* closes the PTY and kills the associated child process, if still alive.
00093  * Also close STDERR pipe, if open.
00094  * Returns 0 on success and -1 on error.
00095  */
00096 int pty_close(struct ptys *ptyp);
00097 
00098 #ifdef  __cplusplus
00099 }
00100 #endif
00101 
00102 #endif  /* _PTYSTREAM_H */