! ! File: UNIXS ! ! UNIX - EMAS Communications Software ! ! Based on ERCC Microcomputer Support ! Group Micro - EMAS routines. ! ! Author: Mark Taunton, ERCC ! ! Date: 9th September 1980 ! ! %external %routine %spec copy (%string(63) f1f2) %external %routine %spec setmode (%string(63) mode) %external %routine %spec messages (%string(63) state) %external %routine %spec destroy (%string(63) file) %external %routine %spec define (%string(63) defs) %external %routine %spec clear (%string(63) stno) %external %integer %fn %spec exist (%string(63) file) %routine get file name (%string(63)%name fn) %external %routine %spec prompt (%string(15) ptext) %integer sym, p fn = "" setmode ("append=5"); ! Put on end of prompt prompt ("EMAS File:") sym = nl %while sym = ' ' %or sym = nl %cycle readsymbol(sym) %repeat p = 0 %while ' ' # sym # nl %cycle %unless p = 63 %start p = p + 1 charno(fn,p) = sym %finish read symbol(sym) %repeat length(fn) = p %end %external %routine take file (%string(63) dummy parm) ! ! Reads all input from terminal (in binary i/p mode) ! and writes it out to a temp file. If transfer is ! successful (the UNIX end sends 'Y' at End-of-file), ! the temp file is copied to the target file, (which ! must not already exist). The temp file is destroyed ! whatever the outcome. ! Any character which is preceded by a DLE (character 16) ! is passed without examination. In this way the stopinput ! character ('?') can itself be read without significance. ! %external %routine %spec close stream (%integer stream) %const %string(10) temp file = "ss#tmpunix" %const %integer dle = 16, cr = 13 %integer mode, i, chars, tf %string(63) fl1, fl2, file %routine abort (%string(63) reason) printstring("** Host -- ") printstring(reason) newline setmode ("append=0,flow=on") messages("on") %if tf # 0 %then destroy (temp file) %stop %end tf = 0 messages ("off") get file name (file) tf = 0 %if exist (file) # 0 %then abort ("File already exists") ! Test for PD File member %if file -> fl1.("_").fl2 %and exist(fl1) = 0 %then %c abort ("P.D. File does not exist.") define("1,".temp file) selectoutput(1) tf = 1; ! Temp file now exists messages("off") setmode("append=0,flow=off,stopinput=63"); ! set terminator = '?' chars = 0 %cycle readch(i) %if i = dle %start readch(i); ! nEXT CHARACTER TRANSPARENT %finish %else %start %exit %if i = 63; ! tERMINATOR %finish chars = chars + 1; printch(i) %repeat selectoutput(0) closestream(1) readsymbol(i); ! cONFIRMATION CHARACTER. setmode ("flow=on") %if i # 'y' %then abort("tRANSFER FAILED") copy(temp file.",".file) DESTROY(TEMP FILE) PRINTSTRING("** Host --") WRITE(CHARS,0) PRINTSTRING(" bytes received") MESSAGES("ON") %END %EXTERNAL %ROUTINE GIVE FILE (%STRING(63) DUMMY PARM) ! ! Opens EMAS file, (having tested for its existence) ! as a store-map file (for speed) and shunts the ! contents a lump at a time down the line to UNIX. ! Protocol defined for Micros is followed. ie. ! ! '*' is the escape character: ! ! *B Beginning of file ! *E End of file. ! *C Literal '*' character ! *? Anything else implies abnormal ! termination - eg. ! ** Host -- file does not exist or ! ** HOST DOWN (!) ! %EXTERNAL %INTEGER %FN %SPEC SMADDR (%INTEGER CHAN, %C %INTEGERNAME LEN) %EXTERNAL %ROUTINE %SPEC CLOSESM (%INTEGER CHAN) %SYSTEM %ROUTINE %SPEC CONSOLE (%INTEGER SER, %C %INTEGERNAME START, LEN) %CONST %INTEGER CHAN NO = 2 %CONST %STRING(1) CHAN ID = "2"; ! Must be same No. as CHAN NO %CONST %STRING(3) S1 = "*B", S2 = "*C", S3 = "*E " %INTEGER STARTSEQ, ENDSEQ, STARSEQ STARTSEQ = ADDR(S1) + 1 STARSEQ = ADDR(S2) + 1 ENDSEQ = ADDR(S3) + 1 %OWN %INTEGER TWO = 2, THREE = 3 %STRING(63) FILE %INTEGER FSTART; ! For store-mapping %INTEGER FLEN; ! Length of file to be transfered %INTEGER POS; ! Address within store-map file %INTEGER ST, L; ! Start and length of area for console call %BYTEINTEGER CH %ROUTINE ABORT(%STRING(70) REASON) PRINTSTRING("** Host -- ") PRINTSTRING(REASON) NEWLINE %STOP %END GET FILE NAME (FILE) %IF LENGTH(FILE) > 30 %THEN ABORT("Invalid filename") %IF EXIST (FILE) = 0 %THEN ABORT("File ".FILE. %C " does not exist, or no access") DEFINE("SM".CHAN ID.",".FILE) FSTART = SMADDR(CHAN NO,FLEN) %IF FLEN = 0 %THEN ABORT("File is empty") messages ("off") SETMODE("FLOW=ON") ST = FSTART CONSOLE(10,STARTSEQ,TWO); ! Printstring("*B") %CYCLE POS = FSTART, 1, FSTART + FLEN - 1 CH = BYTEINTEGER(POS) %IF CH = '*' %START L = POS - ST CONSOLE(10,ST,L) %IF L # 0 CONSOLE(10,STARSEQ,TWO) ST = POS + 1 %FINISH %REPEAT L = POS - ST CONSOLE(10,ST,L) %IF L # 0 CONSOLE(10,ENDSEQ,THREE) READSYMBOL(CH); ! Wait for acknowledgement CLOSESM(CHAN NO) CLEAR(CHAN ID) PRINTSTRING("** Host --") WRITE(FLEN,0) PRINTSTRING(" bytes transmitted") NEWLINE MESSAGES("ON") %END %END %OF %FILE