From b797b7918335e9bb22842d2e9c16e87577e85233 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Fri, 2 Dec 2011 17:49:03 -0200 Subject: [PATCH] index: mmap: add support for searching Almost a clean copy & paste from the previous implementation. --- libkmod/libkmod-index.c | 18 ++++++++++++++++++ libkmod/libkmod-index.h | 1 + 2 files changed, 19 insertions(+) diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c index b20aeec1..8df0f710 100644 --- a/libkmod/libkmod-index.c +++ b/libkmod/libkmod-index.c @@ -756,3 +756,21 @@ static char *index_mm_search_node(struct index_mm_node *node, const char *key, return NULL; } + +/* + * Search the index for a key + * + * Returns the value of the first match + * + * The recursive functions free their node argument (using index_close). + */ +char *index_mm_search(struct index_mm *idx, const char *key) +{ + struct index_mm_node *root; + char *value; + + root = index_mm_readroot(idx); + value = index_mm_search_node(root, key, 0); + + return value; +} diff --git a/libkmod/libkmod-index.h b/libkmod/libkmod-index.h index e611eeeb..9fb96e3c 100644 --- a/libkmod/libkmod-index.h +++ b/libkmod/libkmod-index.h @@ -166,5 +166,6 @@ void index_values_free(struct index_value *values); struct index_mm; struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename); void index_mm_close(struct index_mm *index); +char *index_mm_search(struct index_mm *idx, const char *key); #endif -- 2.47.3