|
|
@@ -43,8 +43,8 @@ GBUdbDataset::GBUdbDataset(const char* SetFileName) : |
|
|
|
} |
|
|
|
|
|
|
|
GBUdbDataset::GBUdbDataset(GBUdbDataset& Original) : // Copy constructor. |
|
|
|
DataArray(NULL), // The array pointer starts as NULL.
|
|
|
|
MyArraySize(Original.MyArraySize), // Copy the ArraySize
|
|
|
|
DataArray(NULL), // The array pointer starts as NULL. |
|
|
|
MyArraySize(Original.MyArraySize), // Copy the ArraySize |
|
|
|
MyFileName(Original.MyFileName) { // Copy the name pointer. |
|
|
|
DataArray = new GBUdbRecord[MyArraySize]; // Allocate a new Array. |
|
|
|
memcpy(DataArray, Original.DataArray, sizeof(GBUdbRecord) * MyArraySize); // Copy the data wholesale. |
|
|
@@ -333,8 +333,8 @@ void GBUdbDataset::save() { |
|
|
|
rename(TempFileName.c_str(), MyFileName.c_str()); // Then make our new file current. |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const RuntimeCheck SaneFileSizeCheck("GBUdbDataset::load():SaneFileSizeCheck(SaneGBUdbFileSizeLimit <= FileSize)");
|
|
|
|
|
|
|
|
const RuntimeCheck SaneFileSizeCheck("GBUdbDataset::load():SaneFileSizeCheck(SaneGBUdbFileSizeLimit <= FileSize)"); |
|
|
|
|
|
|
|
void GBUdbDataset::load() { // Read the GBUdb from disk. |
|
|
|
|
|
|
@@ -509,6 +509,7 @@ bool AlertFor(int count) { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
RuntimeCheck GoodTimestampLength("GBUdb.cpp:getTimestamp snprintf(...) != CorrectTimestampLength"); |
|
|
|
char* getTimestamp(char* TimestampBfr) { // Creates an ISO GMT timestamp. |
|
|
|
|
|
|
|
time_t rawtime; // Get a timer and |
|
|
@@ -516,7 +517,7 @@ char* getTimestamp(char* TimestampBfr) { |
|
|
|
time(&rawtime); // Grab the current time and |
|
|
|
gmt=gmtime(&rawtime); // convert it to GMT. |
|
|
|
|
|
|
|
sprintf(TimestampBfr,"%04d%02d%02d%02d%02d%02d", // Format yyyymmddhhmmss |
|
|
|
size_t l = snprintf(TimestampBfr,UTCBufferSize, "%04d%02d%02d%02d%02d%02d", // Format yyyymmddhhmmss |
|
|
|
gmt->tm_year+1900, |
|
|
|
gmt->tm_mon+1, |
|
|
|
gmt->tm_mday, |
|
|
@@ -525,6 +526,9 @@ char* getTimestamp(char* TimestampBfr) { |
|
|
|
gmt->tm_sec |
|
|
|
); |
|
|
|
|
|
|
|
const size_t CorrectTimestampLength = 4+2+2+2+2+2; |
|
|
|
GoodTimestampLength(l == CorrectTimestampLength); |
|
|
|
|
|
|
|
return TimestampBfr; |
|
|
|
} |
|
|
|
|
|
|
@@ -751,11 +755,11 @@ void GBUdb::compress() { |
|
|
|
MyDataset = BuildCompressedDataset.New(); // Put the new dataset in place. |
|
|
|
delete BuildCompressedDataset.Old(); // Delete the old dataset. |
|
|
|
} // All done, so we're unlocked. |
|
|
|
|
|
|
|
|
|
|
|
int GBUdb::readIgnoreList(const char* FileName) { // setIgnore for a list of IPs |
|
|
|
int IPCount = 0; // Keep track of the IPs we read. |
|
|
|
try { // Capture any exceptions. |
|
|
|
char IPLineBuffer[256]; // Create a line buffer.
|
|
|
|
char IPLineBuffer[256]; // Create a line buffer. |
|
|
|
const int SafeBufferSize = sizeof(IPLineBuffer) - 1; // Safe size always leaves a NULL on the end. |
|
|
|
ifstream ListFile(FileName, ios::in); // Open up the list file. |
|
|
|
while(ListFile.good()) { // While we've got a good file (not eof) |
|
|
@@ -770,7 +774,7 @@ int GBUdb::readIgnoreList(const char* FileName) { |
|
|
|
char* cursor = IPLineBuffer; // Start on the first byte. |
|
|
|
|
|
|
|
if('#' == *cursor) continue; // Lines that start with # are comments. |
|
|
|
while(0 < *cursor && isspace(*cursor)) ++cursor; // Eat any leading spaces.
|
|
|
|
while(0 < *cursor && isspace(*cursor)) ++cursor; // Eat any leading spaces. |
|
|
|
|
|
|
|
// First octet. |
|
|
|
|