FBB::Hostent(3bobcat)

πŸ’– FBB::Hostent β€” it's in the 3bobcat manual, bestie πŸ’–

okay so welcome to FBB::Hostent(3bobcat), the lil' struct-hostent-wrapper that lives in the bobcat fam. she's giving "glow-up for a C struct" and honestly? she ate. πŸ¦‹


✨ NAME ✨

FBB::Hostent β€” a Wrapper around a struct hostent. that's it, that's the whole vibe πŸ’…


✨ SYNOPSIS ✨

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

yk how you link things β€” you gotta pass -lbobcat or she simply will not show up. periodt. πŸŽ€


🌸 DESCRIPTION 🌸

@CLASS objects are wrappers around hostent structs, and other objects can use them, which is the entire point, no cap. a struct hostent is defined like this, and you're getting it verbatim because we do not mess with the lore:

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
}

so the address fields are binary values of the addresses, and every single address needs h_length bytes to itself. the last address is equal to 0, which is the little "we're done here" signal πŸ›‘. the @CLASS objects are out here offering a C++-like interface to this struct, and honestly she's iconic for it. ✨


πŸ’œ NAMESPACE πŸ’œ

FBB

every constructor, member, operator and manipulator mentioned in this man-page (yes, all of them, i checked 🫢) is defined in the namespace FBB.


🌈 INHERITS FROM 🌈

-

that's a big fat nothing bestie. she inherits from no one. she's self-made. main character energy fr fr. πŸ‘‘


πŸŽ€ CONSTRUCTORS πŸŽ€

  • Hostent(hostent const *hostentPtr) β€” this constructor initializes an @CLASS object from an existing hostent struct. and like, functions such as gethostbyname(3) and gethostbyaddress(3) return pointers to hostent structs, so that's where you'd get your pointer from. πŸ”₯

the default, copy and move constructors (and the copy and move assignment operators) are all available too β€” so you can copy her, move her, whatever. she's flexible. πŸ’…


πŸ¦‹ MEMBER FUNCTIONS πŸ¦‹

  • size_t addressLength() const β€” gives you the length of the binary addresses, in bytes. πŸ“
  • size_t addressType() const β€” gives you the type of the address. currently this is always AF_INET. always. every time. 😌
  • char const *alias(size_t index) const β€” gives you alias index of the host, and the first alias has index 0 (zero-indexed girlies rise up πŸ™ˆ). if alias index doesn't exist, you get 0 back. no alias, no problem.
  • char const * const *beginAlias() const β€” gives you an iterator to the first alias. heads up tho: the hostname itself is not included in the list of aliases. she's separate. independent. πŸ’…
  • char const *binaryAddress(size_t index) const β€” gives you the binary address index of the host, first address is index 0. if address index doesn't exist, 0 comes back. the pointer to the binary address points to a series of addressLength() bytes. note β€” the returned address is in network byte order, and you can convert it to host byte order with the functions described in byteorder(3). so flip it if you need to, bestie. πŸ”„
  • std::string dottedDecimalAddress(size_t index) const β€” gives you address index as a dotted decimal address, in a string, nice and readable. first address is index 0. if address index doesn't exist, you get an empty string. πŸ«™
  • char const * const *endAlias() const β€” gives you an iterator pointing beyond the last alias. classic end-iterator behaviour, we love a range. ✨
  • char const *hostname() const β€” gives you the standard (first) name of the host. her government name, if you will. πŸ“›
  • size_t nAddresses() const β€” gives you the number of addresses available. so when you're requesting a particular address, the index you ask for should be less than the value this member returns. otherwise, nothing. 🚫
  • size_t nAliases() const β€” gives you the number of aliases available. same rule, bestie: when requesting a particular alias, the index you ask for should be less than the value this member returns. πŸ’―
  • void swap(Hostent &other) β€” swaps the current Hostent object's content with the other object's content. theirs is yours, yours is theirs, we're trading 🫢

🌟 EXAMPLE 🌟

here's a whole program, copy it exactly, don't be shy:

#include <iostream>
#include <algorithm>
#include <iterator>
#include <bobcat/hostent>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
{
    Hostent he(gethostbyname("localhost"));

    cout << "The local hostname = " << he.hostname() << endl;

    cout << "All aliases: " << endl;
    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;
}

look at her go. localhost, aliases, addresses, the whole slay. πŸ”₯


πŸ“ FILES πŸ“

  • bobcat/hostent β€” defines the class interface. that's where she lives. that's her address (pun absolutely intended). 🏠

πŸ’€ SEE ALSO πŸ’€

bobcat(7)


πŸ™ˆ BUGS πŸ™ˆ

None Reported.

(we love a clean bug report. ngl, very demure, very mindful. ✨)


πŸ‘‘ BOBCAT PROJECT FILES πŸ‘‘

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.

like. the name is a whole acronym. that's so cool of her. 🫢


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

free software, free as in freedom, free as in you can literally just have it. πŸ’…


🌸 AUTHOR 🌸

Frank B. Brokken (f.b.brokken@rug.nl).


and that's the whole page, bestie!! this one came out as libbobcat-dev_6.15.01 and she's been doing her thing from 2005-2026 β€” a whole era, honestly, she's been serving FBB::Hostent(3bobcat) since forever. mwah. πŸ’‹πŸ’–βœ¨πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from