]>
git.saurik.com Git - wxWidgets.git/blob - src/msdos/utilsdos.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: DOS implementations of utility functions
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
18 #include "wx/string.h"
21 #include "wx/apptrait.h"
23 #include "wx/process.h"
28 #include <sys/types.h>
32 //----------------------------------------------------------------------------
34 //----------------------------------------------------------------------------
36 void wxSleep(int nSecs
)
38 wxMilliSleep(1000 * nSecs
);
41 void wxMilliSleep(unsigned long milliseconds
)
43 #if HAVE_USLEEP || defined __DJGPP__
44 usleep(milliseconds
* 1000);
45 #elif defined __WATCOMC__
48 clock_t start
= clock();
49 while ((clock() - start
) * 1000 / CLOCKS_PER_SEC
< (clock_t)milliseconds
)
50 ; // FIXME: need to yield here
54 void wxMicroSleep(unsigned long microseconds
)
56 #if HAVE_USLEEP || defined __DJGPP__
59 wxMilliSleep(microseconds
/1000);
64 unsigned long wxGetProcessId()
66 return (unsigned long)getpid();
69 bool wxGetEnv(const wxString
& var
, wxString
*value
)
71 // wxGetenv is defined as getenv()
72 wxChar
*p
= wxGetenv(var
);
82 bool wxSetEnv(const wxString
& variable
, const wxChar
*value
)
84 wxString s
= variable
;
86 s
<< _T('=') << value
;
89 const char *p
= s
.mb_str();
91 // the string will be free()d by libc
92 char *buf
= (char *)malloc(strlen(p
) + 1);
95 return putenv(buf
) == 0;
98 const wxChar
* wxGetHomeDir(wxString
*home
)
101 return home
->c_str();
104 const wxChar
* wxGetUserHomeDir(wxString
*home
)
107 return home
->c_str();
110 wxChar
*wxGetUserHome(const wxString
&user
)
115 #if WXWIN_COMPATIBILITY_2_2
116 void wxFatalError(const wxString
&msg
, const wxString
&title
)
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()
124 #endif // WXWIN_COMPATIBILITY_2_2
126 bool wxGetUserId(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
128 wxFAIL_MSG( wxT("wxGetUserId not implemented under MS-DOS!") );
132 bool wxGetUserName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
134 wxFAIL_MSG( wxT("wxGetUserName not implemented under MS-DOS!") );
138 bool wxGetHostName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
140 wxFAIL_MSG( wxT("wxGetHostName not implemented under MS-DOS!") );
144 bool wxGetFullHostName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
146 wxFAIL_MSG( wxT("wxGetFullHostName not implemented under MS-DOS!") );
150 int wxKill(long WXUNUSED(pid
), wxSignal
WXUNUSED(sig
), wxKillError
*WXUNUSED(rc
), int WXUNUSED(flags
))
152 wxFAIL_MSG( wxT("wxKill not implemented under MS-DOS!") );
156 long wxExecute(const wxString
& WXUNUSED(command
), int WXUNUSED(flags
), wxProcess
*WXUNUSED(process
))
158 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
162 long wxExecute(char **WXUNUSED(argv
), int WXUNUSED(flags
), wxProcess
*WXUNUSED(process
))
164 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
168 wxToolkitInfo
& wxConsoleAppTraits::GetToolkitInfo()
170 static wxToolkitInfo info
;
171 info
.versionMajor
= -1; // FIXME
172 info
.versionMinor
= -1;
173 info
.name
= _T("wxBase");