]> git.saurik.com Git - wxWidgets.git/blob - src/unix/baseunix.cpp
wxBase/GUI separation: 1st step, wxMSW should build, all the rest is broken
[wxWidgets.git] / src / unix / baseunix.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: unix/baseunix.cpp
3 // Purpose: misc stuff only used in console applications under Unix
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 23.06.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #endif //WX_PRECOMP
29
30 #include "wx/apptrait.h"
31
32 // for waitpid()
33 #include <sys/types.h>
34 #include <sys/wait.h>
35
36 // ============================================================================
37 // wxConsoleAppTraits implementation
38 // ============================================================================
39
40 // ----------------------------------------------------------------------------
41 // wxExecute support
42 // ----------------------------------------------------------------------------
43
44 bool wxConsoleAppTraits::CreateEndProcessPipe(wxExecuteData& WXUNUSED(data))
45 {
46 // nothing to do, so always ok
47 return true;
48 }
49
50 bool
51 wxConsoleAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(data),
52 int WXUNUSED(fd))
53 {
54 // we don't have any pipe
55 return false;
56 }
57
58 void
59 wxConsoleAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(data))
60 {
61 // nothing to do
62 }
63
64
65 int
66 wxConsoleAppTraits::WaitForChild(wxExecuteData& execData)
67 {
68 wxASSERT_MSG( execData.flags & wxEXEC_SYNC,
69 wxT("async execution not supported yet") );
70
71 int exitcode = 0;
72 if ( waitpid(execData.pid, &exitcode, 0) == -1 || !WIFEXITED(exitcode) )
73 {
74 wxLogSysError(_("Waiting for subprocess termination failed"));
75 }
76
77 return exitcode;
78 }
79
80 // ----------------------------------------------------------------------------
81 // misc other stuff
82 // ----------------------------------------------------------------------------
83
84 // WXWIN_OS_DESCRIPTION is normally defined by configure
85 #if defined( __MWERKS__ ) && defined(__MACH__)
86 #define WXWIN_OS_DESCRIPTION "MacOS X"
87 #endif
88
89 int wxConsoleAppTraits::GetOSVersion(int *verMaj, int *verMin)
90 {
91 int major, minor;
92 char name[256];
93
94 if ( sscanf(WXWIN_OS_DESCRIPTION, "%s %d.%d", name, &major, &minor) != 3 )
95 {
96 // unreckognized uname string format
97 major =
98 minor = -1;
99 }
100
101 if ( majorVsn )
102 *majorVsn = major;
103 if ( minorVsn )
104 *minorVsn = minor;
105
106 return wxUNIX;
107 }
108