Pointer variables
A pointer variable is a 4-byte pointer field containing an address. All HLL service routines require one pointer variable called Hlbptr. NetView® calculates the value of Hlbptr and passes it to the HLL command processor or installation exit. When Hlbptr is received as an initial parameter, do not assign a value to Hlbptr. This is the only parameter of this type that you do not have to assign.
If an HLL service routine is expecting an address in a pointer field, you are responsible for assigning a value to that pointer field before starting the HLL service routine. For C, use the & (address) operator when passing pointer variables to HLL service routines rather than creating a separate pointer variable for this purpose. This ensures that the pointer variable is assigned a value before starting the HLL service routine.
Using Pointer Variables in C shows an example of using pointer variables in C. Some of the steps are explained in more detail following the figure.
Using Pointer Variables in C
1 #define VARTOVAR "VARTOVAR" /* VARTOVAR constant */
2 Dsihlb *Hlbptr; /* HLB pointer MUST BE DEFINED */
3 Dsivarch *srcptr; /* Pointer to source buffer */
Dsivarch *dstptr; /* Pointer to destination buffer */
int dstlen; /* Length of destination buffer */
Dsivarch srcbuf; /* Source buffer */
Dsivarch dstbuf; /* Destination buffer */
4 srcptr = &srcbuf; /* Address of source buffer */
dstptr = &dstbuf; /* Address of destination buffer */
dstlen = 255;
5 Cnmcpys(srcptr,dstptr,dstlen,VARTOVAR); /* Copy buffer */- 2
- Hlbptr is defined as a pointer variable. You must not assign a value to Hlbptror include it in the Cnmcpys invocation. NetView inserts Hlbptr in the parameter list for you during the compilation's preprocessor phase.
- 3
- srcptr is defined as a pointer to a structure of type Dsivarch (varying length character string).
- 4
- srcptr is assigned the address of the source buffer (srcbuf) to be used as a operand to Cnmcpys
- 5
- srcptr is
passed as a parameter to Cnmcpys.
Using the & (address) operator in C eliminates the need to define pointer variables. Note the use of a string constant instead of the VARTOVAR constant in this example:
Cnmcpys(&srcbuf,&dstbuf,dstlen,"VARTOVAR"); /* Copy buffer */