# # # cadnet v2.0 # receiv -- retln # # this subroutine receives a line of the transmitted file # from the remote computer. the line is returned in # filine, and its length in lenlen. a zero status code indicates # a successful line transfer, positive indicates end of file, # and negitive indicates an error. # subroutine retln (filine,linlen,ids) logical*1 filine (512),line(132),tsknam(6),lf,enq,offset,eot logical*1 soh, esc, bel, space, bs, null logical contin parameter efn=1,rem=3,err=1 common /task/ tsknam common /buffer/ icnt,line data enq, lf, eot, soh, esc, bel/"5, "12, "4, "1, "33, "7/ data space, bs, null/"40, "10, "0/ # # i=1 # pointer in filine ids=0 # clear status code linlen=0 # clear length of line offset=0 # used to compute control characters # # respond to remote after first execution, and wait 10 continue if(i.gt.1) write(rem,100) num call time icount=icnt icnt=0 # contin=.false. # assumes end of line # # check for end of line. branch if so. if(line(icount).ne.esc) goto 20 contin= .true. # set no end of line icount=icount-1 # delete escape from line # 20 continue if (line(2).eq.null) goto 55 # check for null line if(line(1).ne.lf) goto 200 # check for bad line if (line(2).eq.eot) goto 210 # check for eof # # transfer loop. move file line from line to filine. # also interpret all subsequences and remove them. do 50 j=2,icount if (line(j).lt.space) goto 40 # branch on control char # control char if(offset.gt.0) filine(i)= line(j).and."77 # negitive characters, bit 6 set, bit 6 clear respectively if(offset.eq.-1) filine(i)= line(j).or."200 if(offset.eq.-2) filine(i)= (line(j).and."77).or."200 # normal character if(offset.eq.0) filine(i)= line(j) offset = 0 # clear offset i=i+1 # increment pointer goto 50 40 continue # next char is a control character if(line(j).eq.enq) offset=1 # next character is negitive if(line(j).eq.bel) offset=-1 if(line(j).eq.bs) offset=-2 if(offset.eq.0) goto 200 # this is an error condition 50 continue # # transmit this value if line is not finished num= (icount.and."77) .or. "100 if (contin) goto 10 # 55 continue linlen=i-1 # compute length of line # # prepare end of line response d write (err,1111) linlen,num,ihigh,low d1111 format(' linlen = ',i5/' num = ',i5/' ihigh,low = ',2i5) ihigh = linlen/"100 +"100 low = (linlen.and."77) .or. "100 write(rem,100) num, ihigh, low return # # error in line transmission 200 continue write(err,101) write(rem,100) soh ids=-1 return # # end of file section 210 continue ids=1 write(rem,100) eot return # 100 format(x,4a1) 101 format(' Bad line in file. Aborting communication') end