*****************
*M*  CCI0   GENERATE PATCH FILE, PROCESS GENDCB CMND.& OPEN TAPE
*****************
         SYSTEM   SIG7FDP
*P*
*P*      NAME:    CCI0
*P*      PURPOSE: FORM PATCH FILE & PROCESS GENDCB COMMAND
*P*               IF PATCH DECK CONTAINS ONE.
*P*      DESCRIPTION:  OBTAIN THE PATCH RECORDS AS FORMED BY
*P*               XDELTA & FORM THE PATCH FILE. IF A GENDCB
*P*               COMMAND IS ENCOUNTERED, PROCESS IT & CONTINUE
*P*               PROCESSING PATCHES BUILDING THE PATCH FILE.
*P*               WHEN THE END OF PATCHES IS FOUND, THEN
*P*               SIMULATE THE OPEN OF THE SYSTEM TAPE
*P*               & THEN ENTER BITOTM MODULE TO COPY THE
*P*               FILES TO THE SYSTEM DEVICE. IF COPYING
*P*               UNDER THE FILES, THEN JUST REWIND SYSTEM
*P*               TAPE & THEN ENTER BITOTM MODULE.
*P*
         PAGE
         DEF      PASS0             ENTRY INTO CCI0
CCI0     DSECT    0
         REF      M:BI              DCB
*,*                           USED TO SET M:BI DCB
*,*                           PRIOR TO ENTERING BITOTM MODULE
         REF      M:LL              DCB
*,*                           USED TO OUTPUT MESSAGE TO LL DEV.
         REF      NEWQ              ROUTINE
*,*                           REQUEST SPECIAL I/O TO BE DONE
         REF      MASKS             CONSTANT TABLE
         REF      BOOTFLG           INPUT WORD
*,*                           CONTAINS D.A.FOR PATCHES READ BY
*,*                           XDELTA IN BYTES 1-3.
*,*                           BYTE-0 CONTAINS FLAGS IDENTIFYING
*,*                           THE TYPE OF TAPE BOOT:
*,*                                 80 = I (TTY I/O)
*,*                                 40 = P (LP OUTPUT)
*,*                                 20 = C (CARD PATCHES)
*,*                                 10 = T (TAPE PATCHES)
*,*                                 08 = F (TAPE FILES)
*,*                                 04 = D (XDELTA RETAINED)
*,*                                 02 = S (:SYS FILES)
         REF      DCT1              INPUT HALF WORD
*,*                           VALIDATE BOOT TAPES DEV.ADDR.
         REF      DCT4              INPUT BYTE
*,*                           OBTAIN BOOT TAPES DEV.TYPE
         REF      DCTSIZ            INPUT
*,*                           SIZE OF DCT TABLES
         REF      AVRTBL            OUTPUT DOUBLE WORD
*,*                           MAKE BOOT TAPE APPEAR AVR'ED
         REF      BATAPE            INPUT
*,*                           DCT INDEX WHICH CORRESPONDS TO
*,*                           INDEX =0 IN AVRTBL
         REF      BT31TO0           CONSTANT TABLE
         REF      BITOTM            ROUTINE
*,*                           ROUTINE WHICH COPIES TAPE FILES
*,*                           FROM BOOT TAPE TO SYSTEM DEVICE
         REF      OH:NM             INPUT HALF WORD
*,*                           VALIDATE DEV.TYPE FROM GENDCB
*,*                           COMMAND
         REF      TB:FLGS           INPUT BYTE
*,*                           VERIFY GENDCB COMMANDS DEV.TYPE
*,*                           AS BEING A TAPE DEV.
         REF      TYPMNSZ           INPUT
*,*                           SIZE OF OH:NM TABLE
         REF      PSA%END           WHERE XDELTA PUT PATCHES
         REF      MB:SDI            DEVICE OF SWAPPER
         REF      T:SGRNU           GIVE BACK THE PATCH GRANS
         REF      DSCCVT            FOR INPUT TO T:SGRNU
         PAGE
QREGS    DATA,1   0,255,10,0        FC,PRIO,NRT,DCTX
QBUF     DATA     0,2048            BUFFER,SIZE
QSEEK    DATA     0,0,0             SEEK ADDR
PATCHMBS DATA,1   80,0,0,0          REG FOR MBS TO MOVE RECORD
GETPAGE  DATA,1   8,0,0,1           GET PAGE CAL
PATCHWRT GEN,8,24 17,M:PATCH
         DATA     X'8000030',KEY
KEY      GEN,8,24 3,1000
GMDPREC  GEN,8,24 X'1D',M:PATCH
         DATA     X'80000010'
#GMDS    DATA     0
:LBL     TEXT     ':LBL'
         PAGE
*F*
*F*      NAME:    PASS0
*F*      PURPOSE: BUILD PATCH FILE & OPEN M:BI DCB FOR FILE
*F*               COPY IF FILE COPY IS REQUESTED.
*F*
*D*
*D*      NAME:    PASS0
*D*      ENTRY:   NXTREC
*D*      DESCRIPTION:  READ XDELTA BUILT PATCH RECORDS
*D*               & FORM A REAL PATCH FILE. IN THE PROCESS
*D*               OF DOING THIS, CHECK FOR A GENDCB COMMAND.
*D*               WHEN A GENDCB COMMAND IS FOUND, IT IS PROCESSED
*D*               SYNTACTICALLY & THE INFO IS USED IN SETTING
*D*               THE M:BI DCB (I.E., ACCOUNT #, INSN, ETC.).
*D*               A GENDCB COMMAND IS NOT ENTERED INTO THE
*D*               PATCH FILE.
*D*               IF NO GENDCB COMMAND IS ENCOUNTERED OR THE
*D*               GENDCB COMMAND WHICH IS ENCOUNTERED IS IN
*D*               ERROR SYNTACTICALLY, THE M:BI DCB IS SET
*D*               (AS PREVIOUSLY DESCRIBED) BY PERFORMING
*D*               READS FROM THE BOOT TAPE OBTAINING THE
*D*               SERIAL # & ACCOUNTING INFO.
*D*               THE BITOTM MODULE IS THEN ENTERED FOR
*D*               THE READING OF THE TAPE FILES.
*D*
*D*               NXTREC - GET NEXT PATCH RECORD.
*D*
*D*      INTERFACE:  NEWQ,BITOTM,GENDCB
*D*      ENVIRONMENT:  MAPPED, MASTER
*D*
NEWQ0    LCI      6                 GET REGS FOR NEEWQ AND GO THERE
         LM,12    QREGS
         AI,11    -1
         B        NEWQ
PASS0    EQU      %
         LW,3     PSA%END           ADDR OF PATCH FILE FROM XDLT
         STW,3    QSEEK             SAVE IN QUEUE REGISTERS
         LB,3     MB:SDI
         STH,3    QSEEK
         STS,3    QREGS             SAVE IT
         CAL1,8   GETPAGE           GET A DATA PAGE TO READ ONTI
         STS,9    BUF
         SLS,9    2
         STW,9    QBUF
         STS,9    PATCHMBS
NXTBUF   MTW,-2   QSEEK
         BAL,11   NEWQ0
         LI,4     1
         MTH,-2   BOOTFLG,4         COUNT THEM
         BLZ      PASS0X            ALL DONE
         LW,8     QSEEK             RELEASE THE GRANULE FOR SWAPPING
         BAL,11   DSCCVT
         LH,15    8
         INT,5    QSEEK
         CI,5     X'1478'           NOT LAST 4 GRANS OF 7212
         BGE      %+3
         LI,2     0
         BAL,11   T:SGRNU
         LW,12    QBUF              R12-R13 ARE MBS REGS
NXTREC   LW,13    PATCHMBS          PREPARE TO MOVE
         MBS,12   0                 12 POINTSTO NEXT RECORD IN BLOCK
         LD,4     *BUF              IS THIS A GENDCB
         CD,4     GENDCBT
         BE       GENDCB            YES
         INT,13   BOOTFLG           ONLY CHECK FOR END ON LAST GRAN
         BDR,13   %+3
         AI,4     0                 ZERO IS LAST RECORD+1
         BEZ      PASS0X            DONE WITH COPY
         CI,12    X'7DF'            DID WE MOVE ACROSS PAGE BNDRY
         BAZ      NXTBUF            YES, GET NEXT BUFFER
         CAL1,1   PATCHWRT
         LI,13    1000              INCREMENT KEY
         AWM,13   KEY
         SLS,4    -24               IS THIS GOOD INPUT TO GENMD
         BCS,0    %+4               WAIT UNTIL *
         CI,4     '*'               THEN LOOK FOR GENMDS
         BNE      NXTREC
         MTB,-1   %-3               KIP * CHKEC NOW
         MTW,1    #GMDS             COUNT EM FOR PFIL
         B        NXTREC
         PAGE
M:PATCH  DSECT    2
         DATA     1                 FILE
         DATA     X'100000'         OUTIN
BUF      DATA     X'A000000'
         DATA     X'A00000'         RSZ
         DATA     0,X'80000021'     SAVE,KEYED,SEQUEN
         DATA     PFLP,0,0,0,PKBF
         DATA     0,X'3000000'      KEYM
         DO1      9
         DATA     0
PFLP     DATA,1   1,0,2,2
         TEXTC    'PATCH'
         DATA,1   2,0,2,2
         TEXT     ':SYS  '
         DATA     X'3000002',0,0
         DATA     X'11010101',X'F00' NO AUTO-BACKUP
PKBF     RES      8
         PAGE
         USECT    CCI0
PASS0X   CAL1,1   GMDPREC           START PATCH AT GENMDS
         INT,1    X'25'             FIND TAPE IN DCT TABLES
         LI,6     DCTSIZ
         CH,1     DCT1,6
         BE       GOTDCT
         BDR,6    %-2
         CAL1,2   %+2
         B        %
         DATA     0,X'80000000',NODCT
NODCT    TEXTC    'BOOT DEVICE NOT IN DCT1'
GOTDCT   RES
         LI,7     X'FF'             STICK IT IN QREGS
         STS,6    QREGS
         MTB,5    QREGS             REWIND OFFLINE(=9) IF NO FILES
         LH,3     BOOTFLG           DO WE COPY FILES
         CI,3     X'A00'
         BAZ      PASS0X1           NO, JUST REWIND
         LW,3     BIDEV             DO WE HAVE GENDCB
         BNEZ     PASS0X1           YES, REWIND
         MTB,-5   QREGS             BACK TO READ
         LI,7     2                 ZAP PSWD COUNT
         STB,3    BIPSWD,7
         LI,3     1
         STB,3    BISNS,7           SET SN COUNT
         STW,3    QSEEK             ZAP BACKSPACE COUNT
         LB,3     DCT4,6            GET DEVICE TYPE
         LH,3     OH:NM,3           GET TEXT
         AND,3    MASKS+16          SCRUB SIGN EXTENSION
         STW,3    BIDEV             PUT IT IN FPT
         BAL,11   NEWQ0             READ A RECORD
         LD,0     *BUF              IS THIS :LBL
         CW,0     :LBL
         BNE      %-3               NO, TRY NEXT
         STW,1    BISNS+1           PUT # IN FPT
         LW,0     BT31TO0+30        SET AVR BIT (Y2)
         XW,0     1
         STD,0    AVRTBL-BATAPE-BATAPE,6
         BAL,11   NEWQ0             READ ACN SNTNL
         LCI      3
         LM,0     *BUF
         LCI      2
         STM,1    BIACCN            PUT ACCOUNT IN FPT
PASS0X1  MTB,4    QREGS             READ=>BACKSPACE,BACKSPACE=>REWIND
         BAL,11   NEWQ0
         CAL1,1   BIFPT             SET M:BI
         B        BITOTM            GO COPY FILES
         PAGE
         BOUND    8
BLANKS   TEXT     '       '
GENDCBT  TEXT     ':GENDCB'
M:BIT    TEXT     'M:BI '
INSNT    TEXT     'INSN '
BIFPT    GEN,8,24 X'14',M:BI        FPT FOR SETTING B:BI
         DATA     X'E002',X'40000'
BIDEV    DATA     0
         DATA,1   2,0,2,2           ACCOUNT
BIACCN   RES      2
BIPSWD   DATA,1   3,0,0,2           PASSWORD
         RES      2
BISNS    DATA,1   7,1,0,3           SERIAL NUMBERS
         RES      3
         PAGE
*D*
*D*      NAME:    NNB
*D*      DESCRIPTION:  SEARCH GENDCB COMMAND FOR NEXT
*D*               NON-BLANK CHARACTER.
*D*
*D*      CALL:    R5 = LINK
*D*
*D*      INPUT:   R4 = RELATIVE INDEX INTO GENDCB COMMAND BUFFER
*D*                    OF LAST CHARACTER OBTAINED
*D*
*D*      OUTPUT:  R4 = RELATIVE INDEX INTO GENDCB COMMAND BUFFER
*D*                    OF CURRENT CHARACTER
*D*               R2 = CURRENT NON-BLANK CHARACTER
*D*
*D*      INTERFACE:  SERR
*D*      REGISTERS:  R0,R2,R4 USED, R5 SAVED
*D*      ENVIRONMENT:  MAPPED, MASTER
*D*
NNB      LI,0     ' '               SEARCH FOR NEXT NON-BLANK
         AI,4     1                 NOT INCLUDING CURRENT POS
         CB,0     *BUF,4
         BE       %-2
         CI,4     80                ARE WE STILL IN THE RECORD
         BGE      SERR              NO
         LB,2     *BUF,4
         B        0,5
*
         PAGE
*D*
*D*      NAME:    MOVE
*D*      ENTRY:   SERR
*D*      DESCRIPTION:  OBTAIN A CHARACTER STRING FROM GENDCB
*D*               COMMAND.
*D*
*D*               SERR - DISPLAY ERROR MESSAGE.
*D*
*D*      CALL:    R5 = LINK
*D*
*D*      INPUT:   R4 = RELATIVE CHARACTER POSITION IN GENDCB
*D*                    COMMAND WHERE PROCESSING BEGINS
*D*
*D*      OUTPUT:  R0-R1 = CHARACTER STRING, BLANK PADDED, LEFT
*D*                       JUSTIFIED (8 CHARACTERS MAX.)
*D*               R2 = CHARACTER STRING TERMINATER () ,
*D*
*D*      INTERFACE:  NXTREC
*D*      REGISTERS:  R0-R4 USED, R5 SAVED
*D*      ENVIRONMENT:  MAPPED, MASTER
*D*
*
MOVE     LI,3     -12               MAX CHARS TO MOVE
         LD,0     BLANKS            INITIALIZE TO BLANKS
         LB,2     *BUF,4            GET NEXE CHAR
         CI,2     ' '               IS IT BLANK
         BNE      MOVE1             NO
         AI,4     1                 SKIP OVER BLANKS
         CB,2     *BUF,4
         BE       %-2
         LB,2     *BUF,4
         B        MOVE2
MOVE1    CI,2     ','               IS IT COMMA
         BE       MOVE2             YES
         CI,2     ')'               IS IT RPAREN
         BE       MOVE2             YES
         STB,2    3,3               NO, PUT IN OUTPUT
         AI,4     1
         BIR,3    MOVE+2
MOVE2    AI,3     4                 MAX 8 CHARS
         BGZ      SERR
         CI,3     -8                MIN 1 CHAR
         BG       0,5               O.K., RETURN
SERR     CAL1,2   SERR1             PRINT MESSAGE
         MTB,1    SERR1             MAKE TYPE CAL
         CAL1,2   SERR1             TYPE IT
         MTB,-1   SERR1             MAKE PRINT CAL
         B        NXTREC
         PAGE
SERR1    DATA     1**24,1**31,%+1
         TEXTC    '*** GENDCB ERROR'
GDCBP    GEN,8,24 X'11',M:LL
         DATA     X'30000010'
         PZE      *BUF
         DATA     80
         PAGE
*
*D*
*D*      NAME:    GENDCB
*D*      DESCRIPTION:  PROCESS THE GENDCB COMMAND SYNTACTICALLY.
*D*               IF MORE THAN ONE GENDCB COMMAND IS ENCOUNTERED,
*D*               THE LAST ONE WILL TAKE PRECEDENCE.
*D*               THE GENDCB COMMAND SYNTAX IS AS FOLLOWS:
*D*
*D* :GENDCB (M:BI,ACCNT<,PASWRD>,(INSN,#<,#<,#>>),TAPE-TYPE)
*D*
*D*      OUTPUT:  BIDEV = 0 IF GENDCB COMMAND BAD
*D*                     > 0 GENDCB COMMAND IS O.K.
*D*
*D*      INTERFACE:  NNB,MOVE,SERR,NXTREC.
*D*      ENVIRONMENT:  MAPPED, MASTER
*D*
*
GENDCB   LI,6     2                 INITAIALIZE REGISTER TO 2
         CAL1,1   GDCBP             PRINT IT
         LI,4     0                 AND ZERO
         STB,4    BIPSWD,6          RESET SIZE BYTE
         STB,4    BISNS,6
         STW,4    BIDEV             AND FLAG THAT WE GOT THROUGH
         LI,4     7                 START SCAN IN COLUMN 8(WHICH IS BLANK)
         BAL,5    NNB               GET 1ST CHAR
         CI,2     '('               GOOTA BE LPAREN
         BNE      SERR
         BAL,5    NNB               SKIP (
         BAL,5    MOVE              NOW WE SHOLD GET M:BI
         CD,0     M:BIT
         BNE      SERR
         CI,2     ','               AND MUST END IN ,
         BNE      SERR
         BAL,5    NNB               TO NEXT (MUST BE ACCOUBT)
         BAL,5    MOVE              GET ACCT IN REGS
         LCI      2
         STM,0    BIACCN            STUFF IT AWAY
GENDCB1  CI,2     ','               ACCN,PSWD ALSO END IN ,
         BNE      SERR
         BAL,5    NNB
         CI,2     '('               IF ( , MUST BE NO MORE PSWDS
         BE       GENDCB2
         BAL,5    MOVE              GET PSWD
         MTB,-2   BIPSWD,6          MAX ONE PASSWORD
         BEZ      SERR
         MTB,4    BIPSWD,6
         LCI      2
         STM,0    BIPSWD+1
         B        GENDCB1           ENDS SAME AS ACCOUNT
GENDCB2  BAL,5    NNB               SKIP OVER (
         BAL,5    MOVE              GET INSN TEXT
         CD,0     INSNT             IS IT RIGHTLY SPELLED
         BNE      SERR              NO
GENDCB3  CI,2     ','               MUST END IN , OR 9
         BNE      GENDCB4           COULD BE DONE WITH SNS
         BAL,5    NNB               SKIP COMMA
         BAL,5    MOVE              GET SN
         CI,3     -4                MAX 4 CHARS
         BG       SERR              TOO BIG
         MTB,-3   BISNS,6           MAX THREE OF THEM
         BEZ      SERR
         MTB,4    BISNS,6
         LB,3     BISNS,6           WHERE DOES THIS ONE GO
         STW,0    BISNS,3
         B        GENDCB3
GENDCB4  CI,2     ')'               MUST BE )
         BNE      SERR              SYNTAX SERRER
         LB,3     BISNS,6           DID WE GET AT LEAST ONE
         BEZ      SERR              NO
         BAL,5    NNB               MUST BE , NEXT
         CI,2     ','
         BNE      SERR
         BAL,5    NNB               THEN 9T OR 7T
         BAL,5    MOVE
         CI,0     X'BFBF'           MAX TWO CHARS
         BANZ     SERR
         SAS,0    -16               MAKE HW CVVALUE
         LI,1     TYPMNSZ           SEARCH TABLE OF VALID VALUES
         CH,0     OH:NM,1
         BE       %+3
         BDR,1    %-2
         B        SERR              NOT THERE
         LC       TB:FLGS,1         IS IT A TAPE TYPE DEVICETPYE
         BCS,4    SERR              NO
         BCR,8    SERR              NO
         AND,0    MASKS+16          SCRUB SIGN EXTENSION
         CI,2     ')'               AND MUST END WITH )
         BNE      SERR
         STW,0    BIDEV             SET SUCCESS FLAG
         B        NXTREC            DON T PUT GENDCBS IN PATCH FILE
         END

