Examples: Calling PL/I from COBOL and C

COBOL - PL/I RTS Initialization

      $SET CASE FCDCAT ASSIGN(EXTERNAL)
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLIRTS.
       ENVIRONMENT DIVISION.
       special-names.
        call-convention 8 is litlink.
       WORKING-STORAGE SECTION.    
       01  ARGV                        pointer value null.  
       01  PLI-LANG                    PIC X(02) COMP-5 value 0.
       01  PLI-RETCODE                 PIC X(04) COMP-5.
       01  SYSPRINT-STATUS             PIC X(02).
       LINKAGE SECTION.
       
       PROCEDURE DIVISION.
       
           *>  Initialize the PL/I Runtime 
           call litlink "__lpi_init" using by value 0 size 4
                                     by reference argv
                                     by reference argv *> dummy
                                     by value pli-lang                       
        
           move 0 to return-code
           goback.

COBOL - PL/I RTS Termination

     $SET CASE FCDCAT ASSIGN(EXTERNAL)
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PLIRTS.
       ENVIRONMENT DIVISION.
       special-names.
        call-convention 8 is litlink.
       WORKING-STORAGE SECTION.    
       01  ARGV                        pointer value null.  
       01  PLI-LANG                    PIC X(02) COMP-5 value 0.
       01  PLI-RETCODE                 PIC X(04) COMP-5.
       01  SYSPRINT-STATUS             PIC X(02).
       LINKAGE SECTION.
       
       PROCEDURE DIVISION.
       
           *> Deinitialize the PL/I Runtime.
           call litlink "__lpi_fini_and_return" using 
                                               by value pli-lang
                                               by reference pli-retcode
                                               
           move 0 to return-code
           goback.

C - PL/I RTS Initialization Example

void  __lpi_init(int argc, char **argv, char **env, LANGUAGE_CODE lang);
void   __lpi_fini_and_return(LANGUAGE_CODE lang, int *pRetcode);
static short pli_lang = 0;

void initplirts()
{
    int fini_retcode;
    int argc = 0;
    void * argv = NULL;
    void * dummy = NULL;
    __lpi_init(argc, &argv, &dummy, pli_lang);
   /* Call below is Windows Only  */
   P$SETUPDEFFILES();  /* establish SYSPRINT, SYSIN, SYSOUT in the RTS  */
}