284 lines
15 KiB
HTML
284 lines
15 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 in ILE C: Using keys with List Spooled Files API" />
|
|
<meta name="abstract" content="This example shows the steps necessary to process keyed output from an API" />
|
|
<meta name="description" content="This example shows the steps necessary to process keyed output from an API" />
|
|
<meta name="DC.Relation" scheme="URI" content="opmScenario.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="cmnKeysRPG.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="cmnKeysRPG.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="cmnKeysILEC" />
|
|
<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: Using keys with List Spooled Files API</title>
|
|
</head>
|
|
<body id="cmnKeysILEC"><a name="cmnKeysILEC"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example in ILE C: Using keys with List Spooled Files API</h1>
|
|
<div><p>This example shows the steps necessary to process
|
|
keyed output from an API</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>
|
|
<p>Refer to Example in OPM RPG: Using keys with List
|
|
Spooled Files API for the original example.</p>
|
|
<pre>/******************************************************************/
|
|
/* */
|
|
/* Program: List Spooled Files for Current User */
|
|
/* */
|
|
/* Language: ILE C */
|
|
/* */
|
|
/* Description: This example shows the steps necessary to */
|
|
/* process keyed output from an API */
|
|
/* */
|
|
/* APIs Used: QUSLSPL - List Spooled Files */
|
|
/* QUSCRTUS - Create User Space */
|
|
/* QUSPTRUS - Retrieve Pointer to User Space */
|
|
/* */
|
|
/******************************************************************/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <quslspl.h> /* QUSLSPL API header */
|
|
#include <quscrtus.h> /* QUSCRTUS API header */
|
|
#include <qusptrus.h> /* QUSPTRUS API header */
|
|
#include <qusgen.h> /* Format Structures for User Space <span class="uicontrol">(11)</span> */
|
|
#include <qusec.h> /* Error Code parameter include for APIs */
|
|
#include <qliept.h> /* Entry Point Table include for APIs */
|
|
|
|
/******************************************************************/
|
|
/* Global variables */
|
|
/******************************************************************/
|
|
char spc_name[20] = "SPCNAME QTEMP ";
|
|
int spc_size = 2000;
|
|
char spc_init = 0x00;
|
|
char *spcptr, *lstptr, *lstptr2;
|
|
int pages;
|
|
struct keys { int key1; <span class="uicontrol">(7)</span>
|
|
int key2;
|
|
int key3;} keys = {201, 211, 216}; <span class="uicontrol">(8)</span>
|
|
int number_of_keys = 3;
|
|
char ext_attr[10] = "QUSLSPL ";
|
|
char spc_aut[10] = "*ALL ";
|
|
char spc_text[50] = " ";
|
|
char spc_replac[10] = "*YES ";
|
|
char spc_domain[10] = "*USER ";
|
|
char format[8] = "SPLF0200"; <span class="uicontrol">(4)</span>
|
|
char usr_prf[10] = "*CURRENT ";
|
|
char outq[20] = "*ALL ";
|
|
char formtyp[10] = "*ALL ";
|
|
char usrdta[10] = "*ALL ";
|
|
char jobnam[26] = " ";
|
|
char prtfil[10];
|
|
char opndat[7];
|
|
typedef struct {
|
|
Qus_LSPL_Key_Info_t Key_Info;
|
|
char Data_Field[100];
|
|
} var_record_t;
|
|
Qus_EC_t error_code;
|
|
int i, j;
|
|
char prtlin[100];
|
|
FILE *record;
|
|
|
|
main()
|
|
{
|
|
/***************************************************************/
|
|
/* Open print file for report */
|
|
/***************************************************************/
|
|
|
|
if((record = fopen("QPRINT", "wb, lrecl=132, type=record")) == NULL)
|
|
{ printf("File QPRINT could not be opened\n");
|
|
exit();
|
|
}
|
|
/***************************************************************/
|
|
/* Set Error Code structure to use exceptions */
|
|
/***************************************************************/
|
|
|
|
error_code.Bytes_Provided = 0; <span class="uicontrol">(1)</span>
|
|
|
|
/***************************************************************/
|
|
/* Create a User Space for the List generated by QUSLSPL */
|
|
/***************************************************************/
|
|
|
|
QUSCRTUS(spc_name, /* User space name and library <span class="uicontrol">(2)</span> */
|
|
ext_attr, /* Extended attribute */
|
|
spc_size, /* Initial space size */
|
|
&spc_init, /* Initialize value for space */
|
|
spc_aut, /* Public authorization */
|
|
spc_text, /* Text description */
|
|
spc_replac, /* Replace option */
|
|
error_code, /* Error code structure */
|
|
spc_domain); /* Domain of space */
|
|
|
|
/***************************************************************/
|
|
/* Call QUSLSPL to get all spooled files for *CURRENT user */
|
|
/***************************************************************/
|
|
|
|
QUSLSPL( spc_name, /* User space name and library <span class="uicontrol">(3)</span> */
|
|
format, /* API format <span class="uicontrol">(4)</span> */
|
|
usr_prf, /* User profile */
|
|
outq, /* Output Queue */
|
|
formtyp, /* Form type */
|
|
usrdta, /* User data */
|
|
error_code, /* Error code structure */
|
|
jobnam, /* Job name */
|
|
keys, /* Keys to return <span class="uicontrol">(5)</span> */
|
|
number_of_keys); /* Number of keys <span class="uicontrol">(6)</span> */
|
|
|
|
/***************************************************************/
|
|
/* Get a resolved pointer to the User Space */
|
|
/***************************************************************/
|
|
|
|
QUSPTRUS(spc_name, /* User space name and library <span class="uicontrol">(9)</span> */
|
|
&spcptr, /* Space pointer */
|
|
error_code); /* Error code structure */
|
|
|
|
/***************************************************************/
|
|
/* If valid information returned */
|
|
/***************************************************************/
|
|
|
|
if(memcmp\
|
|
(((Qus_Generic_Header_0100_t *)spcptr)->Structure_Release_Level, <span class="uicontrol">(12)</span>
|
|
"0100", 4) != 0) { printf("Unknown Generic Header"); <span class="uicontrol">(13)</span>
|
|
exit();
|
|
}
|
|
|
|
if((((Qus_Generic_Header_0100_t *)spcptr)->Information_Status=='C')\ <span class="uicontrol">(14)</span>
|
|
|| (((Qus_Generic_Header_0100_t *)spcptr)->Information_Status\
|
|
== 'P'))
|
|
{
|
|
if(((Qus_Generic_Header_0100_t *)spcptr)->Number_List_Entries\ <span class="uicontrol">(16)</span>
|
|
> 0)
|
|
|
|
/***************************************************************/
|
|
/* address current list entry */
|
|
/***************************************************************/
|
|
|
|
{
|
|
lstptr = spcptr + (((Qus_Generic_Header_0100_t *)spcptr)\
|
|
->Offset_List_Data);
|
|
|
|
/***************************************************************/
|
|
/* process all the entries */
|
|
/***************************************************************/
|
|
|
|
for(i = 0; i < (((Qus_Generic_Header_0100_t *)spcptr)\ <span class="uicontrol">(20)</span>
|
|
->Number_List_Entries); i++)
|
|
{
|
|
|
|
/***************************************************************/
|
|
/* set lstptr2 to first variable length record for this entry */
|
|
/***************************************************************/
|
|
|
|
lstptr2 = lstptr + 4;
|
|
|
|
/***************************************************************/
|
|
/* process all the variable length records for this entry */
|
|
/***************************************************************/
|
|
|
|
for(j = 0; j < (((Qus_SPLF0200_t *)lstptr)\ <span class="uicontrol">(22)</span> <span class="uicontrol">(23)</span>
|
|
->Num_Fields_Retd); j++)
|
|
{
|
|
|
|
/***************************************************************/
|
|
/* extract spooled file name for report */
|
|
/***************************************************************/
|
|
|
|
if((((Qus_LSPL_Key_Info_t *)lstptr2)\ <span class="uicontrol">(24)</span> <span class="uicontrol">(25)</span>
|
|
->Key_Field_for_Field_Retd) == 201)
|
|
{ memcpy(prtfil, " ", 10);
|
|
memcpy(prtfil, (((var_record_t *)\
|
|
lstptr2)->Data_Field),
|
|
(((Qus_LSPL_Key_Info_t *)lstptr2)\
|
|
->Data_Length));
|
|
}
|
|
|
|
/***************************************************************/
|
|
/* extract number of pages for report */
|
|
/***************************************************************/
|
|
|
|
if((((Qus_LSPL_Key_Info_t *)lstptr2)\ <span class="uicontrol">(24)</span> <span class="uicontrol">(25)</span>
|
|
->Key_Field_for_Field_Retd) == 211)
|
|
{ memcpy(&pages, (((var_record_t *)\
|
|
lstptr2)->Data_Field),
|
|
(((Qus_LSPL_Key_Info_t *)lstptr2)\
|
|
->Data_Length));
|
|
}
|
|
|
|
/***************************************************************/
|
|
/* extract age of spooled file for report */
|
|
/***************************************************************/
|
|
|
|
if((((Qus_LSPL_Key_Info_t *)lstptr2)\ <span class="uicontrol">(24)</span> <span class="uicontrol">(25)</span>
|
|
->Key_Field_for_Field_Retd) == 216)
|
|
{ memcpy(opndat, " ", 7);
|
|
memcpy(opndat, (((var_record_t *)\
|
|
lstptr2)->Data_Field),
|
|
(((Qus_LSPL_Key_Info_t *)lstptr2)\
|
|
->Data_Length));
|
|
}
|
|
|
|
/***************************************************************/
|
|
/* bump lstptr2 to next variable length record */
|
|
/***************************************************************/
|
|
|
|
lstptr2 = lstptr2 +
|
|
(((Qus_LSPL_Key_Info_t *)lstptr2)\
|
|
->Len_Field_Info_Retd);
|
|
}
|
|
|
|
/***************************************************************/
|
|
/* print collected information */
|
|
/***************************************************************/
|
|
|
|
sprintf(prtlin, "%.10s %.10d %.7s", <span class="uicontrol">(26)</span>
|
|
prtfil, pages, opndat);
|
|
fwrite(prtlin, 1, 100, record);
|
|
|
|
/***************************************************************/
|
|
/* bump lstptr to next list entry */
|
|
/***************************************************************/
|
|
|
|
lstptr += (((Qus_Generic_Header_0100_t *)spcptr)\ <span class="uicontrol">(27)</span>
|
|
->Size_Each_Entry);
|
|
}
|
|
|
|
/***************************************************************/
|
|
/* exit at end of list */
|
|
/***************************************************************/
|
|
|
|
fclose(record);
|
|
exit();
|
|
}
|
|
}
|
|
else
|
|
{ printf("List data not valid"); <span class="uicontrol">(15)</span>
|
|
exit();
|
|
}
|
|
} <span class="uicontrol">(28)</span></pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="opmScenario.htm" title="This scenario demonstrates the use of an original program model (OPM) API in several different programs.">Scenario: Original Program Model (OPM) API</a></div>
|
|
</div>
|
|
<div class="relref"><strong>Related reference</strong><br />
|
|
<div><a href="cmnKeysRPG.htm" title="This example shows the steps necessary to process keyed output from an API.">Example in OPM RPG: Using keys with List Spooled Files API</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |