Interface Data Types


 

C data types included as parameters are unsigned integers (u32), byte arrays (u8 *) and strings (u8 *). Representing these parameters in C is no problem; but representing them in COBOL requires choosing COBOL data types that are compatible.

 

Binary values that are passed to Sunaccess functions must be of comp-5 type and passed BY VALUE:

 

***** data declaration *****

 

01 binary-value pic xx comp-5.

 

01 return-value pic xx comp-5.

***** procedure division *****

 

call c_sunAccessFunction using

 

 

by value binary-value

 

 

returning return-value

 

Strings and byte arrays must either be passed BY REFERENCE or as pointers:

 

***** data declaration *****

 

01 buffer pic x(257).

 

01 string1-ptr pointer.

 

01 string1 pic x(50).

 

01 return-value pic xx comp-5.

***** procedure division *****

 

call c_sunAccessFunction using

 

 

by reference buffer

 

 

returning return-value

 

call c_sunAccessFunction using

 

 

by value string1-ptr

 

 

returning return-value

 

The above example assumes that string1-ptr was set to point at string1. For more information on setting up pointers, see Dealing with Pointers in COBOL.

 



Sunaccess Reference Subprogram Call Format Dealing with Pointers in Cobol