25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
|
#import "OFStream.h"
#ifdef _WIN32
# include <windows.h>
#endif
/**
* \brief A class for stream-like communication with a newly created process.
/*!
* @brief A class for stream-like communication with a newly created process.
*/
@interface OFProcess: OFStream
{
#ifndef _WIN32
pid_t pid;
int readPipe[2], writePipe[2];
#else
HANDLE readPipe[2], writePipe[2];
#endif
int status;
BOOL atEndOfStream;
}
/**
* \brief Creates a new OFProcess with the specified program and invokes the
/*!
* @brief Creates a new OFProcess with the specified program and invokes the
* program.
*
* \param program The program to execute. If it does not start with a slash, the
* @param program The program to execute. If it does not start with a slash, the
* search path specified in PATH is used.
* \return A new, autoreleased OFProcess.
* @return A new, autoreleased OFProcess.
*/
+ (instancetype)processWithProgram: (OFString*)program;
/**
* \brief Creates a new OFProcess with the specified program and arguments and
/*!
* @brief Creates a new OFProcess with the specified program and arguments and
* invokes the program.
*
* \param program The program to execute. If it does not start with a slash, the
* @param program The program to execute. If it does not start with a slash, the
* search path specified in PATH is used.
* \param arguments The arguments to pass to the program, or nil
* \return A new, autoreleased OFProcess.
* @param arguments The arguments to pass to the program, or nil
* @return A new, autoreleased OFProcess.
*/
+ (instancetype)processWithProgram: (OFString*)program
arguments: (OFArray*)arguments;
/**
* \brief Creates a new OFProcess with the specified program, program name and
/*!
* @brief Creates a new OFProcess with the specified program, program name and
* arguments and invokes the program.
*
* \param program The program to execute. If it does not start with a slash, the
* @param program The program to execute. If it does not start with a slash, the
* search path specified in PATH is used.
* \param programName The program name for the program to invoke (argv[0]).
* @param programName The program name for the program to invoke (argv[0]).
* Usually, this is equal to program.
* \param arguments The arguments to pass to the program, or nil
* \return A new, autoreleased OFProcess.
* @param arguments The arguments to pass to the program, or nil
* @return A new, autoreleased OFProcess.
*/
+ (instancetype)processWithProgram: (OFString*)program
programName: (OFString*)programName
arguments: (OFArray*)arguments;
/**
* \brief Initializes an already allocated OFProcess with the specified program
/*!
* @brief Initializes an already allocated OFProcess with the specified program
* and invokes the program.
*
* \param program The program to execute. If it does not start with a slash, the
* @param program The program to execute. If it does not start with a slash, the
* search path specified in PATH is used.
* \return An initialized OFProcess.
* @return An initialized OFProcess.
*/
- initWithProgram: (OFString*)program;
/**
* \brief Initializes an already allocated OFProcess with the specified program
/*!
* @brief Initializes an already allocated OFProcess with the specified program
* and arguments and invokes the program.
*
* \param program The program to execute. If it does not start with a slash, the
* @param program The program to execute. If it does not start with a slash, the
* search path specified in PATH is used.
* \param arguments The arguments to pass to the program, or nil
* \return An initialized OFProcess.
* @param arguments The arguments to pass to the program, or nil
* @return An initialized OFProcess.
*/
- initWithProgram: (OFString*)program
arguments: (OFArray*)arguments;
/**
* \brief Initializes an already allocated OFProcess with the specified program,
/*!
* @brief Initializes an already allocated OFProcess with the specified program,
* program name and arguments and invokes the program.
*
* \param program The program to execute. If it does not start with a slash, the
* @param program The program to execute. If it does not start with a slash, the
* search path specified in PATH is used.
* \param programName The program name for the program to invoke (argv[0]).
* @param programName The program name for the program to invoke (argv[0]).
* Usually, this is equal to program.
* \param arguments The arguments to pass to the program, or nil
* \return An initialized OFProcess.
* @param arguments The arguments to pass to the program, or nil
* @return An initialized OFProcess.
*/
- initWithProgram: (OFString*)program
programName: (OFString*)programName
arguments: (OFArray*)arguments;
/**
* \brief Closes the write direction of the process.
/*!
* @brief Closes the write direction of the process.
*
* This method needs to be called for some programs before data can be read,
* since some programs don't start processing before the write direction is
* closed.
*/
- (void)closeForWriting;
@end
|