summaryrefslogtreecommitdiff
path: root/src/shared/hashmap.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-10-18 03:29:19 +0200
committerLennart Poettering <lennart@poettering.net>2012-10-18 03:35:18 +0200
commit3c1668da6202f1ead3d4d3981b89e9da1a0e98e3 (patch)
treed4e2785f1dac02c19797373bb4342354e1958e9d /src/shared/hashmap.c
parent86b2e20a5e5abf222fb81edcb5d58d012e35cbaa (diff)
journal: add ability to list values a specified field can take in all entries of the journal
The new 'unique' API allows listing all unique field values that a field specified by a field name can take in all entries of the journal. This allows answering queries such as "What units logged to the journal?", "What hosts have logged into the journal?", "Which boot IDs have logged into the journal?". Ultimately this allows implementation of tools similar to lastlog based on journal data. Note that listing these field values will not work for journal files created with older journald, as the field values are not indexed in older files.
Diffstat (limited to 'src/shared/hashmap.c')
-rw-r--r--src/shared/hashmap.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c
index eb5c549e40..26a4eff07f 100644
--- a/src/shared/hashmap.c
+++ b/src/shared/hashmap.c
@@ -758,3 +758,25 @@ char **hashmap_get_strv(Hashmap *h) {
return sv;
}
+
+void *hashmap_next(Hashmap *h, const void *key) {
+ unsigned hash;
+ struct hashmap_entry *e;
+
+ assert(h);
+ assert(key);
+
+ if (!h)
+ return NULL;
+
+ hash = h->hash_func(key) % NBUCKETS;
+ e = hash_scan(h, hash, key);
+ if (!e)
+ return NULL;
+
+ e = e->iterate_next;
+ if (!e)
+ return NULL;
+
+ return e->value;
+}