X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69919241d35e5382ca7800dd47562ff92d2918cf..25a2a4b05ee3b0f457ac89db2c93c0b11af5955a:/src/common/sckaddr.cpp diff --git a/src/common/sckaddr.cpp b/src/common/sckaddr.cpp index 801921e8aa..ab9a1f78c6 100644 --- a/src/common/sckaddr.cpp +++ b/src/common/sckaddr.cpp @@ -10,16 +10,18 @@ ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation "sckaddr.h" + #pragma implementation "sckaddr.h" #endif // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif +#if wxUSE_SOCKETS + #ifndef WX_PRECOMP #endif @@ -43,14 +45,10 @@ #endif // __WINDOWS__ #if defined(__UNIX__) - #ifdef VMS #include #include #else -#if defined(__FreeBSD__) || defined (__NetBSD__) -#include -#endif #include #include #include @@ -60,8 +58,10 @@ #include #ifdef __SUN__ -extern "C" { - int gethostname(char *name, int namelen); +extern "C" +{ + struct hostent *gethostbyname(const char *name); + int gethostname(char *name, int namelen); }; #endif @@ -83,8 +83,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress) #endif wxIPV4address::wxIPV4address() - m_addr = new sockaddr_in; { + m_addr = new sockaddr_in; Clear(); } @@ -128,14 +128,14 @@ bool wxIPV4address::Hostname(const wxString& name) return FALSE; if (!name.IsNumber()) { - if ((theHostent = gethostbyname(name.GetData())) == 0) { + if ((theHostent = gethostbyname(name.fn_str())) == 0) { return FALSE; } } else { #ifdef __WXMAC__ - long len_addr = inet_addr(name.GetData()).s_addr ; + long len_addr = inet_addr(name.fn_str()).s_addr ; #else - long len_addr = inet_addr(name.GetData()); + long len_addr = inet_addr(name.fn_str()); #endif if (len_addr == -1) return FALSE; @@ -163,11 +163,11 @@ bool wxIPV4address::Service(const wxString& name) return FALSE; if (!name.IsNumber()) { - if ((theServent = getservbyname(name, "tcp")) == 0) + if ((theServent = getservbyname(name.fn_str(), "tcp")) == 0) return FALSE; } else { - if ((theServent = getservbyport(atoi(name), "tcp")) == 0) { - m_addr->sin_port = htons(atoi(name)); + if ((theServent = getservbyport(wxAtoi(name), "tcp")) == 0) { + m_addr->sin_port = htons(wxAtoi(name)); return TRUE; } } @@ -198,7 +198,11 @@ wxString wxIPV4address::Hostname() h_ent = gethostbyaddr((char *)&(m_addr->sin_addr), sizeof(m_addr->sin_addr), GetFamily()); - return wxString(h_ent->h_name); + + if (!h_ent) + return wxString(""); + else + return wxString(h_ent->h_name); } unsigned short wxIPV4address::Service() @@ -395,7 +399,7 @@ const wxSockAddress& wxUNIXaddress::operator =(const wxSockAddress& addr) void wxUNIXaddress::Filename(const wxString& fname) { - sprintf(m_addr->sun_path, "%s", WXSTRINGCAST fname); + sprintf(m_addr->sun_path, "%s", MBSTRINGCAST fname.mb_str()); } wxString wxUNIXaddress::Filename() @@ -416,3 +420,6 @@ void wxUNIXaddress::Disassemble(struct sockaddr *addr, size_t len) *m_addr = *(struct sockaddr_un *)addr; } #endif + +#endif + // wxUSE_SOCKETS