ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzalf_5.4.0.1/rzalfileproccallsexamp.htm

96 lines
4.4 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example 1: Call an i5/OS PASE procedure from within i5/OS programs" />
<meta name="abstract" content="The example in this topic shows an ILE program calling an i5/OS PASE procedure." />
<meta name="description" content="The example in this topic shows an ILE program calling an i5/OS PASE procedure." />
<meta name="DC.Relation" scheme="URI" content="rzalfileproccalls.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2000, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2000, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzalfileproccallsexamp" />
<meta name="DC.Language" content="en-us" />
<!-- 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. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example 1: Call an i5/OS PASE
procedure from within i5/OS programs</title>
</head>
<body id="rzalfileproccallsexamp"><a name="rzalfileproccallsexamp"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example 1: Call an <span class="keyword">i5/OS</span> PASE
procedure from within <span class="keyword">i5/OS</span> programs</h1>
<div><p>The example in this topic shows an ILE program calling an <span class="keyword">i5/OS™</span> PASE procedure.</p>
<div class="example"><div class="note"><span class="notetitle">Note:</span> By using the code examples, you agree to
the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
<pre>#include &lt;stdio.h&gt;
#include &lt;qp2shell2.h&gt;
#include &lt;qp2user.h&gt;
#define JOB_CCSID 0
int main(int argc, char *argv[])
{
QP2_ptr64_t id;
void *getpid_pase;
const QP2_arg_type_t signature[] = { QP2_ARG_END };
QP2_word_t result;
/*
* Call QP2SHELL2 to run the i5/OS PASE program
* /usr/lib/start32, which starts i5/OS PASE in
* 32-bit mode (and leaves it active on return)
*/
QP2SHELL2("/usr/lib/start32");
/*
* Qp2dlopen opens the global name space (rather than
* loading a new shared executable) when the first
* argument is a null pointer. Qp2dlsym locates the
* function descriptor for the i5/OS PASE getpid
* subroutine (exported by shared library libc.a)
*/
id = Qp2dlopen(NULL, QP2_RTLD_NOW, JOB_CCSID);
getpid_pase = Qp2dlsym(id, "getpid", JOB_CCSID, NULL);
/*
* Call Qp2CallPase to run the i5/OS PASE getpid
* function, and print the result. Use Qp2errnop
* to find and print the i5/OS PASE errno if the
* function result was -1
*/
int rc = Qp2CallPase(getpid_pase,
NULL, // no argument list
signature,
QP2_RESULT_WORD,
&amp;result)
printf("i5/OS PASE getpid() = %i\n", result);
if (result == -1)
printf("i5/OS errno = %i\n", *Qp2errnop());
/*
* Close the Qp2dlopen instance, and then call
* Qp2EndPase to end i5/OS PASE in this job
*/
Qp2dlclose(id);
Qp2EndPase();
return 0;
}</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzalfileproccalls.htm" title="You can call the Qp2CallPase() and Qp2CallPase2() ILE procedures from within other ILE procedures to run an i5/OS PASE program in a job where the i5/OS PASE environment is already running.">Call an i5/OS PASE procedure from within i5/OS programs</a></div>
</div>
</div>
</body>
</html>