]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/utils.cpp
support mac on little endian systems
[wxWidgets.git] / src / os2 / utils.cpp
index df321ea4e3e61a1c0fdd58b890bf6c176c782477..a2f9dafe5ad45ad92ab0a7960eb69ba11c9c58cc 100644 (file)
@@ -45,7 +45,7 @@
 #include <netbios.h>
 #endif
 
-static const wxChar WX_SECTION[] = _T("wxWindows");
+static const wxChar WX_SECTION[] = _T("wxWidgets");
 static const wxChar eHOSTNAME[]  = _T("HostName");
 static const wxChar eUSERID[]    = _T("UserId");
 static const wxChar eUSERNAME[]  = _T("UserName");
@@ -83,19 +83,19 @@ bool wxGetHostName(
 
     if ((zSysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL)
     {
-        ULONG n = ::PrfQueryProfileString( HINI_PROFILE
-                                          ,(PSZ)WX_SECTION
-                                          ,(PSZ)eHOSTNAME
-                                          ,(PSZ)zDefaultHost
-                                          ,(void*)zBuf
-                                          ,(ULONG)nMaxSize - 1
-                                         );
+        ::PrfQueryProfileString( HINI_PROFILE
+                                ,(PSZ)WX_SECTION
+                                ,(PSZ)eHOSTNAME
+                                ,(PSZ)zDefaultHost
+                                ,(void*)zBuf
+                                ,(ULONG)nMaxSize - 1
+                               );
     }
     else
         wxStrncpy(zBuf, zSysname, nMaxSize - 1);
     zBuf[nMaxSize] = _T('\0');
 #endif
-    return *zBuf ? TRUE : FALSE;
+    return *zBuf ? true : false;
 }
 
 // Get user ID e.g. jacs
@@ -108,9 +108,9 @@ bool wxGetUserId(
     long                            lrc;
     // UPM procs return 0 on success
     lrc = U32ELOCU((unsigned char*)zBuf, (unsigned long *)&nType);
-    if (lrc == 0) return TRUE;
+    if (lrc == 0) return true;
 #endif
-    return FALSE;
+    return false;
 }
 
 bool wxGetUserName(
@@ -125,13 +125,14 @@ bool wxGetUserName(
 #else
     wxStrncpy(zBuf, _T("Unknown User"), nMaxSize);
 #endif
-    return TRUE;
+    return true;
 }
 
 int wxKill(
   long                              lPid
 , wxSignal                          eSig
 , wxKillError*                      peError
+, int                               flags
 )
 {
     return((int)::DosKillProcess(0, (PID)lPid));
@@ -159,9 +160,9 @@ bool wxShell(
     SData.FgBg     = SSF_FGBG_FORE;
     SData.TraceOpt = SSF_TRACEOPT_NONE;
     SData.PgmTitle = PgmTitle;
-    SData.PgmName  = zShell;
+    SData.PgmName  = (char*)zShell;
 
-    sInputs = "/C " + rCommand;
+    sInputs = _T("/C ") + rCommand;
     SData.PgmInputs     = (BYTE*)sInputs.c_str();
     SData.TermQ         = 0;
     SData.Environment   = 0;
@@ -200,22 +201,40 @@ bool wxShell(
 bool wxShutdown(wxShutdownFlags wFlags)
 {
     // TODO
-    return FALSE;
+    return false;
+}
+
+wxPowerType wxGetPowerType()
+{
+    // TODO
+    return wxPOWER_UNKNOWN;
+}
+
+wxBatteryState wxGetBatteryState()
+{
+    // TODO
+    return wxBATTERY_UNKNOWN_STATE;
 }
 
 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
-long wxGetFreeMemory()
+wxMemorySize wxGetFreeMemory()
 {
     void*                           pMemptr = NULL;
-    ULONG                           lSize;
+    LONG                            lSize;
     ULONG                           lMemFlags;
     APIRET                          rc;
 
     lMemFlags = PAG_FREE;
-    rc = ::DosQueryMem(pMemptr, &lSize, &lMemFlags);
+    rc = ::DosQueryMem(pMemptr, (PULONG)&lSize, &lMemFlags);
     if (rc != 0)
-        return -1L;
-    return (long)lSize;
+        lSize = -1L;
+    return (wxMemorySize)lSize;
+}
+
+// Get Process ID
+unsigned long wxGetProcessId()
+{
+    return (unsigned long)getpid();
 }
 
 // ----------------------------------------------------------------------------
@@ -227,14 +246,14 @@ bool wxGetEnv(const wxString& var, wxString *value)
     // wxGetenv is defined as getenv()
     wxChar *p = wxGetenv(var);
     if ( !p )
-        return FALSE;
+        return false;
 
     if ( value )
     {
         *value = p;
     }
 
-    return TRUE;
+    return true;
 }
 
 bool wxSetEnv(const wxString& variable, const wxChar *value)
@@ -256,17 +275,24 @@ bool wxSetEnv(const wxString& variable, const wxChar *value)
 
     return putenv(buf) == 0;
 #else // no way to set an env var
-    return FALSE;
+    return false;
 #endif
 }
 
-void wxUsleep(
+void wxMilliSleep(
   unsigned long                     ulMilliseconds
 )
 {
     ::DosSleep(ulMilliseconds);
 }
 
+void wxMicroSleep(
+  unsigned long                     ulMicroseconds
+)
+{
+    ::DosSleep(ulMicroseconds/1000);
+}
+
 void wxSleep(
   int                               nSecs
 )
@@ -303,7 +329,7 @@ void wxError(
 , const wxString&                   rTitle
 )
 {
-    wxBuffer = new wxChar[256];
+    wxChar *wxBuffer = new wxChar[256];
     wxSprintf(wxBuffer, "%s\nContinue?", WXSTRINGCAST rMsg);
     if (::WinMessageBox( HWND_DESKTOP
                         ,NULL
@@ -353,9 +379,9 @@ void wxAppTraits::TerminateGui(unsigned long ulHab)
 
 wxToolkitInfo & wxConsoleAppTraits::GetToolkitInfo()
 {
-    static wxToolkitInfo           vInfo;
-    ULONG                           ulSysInfo[QSV_MAX] = {0};
-    APIRET                          ulrc;
+    static wxToolkitInfo  vInfo;
+    ULONG                 ulSysInfo[QSV_MAX] = {0};
+    APIRET                ulrc;
 
     vInfo.name = _T("wxBase");
     ulrc = ::DosQuerySysInfo( 1L
@@ -390,7 +416,7 @@ const wxChar* wxGetHomeDir(
 #  define MAX_PATH  256
 #endif
 
-    const wxChar *szHome = wxGetenv("HOME");
+    const wxChar *szHome = wxGetenv((wxChar*)"HOME");
     if ( szHome == NULL ) {
       // we're homeless, use current directory.
       rStrDir = wxT(".");
@@ -409,9 +435,9 @@ wxChar* wxGetUserHome (
     wxChar*                         zHome;
     wxString                        sUser1(rUser);
 
-    wxBuffer = new wxChar[256];
+    wxChar *wxBuffer = new wxChar[256];
 #ifndef __EMX__
-    if (sUser1 != _T(""))
+    if (!sUser1.empty())
     {
         wxChar                      zTmp[64];
 
@@ -433,7 +459,7 @@ wxChar* wxGetUserHome (
         }
     }
 #endif
-    if (sUser1 == _T(""))
+    if (sUser1.empty())
     {
         if ((zHome = wxGetenv(_T("HOME"))) != NULL)
         {
@@ -445,14 +471,7 @@ wxChar* wxGetUserHome (
         }
     }
     delete[] wxBuffer;
-    return NULL; // No home known!
-}
-
-bool wxDirExists(
-  const wxString&                   rDir
-)
-{
-    return (::DosSetCurrentDir(WXSTRINGCAST rDir));
+    return (wxChar*)wxEmptyString; // No home known!
 }
 
 wxString WXDLLEXPORT wxPMErrorToStr(