libwget-dns-caching(3)

πŸ’… libwget-dns-caching β€” DNS caching, bestie edition

okay so this is libwget-dns-caching(3), a Library Functions Manual page, and it's literally all about DNS caching. no cap. it's part of the wget2 crew. let's get into it πŸ¦‹


✨ NAME ✨

libwget-dns-caching β€” DNS caching

like. that's it. that's the whole vibe. it caches DNS lookups so you're not out here asking the resolver the same question forty times like a clown πŸ’€


🌸 SYNOPSIS 🌸

πŸŽ€ Data Structures

  • struct cache_entry
  • struct wget_dns_cache_st

🧚 Functions

int wget_dns_cache_init (wget_dns_cache **cache)
void wget_dns_cache_free (wget_dns_cache **cache)
struct addrinfo * wget_dns_cache_get (wget_dns_cache *cache, const char
    *host, uint16_t port)
int wget_dns_cache_add (wget_dns_cache *cache, const char *host,
    uint16_t port, struct addrinfo **addrinfo)

πŸ”₯ DETAILED DESCRIPTION πŸ”₯

DNS cache management functions. that's the whole thing, bestie β€” the entire job of this lil library is keeping your DNS answers around so you don't have to go ask again. main character energy fr fr πŸ’–


⭐ FUNCTION DOCUMENTATION ⭐

πŸ’œ int wget_dns_cache_init (wget_dns_cache ** cache)

Parameters

  • cache β€” pointer to return newly allocated and initialized wget_dns_cache instance

Returns

  • WGET_E_SUCCESS if OK
  • WGET_E_MEMORY if out-of-memory
  • WGET_E_INVALID if the mutex initialization failed

Allocates and initializes a wget_dns_cache instance. it's giving "birth of a cache" 🍼✨


πŸ’– void wget_dns_cache_free (wget_dns_cache ** cache)

Parameters

  • [in/out] cache β€” pointer to wget_dns_cache instance that will be freed and NULLified

Free the resources allocated by wget_dns_cache_init(). so like, when you're done with your lil cache baby, this is how you let it go. and yes, it NULLifies the pointer too, so no dangling drama afterward. iconic 🫢


πŸ¦‹ struct addrinfo * wget_dns_cache_get (wget_dns_cache * cache, const char * host, uint16_t port)

Parameters

  • cache β€” a wget_dns_cache instance, created by wget_dns_cache_init().
  • host β€” hostname to look up
  • port β€” port to look up

Returns

  • the cached addrinfo structure, or NULL if not found

so you hand it a host + port and it's like "oh bestie I already know this one" and hands you back the cached addrinfo. if it doesn't know? NULL. no hard feelings πŸ’€


🌈 int wget_dns_cache_add (wget_dns_cache * cache, const char * host, uint16_t port, struct addrinfo ** addrinfo)

Parameters

  • cache β€” a wget_dns_cache instance, created by wget_dns_cache_init().
  • host β€” hostname part of the key
  • port β€” port part of the key
  • [in/out] addrinfo β€” addrinfo structure to cache, returns cached addrinfo

Returns

  • WGET_E_SUCCESS on success, else a WGET_E_* error value

this function adds addrinfo to the given DNS cache cache. πŸ‘‘

If an entry for [host,port] already exists, addrinfo is free'd and replaced by the cached entry.

⚠️ do NOT free addrinfo yourself β€” this will be done when the whole cache is freed. like, hands off, bestie, that's not yours to yeet πŸ™ˆ

πŸ‘‘ AUTHOR πŸ‘‘

Generated automatically by Doxygen for wget2 from the source code. so nobody hand-wrote this, it's a robot's lil masterpiece, and honestly? it ate πŸ’…


okay that's the whole page!! this was libwget-dns-caching(3) from the wget2 girlies, Version 2.3.0 β€” cache responsibly, free your caches, and never free an addrinfo you didn't own. periodt. πŸŽ€βœ¨πŸŒΈ

πŸ“¦ where this page comes from