]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: unix/execute.h | |
3 | // Purpose: private details of wxExecute() implementation | |
4 | // Author: Vadim Zeitlin | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 1998 Robert Roebling, Julian Smart, Vadim Zeitlin | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef _WX_UNIX_EXECUTE_H | |
11 | #define _WX_UNIX_EXECUTE_H | |
12 | ||
13 | #include "wx/unix/pipe.h" | |
14 | ||
15 | class WXDLLIMPEXP_BASE wxProcess; | |
16 | class wxStreamTempInputBuffer; | |
17 | ||
18 | // if pid > 0, the execution is async and the data is freed in the callback | |
19 | // executed when the process terminates, if pid < 0, the execution is | |
20 | // synchronous and the caller (wxExecute) frees the data | |
21 | struct wxEndProcessData | |
22 | { | |
23 | int pid, // pid of the process | |
24 | tag; // port dependent value | |
25 | wxProcess *process; // if !NULL: notified on process termination | |
26 | int exitcode; // the exit code | |
27 | }; | |
28 | ||
29 | // struct in which information is passed from wxExecute() to wxAppTraits | |
30 | // methods | |
31 | struct wxExecuteData | |
32 | { | |
33 | wxExecuteData() | |
34 | { | |
35 | flags = | |
36 | pid = 0; | |
37 | ||
38 | process = NULL; | |
39 | ||
40 | #if wxUSE_STREAMS | |
41 | bufOut = | |
42 | bufErr = NULL; | |
43 | #endif // wxUSE_STREAMS | |
44 | } | |
45 | ||
46 | // wxExecute() flags | |
47 | int flags; | |
48 | ||
49 | // the pid of the child process | |
50 | int pid; | |
51 | ||
52 | // the associated process object or NULL | |
53 | wxProcess *process; | |
54 | ||
55 | // pipe used for end process detection | |
56 | wxPipe pipeEndProcDetect; | |
57 | ||
58 | #if wxUSE_STREAMS | |
59 | // the input buffer bufOut is connected to stdout, this is why it is | |
60 | // called bufOut and not bufIn | |
61 | wxStreamTempInputBuffer *bufOut, | |
62 | *bufErr; | |
63 | #endif // wxUSE_STREAMS | |
64 | }; | |
65 | ||
66 | // this function is called when the process terminates from port specific | |
67 | // callback function and is common to all ports (src/unix/utilsunx.cpp) | |
68 | extern WXDLLIMPEXP_BASE void wxHandleProcessTermination(wxEndProcessData *proc_data); | |
69 | ||
70 | // this function is called to associate the port-specific callback with the | |
71 | // child process. The return valus is port-specific. | |
72 | extern WXDLLIMPEXP_CORE int wxAddProcessCallback(wxEndProcessData *proc_data, int fd); | |
73 | ||
74 | #if defined(__DARWIN__) && (defined(__WXMAC__) || defined(__WXCOCOA__)) | |
75 | // For ports (e.g. DARWIN) which can add callbacks based on the pid | |
76 | extern int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid); | |
77 | #endif | |
78 | ||
79 | #endif // _WX_UNIX_EXECUTE_H |