197 lines
5.3 KiB
HTML
197 lines
5.3 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
|
<title>gethostent()--Get Next Entry from Host Database</title>
|
|
<!-- Begin Header Records ========================================== -->
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<!-- Change History: -->
|
|
<!-- Unix8 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- Edited by Kersten Feb 02 -->
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body>
|
|
<!--End Header Records -->
|
|
<!-- Java sync-link -->
|
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
|
</script>
|
|
|
|
<a name="Top_Of_Page"></a>
|
|
|
|
<h2>gethostent()--Get Next Entry from Host Database</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
Syntax<br>
|
|
<pre>
|
|
#include <netdb.h>
|
|
|
|
struct hostent *gethostent()
|
|
</pre>
|
|
|
|
<br>
|
|
Service Program Name: QSOSRV2<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: No; see <a href="#USAGE_NOTES">Usage Notes</a>.<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <em>gethostent()</em> function is used to retrieve information from the
|
|
host database file. When <em>gethostent()</em> is first called, the file is
|
|
opened, and the first entry is returned. Each subsequent call to
|
|
<em>gethostent()</em> results in the next entry in the file being returned. To
|
|
close the file, use <em>endhostent()</em>.</p>
|
|
|
|
<br>
|
|
<h3>Authorities</h3>
|
|
|
|
<p>No authorization is required.</p>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<p><em>gethostent()</em> returns a pointer. Possible values are:</p>
|
|
|
|
|
|
<ul>
|
|
<li>NULL (unsuccessful or end-of-file)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>p (successful), where p is a pointer to <strong>struct
|
|
hostent</strong>.</li>
|
|
</ul>
|
|
|
|
|
|
<p>The structure <strong>struct hostent</strong> is defined in
|
|
<strong><netdb.h></strong>.</p>
|
|
|
|
<pre>
|
|
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]
|
|
</pre>
|
|
|
|
<p><em>h_name</em> points to the character string that contains the name of the
|
|
host. <em>h_aliases</em> 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. <em>h_addrtype</em> contains the address type of the host (for
|
|
example, <samp>AF_INET</samp>). <em>h_length</em> contains the address length.
|
|
<em>h_addr_list</em> is a pointer to a NULL-terminated list of pointers, each
|
|
of which points to a network address for the host, in network byte order. Note
|
|
that the array of address pointers points to structures of type
|
|
<strong>in_addr</strong> defined in <strong><netinet/in.h></strong>.</p>
|
|
|
|
<br>
|
|
<h3><a name="USAGE_NOTES">Usage Notes</a></h3>
|
|
|
|
<ol>
|
|
<li>The iSeries Navigator or the following CL commands can be
|
|
used to access the host database file:
|
|
|
|
<ul>
|
|
<li>ADDTCPHTE (Add TCP/IP Host Table Entry)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>RMVTCPHTE (Remove TCP/IP Host Table Entry)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>CHGTCPHTE (Change TCP/IP Host Table Entry)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>RNMTCPHTE (Rename TCP/IP Host Table Entry)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>MRGTCPHT (Merge TCP/IP Host Tables)</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>The pointer returned by <em>gethostent()</em> points to static storage that
|
|
is overwritten on subsequent calls to the <em>gethostent()</em>,
|
|
<em>gethostbyaddr()</em>, or <em>gethostbyname()</em> functions.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>A coded character set identifier (CCSID) of 65535 requests that no database
|
|
translation be performed. For translation to occur for the host names in the
|
|
hostent structure, the job CCSID must be something other than 65535.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>Do not use the <em>gethostent()</em> function in a multithreaded
|
|
environment. See the multithread alternative <em>gethostent_r()</em>
|
|
function.<br><br></li>
|
|
|
|
<li>When you develop in C-based languages and an application is compiled with the _XOPEN_SOURCE
|
|
macro defined to the value 520 or greater, the <em>gethostent()</em> API is mapped to
|
|
<em>qso_gethostent98()</em>.</li>
|
|
</ol>
|
|
|
|
<br>
|
|
|
|
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li><a href="_xopen_source.htm">_XOPEN_SOURCE</a>--Using _XOPEN_SOURCE for the
|
|
UNIX 98 compatible interface<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="ghosta.htm">gethostbyaddr()</a>--Get Host Information for IP
|
|
Address<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="ghostnm.htm">gethostbyname()</a>--Get Host Information for Host
|
|
Name<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="ehostnt.htm">endhostent()</a>--Close Host Database<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="shostnt.htm">sethostent()</a>--Open Host Database</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<hr>
|
|
API introduced: V3R1
|
|
|
|
<hr>
|
|
<center>
|
|
<table cellpadding="2" cellspacing="2">
|
|
<tr align="center">
|
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a> </td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</body>
|
|
</html>
|
|
|