Coding your MPP program in C language
The program shown below is a skeleton MPP written in C language.
The numbers to the right of the program refer to the notes that follow the program. All storage areas that are referenced in the parameter list of your C language application program call to IMS can reside in the extended virtual storage area.
Skeleton MPP written in C
NOTES
#pragma runopts(env(IMS),plist(IMS)) 1
#include <ims.h>
#include <stdio.h>
/* */
/* ENTRY POINT */
/* */
main() { 2
static const char func_GU[4] = "GU "; 3
static const char func_ISRT[4] = "ISRT";
.
#define io_pcb ((IO_PCB_TYPE *)(_pcblist[0])
4
#define alt_pcb (_pcblist[1])
#define db_pcb (_pcblist[2])
.
int rc;
5
.
#define io_pcb ((IO_PCB_TYPE *)(_pcblist[0])
6
#define alt_pcb (_pcblist[1])
#define db_pcb (_pcblist[2])
.
rc = ctdli(func_GU, io_pcb, msg_seg_io_area);
7
.
rc = ctdli(func_GU, db_pcb, db_seg_io_area, ssa_name);
8
.
rc = ctdli(func_ISRT, alt_pcb, alt_msg_seg_out);
9
.
}
10
C language interface
11Note:
- The env(IMS) establishes
the correct operating environment and the plist(IMS) establishes the correct parameter list,
when invoked under IMS. The ims.h
header file contains declarations for PCB layouts, __pcblist, and
the ctdli routine. The PCB layouts define masks for the DB PCBs that
the program uses as structures. These definitions make it possible
for the program to check fields in the DB PCBs.
The stdio.h header file contains declarations for sprintf, which is useful for building SSAs.
- After IMS has loaded the application program's PSB, IMS passes control to the application program through this entry point.
- These are convenient definitions for the function codes and could be in one of your include files.
- These could be structures, with no loss of efficiency.
- The return code (status value) from DL/I calls can be returned and used separately.
- The C language run-time sets up the __pcblist values. The order in which you refer to the PCBs must be the same order in which they have been defined in the PSB: first the TP PCB, then any alternate PCBs that your program uses, and finally the database PCBs that your program uses.
- The program issues a
GUcall to the I/O PCB to retrieve the first message segment. You can leave out the rc =, and check the status in some other way. - The program issues a
GUcall to the DB PCB to retrieve a database segment. The function codes for these two calls are identical; the way that IMS identifies them is by the PCB to which each call refers. - The program then sends an output message to an alternate destination
by issuing an
ISRTcall to an alternate PCB. - When there are no more messages for the program to process, the program returns control to IMS by returning from main or by calling exit().
- IMS provides a language interface module (DFSLI000) that gives a common interface to IMS. This module must be made available to the application program at bind time.