1 //******************************************************************************
2 //  Copyright (c) 2005-2013 by Jan Van hijfte
3 //
4 //  See the included file COPYING.TXT for details about the copyright.
5 //
6 //  This program is distributed in the hope that it will be useful,
7 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 //******************************************************************************
10 
11 
12 #include "qprocess_c.h"
13 
QProcessEnvironment_Create()14 QProcessEnvironmentH QProcessEnvironment_Create()
15 {
16 	return (QProcessEnvironmentH) new QProcessEnvironment();
17 }
18 
QProcessEnvironment_Destroy(QProcessEnvironmentH handle)19 void QProcessEnvironment_Destroy(QProcessEnvironmentH handle)
20 {
21 	delete (QProcessEnvironment *)handle;
22 }
23 
QProcessEnvironment_Create2(const QProcessEnvironmentH other)24 QProcessEnvironmentH QProcessEnvironment_Create2(const QProcessEnvironmentH other)
25 {
26 	return (QProcessEnvironmentH) new QProcessEnvironment(*(const QProcessEnvironment*)other);
27 }
28 
QProcessEnvironment_swap(QProcessEnvironmentH handle,QProcessEnvironmentH other)29 void QProcessEnvironment_swap(QProcessEnvironmentH handle, QProcessEnvironmentH other)
30 {
31 	((QProcessEnvironment *)handle)->swap(*(QProcessEnvironment*)other);
32 }
33 
QProcessEnvironment_isEmpty(QProcessEnvironmentH handle)34 bool QProcessEnvironment_isEmpty(QProcessEnvironmentH handle)
35 {
36 	return (bool) ((QProcessEnvironment *)handle)->isEmpty();
37 }
38 
QProcessEnvironment_clear(QProcessEnvironmentH handle)39 void QProcessEnvironment_clear(QProcessEnvironmentH handle)
40 {
41 	((QProcessEnvironment *)handle)->clear();
42 }
43 
QProcessEnvironment_contains(QProcessEnvironmentH handle,PWideString name)44 bool QProcessEnvironment_contains(QProcessEnvironmentH handle, PWideString name)
45 {
46 	QString t_name;
47 	copyPWideStringToQString(name, t_name);
48 	return (bool) ((QProcessEnvironment *)handle)->contains(t_name);
49 }
50 
QProcessEnvironment_insert(QProcessEnvironmentH handle,PWideString name,PWideString value)51 void QProcessEnvironment_insert(QProcessEnvironmentH handle, PWideString name, PWideString value)
52 {
53 	QString t_name;
54 	QString t_value;
55 	copyPWideStringToQString(name, t_name);
56 	copyPWideStringToQString(value, t_value);
57 	((QProcessEnvironment *)handle)->insert(t_name, t_value);
58 }
59 
QProcessEnvironment_remove(QProcessEnvironmentH handle,PWideString name)60 void QProcessEnvironment_remove(QProcessEnvironmentH handle, PWideString name)
61 {
62 	QString t_name;
63 	copyPWideStringToQString(name, t_name);
64 	((QProcessEnvironment *)handle)->remove(t_name);
65 }
66 
QProcessEnvironment_value(QProcessEnvironmentH handle,PWideString retval,PWideString name,PWideString defaultValue)67 void QProcessEnvironment_value(QProcessEnvironmentH handle, PWideString retval, PWideString name, PWideString defaultValue)
68 {
69 	QString t_retval;
70 	QString t_name;
71 	QString t_defaultValue;
72 	copyPWideStringToQString(name, t_name);
73 	copyPWideStringToQString(defaultValue, t_defaultValue);
74 	t_retval = ((QProcessEnvironment *)handle)->value(t_name, t_defaultValue);
75 	copyQStringToPWideString(t_retval, retval);
76 }
77 
QProcessEnvironment_toStringList(QProcessEnvironmentH handle,QStringListH retval)78 void QProcessEnvironment_toStringList(QProcessEnvironmentH handle, QStringListH retval)
79 {
80 	*(QStringList *)retval = ((QProcessEnvironment *)handle)->toStringList();
81 }
82 
QProcessEnvironment_keys(QProcessEnvironmentH handle,QStringListH retval)83 void QProcessEnvironment_keys(QProcessEnvironmentH handle, QStringListH retval)
84 {
85 	*(QStringList *)retval = ((QProcessEnvironment *)handle)->keys();
86 }
87 
QProcessEnvironment_insert2(QProcessEnvironmentH handle,const QProcessEnvironmentH e)88 void QProcessEnvironment_insert2(QProcessEnvironmentH handle, const QProcessEnvironmentH e)
89 {
90 	((QProcessEnvironment *)handle)->insert(*(const QProcessEnvironment*)e);
91 }
92 
QProcessEnvironment_systemEnvironment(QProcessEnvironmentH retval)93 void QProcessEnvironment_systemEnvironment(QProcessEnvironmentH retval)
94 {
95 	*(QProcessEnvironment *)retval = QProcessEnvironment::systemEnvironment();
96 }
97 
QProcess_Create(QObjectH parent)98 QProcessH QProcess_Create(QObjectH parent)
99 {
100 	return (QProcessH) new QProcess((QObject*)parent);
101 }
102 
QProcess_Destroy(QProcessH handle)103 void QProcess_Destroy(QProcessH handle)
104 {
105 	delete (QProcess *)handle;
106 }
107 
QProcess_start(QProcessH handle,PWideString program,const QStringListH arguments,unsigned int mode)108 void QProcess_start(QProcessH handle, PWideString program, const QStringListH arguments, unsigned int mode)
109 {
110 	QString t_program;
111 	copyPWideStringToQString(program, t_program);
112 	((QProcess *)handle)->start(t_program, *(const QStringList*)arguments, (QIODevice::OpenMode)mode);
113 }
114 
QProcess_start2(QProcessH handle,PWideString command,unsigned int mode)115 void QProcess_start2(QProcessH handle, PWideString command, unsigned int mode)
116 {
117 	QString t_command;
118 	copyPWideStringToQString(command, t_command);
119 	((QProcess *)handle)->start(t_command, (QIODevice::OpenMode)mode);
120 }
121 
QProcess_start3(QProcessH handle,unsigned int mode)122 void QProcess_start3(QProcessH handle, unsigned int mode)
123 {
124 	((QProcess *)handle)->start((QIODevice::OpenMode)mode);
125 }
126 
QProcess_open(QProcessH handle,unsigned int mode)127 bool QProcess_open(QProcessH handle, unsigned int mode)
128 {
129 	return (bool) ((QProcess *)handle)->open((QIODevice::OpenMode)mode);
130 }
131 
QProcess_program(QProcessH handle,PWideString retval)132 void QProcess_program(QProcessH handle, PWideString retval)
133 {
134 	QString t_retval;
135 	t_retval = ((QProcess *)handle)->program();
136 	copyQStringToPWideString(t_retval, retval);
137 }
138 
QProcess_setProgram(QProcessH handle,PWideString program)139 void QProcess_setProgram(QProcessH handle, PWideString program)
140 {
141 	QString t_program;
142 	copyPWideStringToQString(program, t_program);
143 	((QProcess *)handle)->setProgram(t_program);
144 }
145 
QProcess_arguments(QProcessH handle,QStringListH retval)146 void QProcess_arguments(QProcessH handle, QStringListH retval)
147 {
148 	*(QStringList *)retval = ((QProcess *)handle)->arguments();
149 }
150 
QProcess_setArguments(QProcessH handle,const QStringListH arguments)151 void QProcess_setArguments(QProcessH handle, const QStringListH arguments)
152 {
153 	((QProcess *)handle)->setArguments(*(const QStringList*)arguments);
154 }
155 
QProcess_readChannelMode(QProcessH handle)156 QProcess::ProcessChannelMode QProcess_readChannelMode(QProcessH handle)
157 {
158 	return (QProcess::ProcessChannelMode) ((QProcess *)handle)->readChannelMode();
159 }
160 
QProcess_setReadChannelMode(QProcessH handle,QProcess::ProcessChannelMode mode)161 void QProcess_setReadChannelMode(QProcessH handle, QProcess::ProcessChannelMode mode)
162 {
163 	((QProcess *)handle)->setReadChannelMode(mode);
164 }
165 
QProcess_processChannelMode(QProcessH handle)166 QProcess::ProcessChannelMode QProcess_processChannelMode(QProcessH handle)
167 {
168 	return (QProcess::ProcessChannelMode) ((QProcess *)handle)->processChannelMode();
169 }
170 
QProcess_setProcessChannelMode(QProcessH handle,QProcess::ProcessChannelMode mode)171 void QProcess_setProcessChannelMode(QProcessH handle, QProcess::ProcessChannelMode mode)
172 {
173 	((QProcess *)handle)->setProcessChannelMode(mode);
174 }
175 
QProcess_readChannel(QProcessH handle)176 QProcess::ProcessChannel QProcess_readChannel(QProcessH handle)
177 {
178 	return (QProcess::ProcessChannel) ((QProcess *)handle)->readChannel();
179 }
180 
QProcess_setReadChannel(QProcessH handle,QProcess::ProcessChannel channel)181 void QProcess_setReadChannel(QProcessH handle, QProcess::ProcessChannel channel)
182 {
183 	((QProcess *)handle)->setReadChannel(channel);
184 }
185 
QProcess_closeReadChannel(QProcessH handle,QProcess::ProcessChannel channel)186 void QProcess_closeReadChannel(QProcessH handle, QProcess::ProcessChannel channel)
187 {
188 	((QProcess *)handle)->closeReadChannel(channel);
189 }
190 
QProcess_closeWriteChannel(QProcessH handle)191 void QProcess_closeWriteChannel(QProcessH handle)
192 {
193 	((QProcess *)handle)->closeWriteChannel();
194 }
195 
QProcess_setStandardInputFile(QProcessH handle,PWideString fileName)196 void QProcess_setStandardInputFile(QProcessH handle, PWideString fileName)
197 {
198 	QString t_fileName;
199 	copyPWideStringToQString(fileName, t_fileName);
200 	((QProcess *)handle)->setStandardInputFile(t_fileName);
201 }
202 
QProcess_setStandardOutputFile(QProcessH handle,PWideString fileName,unsigned int mode)203 void QProcess_setStandardOutputFile(QProcessH handle, PWideString fileName, unsigned int mode)
204 {
205 	QString t_fileName;
206 	copyPWideStringToQString(fileName, t_fileName);
207 	((QProcess *)handle)->setStandardOutputFile(t_fileName, (QIODevice::OpenMode)mode);
208 }
209 
QProcess_setStandardErrorFile(QProcessH handle,PWideString fileName,unsigned int mode)210 void QProcess_setStandardErrorFile(QProcessH handle, PWideString fileName, unsigned int mode)
211 {
212 	QString t_fileName;
213 	copyPWideStringToQString(fileName, t_fileName);
214 	((QProcess *)handle)->setStandardErrorFile(t_fileName, (QIODevice::OpenMode)mode);
215 }
216 
QProcess_setStandardOutputProcess(QProcessH handle,QProcessH destination)217 void QProcess_setStandardOutputProcess(QProcessH handle, QProcessH destination)
218 {
219 	((QProcess *)handle)->setStandardOutputProcess((QProcess*)destination);
220 }
221 
QProcess_workingDirectory(QProcessH handle,PWideString retval)222 void QProcess_workingDirectory(QProcessH handle, PWideString retval)
223 {
224 	QString t_retval;
225 	t_retval = ((QProcess *)handle)->workingDirectory();
226 	copyQStringToPWideString(t_retval, retval);
227 }
228 
QProcess_setWorkingDirectory(QProcessH handle,PWideString dir)229 void QProcess_setWorkingDirectory(QProcessH handle, PWideString dir)
230 {
231 	QString t_dir;
232 	copyPWideStringToQString(dir, t_dir);
233 	((QProcess *)handle)->setWorkingDirectory(t_dir);
234 }
235 
QProcess_setEnvironment(QProcessH handle,const QStringListH environment)236 void QProcess_setEnvironment(QProcessH handle, const QStringListH environment)
237 {
238 	((QProcess *)handle)->setEnvironment(*(const QStringList*)environment);
239 }
240 
QProcess_environment(QProcessH handle,QStringListH retval)241 void QProcess_environment(QProcessH handle, QStringListH retval)
242 {
243 	*(QStringList *)retval = ((QProcess *)handle)->environment();
244 }
245 
QProcess_setProcessEnvironment(QProcessH handle,const QProcessEnvironmentH environment)246 void QProcess_setProcessEnvironment(QProcessH handle, const QProcessEnvironmentH environment)
247 {
248 	((QProcess *)handle)->setProcessEnvironment(*(const QProcessEnvironment*)environment);
249 }
250 
QProcess_processEnvironment(QProcessH handle,QProcessEnvironmentH retval)251 void QProcess_processEnvironment(QProcessH handle, QProcessEnvironmentH retval)
252 {
253 	*(QProcessEnvironment *)retval = ((QProcess *)handle)->processEnvironment();
254 }
255 
QProcess_error(QProcessH handle)256 QProcess::ProcessError QProcess_error(QProcessH handle)
257 {
258 	return (QProcess::ProcessError) ((QProcess *)handle)->error();
259 }
260 
QProcess_state(QProcessH handle)261 QProcess::ProcessState QProcess_state(QProcessH handle)
262 {
263 	return (QProcess::ProcessState) ((QProcess *)handle)->state();
264 }
265 
QProcess_pid(QProcessH handle)266 Q_PID QProcess_pid(QProcessH handle)
267 {
268 	return (Q_PID) ((QProcess *)handle)->pid();
269 }
270 
QProcess_waitForStarted(QProcessH handle,int msecs)271 bool QProcess_waitForStarted(QProcessH handle, int msecs)
272 {
273 	return (bool) ((QProcess *)handle)->waitForStarted(msecs);
274 }
275 
QProcess_waitForReadyRead(QProcessH handle,int msecs)276 bool QProcess_waitForReadyRead(QProcessH handle, int msecs)
277 {
278 	return (bool) ((QProcess *)handle)->waitForReadyRead(msecs);
279 }
280 
QProcess_waitForBytesWritten(QProcessH handle,int msecs)281 bool QProcess_waitForBytesWritten(QProcessH handle, int msecs)
282 {
283 	return (bool) ((QProcess *)handle)->waitForBytesWritten(msecs);
284 }
285 
QProcess_waitForFinished(QProcessH handle,int msecs)286 bool QProcess_waitForFinished(QProcessH handle, int msecs)
287 {
288 	return (bool) ((QProcess *)handle)->waitForFinished(msecs);
289 }
290 
QProcess_readAllStandardOutput(QProcessH handle,QByteArrayH retval)291 void QProcess_readAllStandardOutput(QProcessH handle, QByteArrayH retval)
292 {
293 	*(QByteArray *)retval = ((QProcess *)handle)->readAllStandardOutput();
294 }
295 
QProcess_readAllStandardError(QProcessH handle,QByteArrayH retval)296 void QProcess_readAllStandardError(QProcessH handle, QByteArrayH retval)
297 {
298 	*(QByteArray *)retval = ((QProcess *)handle)->readAllStandardError();
299 }
300 
QProcess_exitCode(QProcessH handle)301 int QProcess_exitCode(QProcessH handle)
302 {
303 	return (int) ((QProcess *)handle)->exitCode();
304 }
305 
QProcess_exitStatus(QProcessH handle)306 QProcess::ExitStatus QProcess_exitStatus(QProcessH handle)
307 {
308 	return (QProcess::ExitStatus) ((QProcess *)handle)->exitStatus();
309 }
310 
QProcess_bytesAvailable(QProcessH handle)311 qint64 QProcess_bytesAvailable(QProcessH handle)
312 {
313 	return (qint64) ((QProcess *)handle)->bytesAvailable();
314 }
315 
QProcess_bytesToWrite(QProcessH handle)316 qint64 QProcess_bytesToWrite(QProcessH handle)
317 {
318 	return (qint64) ((QProcess *)handle)->bytesToWrite();
319 }
320 
QProcess_isSequential(QProcessH handle)321 bool QProcess_isSequential(QProcessH handle)
322 {
323 	return (bool) ((QProcess *)handle)->isSequential();
324 }
325 
QProcess_canReadLine(QProcessH handle)326 bool QProcess_canReadLine(QProcessH handle)
327 {
328 	return (bool) ((QProcess *)handle)->canReadLine();
329 }
330 
QProcess_close(QProcessH handle)331 void QProcess_close(QProcessH handle)
332 {
333 	((QProcess *)handle)->close();
334 }
335 
QProcess_atEnd(QProcessH handle)336 bool QProcess_atEnd(QProcessH handle)
337 {
338 	return (bool) ((QProcess *)handle)->atEnd();
339 }
340 
QProcess_execute(PWideString program,const QStringListH arguments)341 int QProcess_execute(PWideString program, const QStringListH arguments)
342 {
343 	QString t_program;
344 	copyPWideStringToQString(program, t_program);
345 	return (int) QProcess::execute(t_program, *(const QStringList*)arguments);
346 }
347 
QProcess_execute2(PWideString program)348 int QProcess_execute2(PWideString program)
349 {
350 	QString t_program;
351 	copyPWideStringToQString(program, t_program);
352 	return (int) QProcess::execute(t_program);
353 }
354 
QProcess_startDetached(PWideString program,const QStringListH arguments,PWideString workingDirectory,qint64 * pid)355 bool QProcess_startDetached(PWideString program, const QStringListH arguments, PWideString workingDirectory, qint64* pid)
356 {
357 	QString t_program;
358 	QString t_workingDirectory;
359 	copyPWideStringToQString(program, t_program);
360 	copyPWideStringToQString(workingDirectory, t_workingDirectory);
361 	return (bool) QProcess::startDetached(t_program, *(const QStringList*)arguments, t_workingDirectory, pid);
362 }
363 
QProcess_startDetached2(PWideString program,const QStringListH arguments)364 bool QProcess_startDetached2(PWideString program, const QStringListH arguments)
365 {
366 	QString t_program;
367 	copyPWideStringToQString(program, t_program);
368 	return (bool) QProcess::startDetached(t_program, *(const QStringList*)arguments);
369 }
370 
QProcess_startDetached3(PWideString program)371 bool QProcess_startDetached3(PWideString program)
372 {
373 	QString t_program;
374 	copyPWideStringToQString(program, t_program);
375 	return (bool) QProcess::startDetached(t_program);
376 }
377 
QProcess_systemEnvironment(QStringListH retval)378 void QProcess_systemEnvironment(QStringListH retval)
379 {
380 	*(QStringList *)retval = QProcess::systemEnvironment();
381 }
382 
QProcess_terminate(QProcessH handle)383 void QProcess_terminate(QProcessH handle)
384 {
385 	((QProcess *)handle)->terminate();
386 }
387 
QProcess_kill(QProcessH handle)388 void QProcess_kill(QProcessH handle)
389 {
390 	((QProcess *)handle)->kill();
391 }
392 
393 #if defined MSWINDOWS
QProcess_nativeArguments(QProcessH handle,PWideString retval)394 void QProcess_nativeArguments(QProcessH handle, PWideString retval)
395 {
396 	QString t_retval;
397 	t_retval = ((QProcess *)handle)->nativeArguments();
398 	copyQStringToPWideString(t_retval, retval);
399 }
400 
QProcess_setNativeArguments(QProcessH handle,PWideString arguments)401 void QProcess_setNativeArguments(QProcessH handle, PWideString arguments)
402 {
403 	QString t_arguments;
404 	copyPWideStringToQString(arguments, t_arguments);
405 	((QProcess *)handle)->setNativeArguments(t_arguments);
406 }
407 
408 #endif
409