www.sas.com > Service and Support > Technical Support
 
Technical Support SAS - The power to know(tm)
  TS Home | Intro to Services | News and Info | Contact TS | Site Map | FAQ | Feedback


/*---------------------------------------------------------------------+
|                Copyright (c) 1995, SAS Institute Inc.                |
|                  Unpublished - All Rights Reserved                   |
|                      S A S / C   S A M P L E                         |
|                                                                      |
|         NAME: SYNAD                                                  |
|     LANGUAGE: C                                                      |
|      PURPOSE: Demonstrate the use of a SYNAD exit from the SAS/C     |
|               BSAM OS Low-Level I/O. The SYNAD exit will be invoked  |
|               when an I/O Error is sensed during I/O to a DCB        |
|        NOTES: This function will open an INPUT DD, read the number   |
|               of records and print the number of input records. If   |
|               an error occurs while reading the DD, the SYNAD exit   |
|               is driven, with the relevant I/O error information.    |
|        NOTES: The INPUT DD should be: RECFM=F, LRECL=80, BLKSIZE=80  |
|   MVS -                                                              |
|      COMPILE, LINK, EXECUTE: SUBMIT prefix.SAMPLE.AUX(SYNAD)         |
|               where "prefix" is the installation defined high-level- |
|               qualifier for the SAS/C product.                       |
|   TSO -                                                              |
|      COMPILE: LC370 CLIST                                            |
|        NOTES: Issue a:  TSO ALLOC F(INPUT) DS('your.input.dd') SHR   |
|        NOTES: Use compiler option: BITFIELD(1)                       |
|        NOTES: To force EXIT processing, use the compiler options:    |
|               BITFIELD(1) DEFINE(ERROR)                              |
|         LINK: CLK370 CLIST                                           |
|      EXECUTE: CALL 'your.load.library(SYNAD)'                        |
|   CMS - N/A                                                          |
|   MISC NOTES: Additional information on BSAM I/O may be found in the |
|               SAS/C Library Reference, Volume 2, Release 6.00,       |
|               Chapter 3, MVS Low-Level I/O functions.                |
+---------------------------------------------------------------------*/
#include <stdio.h>
#include <osio.h>
#include <getmain.h>

static int synad_exit();

int main()
{

DCB_t *input;
exit_t in_exlst(|1|) = {LAST | SYNAD, &synad_exit};
DECB_t input_DECB;
char *buf;
int count = 0;
int err;

/*---------------------------------------------------------------------+
| When the compile option 'DEFINE(ERROR)' is specified, the DCB        |
| attributes do not match the input file. The forces a "wrong length   |
| record" error, reading the file, and the synad exit will be driven.  |
+---------------------------------------------------------------------*/
#ifdef ERROR
   input = osdcb("INPUT   ","recfm=v,lrecl=40,blksize=44", in_exlst, 0);
#else
   input = osdcb("INPUT   ","recfm=f,lrecl=80,blksize=80", in_exlst, 0);
#endif

if (osopen(input, "input",0))
 {
  puts("Input open failed.");
  exit(16);
 }

printf("Hello, I'm in the main function, addr of input_DECB is %08X\n",
        &input_DECB);

buf = GETMAIN_U(input->DCBBLKSI, 0, LOC_BELOW);

for (;;)
 {
  osread(input_DECB, input, buf, 0);
  if ((err = oscheck(input_DECB)) != 0)
     {
      if (err != -1) puts("Input error.");
      break;
     }
  ++count;
 }

printf("%d blocks read", count);
FREEMAIN(buf, input->DCBBLKSI, 0 , UNCOND);
osclose(input,"disp");
return(0);
}


static int synad_exit(p1, p2)
 struct
 {                        /* Consult the Data Administration Guide */
  short synadaf_msg_len;  /* and Data Admin. Macro Reference for a */
  short unused_1;         /* complete description of the SYNADAF   */
  short rec_len;          /* message.                              */
  short unused_2;
  long  buf_address;
  short num_bytes_read;
  char msg(|114|);
 } *p1;
 DECB_t *p2;
{
printf("Hello, I'm in the SYNAD exit\n");
printf("SYNADAF pointer=%08X, DECB_t pointer=%08X\n",p1,p2);
printf("SYNADAF message=%.114s\n",p1->msg);
return(0);
}

Copyright (c) 2000 SAS Institute Inc. All Rights Reserved.
Terms of Use & Legal Information | Privacy Statement