/*-------------------------------------------------------------------+
|                                                                    |
|                Copyright (c) 1996, SAS Institute Inc.              |
|                  Unpublished - All Rights Reserved                 |
|                      S A S / C   S A M P L E                       |
|         Name: UPDBLDH                                              |
|     Language: C                                                    |
|      Purpose: Library includes, function prototypes for static     |
|               functions, various defines, structure mapping for    |
|               SYNAD exit and abend exit functions.                 |
|                                                                    |
|   For Sample: prefix.SAMPLE.C(UPDBLD)                              |
|                                                                    |
+-------------------------------------------------------------------*/
#ifndef __UPDBLDH__
#define __UPDBLDH__
#include <lclib.h>
#include <stdio.h>
#include <stdlib.h>
#include <osio.h>
#include <os.h>
#include <string.h>

#undef DEBUG                    /* Ensure we can use assert()        */
#include <assert.h>

#include "p2upnode.h"
#include "p2upmh.h"

#define NOT_A_DATASET    74
#define MEM_FOUND        0     /* Same as os find macro              */
#define LIST_END         24    /* End of skiplist                    */
#define CONTINUE_LOOP    48
#define OSXXX_SUCCESS    0     /* Successful completion from osget() */
                               /* or osput()                         */
#define SOURCE_DS_EMPTY  "NOTE=> SOURCE DS EMPTY"
#define ALIAS_REAL       "Source: ALIAS AS REAL"
#define REAL_MEMBER      "Source: REAL MEMBER  "
#define OSGET_EOF        -1   /* End-of-file return from osget()    */
#define LRECL            80
#define YES              1
#define NO               0

 /*------------------------------------------------------------------+
 | Structure with the layout of information passed to a SAS/C SYNAD  |
 | exit routine in R1.  It comes from the SYNADF macro issued by     |
 | by the SAS/C library when a SYNAD exit is called.                 |
 |                                                                   |
 | Note: structure members with names 'unused_x' have actual data,   |
 |       however it is not used by this program.                     |
 |                                                                   |
 |       See SYNADAF macro in 'MVS Macro Instructions for Data Sets' |
 |       for details on the information returned.                    |
 |                                                                   |
 +------------------------------------------------------------------*/
 struct SYNAD_INFO
 {
  short synadaf_msg_len;  /* Length : Standard message (LL)         */
  short unused_1;         /* bb                                     */
  short rec_len_std;      /* ll                                     */
  short unused_2;         /* bb                                     */
  long  buf_address;      /* input buffer address                   */
  short num_bytes_read;
  char msg1[114];         /* Message: Standard                      */
  long  parm2;
  long  parm1;
  short pdse_msg_len;     /* Length : PDSE message (LL)             */
  short unused_3;         /* bb                                     */
  short rec_len_pdse;     /* ll*/
  short unused_4;         /* bb                                     */
  char  unused_5;         /* ','                                    */
  char msg2[120];         /* Message: PDSE                          */
 };

 /*------------------------------------------------------------------+
 | Structure with the layout of information passed to a SAS/C DCB    |
 | abend exit routine in R1.  Consult the Data Adminstration Guide   |
 | and Macro Reference for additional information.                   |
 +------------------------------------------------------------------*/
 struct ABEND_INFO
 {
  unsigned abend_code: 12;
  unsigned :4;
  unsigned char return_code;
    union {
            struct
                    {
                     unsigned        : 4;
                     unsigned recover: 1;
                     unsigned ignore : 1;
                     unsigned delay  : 1;
                     unsigned        : 1;
                    } ok_to;
           char action;
          };
  DCB_t * dcbp;
  void * O_C_EOV_workarea;
  void * recovery_work_area;
 };


 /*------------------------------------------------------------------+
 | Prototype: Internal functions used by updbld functioin.           |
 +------------------------------------------------------------------*/

 static int updio       ( DCB_t *, DCB_t *, NODE *, int *);

 static int updprep     ( DCB_t * (*input), DCB_t * (*output) );

 static int updverfi    ( void );

 static int updaka      ( NODE * (*), NODE * (*) );

 static int updproc     ( DCB_t *, DCB_t *, NODE *);

 static int synad_exit  (void *, void * );

 static int abend_exit  (void *, void * );

 static int insert_alias( NODE *, PDS_MBR *);
#endif /* __UPDBLDH__ */