]> code.delx.au - gnu-emacs/blob - test/etags/objc-src/Subprocess.h
Use ‘T *restrict’ proto, not ‘T[restrict]’
[gnu-emacs] / test / etags / objc-src / Subprocess.h
1 /*
2 Subprocess.h (v10)
3 by Charles L. Oei
4 pty support by Joe Freeman
5 with encouragement from Kristofer Younger
6 Subprocess Example, Release 2.0
7 NeXT Computer, Inc.
8
9 You may freely copy, distribute and reuse the code in this example.
10 NeXT disclaims any warranty of any kind, expressed or implied, as to
11 its fitness for any particular use.
12
13 Hacked up for use in PackageInspector by Tom Hageman.
14 */
15
16 #import <objc/Object.h>
17 #import <stdio.h>
18
19 /*
20 This subprocess object sends/receives data to/from any UNIX
21 subprocess asynchronously (via vfork/pipe).
22 Its delegate, if any, will receive the following messages:
23
24 - subprocessDone;
25 // sent when the subprocess exits
26
27 - subprocessOutput:(char *)buffer;
28 // sent whenever there is data on the standard output pipe;
29 // buffer is only valid until next call
30
31 - subprocessError:(const char *)errorString;
32 // sent when an error occurs;
33 // if it ever happens, it's usually only at startup time
34
35 // [TRH] and this is how these should have been done in the first place...
36 - subprocessDone:(SubProcess *)sender;
37 - subprocess:(SubProcess *)sender output:(char *)buffer;
38 */
39
40 // Hack to uniquize classname (to avoid dynload errors.)
41 #define Subprocess SubprocessForPackageInspector
42
43 #define BUFFERSIZE 2048
44
45 @interface Subprocess:Object
46 {
47 FILE *fpToChild;
48 int fromChild;
49 int childPid;
50 id delegate;
51 int masterPty; // file descriptor for master/slave pty
52 int slavePty;
53 int bufferCount;
54 char outputBuffer[BUFFERSIZE];
55 }
56
57 - init:(const char *)subprocessString;
58 // a cover for the below withDelegate:nil, andPtySupport:NO, andStdErr:YES
59
60 - init:(const char *)subprocessString
61 withDelegate:theDelegate
62 andPtySupport:(BOOL)wantsPty
63 andStdErr:(BOOL)wantsStdErr;
64 // optional requests for pseudo terminal support and
65 // redirecting the standard error stream thru standard output
66
67 - send:(const char *)string withNewline:(BOOL)wantNewline;
68 // send the string optionally followed by a new line
69 - send:(const char *)string;
70 // sends the string followed by a new line
71 // shorthand for above withNewline:YES
72 - terminateInput;
73 // sends an end-of-file (EOF) to the subprocess
74 // (and closes input pipe to child)
75 - terminate:sender;
76 // forces the subprocess to terminate (w/ SIGTERM)
77
78 - setDelegate:anObject;
79 - delegate;
80
81 @end