summaryrefslogtreecommitdiffstats
path: root/src/journald
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2013-11-15 17:45:36 +0100
committerTomas Bzatek <tbzatek@redhat.com>2013-11-15 17:45:36 +0100
commitcb1ffc827aa461fcb31cc1de7305d7d611262c90 (patch)
tree02bf7d71eaa126c11a17047509a678acec530cb2 /src/journald
parentaa9cdfa38d112dbfd7805959d9892d1d572b2370 (diff)
downloadopenlmi-providers-cb1ffc827aa461fcb31cc1de7305d7d611262c90.tar.gz
openlmi-providers-cb1ffc827aa461fcb31cc1de7305d7d611262c90.tar.xz
openlmi-providers-cb1ffc827aa461fcb31cc1de7305d7d611262c90.zip
indmanager: Introduce common filter checker
The filter checker code was kinda duplicate across providers and no special plans have been made for it. This change makes passing a filter checker callback during indication manager creation no longer mandatory and default filter checker will be used when NULL. However, the list of acceptable classes need to be registered before first use. This change also brings greater flexibility of the filter query which may now consist of multiple limit conditions.
Diffstat (limited to 'src/journald')
-rw-r--r--src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c3
-rw-r--r--src/journald/instutil.c31
-rw-r--r--src/journald/instutil.h5
3 files changed, 6 insertions, 33 deletions
diff --git a/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c b/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c
index 19dceda..c252383 100644
--- a/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c
+++ b/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c
@@ -34,8 +34,9 @@ static IMError im_err = IM_ERR_OK;
static void LMI_JournalLogRecordInstanceCreationIndicationInitialize(const CMPIContext *ctx)
{
lmi_init(JOURNAL_CIM_LOG_NAME, _cb, ctx, provider_config_defaults);
- im = im_create_manager(ind_gather, ind_filter_cb, false, ind_watcher,
+ im = im_create_manager(ind_gather, NULL, false, ind_watcher,
IM_IND_CREATION, _cb, &im_err);
+ im_register_filter_classes(im, &journald_allowed_classes[0], &im_err);
}
static CMPIStatus LMI_JournalLogRecordInstanceCreationIndicationIndicationCleanup(
diff --git a/src/journald/instutil.c b/src/journald/instutil.c
index c48f243..44b7ddb 100644
--- a/src/journald/instutil.c
+++ b/src/journald/instutil.c
@@ -381,37 +381,6 @@ bool ind_gather(const IMManager *manager, CMPIInstance **old, CMPIInstance **new
return true;
}
-bool ind_filter_cb(const CMPISelectExp *filter)
-{
- /* TODO: copied from account/indication_common.c, may require generalization */
-
- /*
- * Support only simple conditions and only on allowed_classes
- * and type of `sourceinstance ISA allowed_class'
- */
- CMPIStatus st;
- CMPISelectCond *sec = CMGetDoc(filter, &st);
- if (!sec) return false;
- CMPICount count = CMGetSubCondCountAndType(sec, NULL, &st);
- if (count != 1) return false;
- CMPISubCond *sub = CMGetSubCondAt(sec, 0, &st);
- if (!sub) return false;
- count = CMGetPredicateCount(sub, &st);
- if (count != 1) return false;
- CMPIPredicate *pred = CMGetPredicateAt(sub, 0, &st);
- if (!pred) return false;
- CMPIType type;
- CMPIPredOp op;
- CMPIString *lhs = NULL;
- CMPIString *rhs = NULL;
- st = CMGetPredicateData(pred, &type, &op, &lhs, &rhs);
- if (st.rc != CMPI_RC_OK || op != CMPI_PredOp_Isa) return false;
- const char *rhs_str = CMGetCharsPtr(rhs, &st);
- if (!rhs_str) return false;
- if (strcasecmp(rhs_str, LMI_JournalLogRecord_ClassName) == 0) return true;
- return false;
-}
-
/* --------------------------------------------------------------------------- */
/* TODO: count references to the journal struct -- someone may cancel the iteration
diff --git a/src/journald/instutil.h b/src/journald/instutil.h
index 1ea96a2..23c76af 100644
--- a/src/journald/instutil.h
+++ b/src/journald/instutil.h
@@ -28,6 +28,10 @@
#include <ind_manager.h>
#include "LMI_JournalLogRecord.h"
+static const char* journald_allowed_classes[] = {
+ LMI_JournalLogRecord_ClassName,
+ NULL};
+
int create_LMI_JournalLogRecordRef(sd_journal *j, LMI_JournalLogRecordRef *ref, const CMPIBroker *_cb);
int create_LMI_JournalLogRecord(sd_journal *j, LMI_JournalLogRecord *rec, const CMPIBroker *_cb);
@@ -35,7 +39,6 @@ int match_journal_record(sd_journal *j, const char *message, const char *code_fu
void ind_init();
bool ind_watcher(void **data);
-bool ind_filter_cb(const CMPISelectExp *filter);
bool ind_gather(const IMManager *manager, CMPIInstance **old, CMPIInstance **new, void *data);
void ind_destroy();