.TH "FBB::GetHostent" "3bobcat" "2005\-2024" "libbobcat\-dev_6\&.06\&.02" "Host information" .PP .SH "NAME" FBB::GetHostent \- Obtain \fBhostent\fP struct from hostname or \-address .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" \fBFBB::GetHostent\fP objects produce \fIhostent\fP structs which may be used by other types of objects\&. The \fBFBB::GetHostent\fP class is therefore primarily used as a base\-class for other classes and is seldomly used `stand\-alone\(cq\&\&. The \fIhostent\fP structs are static structs, but a non\-static copy may be obtained using an \fBFBB::Hostent\fP object\&. .PP A \fIhostent\fP struct 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 The \fIaddress\fP fields are binary values of the addresses, each address requiring \fIh_length\fP bytes, the last address being equal to 0\&. These binary values may be converted to character\-representations by the \fIaddressToString()\fP member, which uses \fBinet_ntop()\fP, internally\&. .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" All members of the class \fBFBB::GetHostent\fP are static\&. Consequently, there is no need to construct a \fBFBB::GetHostent\fP object\&. .PP .SH "STATIC MEMBERS" .IP o \fBhostent const *gethostent(char const *errorprefix, std::string const &nameOrAddress)\fP: .br The \fBgethostent()\fP member returns a pointer to a static \fBstruct hostent\fP\&. It contains the information about the host whose name or dotted decimal address was provided as its second argument\&. Its first argument is an error string prefix, prefixing the error message in an \fBFBB::Exception\fP object\&. Such an object is thrown as an exception when the host\(cq\&s information could not be retrieved\&. .IP o \fBstd::string addressToString(char const *errorprefix, void const *ads)\fP: .br This member returns the dotted decimal address of the host whose binary address is provided at \fBads\fP\&. Its first argument is an error string prefix, prefixing the error message in an \fBFBB::Exception\fP object\&. Such an object is thrown as an exception when the dotted decimal address could not be determined\&. .IP The class\(cq\& members can only be used when the host whose name or address is searched can be resolved by a name resolution process, e\&.g\&., \fBbind\fP(1)\&. .PP .SH "EXAMPLE" .nf #include #include #include #include #include using namespace std; using namespace FBB; int main(int argc, char **argv) try { if (argc == 1) { cerr << \(dq\&Provide a host name or host address to solve\en\(dq\&; return 1; } Hostent he(GetHostent::gethostent(argv[1], argv[1])); cout << \(dq\&Hostname: \(dq\& << he\&.hostname() << endl; cout << \(dq\&Aliases:\en\(dq\&; 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; } catch (Exception const &err) { cout << err\&.what() << endl; return 1; } .fi .PP .SH "FILES" \fIbobcat/gethostent\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbind\fP(1), \fBbobcat\fP(7), \fBgethostbyaddr\fP(3) \fBgethostbyname\fP(3), \fBhostent\fP(3bobcat), \fBinetaddress\fP(3bobcat), \fBinet_ntop\fP(3) .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_6\&.06\&.02\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_6\&.06\&.02\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_6\&.06\&.02\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_6\&.06\&.02\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_6\&.06\&.02\-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