ibm-information-center/dist/eclipse/plugins/i5OS.ic.apiref_5.4.0.1/exretilec.htm

210 lines
11 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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 in ILE C: Retrieving a file description to a user space" />
<meta name="abstract" content="This example uses ILE C to retrieve a file definition template to a user space." />
<meta name="description" content="This example uses ILE C to retrieve a file definition template to a user space." />
<meta name="DC.Relation" scheme="URI" content="ExTaskRetfile.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="exretilec" />
<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 in ILE C: Retrieving a file description to a user space</title>
</head>
<body id="exretilec"><a name="exretilec"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example in ILE C: Retrieving a file description to a user space</h1>
<div><p>This example uses ILE C to retrieve a file definition template
to a user space.</p>
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code license and disclaimer information</a> for important
legal information.</div>
<pre>/********************************************************************/
/* Program Name: RTVFD */
/* */
/* Program Language: ILE C */
/* */
/* Description: Retrieve a file definition template to a */
/* user space. */
/* */
/* Header Files Included: &lt;stdlib.h&gt; */
/* &lt;signal.h&gt; */
/* &lt;string.h&gt; */
/* &lt;stdio.h&gt; */
/* &lt;quscrtus.h&gt; */
/* &lt;quscusat.h&gt; */
/* &lt;qusptrus.h&gt; */
/* &lt;qdbrtvfd.h&gt; */
/* &lt;qusec.h&gt; */
/* &lt;qus.h&gt; */
/* &lt;qliept.h&gt; */
/* */
/* APIs Used: QUSCRTUS - Create User Space */
/* QUSCUSAT - Change User Space Attributes */
/* QUSPTRUS - Retrieve Pointer to User Space */
/* QDBRTVFD - Retrieve File Description */
/********************************************************************/
#include &lt;stdlib.h&gt;
#include &lt;signal.h&gt;
#include &lt;string.h&gt;
#include &lt;stdio.h&gt;
#include &lt;quscrtus.h&gt;
#include &lt;quscusat.h&gt;
#include &lt;qusptrus.h&gt;
#include &lt;qdbrtvfd.h&gt;
#include &lt;qusec.h&gt;
#include &lt;qus.h&gt;
#include &lt;qliept.h&gt; /* Note that this must be the last */
/* include specified. */
int error_flag = 0; /* Set by error handler */
/********************************************************************/
/* Function: error_handler */
/* Description: Handle exceptions. */
/********************************************************************/
void error_handler(int errparm)
{
_INTRPT_Hndlr_Parms_T ExcDta = {0};
_GetExcData(&amp;ExcDta);
error_flag = 1;
signal(SIGALL,error_handler);
}
/********************************************************************/
/* Start of main procedure */
/********************************************************************/
main(int argc, char **argv)
{
typedef struct attrib_struct {
int attrib_count;
Qus_Vlen_Rec_3_t keyinfo;
char key_value;
} attrib_struct;
Qus_EC_t error_code; /* Error code parameter */
attrib_struct attrib_info; /* Attribute to change */
char user_space[21]; /* User space and library */
char descr[50]; /* Text description */
char initial_value = 0x00; /* Initial value for user space*/
char return_lib[10]; /* Return library */
char ret_file_lib[20]; /* Returned file and library */
char file_and_lib[21]; /* File and library */
char record_fmt[11]; /* Record format name */
char *space_ptr; /* Pointer to user space object*/
/******************************************************************/
/* Start of executable code. */
/******************************************************************/
if (argc != 4) {
printf("This program requires 3 parameters:\n");
printf(" 1) User space name and library\n");
printf(" 2) File name and library\n");
printf(" 3) Record format name\n");
printf("Please retry with those parameters.\n");
exit(1);
}
memcpy(user_space, *++argv, 20);
memcpy(file_and_lib, *++argv, 20);
memcpy(record_fmt, *++argv, 10);
memset(desc,' ',50);
memcpy(descr,"RTVFD User Space",16);
signal(SIGALL,error_handler); /* Enable the error handler */
error_code.Bytes_Provided=0; /* Have APIs return exceptions */
/******************************************************************/
/* Create the user space. */
/******************************************************************/
QUSCRTUS(user_space, /* User space */
" ", /* Extended attribute */
1024, /* Initial size */
&amp;initial_value, /* Initial value */
"*CHANGE ", /* Public authority */
descr, /* Text description */
"*YES ", /* Replace if it exists */
&amp;error_code, /* Error code */
"*USER "); /* Domain = USER */
if (error_flag) {
exit(1);
}
/******************************************************************/
/* Initialize the attributes to change structure. */
/******************************************************************/
attrib_info.attrib_count = 1; /* Number of attributes */
attrib_info.keyinfo.Key = 3; /* Key of attribute to change */
attrib_info.keyinfo.Length_Vlen_Record = 1;
/* Length of data */
attrib_info.key_value='1'; /* Autoextend space */
/******************************************************************/
/* Change the user space to be automatically extendable. */
/******************************************************************/
QUSCUSAT(return_lib, /* Return library */
user_space, /* User space name and library */
&amp;attrib_info, /* Attributes to change */
&amp;error_code); /* Error code */
if (error_flag) {
exit(1);
}
/******************************************************************/
/* Retrieve a pointer to the user space object. */
/******************************************************************/
QUSPTRUS(user_space,&amp;space_ptr);
if (error_flag) {
exit(1);
}
/******************************************************************/
/* Retrieve the file description information to the user space. */
/******************************************************************/
QDBRTVFD(space_ptr, /* Receiver variable */
16776704, /* Return up to 16MB minus 512 */
/* bytes of data */
ret_file_lib, /* Returned file and library */
"FILD0100", /* File definition template */
file_and_lib, /* File and library name */
record_fmt, /* Record format name */
"0", /* No override processing */
"*LCL ", /* Local system */
"*INT ", /* Internal formats <span class="uicontrol">(1)</span> */
&amp;error_code); /* Error code */
if (error_flag) {
exit(1);
}
}</pre>
<p>The example program uses the value *INT (<span class="uicontrol">(1)</span>).
A description and examples of the internal (*INT) and external (*EXT) formats
are provided in the Retrieve Database File Description (QDBRTVFD) API.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="ExTaskRetfile.htm" title="These programming examples show an application that uses a user space as a receiver variable by retrieving a file description to a user space. This approach is possible only if you use an HLL that is able to work with pointers.">Examples: Retrieving a file description to a user space</a></div>
</div>
</div>
</body>
</html>