Fix Windows and GCC compile errors.
This was SVN commit r5412.
This commit is contained in:
parent
746c081c9c
commit
336573b114
@ -994,17 +994,24 @@ void CNetLogger::GetStringDateTime( CStr &str )
|
||||
{
|
||||
char buffer[ 128 ] = { 0 };
|
||||
time_t tm;
|
||||
struct tm now;
|
||||
struct tm *now;
|
||||
|
||||
#if OS_WIN
|
||||
// Set timezone
|
||||
_tzset();
|
||||
|
||||
// Get time and convert to tm structure
|
||||
time( &tm );
|
||||
localtime_s( &now, &tm );
|
||||
struct tm nowBuf;
|
||||
localtime_s( &nowBuf, &tm );
|
||||
now = &nowBuf;
|
||||
#else
|
||||
time ( &tm );
|
||||
now = localtime( &tm );
|
||||
#endif
|
||||
|
||||
// Build custom time string
|
||||
strftime( buffer, 128, "%Y-%m-%d %H:%M:%S", &now );
|
||||
strftime( buffer, 128, "%Y-%m-%d %H:%M:%S", now );
|
||||
|
||||
str = buffer;
|
||||
}
|
||||
@ -1017,17 +1024,24 @@ void CNetLogger::GetStringTime( CStr& str )
|
||||
{
|
||||
char buffer[ 128 ] = { 0 };
|
||||
time_t tm;
|
||||
struct tm now;
|
||||
struct tm *now;
|
||||
|
||||
#if OS_WIN
|
||||
// Set timezone
|
||||
_tzset();
|
||||
|
||||
// Get time and convert to tm structure
|
||||
time( &tm );
|
||||
localtime_s( &now, &tm );
|
||||
struct tm nowBuf;
|
||||
localtime_s( &nowBuf, &tm );
|
||||
now = &nowBuf;
|
||||
#else
|
||||
time ( &tm );
|
||||
now = localtime( &tm );
|
||||
#endif
|
||||
|
||||
// Build custom time string
|
||||
strftime( buffer, 128, "%H%M%S", &now );
|
||||
strftime( buffer, 128, "%H%M%S", now );
|
||||
|
||||
str = buffer;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ PS_RESULT CSocketAddress::Resolve(const char *name, int port, CSocketAddress &ad
|
||||
CStr CSocketAddress::GetString() const
|
||||
{
|
||||
char convBuf[NI_MAXHOST];
|
||||
int res=getnameinfo((struct sockaddr *)&m_Union, sizeof(struct sockaddr),
|
||||
int res=getnameinfo((struct sockaddr *)&m_Union, sizeof(struct sockaddr_in),
|
||||
convBuf, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
if (res == 0)
|
||||
return CStr(convBuf);
|
||||
@ -420,7 +420,7 @@ PS_RESULT CSocketBase::Write(void *buf, uint len, uint *bytesWritten)
|
||||
|
||||
PS_RESULT CSocketBase::Connect(const CSocketAddress &addr)
|
||||
{
|
||||
int res = connect(m_pInternal->m_fd, (struct sockaddr *)(&addr.m_Union), sizeof(struct sockaddr));
|
||||
int res = connect(m_pInternal->m_fd, (struct sockaddr *)(&addr.m_Union), sizeof(struct sockaddr_in));
|
||||
NET_LOG3("connect returned %d [%d]", res, m_NonBlocking);
|
||||
|
||||
if (res != 0)
|
||||
@ -455,7 +455,7 @@ PS_RESULT CSocketBase::Bind(const CSocketAddress &address)
|
||||
|
||||
SetOpMask(READ);
|
||||
|
||||
res=bind(m_pInternal->m_fd, (struct sockaddr *)&address, sizeof(struct sockaddr));
|
||||
res=bind(m_pInternal->m_fd, (struct sockaddr *)&address, sizeof(struct sockaddr_in));
|
||||
if (res == -1)
|
||||
{
|
||||
PS_RESULT ret=PS_FAIL;
|
||||
@ -559,7 +559,7 @@ bool CSocketBase::ConnectError(CSocketBase *pSocket)
|
||||
{
|
||||
pSocket->m_State=SS_UNCONNECTED;
|
||||
PS_RESULT connErr=GetPS_RESULT(errno);
|
||||
NET_LOG("Connect error: %s [%d:%s]", connErr, errno, strerror(errno));
|
||||
NET_LOG4("Connect error: %s [%d:%s]", connErr, errno, strerror(errno));
|
||||
pSocket->m_Error=connErr;
|
||||
return true;
|
||||
}
|
||||
@ -624,7 +624,7 @@ void CSocketBase::SocketReadable(CSocketBase *pSock)
|
||||
// success, nRead != 0 means alive stream socket
|
||||
if (res == -1 && errno != EINVAL)
|
||||
{
|
||||
NET_LOG("RunWaitLoop:ioctl: Connection broken [%d:%s]", errno, strerror(errno));
|
||||
NET_LOG3("RunWaitLoop:ioctl: Connection broken [%d:%s]", errno, strerror(errno));
|
||||
// Don't use API function - we both hold a lock and
|
||||
// it is unnecessary to SendWaitLoopUpdate at this
|
||||
// stage
|
||||
|
Loading…
Reference in New Issue
Block a user