From 3c1668da6202f1ead3d4d3981b89e9da1a0e98e3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 18 Oct 2012 03:29:19 +0200 Subject: 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. --- src/shared/hashmap.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/shared/hashmap.c') 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; +} -- cgit v1.2.3-54-g00ecf