/*-------------------------------------------------------------------+
|                Copyright (c) 1995, SAS Institute Inc.              |
|                  Unpublished - All Rights Reserved                 |
|                      S A S / C   S A M P L E                       |
|                                                                    |
|         NAME: C2COBC                                               |
|     LANGUAGE: C                                                    |
|      PURPOSE: THIS EXAMPLE DEMONSTRATES A C MAIN CALLING A         |
|               COBOL ROUTINE.                                       |
|               IT CONSISTS OF SAMPLE LIBRARY MEMBERS                |
|               C2COBC, C2COBCO, AND C2COBOL.                        |
|   MVS -                                                            |
|      COMPILE: USE JCL PROVIDED IN SAMPLE.AUX(C2COBOL).             |
|         LINK: USE JCL PROVIDED IN SAMPLE.AUX(C2COBOL).             |
|      EXECUTE: USE JCL PROVIDED IN SAMPLE.AUX(C2COBOL).             |
|   TSO -                                                            |
|      COMPILE: COBOL - USE COBOL COMPILER.                          |
|               C - LC370C C2COBC                                    |
|         LINK: ILCLINK w/ CONTROL CARDS IN SAMPLE.AUX(C2COBOL).     |
|      EXECUTE: CALL <SAMPLE>.LOAD(C2COBOL)                          |
|   CMS -                                                            |
|      COMPILE: COBOL - USE COBOL COMPILER.                          |
|               C - LC370 C2COBC                                     |
|          LINK: ILCLINK w/ CONTROL CARDS IN SAMPLE.AUX(C2COBOL).    |
|       EXECUTE: CALL C2COBOL                                        |
|    MISC NOTES: THE FOLLOWING LSCL102 MESSAGES CAN BE IGNORED:      |
|LSCL102 Warning: Can't open file during autocall:ddn:SYSLIB(IGZEBST)|
|LSCL102 Warning: Can't open file during autocall:ddn:SYSLIB(COBPROG)|
+-------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <ilc.h>

   __cobol void COBPROG();

main()
{

   void *token;
   printf("In the C program! \n");
   if(!(token = mkfmwk("cobol","")))
     exit(16);

   else
     {
     printf("Before calling the COBOL routine\n");
     COBPROG();
     printf("In the C pgm again!\n");
     printf("After calling the COBOL routine\n");
     if (dlfmwk(token))
        exit(8);
     else
        exit(0);
     }

 return 1;
}