FBB::GetHostent(3bobcat)

πŸ’– FBB::GetHostent πŸ’–

okay bestie, buckle up, because we're about to talk about host information ✨ this one lives in the FBB::GetHostent(3bobcat) manual page, and no cap, it's lowkey the plug for getting a hostent struct out of a hostname or an address 🌸


✨ NAME ✨

FBB::GetHostent β€” get yourself a hostent struct from a hostname or an -address πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <bobcat/gethostent>
Linking option: -lbobcat

🌸 DESCRIPTION 🌸

so here's the vibe: FBB::GetHostent objects produce hostent structs, and those structs get used by other types of objects. that's literally the whole point πŸ’…. which means the FBB::GetHostent class is primarily used as a base-class for other classes, and it's seldomly used stand-alone. yes bestie, stand-alone in quotes, that's how the original says it 😭.

the hostent structs are static structs, but you can get a non-static copy using an FBB::Hostent object 🫢.

a hostent struct is defined like this, and I'm giving it to you verbatim because character-for-character matters:

struct hostent
{
    char    *h_name;        // official name of host
    char    **h_aliases;    // alias list
    int     h_addrtype;     // host address type (always AF_INET)
    int     h_length;       // length of address
    char    **h_addr_list;  // list of addresses
}

the address fields are the binary values of the addresses πŸ‘€, and each address needs h_length bytes, with the last address being equal to 0. and if you want those binary values as character-representations? use the addressToString() member, which internally uses inet_ntop() ⭐.


πŸ‘‘ NAMESPACE πŸ‘‘

FBB

every single constructor, member, operator and manipulator mentioned in this man-page is defined in the namespace FBB. periodt πŸ’…


🧚 INHERITS FROM 🧚

-

that's it. nothing. inherits from nobody. it's giving independent main character energy ✨


πŸŽ€ CONSTRUCTORS πŸŽ€

all members of the class FBB::GetHostent are static. so like, there is no need to construct an FBB::GetHostent object. you can just... use it. iconic 🌈


πŸ’œ STATIC MEMBERS πŸ’œ

  • hostent const *gethostent(char const *errorprefix, std::string const &nameOrAddress) β€” this returns a pointer to a static struct hostent πŸ’– and it holds the info about the host whose name or dotted decimal address you passed as the second argument. the first argument is an error string prefix, and it gets prefixed onto the error message inside an FBB::Exception object. that exception gets thrown when the host's info could not be retrieved 😭 so yeah, wrap it, bestie.
  • std::string addressToString(char const *errorprefix, void const *ads) β€” this one returns the dotted decimal address of the host whose binary address you passed at ads πŸ¦‹. its first argument is an error string prefix, which prefixes the error message in an FBB::Exception object. that object is thrown as an exception when the dotted decimal address could not be determined πŸ™ˆ.
lowkey important caveat: the class' members can only be used when the host whose name or address is searched can be resolved by a name resolution process, e.g., bind(1) ⭐

πŸ”₯ EXAMPLE πŸ”₯

here's the whole thing, exactly as it is, no edits, no cap:

#include <iostream>
#include <algorithm>
#include <iterator>

#include <bobcat/hostent>
#include <bobcat/gethostent>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
try
{
    if (argc == 1)
    {
        cerr << "Provide a host name or host address to solve\n";
        return 1;
    }

    Hostent he(GetHostent::gethostent(argv[1], argv[1]));
    cout << "Hostname: " << he.hostname() << endl;

    cout << "Aliases:\n";
    copy(he.beginAlias(), he.endAlias(),
            ostream_iterator<char const *>(cout, "\n"));

    cout << "Addresses:\n";
    for (size_t idx = 0; idx < he.nAddresses(); idx++)
        cout << he.dottedDecimalAddress(idx) << endl;
}
catch (Exception const &err)
{
    cout << err.what() << endl;
    return 1;
}

πŸ“ FILES πŸ“

bobcat/gethostent β€” defines the class interface πŸ’…


🌈 SEE ALSO 🌈

bind(1), bobcat(7), gethostbyaddr(3) gethostbyname(3), hostent(3bobcat), inetaddress(3bobcat), inet_ntop(3) ✨


πŸ’€ BUGS πŸ’€

None Reported.

(i know. icon behaviour. nothing to report 😌)


🫢 BOBCAT PROJECT FILES 🫢

  • https://fbb-git.gitlab.io/bobcat/ β€” gitlab project page;
  • Debian Bobcat project files:
    • libbobcat6 β€” debian package containing the shared library, changelog and copyright note;
    • libbobcat-dev β€” debian package containing the static library, headers, manual pages, and developer info;

⭐ BOBCAT ⭐

Bobcat is an acronym of Brokken's Own Base Classes And Templates. slay, honestly πŸ’–


This is free software, distributed under the terms of the GNU General Public License (GPL). πŸŽ€


🌸 AUTHOR 🌸

Frank B. Brokken (f.b.brokken@rug.nl). thank you king πŸ‘‘


and that's the whole page, bestie πŸ¦‹ this came out of libbobcat-dev_6.15.01, dated 2005-2026, and honestly? it's giving timeless. obsessed. mwah πŸ’…βœ¨

πŸ“¦ where this page comes from