;*************************** AMUS Program Label ******************************
; Filename: PPNSIZ.M68                                      Date: 07/01/89
; Category: UTIL         Hash Code: 520-053-430-143      Version: 1.0(100)
; Initials: PSS/AM       Name: DENNIS W. NEDER
; Company: PROFESSIONAL SOFTWARE SYSTEMS           Telephone #: 8189575930
; Related Files: LIB.UNV  (DONT FORGET THIS FILE!)
; Min. Op. Sys.: 1.0                           Expertise Level: BEG
; Special: You must LNKLIT this file after assembly!
; Description: This program will display total number of files, blocks and
; bytes for PPN specified.  If no account is given, current log-in is assumed.
;
;*****************************************************************************
;
; ***********************************************************************
; *     PPNSIZ.M68                                                      *
; *                                                                     *
; *     This program displays the number of blocks currently in use     *
; *     by a particular PPN.  If one is specified, it is verified       *
; *     and then the blocks are computed and displayed.  If no PPN      *
; *     is specified, the current log-in is assumed, (and no verif-     *
; *     ication is performed.)                                          *
; *                                                                     *
; *     Copyright (c) 1988 by Dennis W. Neder                           *
; ***********************************************************************
;
; Edits:
;       14-Jan-85       Created./DWN
;
; Universals:

       EXTERN  $FNPPN
       SEARCH  SYS
       SEARCH  SYSSYM
       SEARCH  LIB
       ASMMSG  "You must LNKLIT this program after assembly."

; Version:

       VMAJOR=1
       VEDIT=100.              ; 14-Jan-85 Created/DWN

; Local equates:

       JOB=A0
       IMP=A5

; Impure area for DDB:

       .OFINI
       .OFDEF  DDB,D.DDB       ; DDB for locating PPN
       .OFDEF  BUFFER,4        ; Display buffer for UNPACK
       .OFDEF  FILCNT,4        ; Number of files counted in PPN
       .OFDEF  BLKS,4          ; Number of blocks counted
       .OFSIZ  IMPSIZ

HDR:    PHDR    -1,0,PH$REE!PH$REU

START:  JOBIDX  JOB             ; Get our job table index
       CRLF
       NAME    HDR             ; Display name of program
       CRLF
       CRT     #11.
       TYPECR  Copyright (c) 1988 by Dennis W. Neder
       CRT     #12.
       CRLF
       BYP
       GETIMP  IMPSIZ,IMP,EXIT$
       INIT    DDB(IMP)        ; Initialize DDB and buffer
       CLR     FILCNT(IMP)     ; Clear number of files counted
       CLR     BLKS(IMP)       ; Clear number of blocks counted
       LIN
       BNE     GETPPN          ; Get user-specified PPN
       MOVW    JOBUSR(JOB),D.PPN(IMP) ; Get Current log-in information
       MOVW    JOBDEV(JOB),D.DEV(IMP)
       MOVW    JOBDRV(JOB),D.DRV(IMP)
       BR      CHKPPN

GETPPN: FSPEC   DDB(IMP)        ; Load PPN information
       BEQ     10$
       EXIT

10$:    TSTW    D.PPN(IMP)      ; Check ppn entered
       JEQ     BADACC
       CMPW    D.DRV(IMP),#177777 ; See if default drive number was given
       BNE     20$
       MOVW    JOBDRV(JOB),D.DRV(IMP) ; Use current specification

20$:    MOVW    D.PPN(IMP),D0   ; Get PPN
       BNE     30$             ; If PPN specified, continue
       MOVW    JOBUSR(JOB),D.PPN(IMP) ; No PPN - use default

30$:    MOVW    D.DEV(IMP),D0   ; Get device
       BNE     CHKPPN
       MOVW    JOBDEV(JOB),D.DEV(IMP) ; No device - use default

CHKPPN: CLR     D0              ; Pre-clear D0
       MOVW    D.PPN(IMP),D1   ; Get requested account
       MOV     IMP,A2          ; Get pointer to DDB for $FNPPN
       CALL    $FNPPN          ; See if PPN exists
       TST     D0              ; Error? (PPN not found)
       JNE     BADACC          ; PPN does not exist

GOTPPN: CLR     D5              ; Pre-clear D5
       MOVW    2(A1),D5        ; Get link to First block of UFD

RDPPN:  CTRLC   EXIT$           ; Exit on ^C
       MOV     D5,D.REC(IMP)   ; Load link to next block
       BEQ     DONE            ; Zero means no more blocks
       READ    DDB(IMP)        ; Get block from disk
       MOV     D.BUF(IMP),A0   ; Get buffer index
       CLR     D5
       MOVW    (A0)+,D5        ; Next block link

SEARCH: MOV     #42.,D0         ; Number of files in a UFD block
10$:    CTRLC   EXIT$           ; Handle ^C
       CLR     D1              ; Pre-clear D1
       MOVW    @A0,D1          ; Get file name
       BEQ     RDPPN           ; If no filename, end of list
       CMPW    D1,#-1          ; Deleted?
       BEQ     20$
       INC     FILCNT(IMP)     ; Bump file pointer
       MOVW    6(A0),D1        ; Get number of blocks for this file
       ADD     D1,BLKS(IMP)    ; Add to number of blocks
20$:    ADD     #14,A0          ; Bump to next file in UFD
       SOB     D0,10$
       BR      RDPPN

DONE:   LEA     A1,D.DEV(IMP)   ; Address device within DDB
       LEA     A2,BUFFER(IMP)  ; Buffer for UNPACK
       UNPACK
       CLRB    @A2             ; Null at end
       TTYL    BUFFER(IMP)     ; Display device name
       CLR     D1              ; Pre-clear D1
       MOVW    D.DRV(IMP),D1   ; Get unit number
       DCVT    0,OT$TRM        ;  and display
       TYPE    :[
       PRPPN   D.PPN(IMP)      ; Now PPN
       TYPESP  ]
       CRT     #11.
       TYPE    has
       CRT     #12.            ; Set regular video
       MOV     FILCNT(IMP),D1  ; Get total file count
       DCVT    0,OT$TRM!OT$LSP
       CRT     #11.            ; Set dim video
       TYPE    < files in>
       CRT     #12.            ; Set regular video
       MOV     BLKS(IMP),D1    ; Get total number of blocks
       DCVT    0,OT$TRM!OT$LSP
       CRT     #11.
       TYPE    < blocks, for a total of>
       CRT     #12.
       MOV     BLKS(IMP),D1
       MUL     D1,#512.        ; Calculate number of bytes
       DCVT    0,OT$TRM!OT$LSP
       CRT     #11.
       TYPECR  < bytes.>
       CRT     #12.

EXIT$:  EXIT

BADACC: TYPECR  ?Invalid account specified
       EXIT

       END