;+ ; ; PROGRAM ATT ; ; PURPOSE ; Changes the record attributes of a file according ; to switches in command. ; ; Switches: ; /CR Give the file the carriage control attribute. When the file ; is printed on a record oriented device (ie a terminal or ; line printer), a line feed is printed before each line and a ; carriage return is printed after each line. This switch is ; the default if no switch is specified. ; ; /FT Gives the file the Fortran attribute. When the file is printed ; on a record oriented device, the first character of each line is ; interpreted as a Fortran carriage control character. ; ; /-FT Same effect as /CR. ; ; /-CR Gives the file no carriage control attribute. When the file is ; printed on a record oriented device, no carriage control is added ; to the output; internal carriage control assumed. ; ; Command format: ; ; >ATT filename.typ/CR ; or ; >ATT ; ATT> filename.typ/FT ; ATT> filename2.typ/-CR ; ATT>^Z ; > ; Currently supports only one file name per command line ; and wildcards only get the first match. ; ; AUTHOR ; Daniel S. McCoy Informatics Inc. Palo Alto, Ca. ; ; REVISIONS ; LAST CHANGE 10/26/78 ; DATE PERSON STATEMENT OF CHANGES ; 10/26/78 DSM Original coding ;- ; NOTES: ; GCML command input uses LUN 1 ; File to be changed is opened on LUN 2 ; Error messages to LUN 3 ; ; Sample compile and task build: ; ; >MAC ATT,ATT=ATT ; >TKB ; TKB>ATT,ATT=ATT ; TKB>/ ; TKB>TASK=...ATT ; TKB>ASG = SY:2,TI:1:3 ; TKB>// ;. ; .MCALL DIR$,QIO$,QIOW$,QIOW$C,EXIT$S .MCALL GCML$,GCMLB$,GCMLD$,CSI$,CSI$SW,CSI$ND,CSI$1,CSI$2 .MCALL FDBDF$,FDOP$A,FINIT$,FSRSZ$ ; ; Allocate one buffer for indirect files FSRSZ$ 1 ; CR=15 ; ASCII carriage return LF=12 ; ASCII line feed ; ; Define get command line block GCLBLK: GCMLB$ 1,ATT ; ; Define CSI stuff ; CSI$ .EVEN ; CSI block must start on a word CSIBLK: .BLKB C.SIZE ; Allocate CSI block .EVEN FTMSK=1 ; Mask for FT (Fortran) switch CRMSK=2 ; Mask for CR (Carriage control) switch ; ; Data structure for CSI switch processing SWTBL: CSI$SW FT,FTMSK,,SET,NEG CSI$SW CR,CRMSK,,SET,NEG CSI$ND .EVEN ; ; File name block ; FID: .BLKW 3 ; File ID, filled by .FIND FNAM: .BLKW 3 ; File name, filled by .PARSE .BLKW 9. ; Rest of file name block ; ; Allocate file descriptor block for .PARSE and .FIND ; FDB: FDBDF$ FDOP$A 2 ; Define it for LUN 2 .EVEN ; ; Define attribute control for ACP QIO's ; RATS: .BYTE -4,40 ; Read attributes into ATTS .WORD ATTS .WORD 0 WATS: .BYTE 4,40 ; Write attributes from ATTS .WORD ATTS .WORD 0 ATTS: .BLKB 40 ; Buffer for attributes ; ; Error messages for TI: QIO's ; .NLIST BEX ERBF0: .ASCII /*ATT* UNDEFINED ERROR/ ERLN0=.-ERBF0 ERBF1: .ASCII /*ATT* COMMAND LINE ERROR/ ERLN1=.-ERBF1 ERBF2: .ASCII /*ATT* INPUT FILE ERROR/ ERLN2=.-ERBF2 ERBF3: .ASCII /*ATT* OUTPUT FILE ERROR/ ERLN3=.-ERBF3 ERBF4: .ASCII /*ATT* DIRECTIVE ERROR/ ERLN4=.-ERBF4 ERBF5: .ASCII /*ATT* COULD NOT FIND FILE/ ERLN5=.-ERBF5 .EVEN .LIST BEX ; ; TI: QIO Directive Parameter Block ; MSGQIO: QIOW$ IO.WVB,3,3,,,, MSGBUF=MSGQIO+Q.IOPL MSGLEN=MSGBUF+2 .EVEN IOST: .BLKW 2 ; I/O status for QIO's ; ; Beginning of program ; START: FINIT$ ; Initialize FCS ; ; Get a command and turn it into a File ID and switches ; MOV #GCLBLK,R0 ; Set up pointer for GCML$ GCML$ ; Get command line BCC 10$ ; Continue if successful CMPB #GE.EOF,G.ERR(R0) ; End of file? BEQ EXIT ; Yes, just quit BR CMERR ; No, report command error 10$: MOV #CSIBLK,R1 ; Get pointer for moves MOV G.CMLD(R0),C.CMLD(R1) ; Move command line length BEQ START ; If zero length line, try again MOV G.CMLD+2(R0),C.CMLD+2(R1) ; Move command line pointer MOV R1,R0 ; Set up pointer for CSI CSI$1 R0 ; Pre-interpret the command line BCS CMERR ; Check for command error ; CSI$2 R0,OUTPUT,#SWTBL ; Get file name and switches BCS CMERR ; Check for command error ; MOV #FDB,R0 ; Get FDB address for .PARSE MOV #FID,R1 ; Get filename block for .PARSE MOV #CSIBLK+C.DEVD,R2 ; Get data set descriptor pointer CLR R3 ; No default name block CALL .PARSE ; Fill in file name block ; CALL .FIND ; Fill in file ID from directory BCS FLERR ; ; Access file and read in attributes ; QIOW$C IO.ACW,2,3,,IOST,, BCS DERR TSTB IOST ; Test for error BMI IERR ; ; Set new attributes ; MOV #ATTS,R5 ; Get pointer to attributes MOV #CSIBLK,R4 ; Get pointer to CSI stuff BIT #FTMSK,C.MKW1(R4) ; FT switch there? BEQ 30$ ; Try CR if no BIT #FTMSK,C.MKW2(R4) ; Yes, was it -FT? BEQ 40$ ; If yes, make it CR BICB #FD.CR,F.RATT(R5) ; Clear CR attribute BISB #FD.FTN,F.RATT(R5) ; Set FT attribute BR 70$ 30$: BIT #CRMSK,C.MKW1(R4) ; CR switch there? BEQ 40$ ; If not assume CR for default BIT #CRMSK,C.MKW2(R4) ; Yes, was it -CR? BEQ 50$ ; If yes, clear both FT and CR 40$: BICB #FD.FTN,F.RATT(R5) ; Clear FT attribute BISB #FD.CR,F.RATT(R5) ; Set CR attribute BR 70$ 50$: BICB #FD.FTN,F.RATT(R5) ; Clear FT attribute BICB #FD.CR,F.RATT(R5) ; Clear CR attribute 70$: ; ; Deaccess the file and write the new attributes back out ; QIOW$C IO.DAC,2,3,,IOST,, BCS DERR TSTB IOST ; Test for error BMI OERR ; ; Clean up and get next command ; CLR C.MKW1(R4) ; Clear old switches CLR C.MKW2(R4) ; Ditto JMP START ; Get next command ; EXIT: EXIT$S ; ; Error processing ; CMERR: ; Command error MOV #ERBF1,MSGBUF MOV #ERLN1,MSGLEN BR ERRMSG IERR: ; Input error on file MOV #ERBF2,MSGBUF MOV #ERLN2,MSGLEN BR ERRMSG OERR: ; Output error on file MOV #ERBF3,MSGBUF MOV #ERLN3,MSGLEN BR ERRMSG DERR: ; Directive error MOV #ERBF4,MSGBUF MOV #ERLN4,MSGLEN BR ERRMSG FLERR: ; File find error MOV #ERBF5,MSGBUF MOV #ERLN5,MSGLEN ERRMSG: DIR$ #MSGQIO ; Output error message JMP START ; Try next command ; .END START