diff options
| author | arf20 <aruizfernandez05@gmail.com> | 2025-12-01 22:40:25 +0100 |
|---|---|---|
| committer | arf20 <aruizfernandez05@gmail.com> | 2025-12-01 22:40:25 +0100 |
| commit | 262c4593ac6df668ed4d4d899c68a256fb237214 (patch) | |
| tree | 81ecfd72099fc4d7def7a80ba73a7d0d5998cffc /index.c | |
| parent | 058f3f3af1f3f15d2dacc04df8bc339301cf3a7c (diff) | |
| download | arfnet2-search-262c4593ac6df668ed4d4d899c68a256fb237214.tar.gz arfnet2-search-262c4593ac6df668ed4d4d899c68a256fb237214.zip | |
wip querying
Diffstat (limited to 'index.c')
| -rw-r--r-- | index.c | 37 |
1 files changed, 31 insertions, 6 deletions
@@ -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 |
