|
|
|
|
@ -52,6 +52,9 @@ typedef struct OutputFiledataLogger_ {
|
|
|
|
|
struct OutputFiledataLogger_ *next;
|
|
|
|
|
const char *name;
|
|
|
|
|
TmmId module_id;
|
|
|
|
|
ThreadInitFunc ThreadInit;
|
|
|
|
|
ThreadDeinitFunc ThreadDeinit;
|
|
|
|
|
ThreadExitPrintStatsFunc ThreadExitPrintStats;
|
|
|
|
|
} OutputFiledataLogger;
|
|
|
|
|
|
|
|
|
|
static OutputFiledataLogger *list = NULL;
|
|
|
|
|
@ -60,11 +63,16 @@ static SCMutex g_waldo_mutex = SCMUTEX_INITIALIZER;
|
|
|
|
|
static int g_waldo_init = 0;
|
|
|
|
|
static int g_waldo_deinit = 0;
|
|
|
|
|
|
|
|
|
|
int OutputRegisterFiledataLogger(const char *name, FiledataLogger LogFunc, OutputCtx *output_ctx)
|
|
|
|
|
int OutputRegisterFiledataLogger(const char *name, FiledataLogger LogFunc,
|
|
|
|
|
OutputCtx *output_ctx, ThreadInitFunc ThreadInit,
|
|
|
|
|
ThreadDeinitFunc ThreadDeinit,
|
|
|
|
|
ThreadExitPrintStatsFunc ThreadExitPrintStats)
|
|
|
|
|
{
|
|
|
|
|
#if 0
|
|
|
|
|
int module_id = TmModuleGetIdByName(name);
|
|
|
|
|
if (module_id < 0)
|
|
|
|
|
return -1;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
OutputFiledataLogger *op = SCMalloc(sizeof(*op));
|
|
|
|
|
if (op == NULL)
|
|
|
|
|
@ -74,7 +82,12 @@ int OutputRegisterFiledataLogger(const char *name, FiledataLogger LogFunc, Outpu
|
|
|
|
|
op->LogFunc = LogFunc;
|
|
|
|
|
op->output_ctx = output_ctx;
|
|
|
|
|
op->name = name;
|
|
|
|
|
#if 0
|
|
|
|
|
op->module_id = (TmmId) module_id;
|
|
|
|
|
#endif
|
|
|
|
|
op->ThreadInit = ThreadInit;
|
|
|
|
|
op->ThreadDeinit = ThreadDeinit;
|
|
|
|
|
op->ThreadExitPrintStats = ThreadExitPrintStats;
|
|
|
|
|
|
|
|
|
|
if (list == NULL)
|
|
|
|
|
list = op;
|
|
|
|
|
@ -299,16 +312,9 @@ static TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, void *initdata, void
|
|
|
|
|
|
|
|
|
|
OutputFiledataLogger *logger = list;
|
|
|
|
|
while (logger) {
|
|
|
|
|
TmModule *tm_module = TmModuleGetByName((char *)logger->name);
|
|
|
|
|
if (tm_module == NULL) {
|
|
|
|
|
SCLogError(SC_ERR_INVALID_ARGUMENT,
|
|
|
|
|
"TmModuleGetByName for %s failed", logger->name);
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tm_module->ThreadInit) {
|
|
|
|
|
if (logger->ThreadInit) {
|
|
|
|
|
void *retptr = NULL;
|
|
|
|
|
if (tm_module->ThreadInit(tv, (void *)logger->output_ctx, &retptr) == TM_ECODE_OK) {
|
|
|
|
|
if (logger->ThreadInit(tv, (void *)logger->output_ctx, &retptr) == TM_ECODE_OK) {
|
|
|
|
|
OutputLoggerThreadStore *ts = SCMalloc(sizeof(*ts));
|
|
|
|
|
/* todo */ BUG_ON(ts == NULL);
|
|
|
|
|
memset(ts, 0x00, sizeof(*ts));
|
|
|
|
|
@ -391,15 +397,8 @@ static TmEcode OutputFiledataLogThreadDeinit(ThreadVars *tv, void *thread_data)
|
|
|
|
|
OutputFiledataLogger *logger = list;
|
|
|
|
|
|
|
|
|
|
while (logger && store) {
|
|
|
|
|
TmModule *tm_module = TmModuleGetByName((char *)logger->name);
|
|
|
|
|
if (tm_module == NULL) {
|
|
|
|
|
SCLogError(SC_ERR_INVALID_ARGUMENT,
|
|
|
|
|
"TmModuleGetByName for %s failed", logger->name);
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tm_module->ThreadDeinit) {
|
|
|
|
|
tm_module->ThreadDeinit(tv, store->thread_data);
|
|
|
|
|
if (logger->ThreadDeinit) {
|
|
|
|
|
logger->ThreadDeinit(tv, store->thread_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OutputLoggerThreadStore *next_store = store->next;
|
|
|
|
|
@ -429,15 +428,8 @@ static void OutputFiledataLogExitPrintStats(ThreadVars *tv, void *thread_data)
|
|
|
|
|
OutputFiledataLogger *logger = list;
|
|
|
|
|
|
|
|
|
|
while (logger && store) {
|
|
|
|
|
TmModule *tm_module = TmModuleGetByName((char *)logger->name);
|
|
|
|
|
if (tm_module == NULL) {
|
|
|
|
|
SCLogError(SC_ERR_INVALID_ARGUMENT,
|
|
|
|
|
"TmModuleGetByName for %s failed", logger->name);
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tm_module->ThreadExitPrintStats) {
|
|
|
|
|
tm_module->ThreadExitPrintStats(tv, store->thread_data);
|
|
|
|
|
if (logger->ThreadExitPrintStats) {
|
|
|
|
|
logger->ThreadExitPrintStats(tv, store->thread_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger = logger->next;
|
|
|
|
|
|