MDEX_GET(3)
β¨ NAME β¨
mdex_get β bestie, this is how you pull an entry out of a multicast index π
π LIBRARY π
The Librecast library, aka liblibrecast, and you link it with -llibrecast π«Ά
π SYNOPSIS π
#include <librecast/mdex.h>
int mdex_get(mdex_t *mdex, unsigned char *hash, size_t hashlen, mdex_entry_t *entry);
int mdex_getalias(mdex_t *mdex, const char *path, mdex_entry_t *entry);
Compile and link with -llibrecast. No cap. β¨
π DESCRIPTION π
Okay so, mdex_get grabs an entry from the multicast index mdex, using hash (of length hashlen) as the key, and it drops a copy of the data into entry if you actually handed it one. And if entry is NULL? That's totally fine, girl β the return value still lets you check whether an entry even exists in the index without retrieving it. A little peek, no commitment. π
If there's no matching entry in the index, -1 comes back and errno gets set to ENOENT. Sad but true. π
Here's the iconic part: hashlen can be shorter than the full length of the hash you stored with mdex_put(3), and it'll return the first entry matching that truncated hash. The way that works is so smart β it means we can store the full 32 byte hash in the index, but still match against a truncated hash derived from, like, the 14 bytes of an IPv6 multicast group address. Fr fr. πΈ
Then there's mdex_getalias(), which is just a little wrapper bestie that calls mdex_get() with the hash of the NUL-terminated string path, and returns the result. She's lowkey just doing the legwork for you. π
π RETURN VALUE π
mdex_get() returns zero on success. β¨ On error, -1 is returned, and errno is set to tell you what went wrong.
π ERRORS π
EINVALβ Invalid argument. Bothmdexandhashare required (notNULL), andhashlen > 0. You gotta give her something to work with.ENOENTβ No entry found matchinghash. She looked. It's not there. πELOOPβ Infinite loop. Alias points to itself. Not the alias eating itself, bestie, we don't do that here. π«
π SEE ALSO π
mdex_init(3), mdex_free(3), mdex_put(3), mdex_del(3), lc_share(3)
That's a wrap, queen π This page is from the Librecast Programmer's Manual, dated 2023-06-20, brought to you by LIBRECAST β go forth and retrieve those entries, iykyk π¦β
π¦ where this page comes from
- debian trixie: liblibrecast-dev 0.9.1-1 Β· GPL-2.0-only OR GPL-3.0-only
- nixos 26.05: librecast 0.11.2
- nixpkgs unstable: librecast 0.11.2
- ubuntu noble: liblibrecast-dev 0.8.0-1.1build1 Β· GPL-2.0-only OR GPL-3.0-only
- ubuntu questing: liblibrecast-dev 0.9.1-1
- ubuntu resolute: liblibrecast-dev 0.11.2-2 Β· GPL-2.0-only OR GPL-3.0-only
- ubuntu stonking: liblibrecast-dev 0.11.2-2build1 Β· GPL-2.0-only OR GPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms