86 lines
3.7 KiB
HTML
86 lines
3.7 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>Generic header files using ILE APIs</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. -->
|
||
|
<!-- Change History: -->
|
||
|
<!-- YYMMDD USERID Change description -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<!-- Java sync-link-->
|
||
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
||
|
</script>
|
||
|
|
||
|
<h2>Generic header files using ILE APIs</h2>
|
||
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
||
|
for information pertaining to code examples.</p>
|
||
|
<p>This section shows how to use a generic header file from the QSYSINC (system
|
||
|
include) library in a program. For information about the QSYSINC header files,
|
||
|
see <a href="../apiref/conQSYSINC.htm">Include files and the QSYSINC library</a>.</p>
|
||
|
|
||
|
<p>In addition to the traditional C-library header files (such as stdio and
|
||
|
string), the API header file qusrgfa1.h is included in the following example.
|
||
|
The qusrgfa1.h header file defines the functions exported from service program
|
||
|
QUSRGFA1. This service program contains the APIs provided for manipulating the
|
||
|
information in the repository. A second service program named QUSRGFA2 contains
|
||
|
the ILE API for retrieving information from the registration facility
|
||
|
repository. The header file qusec.h contains the definition for the error code
|
||
|
structure that is used for the error code parameter. The following list shows
|
||
|
the standard C header files (the first four includes) and a few &sys.-defined
|
||
|
header files for APIs. This list does not show all the header files used in the
|
||
|
example programs for using ILE APIs.</p>
|
||
|
|
||
|
<pre>
|
||
|
#include <stdio.h>
|
||
|
#include <signal.h>
|
||
|
#include <string.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <qusrgfa1.h>
|
||
|
#include <qusec.h>
|
||
|
</pre>
|
||
|
|
||
|
<h3><a name="HDRVLS">Example: Variable-length structure</a></h3>
|
||
|
|
||
|
<p>Many of the structures needed are provided by the QSYSINC (system include)
|
||
|
library. However, any fields of a structure that are variable in length are not
|
||
|
defined by QSYSINC and must be defined by the user. For example, in the qusec.h
|
||
|
header file, the structure Qus_EC_t is defined as:</p>
|
||
|
|
||
|
<pre>
|
||
|
typedef struct Qus_EC {
|
||
|
int Bytes_Provided;
|
||
|
int Bytes_Available;
|
||
|
char Exception_Id[7];
|
||
|
char Reserved;
|
||
|
/*char Exception_Data[]; <strong>(1)</strong>*/ /* Varying length field */
|
||
|
} Qus_EC_t;
|
||
|
</pre>
|
||
|
|
||
|
<p>Because the Exception_Data field <strong>(1)</strong> is a varying-length
|
||
|
field, it is shown as a comment. The following is a new error code structure,
|
||
|
which defines the exception_data field <strong>(2)</strong>. It was created by
|
||
|
using the structure that was defined in the qusec.h header file.</p>
|
||
|
|
||
|
<pre>
|
||
|
typedef struct {
|
||
|
Qus_EC_t ec_fields;
|
||
|
char exception_data[100]<strong>(2)</strong>;
|
||
|
} error_code_struct;
|
||
|
</pre>
|
||
|
|
||
|
<p>Within QSYSINC include files, all varying-length fields and arrays are in
|
||
|
the form of comments so that you can control how much storage to allocate based
|
||
|
on your specific requirements.</p>
|
||
|
<img src="v5r3end.gif" alt="End of change">
|
||
|
<br>
|
||
|
<hr>
|
||
|
</body>
|
||
|
</html>
|
||
|
|