HESIOD(3)

πŸ’– HESIOD(3) β€” hesiod_getservbyname, hesiod_free_servent πŸ’–

okay bestie, welcome to the Library Functions Manual section, HESIOD(3) girlies πŸŽ€ this one's all about pulling service info out of Hesiod, and honestly? it's giving ✨ networking but make it cute ✨


🌸 NAME 🌸

hesiod_getservbyname, hesiod_free_servent β€” the Hesiod girlies for retrieving service information πŸ’…


✨ SYNOPSIS ✨

#include <hesiod.h>

struct servent *hesiod_getservbyname(void *context,
     const char *name, const char *proto)
void hesiod_free_servent(void *context, struct servent *serv)

cc file.c -lhesiod

so you gotta #include <hesiod.h> first, no cap πŸ“š and when you compile, you link it up with -lhesiod like the icon it is 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

This whole lil family of functions lets you retrieve service to port mappings using Hesiod. obsessed tbh 🌈

To actually perform lookups you need an initialized Hesiod context β€” head over to hesiod(3) for the deets on that, iykyk πŸ‘‘

Information comes back in the same format as by getservbyname πŸ’« and here's the part where you have to be a responsible main character: it is the caller's responsibility to call hesiod_free_servent with the returned service entry, so the resources used by that service entry actually get freed. not me forgetting to free and leaking memory... couldn't be me πŸ™ˆ (it's you. free it. πŸ’€)

Hesiod queries for service information are made using the ``service'' Hesiod type, using the service name as the Hesiod name πŸŽ€

The corresponding records should be space-separated lists of strings giving:

  1. the service name
  2. the protocol
  3. the port number (in decimal)
  4. zero or more aliases for the service

and there may be multiple records per service name, bestie β€” in which case hesiod_getservbyname will pick the first one whose protocol matches proto ⭐ periodt.


πŸ’œ RETURN VALUES πŸ’œ

On failure, hesiod_getservbyname returns NULL and sets the global variable errno to indicate the error. yeah. it's giving failure. it's giving check your errno 😭


πŸ’… ERRORS πŸ’…

hesiod_getservbyname may fail for any of the reasons the routine hesiod_resolve may fail. literally any of them. go read that one, bestie πŸ“


🌟 SEE ALSO 🌟


and that's the whole page, angel 🧚 stay hydrated, free your servents, and remember: errno is not a personality trait πŸ’œ

this was the Library Functions Manual for HESIOD(3), brought to you from way back on 30 November 1996 β€” yes she's vintage, she's an icon, she's aged like fine wine πŸ‘‘βœ¨