diff options
Diffstat (limited to 'src/cache/cache.c')
-rw-r--r-- | src/cache/cache.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/cache/cache.c b/src/cache/cache.c index 7080240..e8796f7 100644 --- a/src/cache/cache.c +++ b/src/cache/cache.c @@ -1,9 +1,13 @@ /* ISC license. */ -#include <skalibs/uint64.h> +#include <string.h> + +#include <skalibs/uint16.h> #include <skalibs/posixplz.h> #include <skalibs/strerr.h> +#include <s6-dns/s6dns-domain.h> + #include <shibari/dcache.h> #include "shibari-cache-internal.h" @@ -34,3 +38,16 @@ void cache_load (void) strerr_warnwu2sys("load cache contents from ", g->dumpfile) ; } } + +int cache_search (s6dns_domain_t const *name, uint16_t qtype, dcache_key_t *data) +{ + dcache_node_t *node ; + char key[name->len + 1] ; + uint16_pack_big(key, qtype) ; + memcpy(key + 2, name->s, name->len - 1) ; + node = dcache_search(&cache, key, name->len + 1) ; + if (!node) return 0 ; + data->s = node->key.s + node->key.len ; + data->len = node->datalen ; + return 1 ; +} |