git-svn-id: https://svn.microneil.com/svn/SNF4CGP/trunk@5 59e8e3e7-56fa-483b-b4b4-fa6ab0af3dfcmaster
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/CommandProcessor.cpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC. | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/CommandProcessor.hpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,8 @@ | |||
// SNF4CGP/ExecutiveProcess.cpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC. | |||
// See www.armresearch.com for more information. | |||
#include "ExecutiveProcess.hpp" | |||
using namespace std; | |||
@@ -0,0 +1,50 @@ | |||
// SNF4CGP/ExecutiveProcess.hpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC | |||
// See www.armresearch.com for more information. | |||
// | |||
// SNF4CGP Execuitive Process (Application Object) | |||
// The ExecutiveProcess is responsible for constructing the application, connecting | |||
// it's components, and peforming an orderly startup and shutdown. | |||
#ifndef IncludedExecutiveProcess | |||
#define IncludedExecutiveProcess | |||
#include "JobPool.hpp" | |||
#include "WorkerPool.hpp" | |||
#include "InputProcessor.hpp" | |||
#include "OutputProcessor.hpp" | |||
#include "CommandProcessor.hpp" | |||
#include <string> | |||
class ExecutiveProcess { // The executive process... | |||
private: | |||
const string VersionInfo; // Knows Version and | |||
const string ConfigInfo; // Configuration. | |||
JobPool* Jobs; // Keeps pointers to the apps | |||
WorkerPool* Workers; // components so they can be | |||
InputProcessor* Input; // created, destroyed and | |||
OutputProcessor* Output; // connected together. | |||
CommandProcessor* Processor; | |||
void initializeOutput(); // These do what they say. | |||
void initializeJobPool(); | |||
void initializeWorkerPool(); | |||
void shutdownWorkerPool(); | |||
void shutdownJobPool(); | |||
void shutdownOutput(); | |||
public: | |||
ExecutiveProcess(string& Version, string& Config); // Simple construction. The d'tor needs | |||
~ExecutiveProcess(); // to deal with uncerimoneous shutdowns. | |||
void doStartup(); // The main thread calls these in sequence. | |||
void doProcessing(); | |||
void doShutdown(); | |||
}; | |||
#endif |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/InputProcessor.cpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC. | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,41 @@ | |||
// SNF4CGP/InputProcessor.hpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC | |||
// See www.armresearch.com for more information. | |||
// | |||
// The InputProcessor is responsible for accpting and parsing commands from | |||
// CommuniGate, assigning Jobs to Workers, and watching for the QUIT command. | |||
#ifndef IncludedInputProcessor | |||
#define IncludedInputProcessor | |||
#include "JobPool.hpp" | |||
#include "WorkerPool.hpp" | |||
#include <string> | |||
using namespace std; | |||
struct Command { // Parsed Command Objects | |||
unsigned int Number; // Commands have a serial number | |||
enum CommandType { // Commands have these types: | |||
UNKNOWN; // We don't know this command. | |||
QUIT; // It is time to stop the app. | |||
WAKE; // Report the app is now awake. | |||
INTF; // Report the interface version. | |||
FILE; // Scan this file. | |||
} Type; // Here is where we keep it. | |||
string Data; // Other command data goes here. | |||
}; | |||
class InputProcessor { // Here is the InputProcessor object. | |||
private: | |||
JobPool& Jobs; // It knows where to get jobs. | |||
WorkerPool& Workers; // It knows where to get workers. | |||
public: | |||
InputProcessor(JobPool J, WorkerPool W); | |||
Command getCommand(); // One method: get the next command. | |||
}; | |||
#endif |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/JobPool.cpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC. | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/JobPool.hpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/OutputProcessor.cpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC. | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/OutputProcessor.hpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/ScannerPool.cpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC. | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/ScannerPool.hpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/WorkerPool.cpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC. | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,3 @@ | |||
// SNF4CGP/WoorkerPool.hpp | |||
// Copyright (C) 2009 ARM Research Labs, LLC | |||
// See www.armresearch.com for more information. |
@@ -0,0 +1,48 @@ | |||
// SNF4CGP/main.cpp | |||
// | |||
// (C) Copyright 2009 ARM Research Labs, LLC | |||
// See www.armresearch.com for more information. | |||
// | |||
// SNF4CGP is a "filter helper" for Stalker's CommuniGate Pro | |||
// It implements a full SNFMulti antispam/antimalware engine and multi-threaded | |||
// scanner. SNFMulti scan results are mapped to appropriate responses. | |||
#include <iostream> | |||
#include <string> | |||
#include "ExecutiveProcess.hpp" | |||
using namespace std; // Introduce standard namespace. | |||
const string SNF4CGP_VERSION_INFO = "SNF4CGP Version 0.0.1 Build: " __DATE__ " " __TIME__; | |||
const int ConfigPathArgNumber = 1; | |||
const int CorrectArgcNumber = 2; | |||
bool CommandLineIsValid(int argc, char*argv[]) { // Validate the command line. | |||
if(CorrectArgcNumber != argc) { | |||
cout << "* SNF4CGP - Bad command line, use SNF4CGP <path_to_config_file>" << endl; | |||
return false; | |||
} | |||
return true; | |||
} | |||
void go(string ConfigurationPath) { // Application's main thread. | |||
try { | |||
ExecutiveProcess SNF4CGP(SNF4CGP_VERSION_INFO, ConfigurationPath); | |||
SNF4CGP.doStartup(); | |||
SNF4CGP.doProcessing(); | |||
SNF4CGP.doShutdown(); | |||
} | |||
catch(exception& e) { // Display standard exceptions. | |||
cout << "* SFN4CGP::go() Exception: " << e.what() << endl; | |||
} | |||
catch(...) { // Display unusual exceptions. | |||
cout << "* SNF4CGP::go() Unusual Excetption" << endl; | |||
} | |||
cout << SNF4CGP_VERSION_INFO << endl; | |||
cout << ConfigurationPath << endl; | |||
} | |||
int main(int argc, char* argv[]) { // Main entry point. | |||
if(CommandLineIsValid(argc, argv)) go(argv[ConfigPathArgNumber]); // With a good command line we go. | |||
return 0; // Then we're done. | |||
} |