C language application programming
Application programs in C use the following format, parameters, and DL/I calls to communicate with IMS databases.
Format
Notes:
- 1 For AIBTDLI, parmcount is required for C applications.
Parameters
- rc
- This parameter receives the DL/I status or return code. It is a two-character field shifted into
the 2 low-order bytes of an integer variable (int). If the status code is two blanks, 0 is placed in
the field. You can test the rc parameter with an if statement. For
example,
if (rc == 'IX')
. You can also use rc in a switch statement. You can choose to ignore the value placed in rc and use the status code returned in the PCB instead. - parmcount
- Specifies the name of a fixed binary (31) variable in user-defined storage that contains the number of parameters in the parameter list that follows parmcount.
- function
- Specifies the name of a character (4) variable, left justified in user-defined storage, that contains the call function to be used. The call function must be left-justified and padded with blanks (such as GUbb)
- db pcb
- Specifies the name of a pointer variable that contains the address of the database to be used for the call. The PCB address must be one of the PCB addresses passed on entry to the application program in the PCB list.
- tp pcb
- Specifies the name of a pointer variable that contains the address of the I/O PCB or alternate PCB to be used for the call. The PCB address must be one of the PCB addressed passed on entry to the application program in the PCB list.
- aib
- Specifies the name of the pointer variable that contains the address of the structure that defines the application interface block (AIB) in user-defined storage.
- i/o area
- Specifies the name of a pointer variable to a major structure, array, or character string that defines the I/O area in user-defined storage used for the call. The I/O area must be large enough to contain all of the returned data.
- i/o area length
- Specifies the name of a fixed binary (31) variable in user-defined storage that contains the I/O area length.
- area length
- Specifies the name of a fixed binary (31) variable in user-defined storage that contains the length of the area immediately following it in the parameter list. Up to seven area lengths or area pairs can be specified.
- area
- Specifies the name of the pointer variable that contains the address of the structure that defines the user-defined storage to be checkpointed. Up to seven area lengths or area pairs can be specified.
- token
- Specifies the name of a character (4) variable in user-defined storage that contains a user token.
- stat function
- Specifies the name of a character (9) variable in user-defined storage that contains the stat function to be performed.
- ssa
- Specifies the name of a character variable in user-defined storage that contains the SSAs to be used for the call. Up to 15 SSAs can be specified, one of which is rootssa.
- rootssa
- Specifies the name of a character variable that defines the root segment search argument in user-defined storage.
- rsa
- Specifies the name of a character variable that contains the record search argument for a
GU
call or where IMS should return the rsa for anISRT
orGN
call. - psb name
- Specifies the name of a character (8) variable containing the PSB name to be used for the call.
- uibptr
- Specifies the name of a pointer variable that contains the address of the structure that defines the user interface block (UIB) that is used in user-defined storage.
- sysserve
- Specifies the name of a character (8) variable string in user-defined storage to be used for the call.
I/O area
In C, the I/O area can be of any type, including
structures or arrays. The ctdli declarations in ims.h do not have any prototype
information, so no type checking of the parameters is done. The area may be auto,
static, or allocated (with malloc or calloc). You need to give special
consideration to C-strings because DL/I does not recognize the C convention of terminating strings
with nulls ('\0'
) Instead of the usual strcpy and strcmp functions,
you may want to use memcpy and memcmp.
Example of a DL/I call format
Using the DL/I CEETDLI interface:
#include <leawi.h>
⋮
CEETDLI (function,db pcb,i/o area,ssa1);
Using the DL/I AIBTDLI interface:
int rc;
⋮
rc=AIBTDLI (parmcount,function,aib,i/o area,ssa1);
Using the DL/I language-specific interface:
#include <ims.h>
int rc;
⋮
rc=CTDLI (function,db pcb,i/o area,ssa1);