From 9d32b9cd791fb5f51dad17567152c70a8511a500 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 25 Jul 2013 20:15:05 +0000 Subject: replace sprintf to mir_snprintf (part 6) git-svn-id: http://svn.miranda-ng.org/main/trunk@5485 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ConnectionNotify/src/ConnectionNotify.cpp | 39 +---------------------- plugins/ConnectionNotify/src/ConnectionNotify.h | 35 ++++++++++++++++++++ plugins/ConnectionNotify/src/debug.cpp | 11 +++---- plugins/ConnectionNotify/src/netstat.cpp | 20 ++---------- plugins/ConnectionNotify/src/pid2name.cpp | 12 ++----- 5 files changed, 45 insertions(+), 72 deletions(-) (limited to 'plugins/ConnectionNotify') diff --git a/plugins/ConnectionNotify/src/ConnectionNotify.cpp b/plugins/ConnectionNotify/src/ConnectionNotify.cpp index b1d8f294ac..8bc6f5f6d5 100644 --- a/plugins/ConnectionNotify/src/ConnectionNotify.cpp +++ b/plugins/ConnectionNotify/src/ConnectionNotify.cpp @@ -1,42 +1,4 @@ -#include -//#include -#include -#include -#include -#include "pid2name.h" - - -#ifdef _DEBUG -#include "debug.h" -#endif - -#include "resource.h" - - -#include - -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include -//#include - #include "ConnectionNotify.h" -#include "netstat.h" -#include "filter.h" -#include "version.h" - -#define MAX_SETTING_STR 512 -#define PLUGINNAME "ConnectionNotify" - -#define STATUS_COUNT 9 HINSTANCE hInst; @@ -77,6 +39,7 @@ struct CONNECTION *connCurrentEditModal=NULL; int currentStatus = ID_STATUS_OFFLINE,diffstat=0; BOOL bOptionsOpen=FALSE; TCHAR *tcpStates[]={_T("CLOSED"),_T("LISTEN"),_T("SYN_SENT"),_T("SYN_RCVD"),_T("ESTAB"),_T("FIN_WAIT1"),_T("FIN_WAIT2"),_T("CLOSE_WAIT"),_T("CLOSING"),_T("LAST_ACK"),_T("TIME_WAIT"),_T("DELETE_TCB")}; + PLUGININFOEX pluginInfo={ sizeof(PLUGININFOEX), PLUGINNAME, diff --git a/plugins/ConnectionNotify/src/ConnectionNotify.h b/plugins/ConnectionNotify/src/ConnectionNotify.h index d60e8d0cef..3bf10c9ba4 100644 --- a/plugins/ConnectionNotify/src/ConnectionNotify.h +++ b/plugins/ConnectionNotify/src/ConnectionNotify.h @@ -1,9 +1,44 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _DEBUG +#include "debug.h" +#endif +#include "resource.h" +#include "netstat.h" +#include "filter.h" +#include "version.h" +#include "pid2name.h" + +#define MAX_SETTING_STR 512 +#define PLUGINNAME "ConnectionNotify" +#define MAX_LENGTH 512 +#define STATUS_COUNT 9 #if !defined(MIID_CONNECTIONNOTIFY) #define MIID_CONNECTIONNOTIFY {0x4bb5b4aa, 0xc364, 0x4f23, { 0x97, 0x46, 0xd5, 0xb7, 0x8, 0xa2, 0x86, 0xa5 } } #endif // 4BB5B4AA-C364-4F23-9746-D5B708A286A5 +// Note: could also use malloc() and free() +#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) +#define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) void showMsg(TCHAR *pName,DWORD pid,TCHAR *intIp,TCHAR *extIp,int intPort,int extPort,int state); //int __declspec(dllexport) Load(PLUGINLINK *link); diff --git a/plugins/ConnectionNotify/src/debug.cpp b/plugins/ConnectionNotify/src/debug.cpp index d6bff90fe1..0400b3a673 100644 --- a/plugins/ConnectionNotify/src/debug.cpp +++ b/plugins/ConnectionNotify/src/debug.cpp @@ -1,7 +1,4 @@ -#include "debug.h" - -#define MAX_LENGTH 512 - +#include "ConnectionNotify.h" void _OutputDebugString(TCHAR* lpOutputString, ... ) { @@ -36,7 +33,7 @@ void _OutputDebugString(TCHAR* lpOutputString, ... ) case 's': { TCHAR* s = va_arg( argptr, TCHAR * ); - _stprintf(OutMsg,format,s); + mir_sntprintf(OutMsg, SIZEOF(OutMsg), format, s); _tcsncpy(format,OutMsg,_countof(OutMsg)); j = _tcslen(format); _tcscat(format,_T(" ")); @@ -46,7 +43,7 @@ void _OutputDebugString(TCHAR* lpOutputString, ... ) case 'c': { char c = (char) va_arg( argptr, int ); - _stprintf(OutMsg,format,c); + mir_sntprintf(OutMsg, SIZEOF(OutMsg), format, c); _tcsncpy(format,OutMsg,_countof(OutMsg)); j = _tcslen(format); _tcscat(format,_T(" ")); @@ -56,7 +53,7 @@ void _OutputDebugString(TCHAR* lpOutputString, ... ) case 'd': { int d = va_arg( argptr, int ); - _stprintf(OutMsg,format,d); + mir_sntprintf(OutMsg, SIZEOF(OutMsg), format, d); _tcsncpy(format,OutMsg,_countof(OutMsg)); j = _tcslen(format); _tcscat(format,_T(" ")); diff --git a/plugins/ConnectionNotify/src/netstat.cpp b/plugins/ConnectionNotify/src/netstat.cpp index 2dd190c823..36a8302571 100644 --- a/plugins/ConnectionNotify/src/netstat.cpp +++ b/plugins/ConnectionNotify/src/netstat.cpp @@ -1,18 +1,4 @@ -// GetTcpTable.cpp : Defines the entry point for the console application. -// - -// Link to Ws2_32.lib -//#include -#include -// Link to Iphlpapi.lib -#include -#include -#include -#include -#include "netstat.h" -// Note: could also use malloc() and free() -#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) -#define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) +#include "ConnectionNotify.h" struct CONNECTION* GetConnectionsTable() { @@ -176,10 +162,10 @@ void getDnsName(TCHAR *strIp,TCHAR *strHostName) 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); + _stprintf(strHostName,_T("%s"), strIp); //!!!!!!!!!!! return; } - _stprintf(strHostName,_T("%s"),mir_a2t(h->h_name)); + _stprintf(strHostName,_T("%s"),mir_a2t(h->h_name)); //!!!!!!!!!!!!! //_tcsncpy_s(strHostName,128, h->h_name,_tcslen(h->h_name)); } diff --git a/plugins/ConnectionNotify/src/pid2name.cpp b/plugins/ConnectionNotify/src/pid2name.cpp index 46c51202c7..e3365a574f 100644 --- a/plugins/ConnectionNotify/src/pid2name.cpp +++ b/plugins/ConnectionNotify/src/pid2name.cpp @@ -1,12 +1,4 @@ -#include -// one can also use Winternl.h if needed -//#include // for UNICODE_STRING and SYSTEM_INFORMATION_CLASS -#include -#include -//#include - -#include -#include "pid2name.h" +#include "ConnectionNotify.h" void pid2name(DWORD procid,TCHAR* buffer) { @@ -23,7 +15,7 @@ void pid2name(DWORD procid,TCHAR* buffer) { if(ProcessStruct.th32ProcessID==procid) { - _stprintf(buffer,_T("%s"),ProcessStruct.szExeFile); + _stprintf(buffer,_T("%s"),ProcessStruct.szExeFile); //!!!!!!!!!!!! break; } } -- cgit v1.2.3