! FILE 'rolbx1' !********************** !* rolbx1/rolbx1y !* date: 01.jun.81 * !* ring vsn * !********************* %conststring (7) vsn = "vsn001b" !! stack = 300, streams = 1 %control k'100001' %INCLUDE "DEIMOSPERM" %recordformat xf(%byteinteger unit,fsys,%byteintegerarray fname(0:5)) %BEGIN %owninteger mon = -1 %recordformat mef(%record(mef)%name link,%byteinteger len,type, %c (%bytearray reserved(0:7), %bytearray data(0:239) %or %c %bytearray params(0:239))) %recordformat pf(%byteinteger service,reply,fn, s1, %c (%record (mef)%name mes, %byte gate port, task port %or %c %string (3) facility)) %record(pf) p %constinteger connected = 1 %constinteger title = 2 %constinteger getting = 3 %constinteger ready = 4 %constinteger closing = 5 %constinteger waiting = 6, %c input = 7, %c skipping = 8, %c close i = 9 %ownstring (127) user, pass, file, disc %ownstring (5) usern = "USER " %ownstring (5) passn = "PASS " %ownstring (3) gon = "GO*" %ownstring (7) listn = "LIST " %ownstring (9) lp155n = ",.LP155*" %ownstring (5) rl01n = "RL01" %ownstring (5) rk05n = "RK05" %ownstring (5) rx02n = "RX02" %ownstring (5) testn = "TEST" %ownstring (5) dollar = "$$$$$" %ownstring(25) address = "N90T90S13" %ownstring (9) qual = "W=3/3" %ownstring (25) who %constinteger tt ser=1, gate ser=16, buffer manager=17 %constinteger rd=0, echo off=10 %constinteger request buffer=0, release buffer=1 !************************************************************ !* Function Values between Upper level and Gate !************************************************************ %constinteger connect = 1 ;! start a call up %constinteger accept call = 2; ! accept a call %constinteger Disconnect = 3; ! Stop a call, or reject a connect %constinteger Enable Input = 4; ! Allow data, Gate -> Task %constinteger Put Output = 5; ! Output Block, Gate -> Task %constinteger Enable Output = 4; ! Allow Output, Task -> Gate %constinteger Input Here = 5; ! Input Block, Task -> Gate %constinteger Reset = 6; ! Reset the Virtual Circuit (!) %constinteger Expedited = 7; ! Pass 'Interrputs' %constinteger Datagram = 8; ! Send a 'datagram' %constinteger Datagram Reply = 9; ! Reply to a datagram %constinteger Enable Facility = 10; ! Claim incoming calls Task -> Gate %constinteger Disable Facility= 11; ! Stop them %integer i, node, term, strm, k, flag %owninteger initf %owninteger users, sta, cpu, pkts, sbr, byt, rjei, tim, rjeo %owninteger conn ok, g port, power, kill it, maxc %ownbyteintegerarray buff(0:511) %owninteger pt, block, last block, drive, goah, disc ser, state, pti %owninteger blext = 0, tim2 %constintegerarray dser(0:4) = 3, 3, 8, 14, 28 %ownstring (1) snil = "" %string (127) %fn unpack(%record (mef) %name mes, %integer no) %integer i, l %unless mes == null %or mes_len<=0 %or no<=0 %start l = 0 %while no>1 %cycle l=l+mes_params(l)+1 no = no-1 %repeat %result = string(addr(mes_params(l))) %finish %else %result = "" %end %routine pack(%record(mef) %name mes, %string (*) %name s) string(addr(mes_params(mes_len))) = s mes_len = mes_len+length(s)+1 %end %routine get buffer(%integer reason, r2) p_service=buffer manager; p_reply=id p_fn=request buffer; p_gate port=0; p_task port=reason p_s1 = r2 pon(p) %end %routine free buffer(%record(mef)%name mes) p_service=buffer manager; p_reply=id p_fn=release buffer; p_mes==mes pon(p) %end %routine to gate(%integer fn, %record (mef) %name mes, %c %integer flag) p_service = gate ser; p_reply = id p_fn = fn; p_mes == mes; p_s1 = flag p_gate port = g port; p_task port = 1 pon(p) %end %routine do connect(%integer type) p_service = buffer manager; p_reply = own id p_fn = request buffer; p_gate port = 0 ponoff(p) p_mes_len = 0 pack(p_mes, address); pack(p_mes, snil); pack(p_mes, qual) pack(p_mes,snil) p_service = gate ser; p_reply = own id p_fn = connect p_gate port = 0; p_task port = 1 pon(p) %end %routine put next disc block %integer i, j, k %constintegername null == 0 %recordformat pf(%byteinteger ser, reply, %c %integer a, %byteintegername b, %integer c) %record (pf) p %if block = 0 %start; ! disc check turn off required p_ser = disc ser; p_reply = id p_a = 0; p_b == null ponoff(p) %if p_a # 9 %start printstring("Failed to turn Disc check off") write(p_a, 1); newline %stop %finish %finish %if block > last block %start end of disc: printstring("Whole disc written ") state = skipping %return %finish p_ser = disc ser; p_reply = id p_a = 1; p_b == buff(0); p_c = block!blext ponoff(p) %if p_a # 0 %start printstring("Failed to write Block"); WRITE(BLOCK, 2) printstring(" from the disc - "); WRITE(P_A, 1) newline %if p_a = 4 %then -> end of disc %finish block = block+1 state = input %end %routine do title(%record (mef) %name mes) %integer pt, opt, i %routine plant(%string(*) %name s, %integername ptx) %integer len len = length(s) %return %if len = 0 %cycle i = 1, 1, len mes_data(ptx) = charno(s, i) ptx = ptx+1 %repeat %end pt = 3; opt = 2 mes_data(0)=1; mes_data(1) = nl; ! plant a blank line plant(usern, pt); plant(user, pt) mes_data(opt) = pt-opt-1 opt = pt; pt = pt+1 plant(passn, pt); plant(pass, pt) mes_data(opt) = pt-opt-1 opt = pt; pt = pt+1 plant(gon, pt) mes_data(opt) = pt-opt-1 opt = pt; pt=pt+1 plant(listn, pt); plant(file, pt) plant(lp155n, pt) mes_data(opt) = pt-opt-1 mes_len = pt to gate(put output, mes, 0) state = ready %end %routine do block(%record (mef) %name mes, %integer cnsl) %integer i, j, k %integer a, b, c, len %if cnsl # 0 %then do title(mes) %and %return printstring("FAULT! ") %end %routine input block(%record (mef) %name mes) %owninteger skip = 4 %integer i, j, n, len, rpt len = mes_len; ! -6 for nsi %if mon # 0 %start printstring("LEN ="); WRITE(LEN, 1); NEWLINE %finish n = 0; rpt = 0 %cycle %if n = 0 %start n = mes_data(rpt); rpt = rpt+1 %if n&x'80' # 0 %start n = mes_data(rpt); rpt = rpt+1 %finish %if mon # 0 %start printstring("RECORD LEN ="); WRITE(N, 1); WRITE(RPT, 1) newline %finish %exit %if rpt > len %finish i = mes_data(rpt); rpt = rpt+1 %if skip # 0 %start %if i = '$' %then skip = skip-1 %if skip = 0 %start printstring("Data Phase Starting ") rpt = rpt+1; n = n-1; ! skip the nl %finish %else buff(pti) = i; pti = pti+1 %if pti = 512 %start put next disc block pti = 0 %finish %finish n = n-1 %repeat %end %routine read line(%string(*) %name s) %integer i length(s) = 0 %cycle readsymbol(i) s = s.to string(i) %if i = nl %then %return %repeat %end charno(dollar, 5) = nl charno(gon, 3) = nl; charno(lp155n, 8) = nl i = map virt(buffer manager,4, 3) i = map virt(buffer manager, 5, 4) i = map virt(buffer manager, 6, 5) printstring("Roll Disc Image from Filestore ") prompt("Disc Type?"); read line(disc) prompt("Disc Drive?"); read(drive); skipsymbol prompt("User Name?"); read line(user) prompt("User Pass?"); read line(pass) prompt("File Name?"); read line(file) length(file) = length(file)-1; ! delete the delimeter length(disc) = length(disc)-1 %if disc = testn %start prompt("address?"); read line(address) length(address) = length(address)-1 last block = 100 %finish %if drive = 0 %start printstring("This program is about to overwrite drive 0 !!! Please change the disc now! ") prompt("Please confirm when ready?") readsymbol(i) %stop %unless i = 'y' %finish printstring("Please use NSIW to loggon T155 to the Filestore ") %if drive < 0 %or drive > 4 %start printstring("Only Drive 0, 1 or 2 ") %stop %finish disc ser = dser(drive); bl ext = 0 %if drive = 1 %then bl ext = k'020000' %if disc = rk05n %then last block = 4700 %if disc = rx02n %then last block = 999 %if disc = rl01n %start last block = 9301 %finish %if last block = 0 %start printstring(" Discs - RL01, RK05 and RX02 ") %stop %finish sta = 1 do connect(0) alarm(4*50) %cycle p_service = 0; poff(p) %if p_reply = 0 %start; ! clock %if int = 'A' %start kill it = -1 printstring("KILLING IT ") to gate(disconnect, null, 63) %if conn ok # 0 int = 0 %continue %finish alarm(50); ! 1 secs %if 'M' <= int <= 'P' %start mon = int-'O'; int = 0 %finish %if int='?' %start write(pkts, 1) write(block, 4); newline int = 0 %finish %if tim2 # 0 %start tim2 = tim2-1 %if tim2 = 0 %and state = waiting %start printstring("?? Are you sure the file exists? ") tim2 = 5*60; ! 5 mins %finish %finish %continue %finish %if mon < 0 %start select output(1) printstring("POFF:"); WRITE(P_REPLY, 1) write(p_fn, 1);write(p_s1, 1); write(p_gate port, 3); write(p_task port, 1) newline select output(0) %finish %if p_reply = buffer manager %start %if kill it < 0 %then free buffer(p_mes) %and %continue do block(p_mes, p_s1) %continue %finish %if p_reply = gate ser %start %if p_fn = accept call %start; ! 2nd reply %stop %if kill it < 0 i = p_gate port; ! gate port number !! g port = i printstring("Command File Going to Filestore ") goah = 2 conn ok = 1 get buffer(1, 1); ! get buffer for title %continue %finish %if p_fn = disconnect %start printstring("Disconnect "); write(p_s1, 1); newline %if state < connected %start %if tim = 0 %start printstring("FAILED"); WRITE(P_S1, 1); NEWLINE %finish tim = tim+1 do connect(0); ! try again %continue %finish %stop %if kill it < 0 %if p_s1 > 1 %start; ! failed ! call has been abandoned printstring("File has been abandoned after") write(block, 1); printstring(" blocks ") to gate(disconnect, null, 63) p_service = 0; poff(p); ! catch the timer %stop %finish %if state = skipping %start; ! 'normal' printstring("Eof received from Filestore ") stop it: write(block, 1); printstring(" blocks written ") to gate(disconnect, null, 1) p_service = 0; poff(p); ! catch clock tick %stop %finish %if state = closing %start printstring("Command File gone It may take the Filestore a while to copy the file! ") tim2 = 1*60 p_service = gate ser; p_reply = own id p_fn = enable facility; p_s1 = 0 p_facility = "LP" pon(p) state = waiting %continue %finish printstring("Unexpected close rec'd ") -> stop it %finish %if p_fn = enable output %start goah = goah+1 %if mon # 0 %start select output(1) printstring("OT - GOAH ="); WRITE(GOAH, 1); NEWLINE select output(0) %finish %if state = ready %start state = closing to gate(disconnect, null, 0) %finish %continue %finish %if p_fn = connect %start printstring("Start of File ") who = unpack(p_mes, 2) %if who # "N90T90" %start printstring("File is not from filestore ! Addr =") printstring(who); newline -> out %if disc = testn to gate(disconnect, null, 63) to gate(disable facility, null, 4) %stop %finish out: g port = p_gate port to gate(Accept Call, null, 0) to gate(disable facility, null, 4); ! no more calls thank you state = input %continue %finish %if p_fn = input here %start pkts = pkts+1 %if mon # 0 %start select output(1) printstring("Input Recd ") select output(0) %finish !deal with it input block(p_mes) %if state = input free buffer(p_mes) to gate(enable input, null, 1) %continue %finish printstring("FUNNY FN"); write(p_fn, 1); newline %continue %finish %repeat %endofprogram