ASMB,L,C,R
      HED RBCLS SUBROUTINE OF RDBA-IMAGE/1000 
      NAM RBCLS,7 92069-16224 REV.1912 790130 
* 
* 
******************************************************************* 
* (C) COPYRIGHT HEWLETT-PACKARD COMPANY 1979. ALL RIGHTS RESERVED.
* NO PART OF THIS PROGRAM MAY BE PHOTOCOPIED, REPRODUCED, OR
* TRANSLATED TO ANOTHER PROGRAM LANGUAGE WITHOUT THE PRIOR WRITTEN
* CONSENT OF HEWLETT-PACKARD COMPANY. 
******************************************************************* 
* 
* 
*     SOURCE:    92069-18224
*     RELOC:     92069-16224
* 
*     PRGMR:     CEJ
* 
* 
******************************************************************* 
* 
* 
* 
*  This is the remote DBCLS routine.  Its function is to transform the
*  DBCLS parameters into those needed for RDBA, then to send the request
*  to the remote machine through RBMST. 
* 
*  The calling sequence for RBCLS is: 
* 
*         JSB RBCLS 
*          DEF *+5           return point 
*          DEF BASE          data base parameter from DBCLS call
*          DEF SET           data set parameter from DBCLS call 
*          DEF MODE          mode from DBCLS call 
*          DEF STAT          status array from DBCLS call 
* 
**********************************************************************
*                                                                    *
*  Run Table for local machine in Remote Data Base Access            *
*                                                                    *
*  The local copy of the Run Table used by the RDBA master subrou-   *
*  tines consists of the following sections:                         *
*                                                                    *
*    1) Data Base Control Block                                      *
*    2) Data Item Table                                              *
*    3) Data Set Table                                               *
*    4) Sort Table                                                   *
*                                                                    *
*  These sections are in the order stated.  Details of each section  *
*  follow.                                                           *
*                                                                    *
**********************************************************************
***                                                                ***
*                                                                    *
*  Data Base Control Block - one 17 word entry per data base         *
*                                                                    *
***                                                                ***
RDCBS DEC 17        DBCB size 
* 
RDNAM DEC 0         data base name - three words
      DEC 1 
      DEC 2 
RDRBN DEC 3         remote data base number 
      DEC 4 
RDDSN DEC 5         DS node number
      DEC 6 
RDITC DEC 7         data item count 
RDITP DEC 8         data item table pointer 
RDDSC DEC 9         data set count
RDDSP DEC 10        data set table pointer
RDSOP DEC 11        sort table pointer
      DEC 12
RDLMD DEC 13        lock flag/open mode 
RDLFG EQU RDLMD     1st byte: lock flag 
RDMOD EQU RDLMD     2nd byte: open mode 
      DEC 14
RDCBC DEC 15        # of DCBs desired = 0 
RDMDL DEC 16        maximum data length 
* 
ZERO  EQU RDNAM     base of zero for future equates 
***                                                                ***
*                                                                    *
*  Data Item Table - one 5 word entry per item in a 1000 data base   *
*                                                                    *
***                                                                ***
RI1LN EQU ZERO+5    length of a 1000 entry
* 
RI1NM EQU ZERO      item name - 3 words 
RI1NO EQU ZERO+3    item number 
RI1IL EQU ZERO+4    item length 
***                                                                ***
*                                                                    *
*  Data Set Table - one 6 word entry per set in a 1000 data base     *
*                                                                    *
***                                                                ***
RS1LN EQU ZERO+6    length of a 1000 entry
* 
RS1NM EQU ZERO      set name - 3 words
RS1NO EQU ZERO+3    set number
RS1EL EQU ZERO+4    entry length (in words) 
RS1KL EQU ZERO+5    key item length for a master
***                                                                ***
*                                                                    *
*  Sort Table - one 1 word entry per item and per set.  Each entry   *
*               is a pointer to the respective item or set table     *
*               entry relative to the start of the Run Table         *
*                                                                    *
***                                                                ***
A     EQU 0 
B     EQU 1 
* 
      ENT RBCLS 
      EXT .ENTR,AIRUN,DBDEX,DBRTP,RETBF,RBCST,RBMST 
* 
BASE  NOP 
SET   NOP 
MODE  NOP 
STAT  NOP 
* 
*  Get true parameter and return point addresses. 
* 
RBCLS NOP 
      JSB .ENTR 
       DEF BASE 
* 
*  Make sure that the DBCLS mode is within [1,2]. 
* 
      LDA MODE,I
      CMA,INA 
      INA,SZA,RSS 
      JMP RCLS2     Mode = 1
      INA,SZA 
      JMP E115      Bad mode. 
* 
*  For DBCLS mode 2, ask RBCST to check the set reference for validi- 
*  ty and to return us the data set's number, if valid. 
* 
      JSB RBCST 
       DEF *+4
       DEF SET,I    RBCST needs: set reference
       DEF STNUM        returns: set number 
       DEF STADR                 set's Set Table entry address
      JMP E100      Invalid set return
* 
*  Ask RBMST to build the request, send it and wait for the reply.
* 
RCLS2 JSB RBMST 
       DEF *+11 
       DEF D38      RBMST needs: RDBA Index 
       DEF MODE,I                DBCLS mode 
       DEF STNUM                 data set number
       DEF D0                    dummy
       DEF BASE,I                data base parameter
       DEF STAT,I                status array 
       DEF D0                    outgoing data buffer 
       DEF D0                    outgoing data length 
       DEF D0                    incoming data buffer 
       DEF D0                    incoming data length 
RCLS3 JMP RBCLS,I     <error return>
* 
*  There was no DS error, but check the first word of the status array
*  for an IMAGE error.
* 
      LDA STAT,I
      SZA 
      JMP RCLS3     IMAGE error.
* 
*  There was no IMAGE error either.  If the close mode was 1, we want to
*  release any memory used solely by this data base.
* 
      LDA MODE,I
      CPA D1
      RSS 
      JMP RCLS3     Mode is not 1.
* 
*  First deallocate any extra words in the data (record) buffer used only 
*  by this data base.  DBDEX performs this service for us.
* 
      JSB DBDEX 
       DEF *+1
      JMP E160      Error return, memory corrupt. 
* 
*  Now, release the Run Table memory space. 
* 
      CCA 
      ADA BASE,I    Get primary pointer to Run Table
      ADA DBRTP       by adding the data base number
      STA PTRAD       to the address of pointer table + 1.
* 
      JSB RETBF 
       DEF *+2
       DEF PTRAD,I
* 
      SSA           Did RETBF succeed?
      JMP E160        NO - someone's walked on our memory.
* 
*  A successful DBCLS, replace the first word of the base parameter with
*  its old value (stored in 6th word of DBCB to which AIRUN still points) 
*  then return to user. 
* 
      LDB AIRUN 
      ADB RDDSN 
      LDA B,I 
      STA BASE,I
* 
      JMP RCLS3 
* 
*  Error return points. 
* 
E100  LDB D100      Invalid set reference.
      RSS 
E115  LDB D115      Illegal DBCLS mode. 
      RSS 
E160  LDB D160
* 
      STB STAT,I
      JMP RCLS3 
      SKP 
* 
*  Constants and variables. 
* 
D0    EQU ZERO
D1    EQU ZERO+1
D38   DEC 38
D100  DEC 100 
D115  DEC 115 
D160  DEC 160 
* 
PTRAD NOP 
STADR NOP 
STNUM NOP 
      END 
                                                                                                                                                                                                                        