.TH "FBB::Hostent" "3bobcat" "2005\-2020" "libbobcat\-dev_5\&.07\&.00" "struct hostent wrapper" .PP .SH "NAME" FBB::Hostent \- Wrapper around a \fBstruct hostent\fP .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" \fB@CLASS\fP objects are wrappers around \fBhostent\fP structs which may be used by other objects\&. A \fBstruct hostent\fP is defined as follows: .nf 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 } .fi .PP The \fIaddress\fP fields are binary values of the addresses, each address requiring \fIh_length\fP bytes, the last address being equal to 0\&. The \fB@CLASS\fP objects offer a \fBC++\fP\-like interface to this struct\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \- .PP .SH "CONSTRUCTORS" .IP o \fBHostent(hostent const *hostentPtr)\fP: .br This constructor initializes an \fB@CLASS\fP object from an existing \fBhostent\fP struct\&. Functions like \fBgethostbyname\fP(3) and \fBgethostbyaddress\fP(3) return pointers to \fBhostent\fP structs\&. .PP The default, copy and move constructors (and the copy and move assignment operators) are available\&. .PP .SH "MEMBER FUNCTIONS" .PP .IP o \fBsize_t addressLength() const\fP: .br This member returns the length of the binary addresses in bytes\&. .IP o \fBsize_t addressType() const\fP: .br This member returns the type of the address\&. Currently this is always \fBAF_INET\fP\&. .IP o \fBchar const *alias(size_t index) const\fP: .br This member returns alias `\fIindex\fP\(cq\& of the host\&. The first alias has \fIindex 0\fP\&. If alias `\fIindex\fP\(cq\& does not exist, 0 is returned\&. .IP o \fBchar const * const *beginAlias() const\fP: .br This member returns an iterator to the first alias\&. The hostname itself is not included in the list of aliases\&. .IP o \fBchar const *binaryAddress(size_t index) const\fP: .br This member returns the binary address `\fIindex\fP\(cq\& of the host\&. The first address has \fIindex 0\fP\&. If address `\fIindex\fP\(cq\& does not exist, 0 is returned\&. The pointer to the binary address points to a series of \fBaddressLength()\fP bytes\&. Note that the returned address is in \fInetwork byte order\fP\&. It can be converted to host byte order by the functions described in \fBbyteorder\fP(3)\&. .IP o \fBstd::string dottedDecimalAddress(size_t index) const\fP: .br This member returns address `\fIindex\fP\(cq\& as a dotted decimal address in a string\&. The first address has \fIindex 0\fP\&. If address `\fIindex\fP\(cq\& does not exist, an empty string is returned\&. .IP o \fBchar const * const *endAlias() const\fP: .br This member returns an iterator pointing beyond the last alias\&. .IP o \fBchar const *hostname() const\fP: .br This member returns the standard (first) name of the host\&. .IP o \fBsize_t nAddresses() const\fP: .br This member returns the number of addresses that are available\&. When requesting a particular address, the requested index should be less than the value returned by this member\&. .IP o \fBsize_t nAliases() const\fP: .br This member returns the number of aliases that are available\&. When requesting a particular alias, the requested index should be less than the value returned by this member\&. .IP o \fBvoid swap(Hostent &other)\fP: .br The current \fIHostent\fP object\(cq\&s content are swapped with the other object\(cq\&s content\&. .PP .SH "EXAMPLE" .nf #include #include #include #include using namespace std; using namespace FBB; int main(int argc, char **argv) { Hostent he(gethostbyname(\(dq\&localhost\(dq\&)); cout << \(dq\&The local hostname = \(dq\& << he\&.hostname() << endl; cout << \(dq\&All aliases: \(dq\& << endl; copy(he\&.beginAlias(), he\&.endAlias(), ostream_iterator(cout, \(dq\&\en\(dq\&)); cout << \(dq\&Addresses:\en\(dq\&; for (size_t idx = 0; idx < he\&.nAddresses(); idx++) cout << he\&.dottedDecimalAddress(idx) << endl; } .fi .PP .SH "FILES" \fIbobcat/hostent\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7) .PP .SH "BUGS" None Reported\&. .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_5\&.07\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_5\&.07\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_5\&.07\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP