Title EZFIX -- copy one file to another $ver=1 $ed=1 ; 11:34am, 28 Jan 1983, Frank (remove CUSYM stuff so we can export this...) ; ; Translates EasyWriter files coming from the IBM PC via Kermit into normal ; ASCII files useable on the DEC-20. ; ; Bill Schilit, Frank da Cruz, Ken Rossman, Daphne Tzoar, CUCCA. search monsym,macsym,cmd .require sys:macrel,mac:cmd subttl Definitions & Data t4=+1>+1>+1 ; ACs p=17 CMDSTG ; CMD package expands this for itself pdlsiz==100 ; Stack pdl: block pdlsiz ; ... injfn: z ; Input JFN outjfn: z ; Output JFN lstchr: z ; Last char we read lfFlg: z ; Convert linefeed flag subttl Main Code entvec: jrst start ; Start address jrst start ; Reenter address versio: byte(3)0(9)$ver(6)0(18)$ed ; Version number evlen=.-entvec ; Initialization start: RESET% ; Reset... move p, [pdlsiz,,pdl] ; Set up stack. hrroi t1, [asciz/ EasyWriter conversion program /] PSOUT% call getcnv ; Ask about converting linefeeds call getinp ; Get input jfn, store in injfn call getout ; and the output jfn, store in outjfn setzm lstchr call copy ; Now copy the file call done ; Close the files HALTF% ; Return to superior jrst start ; In case 'continue' is typed Subttl Processing Subroutines getcnv: call cmdini ; Initialize the CMD package. prompt movei t1, [flddb. .cmkey,,yestab,,yes] ; Get keyword. call cfield move t1, (t2) ; Get their choice. hrrzm t1, lfflg ; Save choice permanently ret ; Return to caller yestab: 3,,3 [asciz/no/],,0 [asciz/ok/],,1 [asciz/yes/],,1 ; Get JFN of input file & open it, using TTY: as source of file name getinp: prompt movei t1, [flddb. .cmifi] call cfield movem t2, injfn ; Save input file JFN move t1, t2 ; Open the file. movx t2, ; 7 bit bytes, read access OPENF% ; Open the file ejserr ret ; Same deal for the output file getout: prompt movei t1, [flddb. .cmofi] call cfield movem t2, outjfn ; Save as output file JFN move t1, t2 ; Open the file movx t2, ; 7 bit bytes, write access OPENF% ; Open it ejserr ret ; Main processing loop copy: move t1, injfn ; Load input jfn into t1 BIN% ; Get next byte erjmp tsteof ; Do we have an eof? cain t2, .chcnz ; [KR] Is this char a control-Z? ret ; [KR] Yes, so just return cain t2, .chlfd ; line feed? jrst [ skipn lfflg ; Yes, so do we want to convert linefeeds? jrst .+1 ; No, so skip around it movx t3, .chcrt ; Else, was the last char a carriage return? camn t3, lstchr ; check it out jrst .+1 ; yes, we don't need to do anything move t1, outjfn ; Load output jfn into t1 movx t2, .chcrt ; get a CR BOUT% ejserr movx t2, .chlfd ; reload the line feed jrst .+1 ] ; and continue movem t2,lstchr ; remember the last char move t1, outjfn ; Load output jfn into t1 BOUT% ; Output the byte ejserr ; No recovery on error jrst copy ; Loop for all chars ; We come here on error in bin jsys. See if we have eof. tsteof: GTSTS% ; Find the error code ejserr txnn t2, gs%eof ; Was it an eof? jshlt ; Print error and die ret ; All done ; Here when we've copied the entire file. Now close them and go away. done: hrroi t1, [asciz/ [EZFIX copied /] PSOUT% movei t1, .priou move t2, injfn setzb t3, t4 JFNS% nop hrroi t1, [asciz/ to /] PSOUT% movei t1, .priou move t2, outjfn setzb t3, t4 JFNS% nop hrroi t1, [asciz/ -- OK ] /] PSOUT% movx t1, .fhslf ; Fork handle self CLZFF% ; Close all files and release jfns nop ret end