home *** CD-ROM | disk | FTP | other *** search
- //************************************************************************
- //
- // Most of this code is from the Subprocess object.
- // Numerous additions, deletions, changes and any bugs courtesy of:
- //
- // Felipe A. Rodriguez
- //
- // Portions of this file were derived from:
- //
- // pppkill.c
- // by Scott Hess
- //
- // Subprocess.h (v10)
- // by Charles L. Oei
- // pty support by Joe Freeman
- // with encouragement from Kristofer Younger
- // Subprocess Example, Release 2.0
- // NeXT Computer, Inc.
- //
- // This code is supplied "as is" the author makes no warranty as to its
- // suitability for any purpose. This code is free and may be distributed
- // in accordance with the terms of the:
- //
- // GNU GENERAL PUBLIC LICENSE
- // Version 2, June 1991
- // copyright (C) 1989, 1991 Free Software Foundation, Inc.
- // 675 Mass Ave, Cambridge, MA 02139, USA
- //
- //************************************************************************
-
- #import <objc/Object.h>
- #import <appkit/Application.h>
- #import <appkit/nextstd.h>
- #import <stdio.h>
-
-
- /*
- This subprocess object sends/receives data to/from any UNIX
- subprocess asynchronously (via vfork).
- Its delegate, if any, will receive the following messages:
-
- - subprocessDone;
- // sent when the subprocess exits
-
- - subprocessOutput:(char *)buffer;
- // sent whenever there is data on the standard output pipe;
- // buffer is only valid until next call
-
- - showAlert:(const char *)errorString;
- // sent when an error occurs;
- // if it ever happens, it's usually only at startup time
- */
-
-
- #define BUFFERSIZE 2048
-
- @interface Subprocess:Object
- {
- FILE *fpToChild;
- int fromChild;
- int childPid;
- id delegate;
- int masterPty; // file descriptor for master/slave pty
- int slavePty;
- int bufferCount;
- char outputBuffer[BUFFERSIZE];
- int log;
- FILE *fp;
- char Path[MAXPATHLEN + 1]; // generic buffer to hold paths
- }
-
- // optional redirecting the standard error stream thru standard output
- - init:(const char *)subprocessString withDelegate:theDelegate
- andStdErr:(BOOL)wantsStdErr;
-
- - terminate:sender; // forces the subprocess to terminate (w/ SIGTERM)
-
- // read pppd/syslog output from a FIFO or an ordinary file
- - readFromFile;
- - readFromFIFO;
-
-
- @end
-