]> git.saurik.com Git - wxWidgets.git/blob - src/msdos/utilsdos.cpp
The mmedia contrib requires sys/soundcard.h on unix, so disable it on unix
[wxWidgets.git] / src / msdos / utilsdos.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: utils.cpp
3 // Purpose: DOS implementations of utility functions
4 // Author: Vaclav Slavik
5 // Id: $Id$
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #include "wx/utils.h"
18 #include "wx/string.h"
19
20 #include "wx/intl.h"
21 #include "wx/apptrait.h"
22 #include "wx/log.h"
23 #include "wx/process.h"
24
25 #include <stdarg.h>
26 #include <string.h>
27 #include <sys/stat.h>
28 #include <sys/types.h>
29 #include <unistd.h>
30 #include <time.h>
31
32 //----------------------------------------------------------------------------
33 // misc.
34 //----------------------------------------------------------------------------
35
36 void wxSleep(int nSecs)
37 {
38 wxMilliSleep(1000 * nSecs);
39 }
40
41 void wxMilliSleep(unsigned long milliseconds)
42 {
43 #if HAVE_USLEEP || defined __DJGPP__
44 usleep(milliseconds * 1000);
45 #elif defined __WATCOMC__
46 delay(milliseconds);
47 #else
48 clock_t start = clock();
49 while ((clock() - start) * 1000 / CLOCKS_PER_SEC < (clock_t)milliseconds)
50 ; // FIXME: need to yield here
51 #endif
52 }
53
54 void wxMicroSleep(unsigned long microseconds)
55 {
56 #if HAVE_USLEEP || defined __DJGPP__
57 usleep(microseconds);
58 #else
59 wxMilliSleep(microseconds/1000);
60 #endif
61 }
62
63 // Get Process ID
64 unsigned long wxGetProcessId()
65 {
66 return (unsigned long)getpid();
67 }
68
69 bool wxGetEnv(const wxString& var, wxString *value)
70 {
71 // wxGetenv is defined as getenv()
72 wxChar *p = wxGetenv(var);
73 if ( !p )
74 return FALSE;
75
76 if ( value )
77 *value = p;
78
79 return TRUE;
80 }
81
82 bool wxSetEnv(const wxString& variable, const wxChar *value)
83 {
84 wxString s = variable;
85 if ( value )
86 s << _T('=') << value;
87
88 // transform to ANSI
89 const char *p = s.mb_str();
90
91 // the string will be free()d by libc
92 char *buf = (char *)malloc(strlen(p) + 1);
93 strcpy(buf, p);
94
95 return putenv(buf) == 0;
96 }
97
98 const wxChar* wxGetHomeDir(wxString *home)
99 {
100 *home = wxT(".");
101 return home->c_str();
102 }
103
104 const wxChar* wxGetUserHomeDir(wxString *home)
105 {
106 *home = wxT(".");
107 return home->c_str();
108 }
109
110 wxChar *wxGetUserHome(const wxString &user)
111 {
112 return wxT(".");
113 }
114
115 #if WXWIN_COMPATIBILITY_2_2
116 void wxFatalError(const wxString &msg, const wxString &title)
117 {
118 wxFprintf( stderr, _("Error ") );
119 if (!title.IsNull()) wxFprintf( stderr, wxT("%s "), WXSTRINGCAST(title) );
120 if (!msg.IsNull()) wxFprintf( stderr, wxT(": %s"), WXSTRINGCAST(msg) );
121 wxFprintf( stderr, wxT(".\n") );
122 exit(3); // the same exit code as for abort()
123 }
124 #endif // WXWIN_COMPATIBILITY_2_2
125
126 bool wxGetUserId(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
127 {
128 wxFAIL_MSG( wxT("wxGetUserId not implemented under MS-DOS!") );
129 return FALSE;
130 }
131
132 bool wxGetUserName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
133 {
134 wxFAIL_MSG( wxT("wxGetUserName not implemented under MS-DOS!") );
135 return FALSE;
136 }
137
138 bool wxGetHostName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
139 {
140 wxFAIL_MSG( wxT("wxGetHostName not implemented under MS-DOS!") );
141 return FALSE;
142 }
143
144 bool wxGetFullHostName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
145 {
146 wxFAIL_MSG( wxT("wxGetFullHostName not implemented under MS-DOS!") );
147 return FALSE;
148 }
149
150 int wxKill(long WXUNUSED(pid), wxSignal WXUNUSED(sig), wxKillError *WXUNUSED(rc), int WXUNUSED(flags))
151 {
152 wxFAIL_MSG( wxT("wxKill not implemented under MS-DOS!") );
153 return 0;
154 }
155
156 long wxExecute(const wxString& WXUNUSED(command), int WXUNUSED(flags), wxProcess *WXUNUSED(process))
157 {
158 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
159 return 0;
160 }
161
162 long wxExecute(char **WXUNUSED(argv), int WXUNUSED(flags), wxProcess *WXUNUSED(process))
163 {
164 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
165 return 0;
166 }
167
168 wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
169 {
170 static wxToolkitInfo info;
171 info.versionMajor = -1; // FIXME
172 info.versionMinor = -1;
173 info.name = _T("wxBase");
174 info.os = wxDOS;
175 return info;
176 }