;*********************************
; SHODDB.M68    -       SHOW DDB
;
; by Dave Heyliger - AMUS Staff
;
; Usage: SHODDB input file
;*********************************

       ;search normal files and AAA (on AMUS Network)
       SEARCH SYS
       SEARCH SYSSYM
       SEARCH AAA

       ;create a version number
       VMAJOR  =1.
       VMINOR  =0.
       VEDIT   =100.

;MACRO definitions below:

DEFINE  TYPE1   AA,BB,CC                ;AA: string, BB: string, CC: offset
       TYPE    'AA                     ;type string
       TAB                             ;tab over
       CLR     D1                      ;clear D1 for OCVT
       MOV'BB  FILE+'CC(A4),D1         ;get the number into D1
       OCVT    0,OT$TRM                ;type it out (0 leading spaces)
       CRLF                            ;type a return
ENDM                                    ;end of TYPE1

DEFINE  TYPE2   AA,BB,CC                ;AA: string, BB: string, CC: instr.
       TYPE    'AA                     ;type out string
       TAB                             ;tab over
       LEA     A1,FILE+'BB(A4)         ;point to offset in DDB
       LEA     A2,BUFFER(A4)           ;point to buffer space
       UNPACK                          ;unpack
       'CC                             ;maybe twice...
       CLRB    @A2                     ;clear byte at end of string
       LEA     A2,BUFFER(A4)           ;repoint to start of string
       TTYL    @A2                     ;type it out
       CRLF                            ;and type out a return
ENDM                                    ;end of TYPE2

       ;define two variables: FILE and BUFFER
       .OFINI
       .OFDEF  FILE,D.DDB
       .OFDEF  BUFFER,8.
       .OFSIZ  IMPSIZ

       ;start of program: produce header, A4 points to variables above
START:  PHDR    -1,0,PH$REE!PH$REU
       GETIMP  IMPSIZ,A4

       ;see if filespec is on input line
       BYP                             ;bypass all leading white space
       LIN                             ;just a CR?
       BNE     10$                     ;nope, there is some input
       TYPECR  <Usage: SHODDB filespec (default extension is .TXT)>
       EXIT

       ;get the filespec from the input line, fill the DDB
10$:    FSPEC   FILE(A4),TXT            ;process ASCII input line
       INIT    FILE(A4)                ;create block buffer & get DVR
       LOOKUP  FILE(A4)                ;fill the D.WRK space with DIR info
       JNE     QUIT                    ;quit if not found

TOP:    PRTTAB  -1,0                    ;clear screen
       TYPE1   < D.FLG>,B,D.FLG        ;type out DDB....
       TYPE1   < D.ERR>,B,D.ERR
       TYPE2   < D.DEV>,D.DEV
       TYPE1   < D.DRV>,W,D.DRV
       TYPE2   < D.FIL>,D.FIL,UNPACK
       TYPE2   < D.EXT>,D.EXT

       ;no special TYPE MACRO for the PPN but note routine..
       TYPE    <D.PPN>                 ;type out header
       TAB                             ;tab over
       TYPE    <[>                     ;type left bracket
       PRPPN   FILE+D.PPN(A4)          ;print out P,PN
       TYPECR  <]>                     ;and right bracket

       ;continue til done...
       TYPE1   < BLOCK NUMBER>, ,D.REC
       TYPE1   < BUFFER ADDRESS>, ,D.BUF
       TYPE1   < BUFFER SIZE>, ,D.SIZ
       TYPE1   < BUFFER INDEX>, ,D.IDX
       TYPE1   < D.LVL>,B,D.LVL
       TYPE1   < D.OPN>,B,D.OPN
       TYPE1   < D.ARG>, ,D.ARG
       TYPE1   < D.DVR>, ,D.DVR

       TYPECR  <D.WRK:>
       TAB
       TYPE1   <NUMBER OF BLOCKS>, ,D.WRK
       TAB
       TYPE1   <ACTIVE BYTES LAST BLOCK>, ,D.WRK+4
       TAB
       TYPE1   <FIRST BLOCK NUMBER>, ,D.WRK+10
       CRLF

QUIT:   EXIT
       END