/*---------------------------------------------------------------------+
| Copyright (c) 1995, SAS Institute Inc. |
| Unpublished - All Rights Reserved |
| S A S / C S A M P L E |
| |
| NAME: DYNALLOC |
| LANGUAGE: C |
| PURPOSE: DYNALLOC demonstrates the use of the function: |
| "osdynalloc()", which is used to invoke MVS dynamic |
| allocation SVC (SVC 99). DYNALLOC opens the Internal |
| Reader and submits a job to the JES INTRDR. |
| NOTES: Customize the "#define DATA_SET_NAME" value below, the |
| default value is: SASC.C600.CNTL(NTVALID) |
| NOTES: Additional details on SVC 99 dynamic allocation may be |
| found in the IBM Publication MVS/ESA Application |
| Development Guide: Assembler Language Programs |
| MVS - |
| COMPILE, LINK, EXECUTE: SUBMIT prefix.SAMPLE.AUX(LC370CLG) |
| where "prefix" is the installation defined high-level- |
| qualifier for the SAS/C product. |
| TSO - |
| COMPILE: LC370 CLIST |
| LINK: CLK370 CLIST |
| EXECUTE: CALL 'your.load.lib(DYNALLOC)' |
| CMS - N/A |
+---------------------------------------------------------------------*/
#include <os.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*---------------------------------------------------------------------+
| Modify the "#define" below, the DATA_SET_NAME value should be the |
| dataset name, containing JCL, to be submitted. |
+---------------------------------------------------------------------*/
#define DATA_SET_NAME "dsn:SASC.C600.CNTL(NTVALID)"
main()
{
int reason = 0;
int rc;
char buffer[81];
FILE *fp;
FILE *jfp;
/*---------------------------------------------------------------------+
| call osdynalloc() - action = DYN_ALLOC, keywords = char *, and |
| libmsgbuf = NULL. |
| NOTE: keywords may contain a key_word=?. Each "?" indicates the |
| value, is specified as an additional argument in the argument list. |
| Multiple "?" may be used, and each "?" corresponds directly to |
| additional arguments in the argument list. |
+---------------------------------------------------------------------*/
rc = osdynalloc(DYN_ALLOC,
"ddn=JCLOUT,recfm=F,lrecl=80,sysout=A,"
"sysoutpgm=INTRDR,reason=?",NULL,&reason);
if (rc != 0)
{
printf("osdynalloc INTRDR allocation failed, rc = %d, "
"reason = %04x\n", rc, reason);
exit(EXIT_FAILURE);
}
/*---------------------------------------------------------------------+
| ddn:JCLOUT has been allocated, now call fopen() |
+---------------------------------------------------------------------*/
jfp = fopen("ddn:JCLOUT","wb");
if (jfp == NULL)
{
perror("fopen() for jclout failed");
exit(EXIT_FAILURE);
}
/*---------------------------------------------------------------------+
| call fopen() with the DATA_SET_NAME value |
+---------------------------------------------------------------------*/
fp = fopen(DATA_SET_NAME,"rb");
if (fp == NULL)
{
perror("fopen() for DATA_SET_NAME failed");
exit(EXIT_FAILURE);
}
/*---------------------------------------------------------------------+
| read a line of from DATA_SET_NAME and then write to JCLOUT |
+---------------------------------------------------------------------*/
while (fread(buffer, 80, 1, fp) != NULL)
{
fwrite(buffer, 80, 1, jfp);
}
/*---------------------------------------------------------------------+
| close() JCLOUT and DATA_SET_NAME |
+---------------------------------------------------------------------*/
rc = fclose(jfp);
if (rc != 0)
perror("fclose() error closing jclout");
rc = fclose(fp);
if (rc != 0)
perror("fclose() error DATA_SET_NAME");
printf("DYNALLOC Completed");
return (EXIT_SUCCESS);
}
|