From b61ba851da0157ace3bdfc1ebbf87156b0b76413 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 6 Jun 2012 08:58:27 +0000 Subject: protocols plugins moved to protocols git-svn-id: http://svn.miranda-ng.org/main/trunk@327 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/YAMN/filter/Base/AggressiveOptimize.h | 168 +++++++++++++++ protocols/YAMN/filter/Base/Base.dsp | 108 ++++++++++ protocols/YAMN/filter/Base/Base.mak | 229 ++++++++++++++++++++ protocols/YAMN/filter/Base/debug.cpp | 73 +++++++ protocols/YAMN/filter/Base/docs/base-readme.txt | 63 ++++++ protocols/YAMN/filter/Base/maindll.cpp | 238 +++++++++++++++++++++ protocols/YAMN/filter/Simple/AggressiveOptimize.h | 168 +++++++++++++++ .../YAMN/filter/Simple/docs/simple-readme.txt | 51 +++++ protocols/YAMN/filter/Simple/maindll.cpp | 132 ++++++++++++ protocols/YAMN/filter/Simple/simple.dsp | 105 +++++++++ protocols/YAMN/filter/Simple/simple.mak | 207 ++++++++++++++++++ protocols/YAMN/filter/readme.txt | 1 + 12 files changed, 1543 insertions(+) create mode 100644 protocols/YAMN/filter/Base/AggressiveOptimize.h create mode 100644 protocols/YAMN/filter/Base/Base.dsp create mode 100644 protocols/YAMN/filter/Base/Base.mak create mode 100644 protocols/YAMN/filter/Base/debug.cpp create mode 100644 protocols/YAMN/filter/Base/docs/base-readme.txt create mode 100644 protocols/YAMN/filter/Base/maindll.cpp create mode 100644 protocols/YAMN/filter/Simple/AggressiveOptimize.h create mode 100644 protocols/YAMN/filter/Simple/docs/simple-readme.txt create mode 100644 protocols/YAMN/filter/Simple/maindll.cpp create mode 100644 protocols/YAMN/filter/Simple/simple.dsp create mode 100644 protocols/YAMN/filter/Simple/simple.mak create mode 100644 protocols/YAMN/filter/readme.txt (limited to 'protocols/YAMN/filter') diff --git a/protocols/YAMN/filter/Base/AggressiveOptimize.h b/protocols/YAMN/filter/Base/AggressiveOptimize.h new file mode 100644 index 0000000000..1bf0e19c2c --- /dev/null +++ b/protocols/YAMN/filter/Base/AggressiveOptimize.h @@ -0,0 +1,168 @@ + +////////////////////////////// +// Version 1.40 +// October 22nd, 2002 - .NET (VC7, _MSC_VER=1300) support! +// Version 1.30 +// Nov 24th, 2000 +// Version 1.20 +// Jun 9th, 2000 +// Version 1.10 +// Jan 23rd, 2000 +// Version 1.00 +// May 20th, 1999 +// Todd C. Wilson, Fresh Ground Software +// (todd@nopcode.com) +// This header file will kick in settings for Visual C++ 5 and 6 that will (usually) +// result in smaller exe's. +// The "trick" is to tell the compiler to not pad out the function calls; this is done +// by not using the /O1 or /O2 option - if you do, you implicitly use /Gy, which pads +// out each and every function call. In one single 500k dll, I managed to cut out 120k +// by this alone! +// The other two "tricks" are telling the Linker to merge all data-type segments together +// in the exe file. The relocation, read-only (constants) data, and code section (.text) +// sections can almost always be merged. Each section merged can save 4k in exe space, +// since each section is padded out to 4k chunks. This is very noticeable with smaller +// exes, since you could have only 700 bytes of data, 300 bytes of code, 94 bytes of +// strings - padded out, this could be 12k of runtime, for 1094 bytes of stuff! For larger +// programs, this is less overall, but can save at least 4k. +// Note that if you're using MFC static or some other 3rd party libs, you may get poor +// results with merging the readonly (.rdata) section - the exe may grow larger. +// To use this feature, define _MERGE_DATA_ in your project or before this header is used. +// With Visual C++ 5, the program uses a file alignment of 512 bytes, which results +// in a small exe. Under VC6, the program instead uses 4k, which is the same as the +// section size. The reason (from what I understand) is that 4k is the chunk size of +// the virtual memory manager, and that WinAlign (an end-user tuning tool for Win98) +// will re-align the programs on this boundary. The problem with this is that all of +// Microsoft's system exes and dlls are *NOT* tuned like this, and using 4k causes serious +// exe bloat. This is very noticeable for smaller programs. +// The "trick" for this is to use the undocumented FILEALIGN linker parm to change the +// padding from 4k to 1/2k, which results in a much smaller exe - anywhere from 20%-75% +// depending on the size. Note that this is the same as using /OPT:NOWIN98, which *is* +// a previously documented switch, but was left out of the docs for some reason in VC6 and +// all of the current MSDN's - see KB:Q235956 for more information. +// Microsoft does say that using the 4k alignment will "speed up process loading", +// but I've been unable to notice a difference, even on my P180, with a very large (4meg) exe. +// Please note, however, that this will probably not change the size of the COMPRESSED +// file (either in a .zip file or in an install archive), since this 4k is all zeroes and +// gets compressed away. +// Also, the /ALIGN:4096 switch will "magically" do the same thing, even though this is the +// default setting for this switch. Apparently this sets the same values as the above two +// switches do. We do not use this in this header, since it smacks of a bug and not a feature. +// Thanks to Michael Geary for some additional tips! +// +// Notes about using this header in .NET +// First off, VC7 does not allow a lot of the linker command options in pragma's. There is no +// honest or good reason why Microsoft decided to make this change, it just doesn't. +// So that is why there are a lot of <1300 #if's in the header. +// If you want to take full advantage of the VC7 linker options, you will need to do it on a +// PER PROJECT BASIS; you can no longer use a global header file like this to make it better. +// Items I strongly suggest putting in all your VC7 project linker options command line settings: +// /ignore:4078 /RELEASE +// Compiler options: +// /GL (Whole Program Optimization) +// If you're making an .EXE and not a .DLL, consider adding in: +// /GA (Optimize for Windows Application) +// Some items to consider using in your VC7 projects (not VC6): +// Link-time Code Generation - whole code optimization. Put this in your exe/dll project link settings. +// /LTCG:NOSTATUS +// The classic no-padding and no-bloat compiler C/C++ switch: +// /opt:nowin98 +// +// (C++ command line options: /GL /opt:nowin98 and /GA for .exe files) +// (Link command line options: /ignore:4078 /RELEASE /LTCG:NOSTATUS) +// +// Now, notes on using these options in VC7 vs VC6. +// VC6 consistently, for me, produces smaller code from C++ the exact same sources, +// with or without this header. On average, VC6 produces 5% smaller binaries compared +// to VC7 compiling the exact same project, *without* this header. With this header, VC6 +// will make a 13k file, while VC7 will make a 64k one. VC7 is just bloaty, pure and +// simple - all that managed/unmanaged C++ runtimes, and the CLR stuff must be getting +// in the way of code generation. However, template support is better, so there. +// Both VC6 and VC7 show the same end kind of end result savings - larger binary output +// will shave about 2% off, where as smaller projects (support DLL's, cpl's, +// activex controls, ATL libs, etc) get the best result, since the padding is usually +// more than the actual usable code. But again, VC7 does not compile down as small as VC6. +// +// The argument can be made that doing this is a waste of time, since the "zero bytes" +// will be compressed out in a zip file or install archive. Not really - it doesn't matter +// if the data is a string of zeroes or ones or 85858585 - it will still take room (20 bytes +// in a zip file, 29 bytes if only *4* of them 4k bytes are not the same) and time to +// compress that data and decompress it. Also, 20k of zeros is NOT 20k on disk - it's the +// size of the cluster slop- for Fat32 systems, 20k can be 32k, NTFS could make it 24k if you're +// just 1 byte over (round up). Most end users do not have the dual P4 Xeon systems with +// two gigs of RDram and a Raid 0+1 of Western Digital 120meg Special Editions that all +// worthy developers have (all six of us), so they will need any space and LOADING TIME +// savings they will need; taking an extra 32k or more out of your end user's 64megs of +// ram on Windows 98 is Not a Good Thing. +// +// Now, as a ADDED BONUS at NO EXTRA COST TO YOU! Under VC6, using the /merge:.text=.data +// pragma will cause the output file to be un-disassembleable! (is that a word?) At least, +// with the normal tools - WinDisam, DumpBin, and the like will not work. Try it - use the +// header, compile release, and then use DUMPBIN /DISASM filename.exe - no code! +// Thanks to Gëzim Pani for discovering this gem - for a full writeup on +// this issue and the ramifactions of it, visit www.nopcode.com for the Aggressive Optimize +// article. + +#ifndef _AGGRESSIVEOPTIMIZE_H_ +#define _AGGRESSIVEOPTIMIZE_H_ + +#pragma warning(disable:4711) + +#ifdef NDEBUG +// /Og (global optimizations), /Os (favor small code), /Oy (no frame pointers) +#pragma optimize("gsy",on) + +#if (_MSC_VER<1300) + #pragma comment(linker,"/RELEASE") +#endif + +/* +// Note that merging the .rdata section will result in LARGER exe's if you using +// MFC (esp. static link). If this is desirable, define _MERGE_RDATA_ in your project. +#ifdef _MERGE_RDATA_ +#pragma comment(linker,"/merge:.rdata=.data") +#endif // _MERGE_RDATA_ + +#pragma comment(linker,"/merge:.text=.data") +#if (_MSC_VER<1300) + // In VC7, this causes problems with the relocation and data tables, so best to not merge them + #pragma comment(linker,"/merge:.reloc=.data") +#endif +*/ + +// Merging sections with different attributes causes a linker warning, so +// turn off the warning. From Michael Geary. Undocumented, as usual! +#if (_MSC_VER<1300) + // In VC7, you will need to put this in your project settings + #pragma comment(linker,"/ignore:4078") +#endif + +// With Visual C++ 5, you already get the 512-byte alignment, so you will only need +// it for VC6, and maybe later. +#if _MSC_VER >= 1000 + +// Option #1: use /filealign +// Totally undocumented! And if you set it lower than 512 bytes, the program crashes. +// Either leave at 0x200 or 0x1000 +//#pragma comment(linker,"/FILEALIGN:0x200") + +// Option #2: use /opt:nowin98 +// See KB:Q235956 or the READMEVC.htm in your VC directory for info on this one. +// This is our currently preferred option, since it is fully documented and unlikely +// to break in service packs and updates. +#if (_MSC_VER<1300) + // In VC7, you will need to put this in your project settings + #pragma comment(linker,"/opt:nowin98") +#else + +// Option #3: use /align:4096 +// A side effect of using the default align value is that it turns on the above switch. +// Does nothing under Vc7 that /opt:nowin98 doesn't already give you +// #pragma comment(linker,"/ALIGN:512") +#endif + +#endif // _MSC_VER >= 1000 + +#endif // NDEBUG + +#endif // _AGGRESSIVEOPTIMIZE_H_ diff --git a/protocols/YAMN/filter/Base/Base.dsp b/protocols/YAMN/filter/Base/Base.dsp new file mode 100644 index 0000000000..7231712a74 --- /dev/null +++ b/protocols/YAMN/filter/Base/Base.dsp @@ -0,0 +1,108 @@ +# Microsoft Developer Studio Project File - Name="Base" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=Base - Win32 Release +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "Base.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "Base.mak" CFG="Base - Win32 Release" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "Base - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Base - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Base - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 1 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /G4 /Zp4 /MD /W3 /GX /O1 /Ob0 /I "../../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /G4 /Zp4 /MD /W3 /GX /Zi /O1 /Ob0 /I "../../../../include" /I "../../../../include/msapi" /I "../../../../include_API" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD BASE RSC /l 0x417 /d "NDEBUG" +# ADD RSC /l 0x417 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /machine:I386 /out:"../../../../bin/release/plugins/YAMN-filter/Base.dll" /filealign:512 +# ADD LINK32 kernel32.lib user32.lib /nologo /dll /pdb:"../../../../bin/Release/plugins/YAMN/base.pdb" /debug /machine:I386 /out:"../../../../bin/Release/plugins/YAMN/base.dll" /filealign:512 + +!ELSEIF "$(CFG)" == "Base - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /G4 /Zp4 /MDd /W3 /Gm /Gi /GX /ZI /Od /I "../../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /GZ /c +# ADD CPP /nologo /G4 /Zp4 /MDd /W3 /Gm /Gi /GX /ZI /Od /I "../../../../include" /I "../../../../include/msapi" /I "../../../../include_API" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x417 /d "_DEBUG" +# ADD RSC /l 0x417 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /debug /machine:I386 /out:"../../../../bin/Debug/plugins/YAMN-filter/Base.dll" +# ADD LINK32 kernel32.lib user32.lib /nologo /dll /pdb:"../../../../bin/Debug/plugins/YAMN/base.pdb" /debug /machine:I386 /out:"../../../../bin/Debug/plugins/YAMN/base.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Base - Win32 Release" +# Name "Base - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\debug.cpp +# End Source File +# Begin Source File + +SOURCE=.\maindll.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/protocols/YAMN/filter/Base/Base.mak b/protocols/YAMN/filter/Base/Base.mak new file mode 100644 index 0000000000..75ec59db8a --- /dev/null +++ b/protocols/YAMN/filter/Base/Base.mak @@ -0,0 +1,229 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on Base.dsp +!IF "$(CFG)" == "" +CFG=Base - Win32 Release +!MESSAGE No configuration specified. Defaulting to Base - Win32 Release. +!ENDIF + +!IF "$(CFG)" != "Base - Win32 Release" && "$(CFG)" != "Base - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Base.mak" CFG="Base - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +!IF "$(CFG)" == "Base - Win32 Release" + +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "..\..\..\..\bin\release\plugins\YAMN-filter\base.dll" + + +CLEAN : + -@erase "$(INTDIR)\debug.obj" + -@erase "$(INTDIR)\maindll.obj" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(OUTDIR)\base.exp" + -@erase "..\..\..\..\bin\release\plugins\YAMN-filter\base.dll" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /G4 /Zp4 /MD /W3 /GX /O1 /Ob0 /I "../../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\Base.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ= +RSC=rc.exe +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\Base.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib user32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\base.pdb" /machine:I386 /out:"../../../../bin/release/plugins/YAMN-filter/base.dll" /implib:"$(OUTDIR)\base.lib" /filealign:512 +LINK32_OBJS= \ + "$(INTDIR)\debug.obj" \ + "$(INTDIR)\maindll.obj" + +"..\..\..\..\bin\release\plugins\YAMN-filter\base.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "Base - Win32 Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +ALL : "..\..\..\..\bin\Debug\plugins\YAMN-filter\Base.dll" "$(OUTDIR)\Base.bsc" + + +CLEAN : + -@erase "$(INTDIR)\debug.obj" + -@erase "$(INTDIR)\debug.sbr" + -@erase "$(INTDIR)\maindll.obj" + -@erase "$(INTDIR)\maindll.sbr" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(INTDIR)\vc60.pdb" + -@erase "$(OUTDIR)\Base.bsc" + -@erase "$(OUTDIR)\Base.exp" + -@erase "$(OUTDIR)\Base.pdb" + -@erase "..\..\..\..\bin\Debug\plugins\YAMN-filter\Base.dll" + -@erase "..\..\..\..\bin\Debug\plugins\YAMN-filter\Base.ilk" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /G4 /Zp4 /MDd /W3 /Gm /Gi /GX /ZI /Od /I "../../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\Base.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ= +RSC=rc.exe +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\Base.bsc" +BSC32_SBRS= \ + "$(INTDIR)\debug.sbr" \ + "$(INTDIR)\maindll.sbr" + +"$(OUTDIR)\Base.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib user32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\Base.pdb" /debug /machine:I386 /out:"../../../../bin/Debug/plugins/YAMN-filter/Base.dll" /implib:"$(OUTDIR)\Base.lib" +LINK32_OBJS= \ + "$(INTDIR)\debug.obj" \ + "$(INTDIR)\maindll.obj" + +"..\..\..\..\bin\Debug\plugins\YAMN-filter\Base.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ENDIF + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("Base.dep") +!INCLUDE "Base.dep" +!ELSE +!MESSAGE Warning: cannot find "Base.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "Base - Win32 Release" || "$(CFG)" == "Base - Win32 Debug" +SOURCE=.\debug.cpp + +!IF "$(CFG)" == "Base - Win32 Release" + + +"$(INTDIR)\debug.obj" : $(SOURCE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "Base - Win32 Debug" + + +"$(INTDIR)\debug.obj" "$(INTDIR)\debug.sbr" : $(SOURCE) "$(INTDIR)" + + +!ENDIF + +SOURCE=.\maindll.cpp + +!IF "$(CFG)" == "Base - Win32 Release" + + +"$(INTDIR)\maindll.obj" : $(SOURCE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "Base - Win32 Debug" + + +"$(INTDIR)\maindll.obj" "$(INTDIR)\maindll.sbr" : $(SOURCE) "$(INTDIR)" + + +!ENDIF + + +!ENDIF + diff --git a/protocols/YAMN/filter/Base/debug.cpp b/protocols/YAMN/filter/Base/debug.cpp new file mode 100644 index 0000000000..654ece7b57 --- /dev/null +++ b/protocols/YAMN/filter/Base/debug.cpp @@ -0,0 +1,73 @@ +/* + * Copied from YAMN plugin + * + * (c) majvan 2002-2004 + */ +#ifdef DEBUG_FILTER + +#include +#include +#include + + +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- + +TCHAR DebugUserDirectory[MAX_PATH]="."; +LPCRITICAL_SECTION FileAccessCS; + +void DebugLog(HANDLE File,const char *fmt,...); + +#ifdef DEBUG_FILTER +TCHAR DebugFilterFileName2[]=_T("%s\\yamn-debug.basefilter.log"); +HANDLE FilterFile=INVALID_HANDLE_VALUE; +#endif + +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- + +void InitDebug() +{ + TCHAR DebugFileName[MAX_PATH]; + + if(FileAccessCS==NULL) + { + FileAccessCS=new CRITICAL_SECTION; + InitializeCriticalSection(FileAccessCS); + } + + _stprintf(DebugFileName,DebugFilterFileName2,DebugUserDirectory); + + FilterFile=CreateFile(DebugFileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,0,NULL); + + DebugLog(FilterFile,"Base filter plugin for YAMN - debug file\n"); +} + +void UnInitDebug() +{ + DebugLog(FilterFile,"File is being closed normally."); + CloseHandle(FilterFile); +} + +void DebugLog(HANDLE File,const char *fmt,...) +{ + char *str; + char tids[32]; + va_list vararg; + int strsize; + DWORD Written; + + va_start(vararg,fmt); + str=(char *)malloc(strsize=65536); + _stprintf(tids,_T("[%x]"),GetCurrentThreadId()); + while(_vsnprintf(str,strsize,fmt,vararg)==-1) + str=(char *)realloc(str,strsize+=65536); + va_end(vararg); + EnterCriticalSection(FileAccessCS); + WriteFile(File,tids,(DWORD)strlen(tids),&Written,NULL); + WriteFile(File,str,(DWORD)strlen(str),&Written,NULL); + LeaveCriticalSection(FileAccessCS); + free(str); +} + +#endif //ifdef DEBUG \ No newline at end of file diff --git a/protocols/YAMN/filter/Base/docs/base-readme.txt b/protocols/YAMN/filter/Base/docs/base-readme.txt new file mode 100644 index 0000000000..2e79bbbdd8 --- /dev/null +++ b/protocols/YAMN/filter/Base/docs/base-readme.txt @@ -0,0 +1,63 @@ +======================== += Base Filter for YAMN = +======================== + +Q: What??? +A: YAMN filter to classify incoming email. + +Q: How? +A: Finding occurency of defiend MIME header item and its value from blacklist file. + +Q: Blacklist file? +A: Yes. It is created by yourself and located in Miranda directory with name 'basefilterdeny.txt' + +Q: Created by myself? +A: Just create the file and write there your header MIME items and its values. + +Q: What do you mean "header MIME items" and "its values"? +A: Every mail has header consisting of MIME items like "Subject" or "Return-Path". + +Q: So I need to understand how the header looks like... +A: Yes, if you want to use this filter, you should. Header MIME is defined in RFC822 standard. + +Q: Ok, I've just studied it. So how to set filter (write some rules to the blacklist file)? +A: Each line is one rule: write the exact item, press , press the substring of value needed to be found, press , define spamlevel and then press . + +Q: Spamlevel? +A: Yes. + 0=do not notify + 1=notify, display with another color in mailbrowser + 2=do not notify, display with another color in mailbrowser + 3=delete, display in mailbrowser about deleted mail + 4=delete, do not display (mail's quick death, hehe) + +Q: So the rule has 3 parameters, that's it? +A: Yes. This is the example: +<------ start of file ------> +From CrazyMail 1 +X-Importance low 0 +Subject LinuxMailList 0 +Return-Path cheapsoftware@junkmails.net 2 +X-TextClassification spam 3 +<------ end of file -------> + +Q: Wait while. Ok, but it does not work. +A: Check if you have this plugin listed in Miranda/Options/Plugins/YAMN item + +Q: No, it is not listed in YAMN plugins. +A: Then check if the dll residents in Plugins/YAMN direcotry. + +Q: This directory does not exists. +A: Create it and put the dll there. Restart Miranda. + +Q: Hmmm, ok. But it is not still listed. +A: Your version of YAMN and filter does not match. + +Q: And? +A: Try to look to http://www.majvan.host.sk/Projekty/YAMN for updates. + +Q: Now, it is listed, but does not work anyway. +A: Try to download debug version from YAMN homepage, if you are not using it (the name of filter must contain the word "debug") + +Q: What does debug version do? +A: It creates debug log file in Miranda home directory where you can browse how does filter mark mails. \ No newline at end of file diff --git a/protocols/YAMN/filter/Base/maindll.cpp b/protocols/YAMN/filter/Base/maindll.cpp new file mode 100644 index 0000000000..d6a645bd14 --- /dev/null +++ b/protocols/YAMN/filter/Base/maindll.cpp @@ -0,0 +1,238 @@ +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../m_filterplugin.h" +#if !defined(_WIN64) + #include "aggressiveoptimize.h" +#endif + +typedef INT_PTR(* MIRANDASERVICE)(WPARAM,LPARAM); + +DWORD WINAPI FilterMail(HACCOUNT Account,DWORD AccountVer,HYAMNMAIL Mail,DWORD MailVer);//Function marks mail as spam when it is spam... +DWORD WINAPI UnLoadFilter(LPVOID); + +int LoadRules(); //Load rules from file +int findsubstr(char *original,char *pattern); //finds if original contains substring + +YAMN_FILTERIMPORTFCN FilterFunctions= //we set for YAMN which is our filter function +{ + FilterMail, + UnLoadFilter, +}; + +struct cFilterTable +{ + char account[256]; + char name[256]; + char value[256]; + unsigned char sl; +} *ft=NULL; +int fts=0; + +YAMN_FILTERREGISTRATION FilterRegistration= //classical YAMN registration +{ +#ifdef DEBUG_FILTER + "Base filter plugin for YAMN (debug)", +#else + "Base filter plugin for YAMN", +#endif + __DATE__, + "© majvan", + "Classifies mails using the rules stored in file", + "om3tn@psg.sk", + "http://www.majvan.host.sk/Projekty/YAMN?fm=soft", +}; + +char *FilterPath=NULL; + +struct YAMNExportedFcn +{ + YAMN_SETFILTERPLUGINFCNIMPORTFCN SetFilterPluginFcnImportFcn; + MIRANDASERVICE RegisterFilterPlugin; +} YAMNFcn,*pYAMNFcn; //exported functions from YAMN we will use + +HYAMNFILTERPLUGIN POPFilePlugin; //handle of this plugin for YAMN +HINSTANCE hInst; //handle of this DLL for Windows + +#ifdef DEBUG_FILTER +extern void InitDebug(); +extern void UnInitDebug(); +extern void DebugLog(HANDLE File,const char *fmt,...); +extern HANDLE FilterFile; +#endif + +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved) +{ + hInst=hinstDLL; + return true; +} + +extern "C" int __declspec(dllexport) LoadFilter(MIRANDASERVICE GetYAMNFcnPtr) +{ + FilterPath=new char[MAX_PATH]; + char *delim; + pYAMNFcn=&YAMNFcn; + + GetModuleFileName(GetModuleHandle(NULL),FilterPath,MAX_PATH); + if(NULL!=(delim=strrchr(FilterPath,'\\'))) + *delim=0; + lstrcat(FilterPath,"\\basefilterdeny.txt"); +#ifdef DEBUG_FILTER + InitDebug(); +#endif + + if (!LoadRules()) + return 0; + + pYAMNFcn->RegisterFilterPlugin=(MIRANDASERVICE)GetYAMNFcnPtr((WPARAM)MS_YAMN_REGISTERFILTERPLUGIN,(LPARAM)0); + pYAMNFcn->SetFilterPluginFcnImportFcn=(YAMN_SETFILTERPLUGINFCNIMPORTFCN)GetYAMNFcnPtr((WPARAM)YAMN_SETFILTERPLUGINFCNIMPORTID,(LPARAM)0); +//Register our filter plugin to YAMN + if(NULL==(POPFilePlugin=(HYAMNFILTERPLUGIN)pYAMNFcn->RegisterFilterPlugin((WPARAM)&FilterRegistration,(LPARAM)YAMN_FILTERREGISTRATIONVERSION))) + return 0; +//And add our imported functions for YAMN + if (!pYAMNFcn->SetFilterPluginFcnImportFcn(POPFilePlugin,0xb0000000,&FilterFunctions,YAMN_FILTERIMPORTFCNVERSION)) + return 0; + return 1; //Load luccess +} + +DWORD WINAPI UnLoadFilter(LPVOID) +{ +#ifdef DEBUG_FILTER + UnInitDebug(); +#endif + if(FilterPath!=NULL) + delete[] FilterPath; + FilterPath=NULL; + + return 0; +} + +extern "C" int __declspec(dllexport) UninstallFilter() +{ + if(FilterPath==NULL) + MessageBox(NULL,"Cannot delete blacklist file when Base Filter is not loaded. Please do it manually.","Base Filter uninstalling",MB_OK|MB_ICONWARNING); + else + DeleteFile(FilterPath); + return 0; +} + + +//And this is main filter function. +DWORD WINAPI FilterMail(HACCOUNT Account,DWORD AccountVer,HYAMNMAIL Mail,DWORD MailVer) +{ + struct CMimeItem *Browser; + + if(MailVer!=YAMN_MAILVERSION) //we test if we work with the right YAMNMAIL + return 0; + if(Mail->MailData==NULL) //MailData should be available + return 0; + +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\n"); +#endif + if (!(Mail->Flags & YAMN_MSG_VIRTUAL)) + for(Browser=Mail->MailData->TranslatedHeader;Browser!=NULL;Browser=Browser->Next) //we browse all header stored in Mail->TranslatedHeader + { +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\n",Browser->name,Browser->value); +#endif + for(int i=0;iname,ft[i].name)) + { +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\t\t\n",Browser->name); +#endif + if(findsubstr(Browser->value,ft[i].value)) //and if we find + { + if ((ft[i].sl==0) && ((Mail->Flags & YAMN_MSG_SPAMMASK)==0)) + { + Mail->Flags&=~(YAMN_MSG_POPUP | YAMN_MSG_SYSTRAY | YAMN_MSG_BROWSER | YAMN_MSG_SOUND | YAMN_MSG_APP | YAMN_MSG_NEVENT); +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\t\tSetting individual flags not to notify mail, but does not consider as spam."); +#endif + } + else if ((Mail->Flags & YAMN_MSG_SPAMMASK) < ft[i].sl) //if some filter plugin set higher level of spam, we do nothing + { + Mail->Flags=(Mail->Flags & ~YAMN_MSG_SPAMMASK)+ft[i].sl; //else we set spam level 2 (clearing spam bits and then settting them to level 2 +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\t\tMail marked to be spam #%d\n",Mail->Flags & YAMN_MSG_SPAMMASK); +#endif + } + } +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\t\t\n"); +#endif + } +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\n"); +#endif + } +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\n\n"); +#endif + return 1; +} + +int LoadRules() +{ + char *account=NULL; + char name[256]; + char value[256]; + char BadCompiler[512+5]; + unsigned char sl; + FILE *fp; + +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\n",FilterPath); +#endif + + fp=fopen(FilterPath,"rt"); + if(fp==NULL) + return 0; + + while(!feof(fp)) + { + if(fscanf(fp,"%255s",name) && !feof(fp) && (name[0]!=0)) + { + if(fscanf(fp,"%255s",value) && !feof(fp) && (value[0]!=0)) + { + if(fscanf(fp,"%d",&sl)) + { + fts++; + ft=(struct cFilterTable *)realloc((void *)ft,sizeof(cFilterTable)*fts); + lstrcpy(ft[fts-1].name,name); + lstrcpy(ft[fts-1].value,value); + ft[fts-1].sl=sl; + + sprintf(BadCompiler,"%s %s %d",name,value,sl); +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\t%s%s%d\n",name,value,sl); +#endif + } + } + } + } + + fclose(fp); +#ifdef DEBUG_FILTER + DebugLog(FilterFile,"\n"); +#endif + return 1; +} + +int findsubstr(char *original,char *pattern) +{ + int ol=lstrlen(original); + int pl=lstrlen(pattern); + + for(int i=0;(i+pl)<=ol;i++) + if (!_strnicmp(original+i,pattern,pl)) + return 1; + return 0; +} \ No newline at end of file diff --git a/protocols/YAMN/filter/Simple/AggressiveOptimize.h b/protocols/YAMN/filter/Simple/AggressiveOptimize.h new file mode 100644 index 0000000000..1bf0e19c2c --- /dev/null +++ b/protocols/YAMN/filter/Simple/AggressiveOptimize.h @@ -0,0 +1,168 @@ + +////////////////////////////// +// Version 1.40 +// October 22nd, 2002 - .NET (VC7, _MSC_VER=1300) support! +// Version 1.30 +// Nov 24th, 2000 +// Version 1.20 +// Jun 9th, 2000 +// Version 1.10 +// Jan 23rd, 2000 +// Version 1.00 +// May 20th, 1999 +// Todd C. Wilson, Fresh Ground Software +// (todd@nopcode.com) +// This header file will kick in settings for Visual C++ 5 and 6 that will (usually) +// result in smaller exe's. +// The "trick" is to tell the compiler to not pad out the function calls; this is done +// by not using the /O1 or /O2 option - if you do, you implicitly use /Gy, which pads +// out each and every function call. In one single 500k dll, I managed to cut out 120k +// by this alone! +// The other two "tricks" are telling the Linker to merge all data-type segments together +// in the exe file. The relocation, read-only (constants) data, and code section (.text) +// sections can almost always be merged. Each section merged can save 4k in exe space, +// since each section is padded out to 4k chunks. This is very noticeable with smaller +// exes, since you could have only 700 bytes of data, 300 bytes of code, 94 bytes of +// strings - padded out, this could be 12k of runtime, for 1094 bytes of stuff! For larger +// programs, this is less overall, but can save at least 4k. +// Note that if you're using MFC static or some other 3rd party libs, you may get poor +// results with merging the readonly (.rdata) section - the exe may grow larger. +// To use this feature, define _MERGE_DATA_ in your project or before this header is used. +// With Visual C++ 5, the program uses a file alignment of 512 bytes, which results +// in a small exe. Under VC6, the program instead uses 4k, which is the same as the +// section size. The reason (from what I understand) is that 4k is the chunk size of +// the virtual memory manager, and that WinAlign (an end-user tuning tool for Win98) +// will re-align the programs on this boundary. The problem with this is that all of +// Microsoft's system exes and dlls are *NOT* tuned like this, and using 4k causes serious +// exe bloat. This is very noticeable for smaller programs. +// The "trick" for this is to use the undocumented FILEALIGN linker parm to change the +// padding from 4k to 1/2k, which results in a much smaller exe - anywhere from 20%-75% +// depending on the size. Note that this is the same as using /OPT:NOWIN98, which *is* +// a previously documented switch, but was left out of the docs for some reason in VC6 and +// all of the current MSDN's - see KB:Q235956 for more information. +// Microsoft does say that using the 4k alignment will "speed up process loading", +// but I've been unable to notice a difference, even on my P180, with a very large (4meg) exe. +// Please note, however, that this will probably not change the size of the COMPRESSED +// file (either in a .zip file or in an install archive), since this 4k is all zeroes and +// gets compressed away. +// Also, the /ALIGN:4096 switch will "magically" do the same thing, even though this is the +// default setting for this switch. Apparently this sets the same values as the above two +// switches do. We do not use this in this header, since it smacks of a bug and not a feature. +// Thanks to Michael Geary for some additional tips! +// +// Notes about using this header in .NET +// First off, VC7 does not allow a lot of the linker command options in pragma's. There is no +// honest or good reason why Microsoft decided to make this change, it just doesn't. +// So that is why there are a lot of <1300 #if's in the header. +// If you want to take full advantage of the VC7 linker options, you will need to do it on a +// PER PROJECT BASIS; you can no longer use a global header file like this to make it better. +// Items I strongly suggest putting in all your VC7 project linker options command line settings: +// /ignore:4078 /RELEASE +// Compiler options: +// /GL (Whole Program Optimization) +// If you're making an .EXE and not a .DLL, consider adding in: +// /GA (Optimize for Windows Application) +// Some items to consider using in your VC7 projects (not VC6): +// Link-time Code Generation - whole code optimization. Put this in your exe/dll project link settings. +// /LTCG:NOSTATUS +// The classic no-padding and no-bloat compiler C/C++ switch: +// /opt:nowin98 +// +// (C++ command line options: /GL /opt:nowin98 and /GA for .exe files) +// (Link command line options: /ignore:4078 /RELEASE /LTCG:NOSTATUS) +// +// Now, notes on using these options in VC7 vs VC6. +// VC6 consistently, for me, produces smaller code from C++ the exact same sources, +// with or without this header. On average, VC6 produces 5% smaller binaries compared +// to VC7 compiling the exact same project, *without* this header. With this header, VC6 +// will make a 13k file, while VC7 will make a 64k one. VC7 is just bloaty, pure and +// simple - all that managed/unmanaged C++ runtimes, and the CLR stuff must be getting +// in the way of code generation. However, template support is better, so there. +// Both VC6 and VC7 show the same end kind of end result savings - larger binary output +// will shave about 2% off, where as smaller projects (support DLL's, cpl's, +// activex controls, ATL libs, etc) get the best result, since the padding is usually +// more than the actual usable code. But again, VC7 does not compile down as small as VC6. +// +// The argument can be made that doing this is a waste of time, since the "zero bytes" +// will be compressed out in a zip file or install archive. Not really - it doesn't matter +// if the data is a string of zeroes or ones or 85858585 - it will still take room (20 bytes +// in a zip file, 29 bytes if only *4* of them 4k bytes are not the same) and time to +// compress that data and decompress it. Also, 20k of zeros is NOT 20k on disk - it's the +// size of the cluster slop- for Fat32 systems, 20k can be 32k, NTFS could make it 24k if you're +// just 1 byte over (round up). Most end users do not have the dual P4 Xeon systems with +// two gigs of RDram and a Raid 0+1 of Western Digital 120meg Special Editions that all +// worthy developers have (all six of us), so they will need any space and LOADING TIME +// savings they will need; taking an extra 32k or more out of your end user's 64megs of +// ram on Windows 98 is Not a Good Thing. +// +// Now, as a ADDED BONUS at NO EXTRA COST TO YOU! Under VC6, using the /merge:.text=.data +// pragma will cause the output file to be un-disassembleable! (is that a word?) At least, +// with the normal tools - WinDisam, DumpBin, and the like will not work. Try it - use the +// header, compile release, and then use DUMPBIN /DISASM filename.exe - no code! +// Thanks to Gëzim Pani for discovering this gem - for a full writeup on +// this issue and the ramifactions of it, visit www.nopcode.com for the Aggressive Optimize +// article. + +#ifndef _AGGRESSIVEOPTIMIZE_H_ +#define _AGGRESSIVEOPTIMIZE_H_ + +#pragma warning(disable:4711) + +#ifdef NDEBUG +// /Og (global optimizations), /Os (favor small code), /Oy (no frame pointers) +#pragma optimize("gsy",on) + +#if (_MSC_VER<1300) + #pragma comment(linker,"/RELEASE") +#endif + +/* +// Note that merging the .rdata section will result in LARGER exe's if you using +// MFC (esp. static link). If this is desirable, define _MERGE_RDATA_ in your project. +#ifdef _MERGE_RDATA_ +#pragma comment(linker,"/merge:.rdata=.data") +#endif // _MERGE_RDATA_ + +#pragma comment(linker,"/merge:.text=.data") +#if (_MSC_VER<1300) + // In VC7, this causes problems with the relocation and data tables, so best to not merge them + #pragma comment(linker,"/merge:.reloc=.data") +#endif +*/ + +// Merging sections with different attributes causes a linker warning, so +// turn off the warning. From Michael Geary. Undocumented, as usual! +#if (_MSC_VER<1300) + // In VC7, you will need to put this in your project settings + #pragma comment(linker,"/ignore:4078") +#endif + +// With Visual C++ 5, you already get the 512-byte alignment, so you will only need +// it for VC6, and maybe later. +#if _MSC_VER >= 1000 + +// Option #1: use /filealign +// Totally undocumented! And if you set it lower than 512 bytes, the program crashes. +// Either leave at 0x200 or 0x1000 +//#pragma comment(linker,"/FILEALIGN:0x200") + +// Option #2: use /opt:nowin98 +// See KB:Q235956 or the READMEVC.htm in your VC directory for info on this one. +// This is our currently preferred option, since it is fully documented and unlikely +// to break in service packs and updates. +#if (_MSC_VER<1300) + // In VC7, you will need to put this in your project settings + #pragma comment(linker,"/opt:nowin98") +#else + +// Option #3: use /align:4096 +// A side effect of using the default align value is that it turns on the above switch. +// Does nothing under Vc7 that /opt:nowin98 doesn't already give you +// #pragma comment(linker,"/ALIGN:512") +#endif + +#endif // _MSC_VER >= 1000 + +#endif // NDEBUG + +#endif // _AGGRESSIVEOPTIMIZE_H_ diff --git a/protocols/YAMN/filter/Simple/docs/simple-readme.txt b/protocols/YAMN/filter/Simple/docs/simple-readme.txt new file mode 100644 index 0000000000..34c0842c87 --- /dev/null +++ b/protocols/YAMN/filter/Simple/docs/simple-readme.txt @@ -0,0 +1,51 @@ +========================== += Simple Filter for YAMN = +========================== + +Q: What??? +A: YAMN filter to classify incoming email. + +Q: How? +A: Regarding what the email is from and finding it in the blacklist email file. + +Q: Blacklist email file? +A: Yes. It is created by yourself and located in Miranda directory with name 'simplefilterdeny.txt' + +Q: Created by myself? +A: Just create the file and write there your blacklist mails in every line. + +Q: That's all? +A: Yes and no. You can specify spamlevel for each mail. + +Q: Spamlevel? +A: Yes. + 1=notify, display with another color in mailbrowser + 2=do not notify, display with another color in mailbrowser + 3=delete, display in mailbrowser about deleted mail + 4=delete, do not display (mail's quick death, hehe) + +Q: How to specify it? +A: After email press and write number 1-4. Note this is optional. If not defined, level 2 is default. + +Q: Ok, that's easy. +A: Yes, this is the example: +<------ start of file ------> +nigeria@spamserver.com 2 +cheapsoftware@junkmails.net 3 +learnenglish@commercial.org +<------ end of file -------> + +Q: Wait while. Ok, but it does not work. +A: Check if you have this plugin listed in Miranda/Options/Plugins/YAMN item as YAMN plugin. + +Q: No, it is not listed in YAMN plugins. +A: Then check if the dll residents in Plugins/YAMN direcotry. + +Q: This directory does not exists. +A: Create it and put the dll there. Restart Miranda. + +Q: Hmmm, ok. But it is not still listed. +A: Your version of YAMN and filter does not match. + +Q: And? +A: Try to look to http://www.majvan.host.sk/Projekty/YAMN for updates. \ No newline at end of file diff --git a/protocols/YAMN/filter/Simple/maindll.cpp b/protocols/YAMN/filter/Simple/maindll.cpp new file mode 100644 index 0000000000..62aa87b28d --- /dev/null +++ b/protocols/YAMN/filter/Simple/maindll.cpp @@ -0,0 +1,132 @@ +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../m_filterplugin.h" +#if !defined(_WIN64) + #include "aggressiveoptimize.h" +#endif + +typedef INT_PTR(* MIRANDASERVICE)(WPARAM,LPARAM); + +DWORD WINAPI FilterMail(HACCOUNT Account,DWORD AccountVer,HYAMNMAIL Mail,DWORD MailVer);//Function marks mail as spam when it is spam... +DWORD WINAPI UnLoadFilter(LPVOID); + +YAMN_FILTERIMPORTFCN FilterFunctions= //we set for YAMN which is our filter function +{ + FilterMail, + UnLoadFilter, //No unloading +}; + +YAMN_FILTERREGISTRATION FilterRegistration= //classical YAMN registration +{ + "Simple filter plugin for YAMN", + __DATE__, + "© porter+ majvan", + "Classifies mails using the blacklist emails stored in file", + "porterbox@hotmail.com", + "http://www.majvan.host.sk/Projekty/YAMN?fm=soft", +}; + +char *FilterPath=NULL; + +struct YAMNExportedFcn +{ + YAMN_SETFILTERPLUGINFCNIMPORTFCN SetFilterPluginFcnImportFcn; + MIRANDASERVICE RegisterFilterPlugin; +} YAMNFcn,*pYAMNFcn; //exported functions from YAMN we will use + +HYAMNFILTERPLUGIN POPFilePlugin; //handle of this plugin for YAMN +HINSTANCE hInst; //handle of this DLL for Windows + +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved) +{ + hInst=hinstDLL; + return true; +} + +extern "C" int __declspec(dllexport) LoadFilter(MIRANDASERVICE GetYAMNFcnPtr) +{ + FilterPath=new char[MAX_PATH]; + char *delim; + pYAMNFcn=&YAMNFcn; + + GetModuleFileName(GetModuleHandle(NULL),FilterPath,MAX_PATH); + if(NULL!=(delim=strrchr(FilterPath,'\\'))) + *delim=0; + lstrcat(FilterPath,"\\simplefilterdeny.txt"); + + pYAMNFcn->RegisterFilterPlugin=(MIRANDASERVICE)GetYAMNFcnPtr((WPARAM)MS_YAMN_REGISTERFILTERPLUGIN,(LPARAM)0); + pYAMNFcn->SetFilterPluginFcnImportFcn=(YAMN_SETFILTERPLUGINFCNIMPORTFCN)GetYAMNFcnPtr((WPARAM)YAMN_SETFILTERPLUGINFCNIMPORTID,(LPARAM)0); +//Register our filter plugin to YAMN + if(NULL==(POPFilePlugin=(HYAMNFILTERPLUGIN)pYAMNFcn->RegisterFilterPlugin((WPARAM)&FilterRegistration,(LPARAM)YAMN_FILTERREGISTRATIONVERSION))) + return 0; +//And add our imported functions for YAMN + if (!pYAMNFcn->SetFilterPluginFcnImportFcn(POPFilePlugin,0xb0000000,&FilterFunctions,YAMN_FILTERIMPORTFCNVERSION)) + return 0; + return 1; //Load luccess +} + +DWORD WINAPI UnLoadFilter(LPVOID) +{ + if(FilterPath!=NULL) + delete[] FilterPath; + FilterPath=NULL; + + return 0; +} + +extern "C" int __declspec(dllexport) UninstallFilter() +{ + if(FilterPath==NULL) + MessageBox(NULL,"Cannot delete blacklist file when Simple Filter is not loaded. Please do it manually.","Simple Filter uninstalling",MB_OK|MB_ICONWARNING); + else + DeleteFile(FilterPath); + return 0; +} + + +//And this is main filter function. +DWORD WINAPI FilterMail(HACCOUNT Account,DWORD AccountVer,HYAMNMAIL Mail,DWORD MailVer) +{ + FILE *fp; + char EmailSpam[256]; + unsigned char spamLevel; + struct CMimeItem *Browser; + + if(MailVer!=YAMN_MAILVERSION) //we test if we work with the right YAMNMAIL + return 0; + if(Mail->MailData==NULL) //MailData should be available + return 0; + fp=fopen(FilterPath,"rt"); + if(fp != NULL) { + if (!(Mail->Flags & YAMN_MSG_VIRTUAL)) + for(Browser=Mail->MailData->TranslatedHeader;Browser!=NULL;Browser=Browser->Next) { //we browse all header stored in Mail->TranslatedHeader + if ((!lstrcmp(Browser->name,"Return-Path")) || (!lstrcmp(Browser->name,"From"))) { //and if we find + fseek(fp, 0L, SEEK_SET); + while(!feof(fp)) { + if(fscanf(fp, "%255s", EmailSpam) != 0) { + if (!feof(fp)) + if(fscanf(fp, "%d", &spamLevel)==0) + spamLevel=2; + if(spamLevel>4) + spamLevel=2; + if(strstr(Browser->value,EmailSpam)!=NULL) { + if ((Mail->Flags & (YAMN_MSG_SPAMMASK==0)) && (spamLevel==0)) + Mail->Flags&=~(YAMN_MSG_SOUND | YAMN_MSG_APP | YAMN_MSG_POPUP | YAMN_MSG_SYSTRAY | YAMN_MSG_BROWSER); + else if ((Mail->Flags & YAMN_MSG_SPAMMASK) < spamLevel) //if some filter plugin set higher level of spam, we do nothing + Mail->Flags=(Mail->Flags & ~YAMN_MSG_SPAMMASK)+spamLevel; //else we set spam level 2 (clearing spam bits and then settting them to level 2 + } + } + } + } + } + fclose(fp); + } + return 1; +} diff --git a/protocols/YAMN/filter/Simple/simple.dsp b/protocols/YAMN/filter/Simple/simple.dsp new file mode 100644 index 0000000000..dc6d52e6c1 --- /dev/null +++ b/protocols/YAMN/filter/Simple/simple.dsp @@ -0,0 +1,105 @@ +# Microsoft Developer Studio Project File - Name="simple" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=simple - Win32 Release +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "simple.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "simple.mak" CFG="simple - Win32 Release" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "simple - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "simple - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "simple - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 1 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /G4 /Zp4 /MD /W3 /GX /O1 /Ob0 /I "../../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /G4 /Zp4 /MD /W3 /GX /Zi /O1 /Ob0 /I "../../../../include" /I "../../../../include/msapi" /I "../../../../include_API" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD BASE RSC /l 0x417 /d "NDEBUG" +# ADD RSC /l 0x417 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /machine:I386 /out:"../../../../bin/release/plugins/YAMN-filter/simple.dll" /filealign:512 +# ADD LINK32 kernel32.lib user32.lib /nologo /dll /pdb:"../../../../bin/Release/plugins/YAMN/simple.pdb" /debug /machine:I386 /out:"../../../../bin/Release/plugins/YAMN/simple.dll" /filealign:512 + +!ELSEIF "$(CFG)" == "simple - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 1 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /G4 /Zp4 /MDd /W3 /Gm /Gi /GX /ZI /Od /I "../../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /GZ /c +# ADD CPP /nologo /G4 /Zp4 /MDd /W3 /Gm /Gi /GX /ZI /Od /I "../../../../include" /I "../../../../include/msapi" /I "../../../../include_API" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x417 /d "_DEBUG" +# ADD RSC /l 0x417 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /debug /machine:I386 /out:"../../../../bin/Debug/plugins/YAMN-filter/simple.dll" +# ADD LINK32 kernel32.lib user32.lib /nologo /dll /pdb:"../../../../bin/Debug/plugins/YAMN/simple.pdb" /debug /machine:I386 /out:"../../../../bin/Debug/plugins/YAMN/simple.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "simple - Win32 Release" +# Name "simple - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\maindll.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/protocols/YAMN/filter/Simple/simple.mak b/protocols/YAMN/filter/Simple/simple.mak new file mode 100644 index 0000000000..085dc22e33 --- /dev/null +++ b/protocols/YAMN/filter/Simple/simple.mak @@ -0,0 +1,207 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on simple.dsp +!IF "$(CFG)" == "" +CFG=simple - Win32 Release +!MESSAGE No configuration specified. Defaulting to simple - Win32 Release. +!ENDIF + +!IF "$(CFG)" != "simple - Win32 Release" && "$(CFG)" != "simple - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "simple.mak" CFG="simple - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "simple - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "simple - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +!IF "$(CFG)" == "simple - Win32 Release" + +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "..\..\..\..\bin\release\plugins\YAMN-filter\simple.dll" + + +CLEAN : + -@erase "$(INTDIR)\maindll.obj" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(OUTDIR)\simple.exp" + -@erase "..\..\..\..\bin\release\plugins\YAMN-filter\simple.dll" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /G4 /Zp4 /MD /W3 /GX /O1 /Ob0 /I "../../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\simple.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ= +RSC=rc.exe +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\simple.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib user32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\simple.pdb" /machine:I386 /out:"../../../../bin/release/plugins/YAMN-filter/simple.dll" /implib:"$(OUTDIR)\simple.lib" /filealign:512 +LINK32_OBJS= \ + "$(INTDIR)\maindll.obj" + +"..\..\..\..\bin\release\plugins\YAMN-filter\simple.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "simple - Win32 Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +ALL : "..\..\..\..\bin\Debug\plugins\YAMN-filter\simple.dll" "$(OUTDIR)\simple.bsc" + + +CLEAN : + -@erase "$(INTDIR)\maindll.obj" + -@erase "$(INTDIR)\maindll.sbr" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(INTDIR)\vc60.pdb" + -@erase "$(OUTDIR)\simple.bsc" + -@erase "$(OUTDIR)\simple.exp" + -@erase "$(OUTDIR)\simple.pdb" + -@erase "..\..\..\..\bin\Debug\plugins\YAMN-filter\simple.dll" + -@erase "..\..\..\..\bin\Debug\plugins\YAMN-filter\simple.ilk" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +CPP_PROJ=/nologo /G4 /Zp4 /MDd /W3 /Gm /Gi /GX /ZI /Od /I "../../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\simple.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +MTL=midl.exe +MTL_PROJ= +RSC=rc.exe +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\simple.bsc" +BSC32_SBRS= \ + "$(INTDIR)\maindll.sbr" + +"$(OUTDIR)\simple.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +LINK32_FLAGS=kernel32.lib user32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\simple.pdb" /debug /machine:I386 /out:"../../../../bin/Debug/plugins/YAMN-filter/simple.dll" /implib:"$(OUTDIR)\simple.lib" +LINK32_OBJS= \ + "$(INTDIR)\maindll.obj" + +"..\..\..\..\bin\Debug\plugins\YAMN-filter\simple.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ENDIF + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("simple.dep") +!INCLUDE "simple.dep" +!ELSE +!MESSAGE Warning: cannot find "simple.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "simple - Win32 Release" || "$(CFG)" == "simple - Win32 Debug" +SOURCE=.\maindll.cpp + +!IF "$(CFG)" == "simple - Win32 Release" + + +"$(INTDIR)\maindll.obj" : $(SOURCE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "simple - Win32 Debug" + + +"$(INTDIR)\maindll.obj" "$(INTDIR)\maindll.sbr" : $(SOURCE) "$(INTDIR)" + + +!ENDIF + + +!ENDIF + diff --git a/protocols/YAMN/filter/readme.txt b/protocols/YAMN/filter/readme.txt new file mode 100644 index 0000000000..a46db0236a --- /dev/null +++ b/protocols/YAMN/filter/readme.txt @@ -0,0 +1 @@ +This folder contains filter plugin sources for YAMN. \ No newline at end of file -- cgit v1.2.3