From 262c4593ac6df668ed4d4d899c68a256fb237214 Mon Sep 17 00:00:00 2001 From: arf20 Date: Mon, 1 Dec 2025 22:40:25 +0100 Subject: wip querying --- index.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'index.c') diff --git a/index.c b/index.c index 34e354c..44864bb 100644 --- a/index.c +++ b/index.c @@ -183,7 +183,7 @@ index_new(size_t icapacity, const char *dir, int examine) /* recurse */ map_t *child = NULL; if (de->d_type == DT_DIR) { - index_new(icapacity, path); + index_new(icapacity, path, examine); } map_insert(map, de->d_name, data, child); @@ -192,7 +192,7 @@ index_new(size_t icapacity, const char *dir, int examine) return map; } -int +void index_lookup_substr(map_t *index, const char *query, results_t *results) { @@ -200,12 +200,29 @@ index_lookup_substr(map_t *index, const char *query, if (!index->map[i].data) continue; - for (struct node_s *node = &index->map[i]; node->next; node = node->next) - if (strstr(node->data.name, query)) - results_insert(results, ) + for (struct node_s *node = &index->map[i]; node->next; node = node->next) { + if (strstr(node->data->name, query)) + results_insert(results, node->data); + if (node->child) + index_lookup_substr(node->child, query, results); + } } } +void +index_lookup_substr_nocase(map_t *index, const char *query, + results_t *results) +{ + +} + +void +index_lookup_regex(map_t *index, const char *query, + results_t *results) +{ + +} + results_t * index_lookup(map_t *index, lookup_type_t type, const char *query) { @@ -213,10 +230,18 @@ index_lookup(map_t *index, lookup_type_t type, const char *query) switch (type) { case LOOKUP_SUBSTR: - return index_lookup_substr(index, query, results); + index_lookup_substr(index, query, results); + break; + case LOOKUP_SUBSTR_NOCASE: + index_lookup_substr_nocase(index, query, results); + break; + case LOOKUP_REGEX: + index_lookup_regex(index, query, results); break; } + + return results; } void -- cgit v1.2.3