161 lines
8.5 KiB
HTML
161 lines
8.5 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: ILE C program for allocating a Coprocessor" />
|
|
<meta name="abstract" content="Change this program example to suit your needs for allocating a Coprocessor." />
|
|
<meta name="description" content="Change this program example to suit your needs for allocating a Coprocessor." />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajcworking.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajcmultiplecoprocessors.htm#allocating" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="crpallocc" />
|
|
<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: ILE C program for allocating a Coprocessor</title>
|
|
</head>
|
|
<body id="crpallocc"><a name="crpallocc"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: ILE C program for allocating a Coprocessor</h1>
|
|
<div><p>Change this program example to suit your needs for allocating a
|
|
Coprocessor.</p>
|
|
<div class="section"><div class="p"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code license and disclaimer information</a> for
|
|
important legal information.</div>
|
|
</div>
|
|
</div>
|
|
<div class="example"> <pre>/*-------------------------------------------------------------------*/
|
|
/* Allocate a crypto device to the job. */
|
|
/* */
|
|
/* */
|
|
/* COPYRIGHT 5769-SS1 (C) IBM CORP. 2000, 2000 */
|
|
/* */
|
|
/* This material contains programming source code for your */
|
|
/* consideration. These examples have not been thoroughly */
|
|
/* tested under all conditions. IBM, therefore, cannot */
|
|
/* guarantee or imply reliability, serviceability, or function */
|
|
/* of these program. All programs contained herein are */
|
|
/* provided to you "AS IS". THE IMPLIED WARRANTIES OF */
|
|
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
|
|
/* ARE EXPRESSLY DISCLAIMED. IBM provides no program services for */
|
|
/* these programs and files. */
|
|
/* */
|
|
/* */
|
|
/* Note: Input format is more fully described in Chapter 2 of */
|
|
/* IBM CCA Basic Services Reference and Guide */
|
|
/* (SC31-8609) publication. */
|
|
/* */
|
|
/* Parameters: */
|
|
/* none. */
|
|
/* */
|
|
/* Example: */
|
|
/* CALL PGM(CRPALLOC) (CRP02) */
|
|
/* */
|
|
/* */
|
|
/* The Common Cryptographic Architecture (CCA) verb used is */
|
|
/* Cryptographic_Resource_Allocate (CSUACRA). */
|
|
/* */
|
|
/* Use these commands to compile this program on the system: */
|
|
/* ADDLIBLE LIB(QCCA) */
|
|
/* CRTCMOD MODULE(CRPALLOC) SRCFILE(SAMPLE) */
|
|
/* CRTPGM PGM(CRPALLOC) MODULE(CRPALLOC) */
|
|
/* BNDSRVPGM(QCCA/CSUACRA) */
|
|
/* */
|
|
/* Note: Authority to the CSUACRA service program in the */
|
|
/* QCCA library is assumed. */
|
|
/* */
|
|
/*-------------------------------------------------------------------*/
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "csucincl.h"
|
|
|
|
/*-------------------------------------------------------------------*/
|
|
/* standard return codes */
|
|
/*-------------------------------------------------------------------*/
|
|
|
|
#define ERROR -1
|
|
#define OK 0
|
|
#define WARNING 4
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
/*-------------------------------------------------------------------*/
|
|
/* standard CCA parameters */
|
|
/*-------------------------------------------------------------------*/
|
|
long return_code = 0;
|
|
long reason_code = 0;
|
|
long exit_data_length = 2;
|
|
char exit_data[4];
|
|
char rule_array[2][8];
|
|
long rule_array_count = 2;
|
|
long resource_name_length;
|
|
|
|
/*-------------------------------------------------------------------*/
|
|
/* Process the parameters */
|
|
/*-------------------------------------------------------------------*/
|
|
if (argc < 1)
|
|
{
|
|
printf("Device parameter must be specified.\n");
|
|
return(ERROR);
|
|
}
|
|
|
|
/*-------------------------------------------------------------------*/
|
|
/* Set the keyword in the rule array */
|
|
/*-------------------------------------------------------------------*/
|
|
memcpy(rule_array,"DEVICE ",8);
|
|
rule_array_count = 1;
|
|
|
|
/*-------------------------------------------------------------------*/
|
|
/* Set the resource name length */
|
|
/*-------------------------------------------------------------------*/
|
|
resource_name_length = strlen(argv[1]);
|
|
|
|
/*-------------------------------------------------------------------*/
|
|
/* Call Cryptographic Resource Allocate SAPI */
|
|
/*-------------------------------------------------------------------*/
|
|
CSUACRA( &return_code, &reason_code, &exit_data_length,
|
|
(char *)exit_data,
|
|
(long *) &rule_array_count,
|
|
(char *) rule_array,
|
|
(long *) &resource_name_length,
|
|
(char *) argv[1]); /* resource name */
|
|
|
|
/*-------------------------------------------------------------------*/
|
|
/* Check the return code and display the results */
|
|
/*-------------------------------------------------------------------*/
|
|
if ( (return_code == OK) | (return_code == WARNING) )
|
|
{
|
|
printf("Request was successful\n");
|
|
return(OK);
|
|
}
|
|
else
|
|
{
|
|
printf("Request failed with return/reason codes: %d/%d \n",
|
|
return_code, reason_code);
|
|
return(ERROR);
|
|
}
|
|
}</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajcworking.htm" title="After you set up your Cryptographic Coprocessor, you can begin writing programs to make use of your Cryptographic Coprocessor's cryptographic functions.">Manage the Cryptographic Coprocessor</a></div>
|
|
</div>
|
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
|
<div><a href="rzajcmultiplecoprocessors.htm#allocating">Allocating a device</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |