From 7c92a662d9045ca1c1c986c7d282c4d002a12b78 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Tue, 7 Jan 2014 15:14:17 -0500 Subject: [PATCH] Add functions to set the stats callbacks. Don't submit stats when verifying CVDs. --- freshclam/manager.c | 1 + libclamav/cvd.c | 1 + libclamav/stats.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/freshclam/manager.c b/freshclam/manager.c index 72d990383..16dff5ddb 100644 --- a/freshclam/manager.c +++ b/freshclam/manager.c @@ -1784,6 +1784,7 @@ test_database (const char *newfile, const char *newdb, int bytecode) { return FCE_TESTFAIL; } + cl_engine_set_clcb_stats_submit(engine, NULL); if ((ret = cl_load (newfile, engine, &newsigs, diff --git a/libclamav/cvd.c b/libclamav/cvd.c index 29353c301..dee54d14f 100644 --- a/libclamav/cvd.c +++ b/libclamav/cvd.c @@ -567,6 +567,7 @@ int cl_cvdverify(const char *file) fclose(fs); return CL_EMEM; } + engine->cb_stats_submit = NULL; /* Don't submit stats if we're just verifying a CVD */ ret = cli_cvdload(fs, engine, NULL, CL_DB_STDOPT | CL_DB_PUA, !!cli_strbcasestr(file, ".cld"), file, 1); diff --git a/libclamav/stats.c b/libclamav/stats.c index 37c76c09f..e05c6f5eb 100644 --- a/libclamav/stats.c +++ b/libclamav/stats.c @@ -461,3 +461,48 @@ static cli_flagged_sample_t *find_sample(cli_intel_t *intel, const char *virname return NULL; } + +void cl_engine_set_clcb_stats_submit(struct cl_engine *engine, clcb_stats_submit callback) +{ + engine->cb_stats_submit = callback; +} + +void cl_engine_stats_set_cbdata(struct cl_engine *engine, void *cbdata) +{ + engine->stats_data = cbdata; +} + +void cl_engine_set_clcb_stats_add_sample(struct cl_engine *engine, clcb_stats_add_sample callback) +{ + engine->cb_stats_add_sample = callback; +} + +void cl_engine_set_clcb_stats_remove_sample(struct cl_engine *engine, clcb_stats_remove_sample callback) +{ + engine->cb_stats_remove_sample = callback; +} + +void cl_engine_set_clcb_stats_decrement_count(struct cl_engine *engine, clcb_stats_decrement_count callback) +{ + engine->cb_stats_decrement_count = callback; +} + +void cl_engine_set_clcb_stats_flush(struct cl_engine *engine, clcb_stats_flush callback) +{ + engine->cb_stats_flush = callback; +} + +void cl_engine_set_clcb_stats_get_num(struct cl_engine *engine, clcb_stats_get_num callback) +{ + engine->cb_stats_get_num = callback; +} + +void cl_engine_set_clcb_stats_get_size(struct cl_engine *engine, clcb_stats_get_size callback) +{ + engine->cb_stats_get_size = callback; +} + +void cl_engine_set_clcb_stats_get_hostid(struct cl_engine *engine, clcb_stats_get_hostid callback) +{ + engine->cb_stats_get_hostid = callback; +}