Typed buffers are defined by data structures in header files (in C) or COPY elements (in COBOL), which must be used in the participating programs.
Data is exchanged between the programs on the basis of these data structures, which must therefore be known to both the client and the server. All data types described in the table on "Typed buffers" are permitted.
The header files or COBOL COPY files in which the typed buffers are described serve as input for the configuration program xatmigen
, see section “The xatmigen tool”. The following rules apply to these files:
C and COBOL data structures must be contained in separate files. A file that contains both C includes and COBOL COPY elements is not permitted as input.
The files can only comprise definitions of data structures, blank lines, and comment statements. Macro statements, i.e. statements beginning with ‘#’, are permitted in C.
The data structure definitions must be specified in full. In particular, COBOL data records must begin with the level number “01”.
The data structures must not be nested.
Only absolute values are permitted as field lengths, macro constants are not accepted.
Only the data types listed in the table on "Typed buffers" are permitted. In particular, no pointer types are permitted in C.
The user may have to use the configuration tool xatmigen
to map the character arrays to
ASN.1 string types because neither C nor COBOL recognizes these data types; see section“The xatmigen tool”.
XATMI calls for memory allocation are available for C (tpalloc ...).
Two simple examples are provided below for C and COBOL respectively.
Example
typedef struct { char name[20]; /* person’s name */ int age; /* age */ char sex; long shoesize; } t_person; struct t_city { char name[32]; /* name of city */ char country; long inhabitants; short churches[20]; long founded; }
***** Personal record 01 PERSON-REC. 05 NAME PIC X(20). 05 AGE PICTURE S9(9) COMP-5. 05 SEX PIC X. 05 SHOESIZE PIC S9(9) COMP-5. ***** City record 01 CITY-REC. 05 NAME PIC X(32). 05 COUNTRY PIC X. 05 INHABITANTS PIC S9(9) COMP-5. 05 CHURCHES PIC S9(4) COMP-5 OCCURS 20 TIMES. 05 FOUNDED PIC S9(9) COMP-5.
Further examples can be found in the X/Open Specification on XATMI.