summaryrefslogtreecommitdiff
path: root/plugins/ConnectionNotify/src/netstat.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-25 10:00:22 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-25 10:00:22 +0000
commit77cc30f66c53cd638eb73bb92340c9144114e07a (patch)
treea5462767042dd144390a08ba49be1e7ebfce22ea /plugins/ConnectionNotify/src/netstat.cpp
parent66fe24c1af7b15aaf749413bf2aacc1d030610e2 (diff)
warning fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@6223 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/ConnectionNotify/src/netstat.cpp')
-rw-r--r--plugins/ConnectionNotify/src/netstat.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/plugins/ConnectionNotify/src/netstat.cpp b/plugins/ConnectionNotify/src/netstat.cpp
index 36a8302571..ae813c9d1d 100644
--- a/plugins/ConnectionNotify/src/netstat.cpp
+++ b/plugins/ConnectionNotify/src/netstat.cpp
@@ -45,14 +45,14 @@ struct CONNECTION* GetConnectionsTable()
memset(newConn,0,sizeof(struct CONNECTION));
//pid2name(pTcpTable->table[i].dwOwningPid,&newConn->Pname);
- if(pTcpTable->table[i].dwLocalAddr)
+ if (pTcpTable->table[i].dwLocalAddr)
{
IpAddr.S_un.S_addr = (ULONG) pTcpTable->table[i].dwLocalAddr;
//_snprintf(newConn->strIntIp,_countof(newConn->strIntIp),"%d.%d.%d.%d",IpAddr.S_un.S_un_b.s_b1,IpAddr.S_un.S_un_b.s_b2,IpAddr.S_un.S_un_b.s_b3,IpAddr.S_un.S_un_b.s_b4);
wcsncpy(newConn->strIntIp, mir_a2t(inet_ntoa(IpAddr)),_tcslen(mir_a2t(inet_ntoa(IpAddr))));
}
- if(pTcpTable->table[i].dwRemoteAddr)
+ if (pTcpTable->table[i].dwRemoteAddr)
{
IpAddr.S_un.S_addr = (u_long) pTcpTable->table[i].dwRemoteAddr;
wcsncpy(newConn->strExtIp, mir_a2t(inet_ntoa(IpAddr)),_tcslen(mir_a2t(inet_ntoa(IpAddr))));
@@ -147,27 +147,19 @@ struct CONNECTION* searchConnection(struct CONNECTION* head,TCHAR *intIp,TCHAR *
struct CONNECTION *cur=head;
while(cur!=NULL)
{
- if(wcscmp(cur->strIntIp,intIp)==0 && wcscmp(cur->strExtIp,extIp)==0 && cur->intExtPort==extPort && cur->intIntPort==intPort && cur->state==state)
+ if (wcscmp(cur->strIntIp,intIp)==0 && wcscmp(cur->strExtIp,extIp)==0 && cur->intExtPort==extPort && cur->intIntPort==intPort && cur->state==state)
return cur;
cur=cur->next;
}
return NULL;
}
-void getDnsName(TCHAR *strIp,TCHAR *strHostName)
+void getDnsName(TCHAR *strIp, TCHAR *strHostName, size_t len)
{
- struct in_addr iaHost;
- struct hostent *h;
-
+ in_addr iaHost;
iaHost.s_addr = inet_addr(mir_t2a(strIp));
- if ((h = gethostbyaddr ((char *)&iaHost, sizeof(struct in_addr), AF_INET))== NULL)
- { // get the host info error
- _stprintf(strHostName,_T("%s"), strIp); //!!!!!!!!!!!
- return;
- }
- _stprintf(strHostName,_T("%s"),mir_a2t(h->h_name)); //!!!!!!!!!!!!!
- //_tcsncpy_s(strHostName,128, h->h_name,_tcslen(h->h_name));
-
+ hostent *h = gethostbyaddr((char *)&iaHost, sizeof(struct in_addr), AF_INET);
+ _tcsncpy_s(strHostName, len, (h == NULL) ? strIp : _A2T(h->h_name), _TRUNCATE);
}
int wildcmp(const TCHAR *wild, const TCHAR *string) {