C*	NOT - PRINT DAILY NOTICE AND DISK SUMMARY AT LOGIN
C
	PROGRAM NOT
C
C06/21/79	- LEN
C		SUPPRESS NOTICE AND DISK SUMMARY IF RUNNING FROM 'BA'
C 11/23/79	LEN - UPDATED FOR DISK ALLOCATION CHECK AND FOR
C		RECEIVING THE USERS DEFAULT UIC ON THE COMMAND LINE IF
C		...NOT WAS RUN DURING A PDS LOGIN SEQUENCE.
C 12/03/79	LEN - REMOVED MESSAGE ABOUT FILE-ID MISMATCHES
C 12/18/79	LEN - BUG FIXED FOR BATCH - NOT GETTING MCR LINE
C
	INCLUDE 'NOTCM.COM/LIST'
C
	DIMENSION IDVUN(2), IDTTM(9), IBUF(40), FIDNO(3), IMSG(6)
	DIMENSION RBNO(128)
	DIMENSION BDUIC(2), BBUF(80)
	EQUIVALENCE (IDUIC,BDUIC), (IBUF,BBUF)
	EQUIVALENCE (IMSG(1),ITNFO), (IMSG(2),NWARN), (IMSG(3),KTBU),
	1	(IMSG(5),KTOT)
C
	DATA NWSTAT/7/, ILTB/2/, IRBTB/1/, BELL/7/
	DATA IRBNO/1/, ILNO/1/
	DATA NRMSG/10/
	DATA LNOTIC/.TRUE./, LDUSEP/.TRUE./
C
C	CHECK IF WE'RE RUNNING FROM BATCH. IF SO, SUPPRESS THE NOTICE AND
C	DISK USEAGE TO IMPROVE LOGIN RESPONSE.
C
	CALL GETLUN (5, IBUF)
	IF (IBUF(1) .NE. 'BA') GO TO 50
	LNOTIC = .FALSE.
	LDUSEP = .FALSE.
C
C	GET COMMAND LINE AND CHECK IF WE'VE BEEN CALLED BY THE PDS
C	LOGIN PROCEDURE. IF SO WE WILL BE ABLE TO FIND THE FOLLOWING
C	SEQUENCE OF BYTES -
C
C	AN ASCII '=' FOLLOWED BY
C	A BINARY BYTE 1 FOLLOWED BY
C	2 BYTES OF THE USERS UIC, FOLLOWED BY
C	A BINARY BYTE 1 AS A TERMINATOR
C
C	IF THIS PATTERN IS MATCHED THEN FINDING A 'B' ON THE COMMAND LINE
C	SAYS THIS IS A NONOTICE LOGIN. TO SUM UP, THE TWO POSSIBLE COMMAND
C	LINES WHICH ARE VALID ARE -
C
C	1) NOT TO:=(4 BINARY BYTES)[1,1]NOTICE.TXT      OR
C	2) NOT TO:=(4 BINARY BYTES)[1,1]BATNOTICE.TXT
C
 50	CONTINUE
	CALL GETMCR (IBUF, IDSW)
	IF (IDSW .LE. 0) GO TO 410
	BBUF(40) = 0			! 0 BYTE FOR IBLUF CALL
	ISC = IBLUF ('=', BBUF)		! EQUAL SIGN ?
	IF (ISC .LE. 0) GO TO 70	! NOT FROM PDS LOGIN
C
C	MAY BE FROM PDS LOGIN - CHECK HEADER AND TRAILER BYTES CONTAINING
C	THE VALUE OF 1.
C
	IF (BBUF(ISC+1).NE.1 .OR. BBUF(ISC+4).NE.1) GO TO 70
C
C	HEADER AND TRAILER MATCH - GET THE USERS UIC FROM THE COMMAND LINE
C
	BDUIC(1) = BBUF(ISC+2)
	BDUIC(2) = BBUF(ISC+3)
C
C	NOW CHECK IF WE CAN FIND THE 'B'
C	IF NOT FOUND THEN LNOTIC IS .TRUE. AND NOTICE.TXT SHOULD BE TYPED
C
	LNOTIC = (IBLUF('B', BBUF(ISC+5)).LE.0) .AND. LNOTIC
C
C	SET FLAG FOR PRINTING DISK USEAGE SAME AS LNOTIC
C
	LDUSEP = LNOTIC
C
C	OK - NOW GO CHECK FOR OVERRUN ON DISK ALLOCATION
C
	GO TO 72
C
C
C	COME HERE IF NOT FROM PDS LOGIN SEQUENCE. THIS MEANS WE WERE
C	REQESTED SPECIFICALLY BY A USERS WISHING TO SEE THE NOTICES AND
C	DISK USEAGE STATUS.
C	GET THE DEFAULT UIC VIA GETTSK DIRECTIVE
C
 70	CONTINUE
	CALL GETTSK (IBUF, IDSW)
	IDUIC = IBUF(16)
	LNOTIC = .TRUE.
	LDUSEP = .TRUE.
C
 72	CONTINUE
	IF (.NOT. LNOTIC) GO TO 75
C
C	PRINT OUT LB0:[1,1]NOTICE.TXT
C
	CALL X1LU (FIDNO, RBNO, IRBNO, 1, 0,
	1	ILNO, 'R', 'LB0:', -1, '[1,1]NOTICE.TXT', NER)
	IF (NER .NE. 0) GO TO 75
	CALL X1LRN (FIDNO, NOLRN)
C
C	READ NOTICES
C
	NRNO = 1
 100	CONTINUE
	IF (NRNO .GT. NOLRN) GO TO 180
	CALL X1DR (FIDNO, NRNO, 1, NBYTES)
	BBUF(1) = ' '				! FOR NULL RECORD PRINT
	IF (NBYTES .NE. 0)
	1	CALL X1DR (FIDNO, NRNO, (NBYTES+1)/2, IBUF)
	WRITE (5, 510) (BBUF(I),I=1,NBYTES)
 510	FORMAT (' ',80A1)
	GO TO 100
C
C	END OF NOTICES
C
 180	CONTINUE
	CALL X1EF (FIDNO)
C
C
C	CHECK THE DISK ALLOCATION MESSAGES IN DSMNOT.DAT FOR ALL USERS.
C	WHETHER OR NOT NONOTICE WAS SPECIFIED AT LOGIN.
C
C
C	LOOK UP LB0:[1,1]DSMNOT.DAT - CONTAINING BLOCKS USED PER UIC/DEVICE
C	AND ANY MESSAGES FOR OVER ALLOCATIONS.
C
 75	CONTINUE
	CALL X1LU (FIDTB, RBTB, IRBTB, 1, 0,
	1	ILTB, 'R', 'LB0:', -1, '[1,1]DSMNOT.DAT', NER)
	IF (NER .NE. 0) GO TO 90
C
C	FILE OPENED OKAY - CHECK FOR ALLOCATION ERRORS
C
	NRTB = 1
	CALL X1DR (FIDTB, NRTB, 9, IDTTM)		! DATE/TIME
	I = NRMSG
	CALL X1DR (FIDTB, I, 1, NRTB)
	LFIRST = .TRUE.
C
 80	CONTINUE
	CALL X1DR (FIDTB, NRTB, 6, IMSG)		! # UICS
	IF (ITNFO .EQ. 0) GO TO 95			! NO MORE
C
C	COMPARE THE UIC'S FOR THIS WARNING MESSAGE
C
	DO 82 I=1, ITNFO
	CALL X1DR (FIDTB, NRTB, 1, IUIC)
	IF (IUIC .EQ. IDUIC) GO TO 83			! MATCH
 82	CONTINUE
C
C	NO MATCH UPDATE NRTB PAST 40 WORD MESSAGE AND CHECK THE NEXT ONE
C
	NRTB = NRTB + 40
	GO TO 80
C
C	MATCH - UPDATE NRTB PAST REST OF UIC'S IN LIST AND PRINT THE
C	ERROR MESSAGE AND WARNING NUMBER
C
 83	CONTINUE
	LDUSEP = .TRUE.			! WANT TO SEE THIS NOW
	NRTB = NRTB + ITNFO-I
	CALL X1DR (FIDTB, NRTB, 40, IBUF)
C
C	PRINT THE MESSAGES
C
	IF (.NOT.LFIRST) GO TO 85
	TYPE 504, BELL
	TYPE 505, IDTTM
 504	FORMAT (//' ', 6('---WARNING---'), A1)
 505	FORMAT (/' DISK ALLOCATION EXCEEDED AS OF ',9A2)
 85	CONTINUE
	KDIF = KTBU - KTOT
	TYPE 506, NWARN, KTBU, KTOT, KDIF, IBUF
 506	FORMAT (/' WARNING #',I3,' - BLOCKS USED/LIMIT',I7,'./',I6,'.',
	1	'    BLOCKS OVER LIMIT',I7,'.'  /' ',40A2)
	LFIRST = .FALSE.
	GO TO 80
C
C	HERE IF ERROR OPENING DSMNOT.DAT
C
 90	CONTINUE
	LDUSED = .FALSE.
C
 95	CONTINUE
C
	IF (.NOT. LDUSEP) GO TO 410
C
C	PRINT OUT DISK SUMMARY INFO COLLECTED BY $$$DSM
C
C	SET RECORD POINTER
C
	NRTB = NRMSG + 1
	LFIRST = .TRUE.
D	READ (5, 501) BDUIC(2), BDUIC(1)
D 501	FORMAT (2O3)
C
C	START OF LOOP ON EACH DEVICE - NFO=0 MEANS END OF DATA
C
 200	CONTINUE
	CALL X1DR (FIDTB, NRTB, 1, NFO)
	IF (NFO .EQ. 0) GO TO 400		! DONE !
C
C	GET DEVICE AND UNIT NO. FORM DATA FILE
C
	CALL X1DR (FIDTB, NRTB, 2, IDVUN)
D	TYPE 901,NFO,IDVUN
D 901	FORMAT (' ',I3,1X,A2,O1)
C
C	LOOP THROUGH UIC'S TILL MATCH DEFAULT
C
	DO 250 I=1, NFO
	CALL X1DR (FIDTB, NRTB, NWSTAT, ISTAT)
D	TYPE 902,BUIC(2),BUIC(1)
D 902	FORMAT (' ',2O3)
	IF (IDUIC .EQ. IUIC) GO TO 300		! MATCHED UIC
 250	CONTINUE
	GO TO 200
C
C	UPDATE NRTB PAST REST OF DATA FOR THIS DEVICE
C
 300	CONTINUE
	NRTB = NRTB + (NFO-I)*NWSTAT
	IF (.NOT. LFIRST) GO TO 320
C
C	HEADING LINE
C
	TYPE 550, IDTTM, BUIC(2),BUIC(1)
 550	FORMAT (/' DISK UTILIZATION SUMMARY AS OF ',9A2,' FOR [',O3,',',O3,
	1	']'/)
	LFIRST = .FALSE.
C
C	1 STAT LINE PRINTED PER DEVICE
C
 320	CONTINUE
	TYPE 560, IDVUN, KUSED, KALLOC, NFILES
 560	FORMAT (' ',A2,O1,': ',I6,'./',I6,'. BLOCKS IN',I5,' FILE(S)',$)
	GO TO 200
C
C	END OF DEVICES
C
 400	CONTINUE
	CALL X1EF (FIDTB)
C
 410	CONTINUE
	END
