prelude-lml/master: Provide the ability to reference an lml_log_entry_t
[email protected] Tue, 26 Jan 2010 14:22:15 +0100 (CET)
| Newsgroups | gmane.comp.security.ids.prelude.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit dde2a332d07c42cfe66cdda7fde8f9acf1df424f Author: Yoann Vandoorselaere <[email protected]> Date: Fri Jan 22 10:45:33 2010 +0100 Provide the ability to reference an lml_log_entry_t ======================================== plugins/debug/debug.c | 2 +- plugins/pcre/pcre-mod.c | 2 +- src/include/log-entry.h | 2 -- src/include/prelude-lml.h | 11 ++++++++--- src/log-entry.c | 13 +++++++++++++ 5 files changed, 23 insertions(+), 7 deletions(-) ======================================== diff --git a/plugins/debug/debug.c b/plugins/debug/debug.c index f5efa2c..c21b7fc 100644 --- a/plugins/debug/debug.c +++ b/plugins/debug/debug.c @@ -46,7 +46,7 @@ extern prelude_option_t *lml_root_optlist; -static void debug_run(prelude_plugin_instance_t *pi, const lml_log_source_t *ls, const lml_log_entry_t *log_entry) +static void debug_run(prelude_plugin_instance_t *pi, const lml_log_source_t *ls, lml_log_entry_t *log_entry) { int ret; debug_plugin_t *plugin; diff --git a/plugins/pcre/pcre-mod.c b/plugins/pcre/pcre-mod.c index a79e346..5a669fb 100644 --- a/plugins/pcre/pcre-mod.c +++ b/plugins/pcre/pcre-mod.c @@ -831,7 +831,7 @@ static int parse_ruleset(prelude_list_t *head, pcre_plugin_t *plugin, const char -static void pcre_run(prelude_plugin_instance_t *pi, const lml_log_source_t *ls, const lml_log_entry_t *log_entry) +static void pcre_run(prelude_plugin_instance_t *pi, const lml_log_source_t *ls, lml_log_entry_t *log_entry) { int ret; prelude_list_t *tmp; diff --git a/src/include/log-entry.h b/src/include/log-entry.h index be2ff27..ef99508 100644 --- a/src/include/log-entry.h +++ b/src/include/log-entry.h @@ -31,8 +31,6 @@ lml_log_entry_t *lml_log_entry_new(void); int lml_log_entry_set_log(lml_log_entry_t *lc, lml_log_source_t *ls, char *entry, size_t size); -void lml_log_entry_destroy(lml_log_entry_t *lc); - const lml_log_format_t *lml_log_entry_get_format(const lml_log_entry_t *log); #endif /* _LOG_ENTRY_H */ diff --git a/src/include/prelude-lml.h b/src/include/prelude-lml.h index 20929e9..bfe1475 100644 --- a/src/include/prelude-lml.h +++ b/src/include/prelude-lml.h @@ -6,7 +6,7 @@ * This file is part of the Prelude-LML program. * * This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by +* it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * @@ -32,11 +32,16 @@ typedef struct lml_log_source lml_log_source_t; typedef struct { - PRELUDE_PLUGIN_GENERIC; - void (*run)(prelude_plugin_instance_t *pi, const lml_log_source_t *ls, const lml_log_entry_t *log); + PRELUDE_PLUGIN_GENERIC; + void (*run)(prelude_plugin_instance_t *pi, const lml_log_source_t *ls, lml_log_entry_t *log); } lml_log_plugin_t; +void lml_log_entry_destroy(lml_log_entry_t *lc); + +lml_log_entry_t *lml_log_entry_ref(lml_log_entry_t *log_entry); + + const char *lml_log_entry_get_message(const lml_log_entry_t *log_entry); const char *lml_log_entry_get_original_log(const lml_log_entry_t *log_entry); diff --git a/src/log-entry.c b/src/log-entry.c index f662cfc..83ded6e 100644 --- a/src/log-entry.c +++ b/src/log-entry.c @@ -47,6 +47,8 @@ struct lml_log_entry { + int refcount; + char *original_log; size_t original_log_len; @@ -254,6 +256,7 @@ lml_log_entry_t *lml_log_entry_new(void) return NULL; } + log_entry->refcount = 1; gettimeofday(&log_entry->tv, NULL); return log_entry; @@ -300,8 +303,18 @@ int lml_log_entry_set_log(lml_log_entry_t *log_entry, lml_log_source_t *ls, char +lml_log_entry_t *lml_log_entry_ref(lml_log_entry_t *log_entry) +{ + log_entry->refcount++; + return log_entry; +} + + void lml_log_entry_destroy(lml_log_entry_t *log_entry) { + if ( --log_entry->refcount > 0 ) + return; + if ( log_entry->original_log ) free(log_entry->original_log); _______________________________________________ Prelude-cvslog site list [email protected] http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog