Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/bbchng.mac
There are no other files named bbchng.mac in the archive.
	Title	BBCHNG

Comment %
Mabry Tyson
Nov 20, 1980

BBCHNG - To change the format of BBOARD's .DAT files from 1 word
	per directory number of users to 2 words so that both
	date of the last message viewed and date of .TXT file read are
	available.

	Note that the new BBOARD uses *.DATA as the name of the data file
	while the old one used *.DAT.  I suggest following this so that
	no one has trouble  if it doesn't work.

	To use this, just do the following
	COPY {bboard name}.DAT {bboard name}.DATACHNG	;Save old one until
							;you know new one works
	DSK:BBCHNG {bboard name}			;Works on DATACHNG
							;so you don't clobber 
							;.DAT or .DATA files!
	REN {bboard name}.DATACHNG {bboard name}.DATA	;Use new name

	eg.,

	COPY <BBOARD>MAIL.DAT <BBOARD>MAIL.DATACHNG
	DSK:BBCHNG <BBOARD>MAIL		;**** WARNING! Directory defaults to
					;<BBOARD>, not connected directory!
	RENAME <BBOARD>MAIL.DATACHNG <BBOARD>MAIL.DATA
	
%
	search	monsym,macsym,cmd
	.require sys:macrel,cmd

; AC's
F==0
A==1
B==2
C==3
D==4
E==5
P==17

; The file to get changed
DATFIL:	ASCIZ 'PS:<BBOARD>TEST.datachng'
;Where to map the data in
DATPAG==700

GO:	RESET
	MOVE	P,[IOWD PDLL, PDL]
; First of a bunch of command parsing stuff that I got from BBOARD.MAC
	hrroi a,filnam
	hrroi b,[asciz /PS:<BBOARD>/]
	setz c,
	sout
	call rescan			;rescan command line for date/time
GETFIL:	skipe a,bbdfil		; if we have jfn on data file,
	jrst getfl0		;  go open it
	MOVSI	a, (GJ%OLD+GJ%SHT)	; TRY TO GET DATA FILE
	HRROI	b, [ASCIZ 'PS:<BBOARD>MAIL.datachng']
	GTJFN			
	 JRST	[HRROI A,[ASCIZ /? Can't get at .DATA file
/]
		 PSOUT
		 CALL ERRF
		 HALTF
		 JRST GO]
getfl0:				;[7]
	MOVEM	A,DATJFN
	MOVE	B,[44B5+OF%RD+OF%WR+OF%THW]
	OPENF
	 ERJMP	[HRROI A,[ASCIZ /? Can't open .DATA file
/]
		 PSOUT
		 CALL ERRF
		 JRST DONE]
	MOVEI	D,1000-DATPAG ;Describes the highest page
PGLP:	SOSGE	A,D		; Next lower page	
	 JRST	 DIDPGS		;  No, did them all
	HRL	A,DATJFN	; Set up [source,,page]
	RPACS			; Get accessibility of page
	TLNN	B,(PA%PEX)	; Does the page exist?
	 JRST	PGLP		;  No, go to next
	MOVEI	A,(D)
	HRL	A,DATJFN	; Set up [source,,page]
	MOVEI	B,MDATPG
	HRLI	B,.FHSLF	; Set up [me,,page]
	MOVSI	C,(PM%RD+PM%WR)	; Read and write the page
	PMAP
	TRZ	F,(F%WRT1+F%WRT2) ;Haven't written on either page
	SETZM	MOUTAD		; Clear first word of output pages
	MOVE	A,[MOUTAD,,MOUTAD+1] ; Set up to clear block
	BLT	A,MOUTAD+1777	; Clear 2 pages

	MOVEI	A,1000		; Last word on page + 1
WDLP:	SOJL	A,DIDWDS	; Do all the words
	SKIPN	B,MDATAD(A)	; Anything there?
	 JRST	WDLP		;  No, try next
	CAIL	A,400		; See which page will be written
	 TROA	F,F%WRT2	; Write second page
	TRO	F,F%WRT1	; Write first page
	MOVEI	C,(A)		; Get a copy of the address
	IMULI	C,2		; Double it
	MOVEM	B,MOUTAD(C)	; Write the first of the words to output page
	MOVEM	B,MOUTAD+1(C)	;  Second word
	JRST	WDLP		; Go for more

DIDWDS:	; Did the words on this page, now delete the source page
	; and write out the ones that got the new data
	SETO	A,		; Will unmap the page first
	MOVEI	B,MDATPG	; File page
	HRLI	B,.FHSLF	; This process
	SETZ	C,		; Unmap only the one page
	PMAP

	SETO	A,		; Will delete the page
	MOVEI	B,(D)		; File page that we read
	HRL	B,DATJFN	; File to diddle
	SETZ	C,		; Delete only the one page
	PMAP

	TRZN	F,F%WRT2	; Did the second page get anything?
	 JRST	PAGE1		;  No, go do page 1
	MOVE	A,[.FHSLF,,MOUTPG+1] ;Write out second page of this process
	MOVEI	B,(D)		; Original page of file
	ADDI	B,1(D)		; Double it and add 1
	HRL	B,DATJFN	; File JFN
	MOVSI	C,(PM%RD+PM%WR)
	PMAP			; Create second page
	SETO	A,		; Now unmap this page
	MOVE	B,[.FHSLF,,MOUTPG+1]
	SETZ	C,
	PMAP

PAGE1:	TRZN	F,F%WRT1	; Did the first page get anything?
	 JRST	 PGLP		;  No, go do next page
	MOVE	A,[.FHSLF,,MOUTPG] ;Write out first page
	MOVEI	B,(D)		; Original page of file
	ADDI	B,(D)		; Double it
	HRL	B,DATJFN	; File JFN
	MOVSI	C,(PM%RD+PM%WR)
	PMAP
	SETO	A,		; Now unmap this page
	MOVE	B,[.FHSLF,,MOUTPG]
	SETZ	C,
	PMAP
	JRST	PGLP

DIDPGS:	; Come here when you have done the entire file
DONE:	SETO	A,		; Close and release all files
	CLOSF
	 TRN
	HALTF
	JRST	GO

ERRF:	MOVEI	A,.PRIOU
	MOVE	B,[.FHSLF,,-1]
	SETZ	C,
	ERSTR
	 CAIA
	 CAI
	RET
	subttl rescanning code

rescan:	movei a,.rsini			;select rescan buffer
	rscan
	 jserr
	jumpe a,cpopj			;return if nothing there
	call cmdini		; init comnd jsys package
	prompt (BBchng>)	; init comand jsys (does .cmini)
	movei a,[flddb. .cmkey,,pgmtab] ;
	call rflde		; collect program name, start, etc.
	 jrst erreat		; garbage...
	hrrz b,(b)		; get indicator
	jumpe b,eat		; if not program name, forget this line
	hrli a,dfltbk		; build a blt pointer
	hrri a,cjfnbk		;  for defaults
	blt a,cjfnbk+dfltln-1	; set up default bboard file
rsclup:	movei a,[flddb. .cmcfm,,,,,[ 			; or confirm
		flddb. .cmfil,,]] 			; or filename
							;(.cmfil must be last)
	call rflde		;
	 jrst erreat		; what's wrong?
	hrli c,331100		; build byte pointer to function code
	ldb a,c			; get function which matched
	cain a,.cmfil		; did we get a filespec?
	jrst rscfil		; yes, do that up
	 ret			; no, must be a confirm - return

; we've rescanned a filename

rscfil:	movem b,bbofil		; save bboard file name
	hrroi a,buf		; point to buffer
	move c,[fld(.jsaof,js%dev)!fld(.jsaof,js%dir)!fld(.jsaof,js%nam)!js%paf] ; output all but extension
	jfns			;
	hrroi b,[asciz \.datachng\]	; here is the extension
	setz c,			;
	sout			; complete filename
	hrroi a,filnam		; copy the file name specified here to
	hrroi b,atmbuf		; save it for end message
	sout			;
	ldb b,a			; get the last character
	cain b,15		; a CR?
	dpb c,a			; yes, make it a null instead
	movx a,gj%old!gj%sht	; old file, short gtjfn form
	hrroi b,buf		; point to name we constructed
	gtjfn			; get a jfn on it
	 ercal [hrroi a,[asciz \Can't GTJFN \] ;
		esout		;
		hrroi a,buf	; output filename
		psout		;
		call jshlt0]	; die
	movem a,bbdfil		; save dat file jfn
	jrst rsclup		;

erreat:	hrroi a,[asciz \Can't parse: \] ;
	esout			;
	move a,sbk+.cmptr	; the unparsed stuff
	psout			;
	movei a,.priin		; clear input buffer
	cfibf			; (bug in esout, currently)
	jrst eat1		;

eat:	movei a,[flddb. .cmtxt]	; swallow to eol
	call rfield		;
	 jfcl			;
eat1:	setzm bbofil		;  and any files
	setzm bbdfil		;
cpopj:	ret			;
;DATA
DATJFN:
bbdfil:	0				; 0 or jfn of .DATA file
bbofil: 0

; defaults for BBOARD file

dfltbk:	gj%old			; flag bits,,generation number
	0			; jfns (supplied by comnd jsys)
	-1,,[asciz \ps\]	; device
	-1,,[asciz \bboard\]	; directory
	-1,,[asciz \mail\]	; filename
	-1,,[asciz \datachng\]	; extension
	dfltln==.-dfltbk	;


filnam:	block ^d8*4		; space to save file specified by user
lall

pgmtab:	pgmlen,,pgmlen		; program name keyword table

ife 0 ,<			;
	[asciz \bbchng\],,1	;
	[asciz \erun\],,0	;
	[asciz \r\],,0		;
	[asciz \reenter\],,0	;
	[asciz \run\],,0	;
	[asciz \start\],,0	;
>				;
	pgmlen==.-pgmtab-1	;

	cmdstg			; storage for CMD package


MDATPG==400			; Page to get input from .DATA
MOUTPG==500			; First page to get output to .DATA

MDATAD==MDATPG*1000		; (Address for MDATPG)
MOUTAD==MOUTPG*1000		; (Address for MOUTPG)

F%WRT1==1
F%WRT2==2

BUFSIZ==200				; MAX NUM OF CHARS IN BUF
BUF:	BLOCK	BUFSIZ/5+1		; RANDOM PARSING BUFFER

PDLL==20
PDL:	BLOCK	PDLL

	END	GO