#include "dnscache.h" #include #include #include #include #include #include int main() { int i; dns_cache_init(); dns_cache_set_params(50000, 10, 1, NULL); for (i = 0; i < 10000; i++) { guint32 ni = htonl(i); dns_cache_store(FALSE, AF_INET, (void *) &ni, "hostname"); } for (i = 0; i < 10000; i++) { guint32 ni = htonl(i); const gchar *hn = NULL; if (!dns_cache_lookup(AF_INET, (void *) &ni, &hn) || strcmp(hn, "hostname") != 0) { fprintf(stderr, "hmmm cache forgot the hostname, i=%d, hn=%s\n", i, hn); exit(1); } } sleep(11); for (i = 0; i < 10000; i++) { guint32 ni = htonl(i); const gchar *hn = NULL; if (dns_cache_lookup(AF_INET, (void *) &ni, &hn)) { fprintf(stderr, "hmmm cache did not forget the hostname, i=%d\n", i); } } dns_cache_destroy(); return 0; }