Figure 1 shows example program
CCNGCP5, which shows how parameters are received from a CSP application
that uses a CALL statement to transfer control. The z/OS® XL C program
is expecting to receive an int as a parameter.
Figure 1. CSP
CALLing z/OS XL C under
CICS/* this example shows how to call C from CSP under CICS, and how */
/* parameters are passed */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
main()
{
struct tag_commarea { /* commarea passed to z/OS C from R924A1 */
int *ptr1 ;
int *ptr2 ;
int *ptr3 ;
} * ca_ptr ; /* commarea ptr */
int *parm1_ptr ;
int *parm2_ptr ;
int *parm3_ptr ;
/* addressability to EIB control block */
/* and COMMUNICATION AREA */
EXEC CICS ADDRESS EIB(dfheiptr) COMMAREA(ca_ptr) ;
parm1_ptr = ca_ptr->ptr1 ;
parm2_ptr = ca_ptr->ptr2 ;
parm3_ptr = ca_ptr->ptr3 ;
*parm3_ptr = (int) pow((double) *parm1_ptr,
(double) *parm2_ptr);
EXEC CICS RETURN;
}
Figure 2 (example program CCNGCP6)
shows how parameters are received from a CSP application that uses
an XFER statement to transfer control.
Figure 2. CSP transferring control
to z/OS XL C under CICS using the XFER statement/* this example shows how to XFER control to C from CSP under CICS */
/* XFER CALL */
/* R924A3 ====> CCNGCP6 ====> R924A6 */
/* R924A3 and R924A6 are CSP applications */
#include <math.h>
#include <string.h>
/* structure passed to R924A6*/
void main()
{
struct {
char *appl_ptr;
_Packed struct tag_a3rec *rec3_ptr ;
} parm_ptr ;
/* Structure received R924A3*/
struct tag_a3rec {
char a3ct [ 4];
char a3lan [ 4];
char fil1 [ 8]; /* packed fields for PLI */
char fil2 [ 8]; /* packed fields for PLI */
char fil3 [ 8]; /* packed fields for PLI */
int a3xbc; /* int field 1 for z/OS C */
int a3ybc; /* int field 2 for z/OS C */
int a3zbc; /* int field 3 for z/OS C */
}
|
_Packed struct tag_a3rec a3rec ;
char lk_appl[16] = "USR5ALF.R924A6 " ;
struct tag_a3progx {
char alfx [ 8];
char applx [ 8];
};
_Packed struct tag_a3progx a3progx = {"USR5ALF.","R924A6 "} ;
short length_a3rec = sizeof(a3rec) ;
char * pa3rec ;
short i ;
/*----- start of CSP XFER-ing to C under CICS ------------------*/
EXEC CICS ADDRESS EIB(dfheiptr);
/* retrieve data from CSP */
EXEC CICS RETRIEVE INTO(&a3rec) LENGTH(length_a3rec) ;
a3rec.a3zbc = (int) pow((double) a3rec.a3xbc,
(double) a3rec.a3ybc);
/*----- end of CSP XFER-ing to C under CICS --------------------*/
/* call CSP to display results*/
parm_ptr.appl_ptr = lk_appl ; /* alf.application */
parm_ptr.rec3_ptr = &a3rec ;
/* LINK to CSP application */
EXEC CICS LINK PROGRAM("DCBINIT ")
COMMAREA(parm_ptr)
LENGTH(8) ;
if (dfheiptr->eibresp2 != 0) {
printf("CCNGCP6: EXEC CICS LINK returned non zero \n");
printf(" return code. eibresp2 =%d\n",
dfheiptr->eibresp2);
}
/*----- end of C calling CSP under CICS ------------------------*/
EXEC CICS RETURN ;
}
|
Figure 3 (example program CCNGCP7)
The following example program shows how parameters are received from
a CSP application that uses a DXFR statement to transfer
control. You must receive a structure.
Figure 3. CSP Transferring Control
to z/OS XL C under CICS Using the DXFR Statement/* this example shows how to transfer control to C from CSP under */
/* CICS, using the DXFR statement */
/* DXFR XCTL( equivalent to dxfr) */
/* R924A3 ====> CCNGCP7 ====> DCBINIT ( appl R924A5) */
/* R924A3 is a CSP application */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
main ()
{
struct tag_a3rec {
char a3ct [ 4];
char a3lan [ 4];
char fil1 [ 8]; /* packed fields for PLI */
char fil2 [ 8]; /* packed fields for PLI */
char fil3 [ 8]; /* packed fields for PLI */
int a3xbc;
int a3ybc;
int a3zbc;
};
|
/* commarea passed to C/370 from R924A3 */
struct tag_commarea {
char a3ct [ 4] ;
char a3lan [ 4];
char fil1 [ 8]; /* packed fields for PLI */
char fil2 [ 8]; /* packed fields for PLI */
char fil3 [ 8]; /* packed fields for PLI */
int a3xbc;
int a3ybc;
int a3zbc;
} * ca_ptr ; /* commarea ptr */
struct tag_a5progc {
char alfc [ 8] ;
char applc [ 8] ;
struct tag_a3rec a3rec;
} a5progc = {"USR5ALF.","R924A5 "};
short length_a3rec = sizeof(struct tag_a3rec) ;
short length_a5progc = sizeof(struct tag_a5progc) ;
/* addressability to EIB control block */
/* and COMMUNICATION AREA */
EXEC CICS ADDRESS EIB(dfheiptr) COMMAREA(ca_ptr) ;
if (dfheiptr->eibcalen == length_a3rec ) {
memcpy(&a5progc.a3rec, ca_ptr , length_a3rec);
/* calculate the pow(x,y) */
a5progc.a3rec.a3zbc = (int) pow((double) a5progc.a3rec.a3xbc,
(double) a5progc.a3rec.a3ybc);
EXEC CICS XCTL
PROGRAM("DCBINIT ")
COMMAREA(a5progc)
length(length_a5progc) ;
if (dfheiptr->eibresp2 != DFHRESP(NORMAL)) {
printf ("CCNGCP7: failed on xctl call to DCBINIT\n");
printf (" \n");
}
}
else {
printf ("CCNGCP7:length of COMMAREA is different from expected\n");
printf (" expected %d, actual %d\n",
length_a3rec, dfheiptr->eibcalen);
printf (" \n");
EXEC CICS RETURN;
}
EXEC CICS RETURN;
}
|