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

252 lines
6.4 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>svcerr_systemerr()--Send Information to Client for System Error</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 -->
<!-- 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>svcerr_systemerr()--Send Information to Client for System Error</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<!-- iddvc RMBR -->
<br>
<pre>
#include &lt;rpc/rpc.h&gt;
void svcerr_systemerr(const SVCXPRT *<em>xprt</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>svcerr_systemerr()</strong> function sends information to the
remote client that the service dispatch routine detected a system error not
covered by any particular protocol.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>xprt</strong> &nbsp;(Input)&nbsp;</dt>
<dd>A pointer to the RPC service transport handle.</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>No authorization is required.</p>
<br>
<h3>Return Value</h3>
<p>None.</p>
<br>
<h3>Error Conditions</h3>
<p>In case of an exception, the <em>errno</em> global variable is set to
EUNKNOWN.</p>
<br>
<h3>Error Messages</h3>
<table width="100%" cellpadding="5">
<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">CPF3CF2 E</td>
<td width="85%" 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>svcerr_systemerr()</strong> is
used:</p>
<pre>
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt; /* getenv, exit */
#include &lt;rpc/rpc.h&gt;
#define MESSAGEPROG ((unsigned long)(0x20000001))
#define PRINTMESSAGEVERS ((unsigned long)(1))
#define PRINTMESSAGE ((unsigned long)(1))
/* This procedure is called by dispatcher routine */
int *printmessage_l(char **msg, struct svc_req *req)
{
static int result;
char stffl30&quot;;
int fd;
/* Do something with *msg contents */
...
result = 1;
return(&amp;result);
}
/* This is the server dispatcher routine.
It is called when a request arrives from client
and it applies to MESSAGEPROG program number and PRINTMESSAGEVERS
version number */
static void
messageprog_l(struct svc_req *rqstp, SVCXPRT *transp)
{
union u_argument{
char *printmessage_l_arg;
}argument;
char *result;
bool_t (*_xdr_argument)(), (*_xdr_result)();
char *(*local)(union u_argument *, struct svc_req *);
_rpcsvccount++;
switch(rqstp-&gt;rq_proc)
{
/* rqstp-&gt;rq_proc contains the procedure number
of procedure that should be called */
case NULLPROC: /* empty procedure, do nothing, just send the ack */
<strong>svc_sendreply</strong>(transp, (xdrproc_t)xdr_void, (char *)NULL);
return;
case PRINTMESSAGE: /* printmessage_l() */
if (rqstp-&gt;rq_cred.oa_flavor != AUTH_SYS) {
/* AUTH_SYS is required by this procedure */
svcerr_weakauth(transp);
return;
}
_xdr_argument = (bool_t(*)())xdr_wrapstring;
_xdr_result = (bool_t(*)())xdr_int;
local = (char *(*)(u_argument *, struct svc_req *))
printmessage_l;
break;
default: /* no other procedures available */
<strong>svcerr_noproc</strong>(transp);
return;
}
memset((char *)&amp;argument, 0, sizeof(argument));
/* decode arguments for the procedure */
if (!<strong>svc_getargs</strong>(transp, (xdrproc_t)_xdr_argument,
(char *)&amp;argument)){
<strong>svcerr_decode</strong>(transp);
return;
}
/* Invoke the procedure */
result = (*local)(&amp;argument, rqstp);
/* Send reply to the client containing results of the invocation */
if (result != NULL &amp;&amp; !<strong>svc_sendreply</strong>(transp,
(xdrproc_t)_xdr_result, result)){
<strong>svcerr_systemerr</strong>(transp);
}
if (!<strong>svc_freeargs</strong>(transp, (xdrproc_t)_xdr_argument,
(char *)&amp;argument)){
printf(&quot;unable to free arguments&quot;);
exit(1);
}
return;
}
main()
{
pid_t pid;
int i;
printf(&quot;Start..&quot;);
printf(&quot;Try to create..&quot;);
/* Create a new RPC server instance which will use messageprog_l()
as a dispatcher function associated with MESSAGEPROG program
number and PRINTMESSAGEVERS version number.
Since &quot;VISIBLE&quot; nettype is selected, a number of server instances
will be actually created: one for each &quot;VISIBLE&quot; entry in
/etc/netconfig */
if(!<strong>svc_create</strong>(messageprog_l, MESSAGEPROG, PRINTMESSAGEVERS,
&quot;VISIBLE&quot;)){
printf(&quot;Unable to create service.&quot;);
return 1;
}
/* Enter the main loop of RPC */
<strong>svc_run</strong>();
return 0;
}
</pre>
<br>
<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>