X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dee1a63ff52bfe4da396187f8438aa1a29796737..6945b5878c8d46a56f1a59f558837a0943492f3c:/src/os2/utils.cpp diff --git a/src/os2/utils.cpp b/src/os2/utils.cpp index ccf622b9a2..091c160fec 100644 --- a/src/os2/utils.cpp +++ b/src/os2/utils.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: utils.cpp +// Name: src/os2/utils.cpp // Purpose: Various utilities // Author: David Webster // Modified by: @@ -13,7 +13,6 @@ #include "wx/wxprec.h" #ifndef WX_PRECOMP - #include "wx/setup.h" #include "wx/utils.h" #include "wx/app.h" #endif //WX_PRECOMP @@ -59,18 +58,17 @@ static const wxChar eHOSTNAME[] = _T("HostName"); // functions beyond those provided by WinSock // Get full hostname (eg. DoDo.BSn-Germany.crg.de) -bool wxGetHostName( - wxChar* zBuf -, int nMaxSize -) +bool wxGetHostName( wxChar* zBuf, int nMaxSize ) { -#if wxUSE_NET_API - char zServer[256]; - char zComputer[256]; - unsigned long ulLevel = 0; - unsigned char* zBuffer = NULL; - unsigned long ulBuffer = 256; - unsigned long* pulTotalAvail = NULL; + if (!zBuf) return false; + +#if defined(wxUSE_NET_API) && wxUSE_NET_API + char zServer[256]; + char zComputer[256]; + unsigned long ulLevel = 0; + unsigned char* zBuffer = NULL; + unsigned long ulBuffer = 256; + unsigned long* pulTotalAvail = NULL; NetBios32GetInfo( (const unsigned char*)zServer ,(const unsigned char*)zComputer @@ -81,8 +79,8 @@ bool wxGetHostName( ); strcpy(zBuf, zServer); #else - wxChar* zSysname; - const wxChar* zDefaultHost = _T("noname"); + wxChar* zSysname; + const wxChar* zDefaultHost = _T("noname"); if ((zSysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL) { @@ -95,9 +93,13 @@ bool wxGetHostName( ); } else + { wxStrncpy(zBuf, zSysname, nMaxSize - 1); + } + zBuf[nMaxSize] = _T('\0'); #endif + return *zBuf ? true : false; } @@ -442,9 +444,9 @@ wxChar* wxGetUserHome ( const wxString &rUser ) return (wxChar*)wxEmptyString; // No home known! } -wxString WXDLLEXPORT wxPMErrorToStr(ERRORID vError) +wxString wxPMErrorToStr(ERRORID vError) { - wxString sError; + wxString sError; // // Remove the high order byte -- it is useless @@ -495,7 +497,7 @@ wxString WXDLLEXPORT wxPMErrorToStr(ERRORID vError) default: sError = wxT("Unknown error"); } - return(sError); + return sError; } // end of wxPMErrorToStr // replacement for implementation in unix/utilsunx.cpp,