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

190 lines
4.6 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!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>xdr_enum()--Translate between Enumeration and XDR</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 ========================================== -->
<!-- RPCMST SCRIPT A converted by B2H R4.1 (346) (CMS) by PMHALL at -->
<!-- RCHVMW2 on 7 Oct 1998 at 23:43:14 -->
<!-- 041209 EMIG Add note to use ENUM(*INT) compiler option -->
<!-- Edited by Kersten Feb 02 -->
<!--End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<a name="Top_of_Page"></a>
<!-- Java sync-link -->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<h2>xdr_enum()--Translate between Enumeration and XDR</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;rpc/xdr.h&gt;
bool_t xdr_enum(XDR *<em>xdrs</em>,
enum_t *<em>ep</em>);
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QZNFTRPC<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: No<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>xdr_enum</strong> function is a filter primitive that translates
between C-language enumeration (enum) and its external representation.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>xdrs</strong> &nbsp;(Input)&nbsp;</dt>
<dd>A pointer to the eXternal Data Representation (XDR) stream handle.<br>
<br>
</dd>
<dt><strong>ep</strong> &nbsp;(I/O)&nbsp;</dt>
<dd>The address of the enumeration data.</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>No authorization is required.</p>
<br>
<img src="delta.gif" alt="Start of change">
<h3>Notes</h3>
<p>Callers of the xdr_enum() function should ensure that <strong>ep</strong>
points to a 4 byte location in memory. The ENUM(*INT) compiler option should
be used when compiling code that calls xdr_enum() to ensure that enumerated
data types are represented internally as integers. Failure to do so, may
cause unexpected values to be encoded to the XDR data stream.</p>
<img src="deltaend.gif" alt="End of change">
<br>
<h3>Return Value</h3>
<table cellpadding="5">
<!-- cols="15 85" -->
<tr>
<td align="left" valign="top"><em>TRUE (1)</em></td>
<td align="left" valign="top">Successful</td>
</tr>
<tr>
<td align="left" valign="top"><em>FALSE (0)</em></td>
<td align="left" valign="top">Unsuccessful</td>
</tr>
</table>
<br>
<br>
<h3>Error Conditions</h3>
<p>None.</p>
<br>
<h3>Error Messages</h3>
<table width="100%" cellpadding="5">
<!-- cols="15 85" -->
<tr>
<th align="left" valign="top">Message ID</th>
<th align="left" valign="top">Error Message Text</th>
</tr>
<tr>
<td width="15%" valign="top">CPE3418 E</td>
<td width="85%" valign="top">Possible APAR condition or hardware failure.</td>
</tr>
<tr>
<td align="left" valign="top">CPF3CF2 E</td>
<td align="left" valign="top">Error(s) occurred during running of &amp;1
API.</td>
</tr>
<tr>
<td align="left" valign="top">CPF9872 E</td>
<td align="left" valign="top">Program or service program &amp;1 in library
&amp;2 ended. Reason code &amp;3.</td>
</tr>
</table>
<br>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>The following example shows how <strong>xdr_enum()</strong> is used:</p>
<pre>
#include &lt;stdio.h&gt;
#include &lt;xdr.h&gt;
typedef enum fruit_state { green, ripe } fruit_state;
typedef enum fruit_weight { small, sufficient } fruit_weight;
typedef struct fruit
{
fruit_state state;
fruit_weight weight;
} fruit;
bool xdr_fruit(XDR *xdrs, fruit *p_fruit)
{
if(!<strong>xdr_enum</strong>(xdrs,(enum_t *)&amp;(p_fruit-&gt;state)))
return FALSE;
return <strong>xdr_enum</strong>(xdrs,
(enum_t *)&amp;(p_fruit-&gt;weight));
}
</pre>
<hr>
API introduced: V4R2
<hr>
<table cellpadding="2" cellspacing="2" align="center">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"rpc1.htm">Remote Procedure Call (RPC) APIs</a> | <a href="aplist.htm">APIs by
category</a></td>
</tr>
</table>
</body>
</html>