ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/tsgserve.htm

191 lines
5.6 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>getservent_r()--Get Next Entry from Service Database</title>
<!-- 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. -->
<!-- Begin Header Records ========================================== -->
<!-- Unix8 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
<!--End Header Records -->
<!-- Edited by Kersten Feb 02 -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<a name="Top_Of_Page"></a>
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<h2>getservent_r()--Get Next Entry from Service Database</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;netdb.h&gt;
int getservent_r(struct servent *<em>servent_struct_addr</em>,
struct servent_data
*<em>servent_data_struct_addr</em>)
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QSOSRV2<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <em>getservent_r()</em> function is used to retrieve information about
services: the protocol being used by the service and the port number assigned
for the service. The information is retrieved from the services database file.
When the <em>getservent_r()</em> is first called, the file is opened, and the
first entry is returned. Each subsequent call of <em>getservent_r()</em>
results in the next entry in the file being returned. To close the file, use
<em>endservent_r()</em>.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt>struct servent *<strong>servent_struct_addr</strong>
&nbsp;(input/output)&nbsp;</dt>
<dd>Specifies the pointer to a servent structure where the results will be
placed. All results must be referenced through this structure.<br>
<br>
</dd>
<dt>struct servent_data *<strong>servent_data_struct_addr</strong>
&nbsp;(input/output)&nbsp;</dt>
<dd>Specifies the pointer to the servent_data structure, which is used to pass
and preserve results between function calls. The field serve_control_blk in the
servent_data structure must be initialized with hexadecimal zeros before its
initial use. If compatibility with other platforms is required, then the entire
servent_data structure must be initialized with hexadecimal zeros before
initial use.</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>No authorization is required.</p>
<br>
<h3>Return Value</h3>
<p>The <em>getservent_r()</em> function returns an integer. Possible values
are:</p>
<ul>
<li>-1 (unsuccessful call)</li>
<li>0 (successful call)</li>
</ul>
<p>The <strong>struct servent</strong> denoted by
<strong><em>servent_struct_addr</em></strong> and <strong>struct
servent_data</strong>denoted by
<strong><em>servent_data_struct_addr</em></strong> are both defined in
<strong>&lt;netdb.h&gt;</strong>. The structure <strong>struct
servent</strong>is defined as:</p>
<pre>
struct servent [
char *s_name;
char **s_aliases;
int s_port;
char *s_proto
];
</pre>
<p><em>s_name</em> points to the character string that contains the name of the
service. <em>s_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 service. <em>s_port</em> is the port number assigned to the service.
<em>s_proto</em> is a pointer to a character string that contains the name of
the protocol being used by the service.</p>
<br>
<h3>Error Conditions</h3>
<p>When the <em>getservent_r()</em> function fails, <em>errno</em> can be set
to:</p>
<dl>
<dt><em><samp>[einval]</samp></em></dt>
<dd><p>The servent_data structure was not properly initialized with hexadecimal zeros before
initial use. For corrective action, see the description for structure servent_data.</p></dd>
</dl>
<br>
<h3>Usage Notes</h3>
<p>The iSeries Navigator or the following CL commands can be
used to access the services database file:</p>
<ul>
<li>WRKSRVTBLE (Work with Service Table Entries)</li>
<li>ADDSRVTBLE (Add Service Table Entry)</li>
<li>RMVSRVTBLE (Remove Service Table Entry)</li>
</ul>
<p>A coded character set identifier (CCSID) of 65535 for the job requests that
no database translation be performed. For translation to occur for the service
names returned in the servent structure, the job CCSID must be something other
than 65535.</p>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="tsgservn.htm">getservbyname_r()</a>--Get Port Number for Service
Name<br>
<br>
</li>
<li><a href="tsgservp.htm">getservbyport_r()</a>--Get Service Name for Port
Number<br>
<br>
</li>
<li><a href="tssserve.htm">setservent_r()</a>--Open Service Database<br>
<br>
</li>
<li><a href="tseserve.htm">endservent_r()</a>--Close Service 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>