|
|
|
|
|
|
|
|
const ThreadType snf_Reloader::Type("snf_Reloader"); // The thread's type. |
|
|
const ThreadType snf_Reloader::Type("snf_Reloader"); // The thread's type. |
|
|
|
|
|
|
|
|
snf_Reloader::snf_Reloader(snf_RulebaseHandler& R) : // When we are created, we |
|
|
snf_Reloader::snf_Reloader(snf_RulebaseHandler& R) : // When we are created, we |
|
|
Thread(snf_Reloader::Type, "Reloader"), // brand and name our thread, |
|
|
|
|
|
RulebaseGetterIsTurnedOn(false), // rulebase getter is off at first, |
|
|
|
|
|
RulebaseGetter("RulebaseGetter"), // setup our ScriptCaller thread, |
|
|
|
|
|
MyRulebase(R), // capture the rulebase handler. |
|
|
|
|
|
TimeToStop(false) { // It's not time to stop yet. |
|
|
|
|
|
|
|
|
Thread(snf_Reloader::Type, "Reloader"), // brand and name our thread. |
|
|
|
|
|
MyRulebase(R), // Capture the rulebase handler.
|
|
|
|
|
|
TimeToStop(false), // It's not time to stop yet.
|
|
|
|
|
|
RulebaseGetter("RulebaseGetter"), // Setup our ScriptCaller thread. |
|
|
|
|
|
RulebaseGetterIsTurnedOn(false) { // Rulebase getter is off at first.
|
|
|
captureFileStats(); // Set up the initial stats. |
|
|
captureFileStats(); // Set up the initial stats. |
|
|
captureGetterConfig(); // Set up RulebaseGetter config. |
|
|
captureGetterConfig(); // Set up RulebaseGetter config. |
|
|
run(); // Run our maintenenace thread. |
|
|
run(); // Run our maintenenace thread. |
|
|
|
|
|
|
|
|
struct tm FileNameTime; // Allocate a time structure. |
|
|
struct tm FileNameTime; // Allocate a time structure. |
|
|
FileNameTime = *(gmtime(&FileNameStat.st_mtime)); // Copy the file time to it as UTC. |
|
|
FileNameTime = *(gmtime(&FileNameStat.st_mtime)); // Copy the file time to it as UTC. |
|
|
|
|
|
|
|
|
char TimestampBfr[20]; // Timestamp buffer. |
|
|
|
|
|
|
|
|
char TimestampBfr[20]; // Timestamp buffer. |
|
|
|
|
|
|
|
|
sprintf(TimestampBfr,"%04d%02d%02d%02d%02d%02d\0", // Format yyyymmddhhmmss |
|
|
|
|
|
|
|
|
sprintf(TimestampBfr,"%04d%02d%02d%02d%02d%02d", // Format yyyymmddhhmmss |
|
|
FileNameTime.tm_year+1900, |
|
|
FileNameTime.tm_year+1900, |
|
|
FileNameTime.tm_mon+1, |
|
|
FileNameTime.tm_mon+1, |
|
|
FileNameTime.tm_mday, |
|
|
FileNameTime.tm_mday, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void snf_RulebaseHandler::drop(snfCFGPacket& CP) { // Deactiveate this Rulebase. |
|
|
void snf_RulebaseHandler::drop(snfCFGPacket& CP) { // Deactiveate this Rulebase. |
|
|
const TokenMatrix* t = CP.MyTokenMatrix; // Grab the token matrix pointer. |
|
|
const TokenMatrix* t = CP.MyTokenMatrix; // Grab the token matrix pointer. |
|
|
CP.MyCFGData == NULL; // Null the configuration pointer. |
|
|
|
|
|
|
|
|
CP.MyCFGData = NULL; // Null the configuration pointer. |
|
|
ScopeMutex HoldStillPlease(MyMutex); // Lock the rulebase until we're done. |
|
|
ScopeMutex HoldStillPlease(MyMutex); // Lock the rulebase until we're done. |
|
|
if(t==Rulebase) { // If we're dropping the current rulebase |
|
|
if(t==Rulebase) { // If we're dropping the current rulebase |
|
|
CurrentCount--; // then reduce the current count. |
|
|
CurrentCount--; // then reduce the current count. |
|
|
|
|
|
|
|
|
// *nix like systems if the software and/or scripting involved isn't |
|
|
// *nix like systems if the software and/or scripting involved isn't |
|
|
// quite up to spec. We are reading a file, after all. |
|
|
// quite up to spec. We are reading a file, after all. |
|
|
|
|
|
|
|
|
int ipt = 0; // Insert search point. |
|
|
|
|
|
|
|
|
unsigned int ipt = 0; // Insert search point. |
|
|
|
|
|
|
|
|
if(MessageBuffer.size() != MyScanData.ScanSize) { // If our scanner skipped data at |
|
|
if(MessageBuffer.size() != MyScanData.ScanSize) { // If our scanner skipped data at |
|
|
ipt = MessageBuffer.size() - MyScanData.ScanSize; // the top of the message buffer then |
|
|
ipt = MessageBuffer.size() - MyScanData.ScanSize; // the top of the message buffer then |
|
|
|
|
|
|
|
|
break; // That's all. |
|
|
break; // That's all. |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case New: { |
|
|
|
|
|
|
|
|
case New: {
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case Unknown: // Unknown - most likely we couldn't
|
|
|
|
|
|
default: { // find a usable source.
|
|
|
|
|
|
break; // Do nothing.
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} // End of IP source depended work (GBUdbOverrides) |
|
|
} // End of IP source depended work (GBUdbOverrides) |