#include <sys/types.h> #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> const char * res_hostalias(const state* res, const char* name, char* destination, size_t destination_length)
The res_hostalias() looks up the specified name in the host aliases file specified by the environment variable HOSTALIASES.
A user may create a host aliases file. This file maps user defined aliases to host names, unlike the i5/OS host table (or a DNS) which maps host names to ip addresses. Also, it requires no special authorities for a user to define an alias. It's simply a shorthand for a server which can be easily changed and controlled by users. No iSeries server default alias file is created.
The format is simply an alias followed by blank(s) followed by a domain name. For example, mypc may be an alias for m999.mydomain.ibm.com and myaix may be an alias for m111.mydomain.ibm.com:
mypc m999.mydomain.ibm.com.
myaix m111.mydomain.ibm.com
Other functions, like res_nsearch() or gethostbyname_r() will resolve an alias like "mypc" to the full domain name "m999.mydomain.ibm.com." before querying the DNS or i5/OS host table.
Note:An alias may not contain periods.
Authorization of *R (allow access to the object) to the host aliases file specified by the HOSTALIASES environment variable.
You also need *X authority to each directory in the path of the host aliases file.
(NULL) No alias found or an error occurred.
(destination) A pointer to the destination buffer updated with the alias found.
When the res_hostalias() function fails, errno can be set to one of the following:
Permission denied. The process does not have the appropriate privileges to the host aliases file specified by the HOSTALIASES environment variable.
The system detected a pointer that was invalid while attempting to access an input pointer.
One of the following reasons:
Top | UNIX-Type APIs | APIs by category |