gethostent_r()--Get Next Entry from Host Database


  Syntax
 #include <netdb.h>
 int gethostent_r(struct hostent
                     *hostent_struct_addr,
                  struct hostent_data
                     *hostent_data_struct_addr)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: Yes

The gethostent_r() function is used to retrieve information from the host database file. When the gethostent_r() is first called, the file is opened, and the first entry is returned. Each subsequent call of gethostent_r() results in the next entry in the file being returned. To close the file, use endhostent_r().


Parameters

struct hostent *hostent_struct_addr  (input/output) 
Specifies the pointer to a hostent structure where the results will be placed. All results must be referenced through this structure.

struct hostent_data *hostent_data_struct_addr  (input/output) 
Specifies the pointer to the hostent_data structure, which is used to pass and preserve results between function calls. The field host_control_blk in the hostent_data structure must be initialized with hexadecimal zeros before its initial use. If compatibility with other platforms is required, then the entire hostent_data structure must be initialized to hexadecimal zeros before initial use.

Authorities

No authorization is required.


Return Value

The gethostent_r() function returns an integer. Possible values are:

The struct hostent denoted by hostent_struct_addr and struct hostent_datadenoted by hostent_data_struct_addr are both defined in <netdb.h>. The structure struct hostentis defined as:

      struct hostent [
        char   *h_name;
        char   **h_aliases;
        int    h_addrtype;
        int    h_length;
        char   **h_addr_list;
      ];

      #define h_addr  h_addr_list[0]

h_name points to the character string that contains the name of the host. h_aliases is a pointer to a NULL-terminated list of pointers, each of which points to a character string that represents an alternative name for the host. h_addrtype contains the address type of the host (for example, af_inet). h_length contains the size of an address in octets (for example, the size of an Internet address is 4 octets). h_addr_list is a pointer to a NULL-terminated list of pointers, each of which points to a network address (in network byte order) for the host.


Error Conditions

When the gethostent_r() function fails, errno can be set to:

[EINVAL]

The hostent_data structure was not properly initialized to hexadecimal zeros before initial use. For corrective action, see the description for structure hostent_data.



Usage Notes

  1. The iSeries Navigator or the following CL commands can be used to access the host database file:


  2. A coded character set identifier (CCSID) of 65535 for the job requests that no database translation be performed. For translation to occur for the host names returned in the hostent structure, the job CCSID must be something other than 65535.

Related Information



API introduced: V3R1
Top | UNIX-Type APIs | APIs by category