Sample C to PL/I ILC applications

PL/I main routine calling a C subroutine:
 *PROCESS LC(101),OPT(0),S,MAP,LIST,STMT,A(F),AG;                         
   CEPLI2C: PROC OPTIONS(MAIN);                                           
   /*Module/File Name: IBMCPL       */                                    
   /***********************************************************/          
   /* FUNCTION   :  Interlanguage communications call to      *
   /*               a C program.                              *
   /* This example illustrates an interlanguage call from     *
   /* a PL/I main program to a C subroutine.                  *
   /* The parameters passed across the call from PL/I to      *
   /* C have the following declarations:                      *
   /*                                                         *
   /* PL/I fixed bin(15,0) to C short as pointer to BIN       *
   /* PL/I fixed bin(31,0) to C int                           *
   /* PL/I float bin(53) to C double                          *
   /* PL/I float bin(109) to C long double                    *
   /* PL/I characters to C as pointer to pointer to CHAR      *
   /***********************************************************/          
   /***********************************************************/
   /* DECLARES FOR THE CALL TO C                              *
   /***********************************************************/
      DCL ADDR               BUILTIN;
      DCL J                  FIXED BIN(31,0);
      DCL CECFPLI            EXTERNAL ENTRY RETURNS(FIXED BIN(31,0));
      DCL PL1_SHORT          FIXED BIN(15,0) INIT(15);
      DCL PL1_INT            FIXED BIN(31,0) INIT(31);
      DCL PL1_DOUBLE         FLOAT BIN(53) INIT (53.99999);
      DCL PL1_LONG_DOUBLE    FLOAT BIN(109) INIT(3.14151617);
      DCL PL1_POINTER        PTR;
      DCL CHARSTRING         CHAR(23) INIT('PASSED CHARACTER STRING');
                                                                          
   /************************************************************/          
   /*  PROCESS STARTS HERE                                     *
   /************************************************************/          
      PUT SKIP LIST ('**********************************');                
      PUT SKIP LIST ('PL/I CALLING C/370 EXAMPLE STARTED');                
      PUT SKIP LIST ('**********************************');                
      PL1_POINTER = ADDR(CHARSTRING);                                      
      PUT SKIP LIST ('Calling C/370 subroutine');                          
      J = CECFPLI( ADDR(PL1_SHORT), PL1_INT, PL1_DOUBLE,                   
         PL1_LONG_DOUBLE, ADDR(PL1_POINTER));                              
      PUT SKIP LIST ('Returned from C/370 subroutine');                    
      IF (J ¬= 999) THEN                                                   
         PUT SKIP LIST ('Error in return code from C/370');                
      PUT SKIP LIST ('**********************************');                
      PUT SKIP LIST ('PL/I CALLING C/370 EXAMPLE ENDED  ');                
      PUT SKIP LIST ('**********************************');                
   END CEPLI2C;                                                            

C routine called by PL/I main routine

 /*Module/File Name:  EDCCPL   */                                                                          
 #pragma linkage (CECFPLI,PLI)                                            
 #include <stdio.h>
 #include <string.h>
  /******************************************************************     
   *This is an example of a C program invoked by a PL/I program.    *
   *CECFPLI is called from PL/I program CEPLI2C with the following  *
   *list of arguments:                                              *
   * PL/I fixed bin(15,0) to C short as pointer to BIN              *
   * PL/I fixed bin(31,0) to C int                                  *
   * PL/I float bin(53) to C double                                 *
   * PL/I float bin(109) to C long double                           *
   * PL/I characters to C as pointer to pointer to CHAR             *
   ******************************************************************/    
  int CECFPLI (short **c_short,                                           
               int *c_int,                                               
               double *c_double,                                         
               long double *c_long_double,                               
               char *** c_character_string                               
                )                                                         
  {                                                                       
     int ret=999; /* pli is expecting 999 returned */                                                                          
     fprintf(stderr,"CECFPLI STARTED\n");                                 
  /******************************************************************     
   * Compare each passed argument against the C value.              *
   * Issue an error message for any incorrectly passed parameter.   *
   ******************************************************************/    
     if (**c_short != 15)                                                 
     {                                                                    
       fprintf(stderr,"**c_short not = 15\n");                            
       --ret;                                                             
     }                                                                       
     if (*c_int != 31)                                                    
     {                                                                    
       fprintf(stderr,"*c_int not = 31\n");                               
       --ret;                                                             
     }                                                                    
     if ((53.99999 - *c_double) >1.0E-14)                                 
     {                                                                    
       fprintf(stderr,                                                    
            "53.99999 - *c_double not >1.0E-14\n");                       
       --ret;                                                             
     }                                                                    
     if ((3.14151617 - *c_long_double) >1.0E-16)                          
     {                                                                    
       fprintf(stderr,                                                    
            "3.14151617 - *c_long_double not >1.0E-16\n");                
       --ret;                                                             
     }                                                                     
     if (memcmp(**c_character_string,"PASSED CHARACTER STRING",23)        
               != 0)                                                      
     {                                                                    
       fprintf(stderr,"**c_character_string not %s\n",                    
       "\"PASSED CHARACTER STRING\"");                                    
       --ret;                                                             
     }                                                                    
  /******************************************************************     
   * PL/I will check for a correct return code.                     *
   ******************************************************************/    
     fprintf(stderr,"CECFPLI ENDED\n");                                   
     return(ret);                                                         
  }