index: mmap: add support for searching
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Fri, 2 Dec 2011 19:49:03 +0000 (17:49 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Sat, 3 Dec 2011 06:07:16 +0000 (04:07 -0200)
Almost a clean copy & paste from the previous implementation.

libkmod/libkmod-index.c
libkmod/libkmod-index.h

index b20aeec..8df0f71 100644 (file)
@@ -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;
+}
index e611eee..9fb96e3 100644 (file)
@@ -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