git-svn-id: https://svn.microneil.com/svn/PKG-SNF-SDK-WIN/trunk@14 7d91e7c8-5a61-404e-b06a-95855fde9112master
LIBRARY snfmulti | |||||
EXPORTS | EXPORTS | ||||
closeScan @1 | closeScan @1 | ||||
getIPReputation @2 | getIPReputation @2 |
README file for command files for building SNFServer library and applications | |||||
Copyright (c) 2009 ARM Research Laboratories | |||||
This is the README file for building the SNFMulti library and | |||||
SNFMultiTest application using the 64-bit MinGW toolchain. | |||||
To build SNFMulti.dll | |||||
1) Run "compileSNFMultiDLL.cmd". This compiles the SNFMulti files | |||||
for building a DLL. The object files are created in the current | |||||
directory. The source files are in the ../SNFMulti and | |||||
../CodeDweller directories. | |||||
2) Run "buildSNFMultiDLL.cmd". This builds snfmulti.dll, | |||||
libsnfmulti.a, and snfmulti.def. These are the same files built | |||||
by Code::Blocks. | |||||
To build the import and export SNFMulti libraries for VS2008: | |||||
1) With the VS2008 command prompt, run "buildVS2008SNFMultiImportLib.cmd". | |||||
This reads snfmulti.def and creates vs2008_snfmulti.lib (the SNFMulti import | |||||
library) and vs2008_snfmulti.exp (the SNFMulti export library). | |||||
To copy to where the sample programs can find the files: | |||||
1) Run "installSNFMultiLibrary.cmd". This copies the output files into | |||||
the ..\64bitDll directory. | |||||
To build SNFMultiTest linked with SNFMulti.dll: | |||||
1) Run "buildSNFMultiTestDLL.cmd". This builds SNFMultiTest.exe, | |||||
linking with SNFMulti.dll. Because SNFMulti.dll is in the current | |||||
directory, SNFMultiTest.exe can be run from the command line | |||||
without modifying the PATH variable. | |||||
setlocal | |||||
del snfmulti.dll snfmulti.def libsnfmulti.a | |||||
set path=c:\MinGW\bin;%path% | |||||
set CXX=c++ | |||||
set LIB=c:\MinGW\lib\libws2_32.a -loleaut32 | |||||
set LDFLAGS=-Wl,--output-def=snfmulti.def -Wl,--out-implib=libsnfmulti.a -Wl,-dll | |||||
%CXX% -shared -o snfmulti.dll %LDFLAGS% snfmultidll.o FilterChain.o GBUdb.o mangler.o scanner.o snfCFGmgr.o snf_engine.o snfGBUdbmgr.o snf_HeaderFinder.o snfLOGmgr.o SNFMulti.o snfNETmgr.o snf_sync.o snf_xci.o snfXCImgr.o base64codec.o configuration.o networking.o threading.o timing.o %LIB% |
setlocal | |||||
del SNFMultiTest.exe | |||||
set path=c:\MinGW\bin;%path% | |||||
set CXX=c++ | |||||
set CXXFLAGS=-I../include -I../SNFMulti -I../CodeDweller -I.. -mthreads | |||||
set LIB=c:\MinGW\lib\libws2_32.a | |||||
set LDFLAGS=-L. -lSNFMulti | |||||
%CXX% ../SNFMultiTest/main.cpp ../CodeDweller/timing.cpp ../CodeDweller/threading.cpp %CXXFLAGS% -o SNFMultiTest.exe %LDFLAGS% |
DEL vs2008_snfmulti.* | |||||
LIB /DEF:SNFMulti.def /OUT:vs2008_snfmulti.lib /MACHINE:X86 |
setlocal | |||||
set path=c:\MinGW\bin;%path% | |||||
set CXX=c++ | |||||
set CXXFLAGS=-I../CodeDweller -I../SNFMulti -mthreads -O3 | |||||
del *.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/FilterChain.cpp -o FilterChain.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/GBUdb.cpp -o GBUdb.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/scanner.cpp -o scanner.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/snfCFGmgr.cpp -o snfCFGmgr.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/snfGBUdbmgr.cpp -o snfGBUdbmgr.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/snfLOGmgr.cpp -o snfLOGmgr.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/SNFMulti.cpp -o SNFMulti.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMultiDll/snfmultidll.cpp -I../include -o snfmultidll.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/snfNETmgr.cpp -o snfNETmgr.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/snfXCImgr.cpp -o snfXCImgr.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/snf_engine.cpp -o snf_engine.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/snf_HeaderFinder.cpp -o snf_HeaderFinder.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/snf_sync.cpp -o snf_sync.o | |||||
%CXX% %CXXFLAGS% -c ../SNFMulti/snf_xci.cpp -o snf_xci.o | |||||
%CXX% %CXXFLAGS% -c ../CodeDweller/base64codec.cpp -o base64codec.o | |||||
%CXX% %CXXFLAGS% -c ../CodeDweller/configuration.cpp -o configuration.o | |||||
%CXX% %CXXFLAGS% -c ../CodeDweller/mangler.cpp -o mangler.o | |||||
%CXX% %CXXFLAGS% -c ../CodeDweller/networking.cpp -o networking.o | |||||
%CXX% %CXXFLAGS% -c ../CodeDweller/threading.cpp -o threading.o | |||||
%CXX% %CXXFLAGS% -c ../CodeDweller/timing.cpp -o timing.o |
set DESTDIR=..\32bitDll | |||||
COPY snfmulti.dll %DESTDIR% | |||||
COPY snfmulti.def %DESTDIR% | |||||
COPY vs2008_snfmulti.* %DESTDIR% |
libsnfmulti.a, and snfmulti.def. These are the same files built | libsnfmulti.a, and snfmulti.def. These are the same files built | ||||
by Code::Blocks. | by Code::Blocks. | ||||
3) Run "installSNFMultiLibrary.cmd". This copies the output files into | |||||
the ..\64bitDll directory. | |||||
To build the import and export SNFMulti libraries for VS2008: | To build the import and export SNFMulti libraries for VS2008: | ||||
1) Run "buildVS2008SNFMultiImportLib.cmd". This reads snfmulti.def | |||||
and creates vs2008_snfmulti.lib (the SNFMulti import library) and | |||||
vs2008_snfmulti.exp (the SNFMulti export library). | |||||
1) With the VS2008 command prompt, run "buildVS2008SNFMultiImportLib.cmd". | |||||
This reads snfmulti.def and creates vs2008_snfmulti.lib (the SNFMulti import | |||||
library) and vs2008_snfmulti.exp (the SNFMulti export library). | |||||
To copy to where the sample programs can find the files: | |||||
1) Run "installSNFMultiLibrary.cmd". This copies the output files into | |||||
the ..\64bitDll directory. | |||||
To build SNFMultiTest linked with SNFMulti.dll: | To build SNFMultiTest linked with SNFMulti.dll: | ||||
DEL vs2008_snfmulti.* | |||||
LIB /DEF:SNFMulti.def /OUT:vs2008_snfmulti.lib /MACHINE:X64 |
LIBRARY snfmulti | |||||
EXPORTS | EXPORTS | ||||
closeScan @1 | closeScan @1 | ||||
getIPReputation @2 | getIPReputation @2 |
//// TCPClient methods ///////////////////////////////////////////////////////// | //// TCPClient methods ///////////////////////////////////////////////////////// | ||||
int TCPClient::transmit(const char* bfr, int size) { // How to send a buffer of data. | int TCPClient::transmit(const char* bfr, int size) { // How to send a buffer of data. | ||||
LastError = 0; // No errors yet. | |||||
if(0 == size) return 0; // Nothing to send, send nothing. | if(0 == size) return 0; // Nothing to send, send nothing. | ||||
if(0 == bfr) // Watch out for null buffers. | if(0 == bfr) // Watch out for null buffers. | ||||
throw Networking::SocketWriteError("TCPClient::transmit() NULL Bfr!"); | throw Networking::SocketWriteError("TCPClient::transmit() NULL Bfr!"); | ||||
if(0 > size) // Watch out for bad sizes. | if(0 > size) // Watch out for bad sizes. | ||||
throw Networking::SocketWriteError("TCPClient::transmit() 0 > size!"); | throw Networking::SocketWriteError("TCPClient::transmit() 0 > size!"); | ||||
int ByteCount = send(Handle, bfr, size, MSG_NOSIGNAL); // Try to send and capture the count. | |||||
if(0 > ByteCount) ByteCount = 0; // Mask error results as 0 bytes sent. | |||||
if(size > ByteCount) { // If we didn't send it all check it out. | |||||
LastError = Network.getLastError(); // Grab the error code. | |||||
if(Network.WouldBlock(LastError)) { // If the error was WouldBlock then | |||||
return ByteCount; // it was a partial send - return. | |||||
LastError = 0; // No errors yet. | |||||
int ByteCount = 0; // No bytes sent yet this pass. | |||||
ByteCount = send(Handle, bfr, size, MSG_NOSIGNAL); // Try to send and capture the count. | |||||
LastError = Network.getLastError(); // Grab any error code. | |||||
bool AnErrorOccurred = (0 > ByteCount); // How to know if an error occurred. | |||||
const int NoBytesSent = 0; // This is our "Would Block" result. | |||||
if(AnErrorOccurred) { // If there was an error check it out. | |||||
if(Network.WouldBlock(LastError)) { // If the error was "Would Block" then | |||||
return NoBytesSent; // return no bytes sent (try again). | |||||
} else { // If this was a different kind of error | } else { // If this was a different kind of error | ||||
throw Networking::SocketWriteError( // then throw! | throw Networking::SocketWriteError( // then throw! | ||||
Network.DescriptiveError( | Network.DescriptiveError( | ||||
"TCPClient::transmit().send()", LastError)); | "TCPClient::transmit().send()", LastError)); | ||||
} | } | ||||
} | } | ||||
return ByteCount; // Ultimately return the byte count. | |||||
return ByteCount; // Usually: return the sent byte count. | |||||
} | } | ||||
int TCPClient::receive(char* bfr, int size) { // How to receive a buffer of data. | int TCPClient::receive(char* bfr, int size) { // How to receive a buffer of data. |
2) The SNFMulti C++ test built with Visual Studio 2008. This can be | 2) The SNFMulti C++ test built with Visual Studio 2008. This can be | ||||
built with solution file | built with solution file | ||||
VS2008/SNFMultiDLLExampleCsharp/SNFMultiDLLTestC++.sln. | |||||
VS2008CPPSample/VS2008CPPSample.sln. | |||||
3) A Visual Studio 2008 C# example application. This can be built | 3) A Visual Studio 2008 C# example application. This can be built | ||||
with solution file | |||||
VS2008/SNFMultiDLLExampleCsharp/SNFMultiDLLExampleCsharp.sln. | |||||
with solution file VS2008CSSample/VS2008CSSample.sln. | |||||
4) A Visual Studio 2008 VB example application. This can be built | 4) A Visual Studio 2008 VB example application. This can be built | ||||
with the solution file | |||||
VS2008/SNFMultiDLLExampleVB/SNFMultiDLLExampleVB.sln. | |||||
with the solution file VS2008VBSample/VS2008VBSample.sln. | |||||
This package includes the following directories (each has a README | This package includes the following directories (each has a README | ||||
file with further information): | file with further information): | ||||
MinGW--Contains .CMD files for building SNFMulti.dll and associated | |||||
MinGW--Contains .CMD files for building 64-bit SNFMulti.dll and associated | |||||
files, and also the C++ application SNFMultiTest. It uses the | |||||
source files in the SNFMulti, CodeDweller, and SNFMultiTest | |||||
directories. These directories must be present. | |||||
MinGW-32--Contains .CMD files for building 32-bit SNFMulti.dll and associated | |||||
files, and also the C++ application SNFMultiTest. It uses the | files, and also the C++ application SNFMultiTest. It uses the | ||||
source files in the SNFMulti, CodeDweller, and SNFMultiTest | source files in the SNFMulti, CodeDweller, and SNFMultiTest | ||||
directories. These directories must be present. | directories. These directories must be present. | ||||
SNFMultiTest--Contains the source for the C++ test application | SNFMultiTest--Contains the source for the C++ test application | ||||
SNFMultiTest. | SNFMultiTest. | ||||
VS2008--Contains the Visual Studio files for building the C# and VB | |||||
example applications, and the C++ test. | |||||
VS2008CSSample, VS2008VBSample, VS2008CPPSample--Contains the Visual Studio files | |||||
for building the C# and VB example applications, and the C++ test. | |||||
To build the applications in the MinGW, CodeBlocks, and VS2008 | To build the applications in the MinGW, CodeBlocks, and VS2008 | ||||
directories: | directories: |