From ce4f8a168c2024021fe419538cafd7ac6f0a96c2 Mon Sep 17 00:00:00 2001 From: Eric Swenson Date: Sun, 18 Dec 2016 15:07:36 -0800 Subject: [PATCH] Added PORTS. Resolves #123. --- README.md | 1 + build/build.tcl | 4 ++ src/sysen2/ports.1 | 108 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100755 src/sysen2/ports.1 diff --git a/README.md b/README.md index 59ff0c4e..1531bc13 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ A list of [known ITS machines](doc/machines.md). - PEEK, system monitoring. - PFTHMG, Puff the magic dragon. - PHOTO, capture STY session output. + - PORTS, display free network ports. - PR, print out various system documentation. - PROBE, probe inside job and display various information about it. - PRUFD, list files on disk volume. diff --git a/build/build.tcl b/build/build.tcl index fa713e3d..1d81cd74 100644 --- a/build/build.tcl +++ b/build/build.tcl @@ -752,6 +752,10 @@ expect ":KILL" respond "*" ":midas sys1;ts timoon_syseng;timoon\r" expect ":KILL" +# ports +respond "*" ":midas sys2;ts ports_sysen2;ports\r" +expect ":KILL" + # sysmsg respond "*" ":midas sys1;ts sysmsg_sysen1;sysmsg\r" expect ":KILL" diff --git a/src/sysen2/ports.1 b/src/sysen2/ports.1 new file mode 100755 index 00000000..f655922b --- /dev/null +++ b/src/sysen2/ports.1 @@ -0,0 +1,108 @@ +;-*-midas-*- + +title ports-> print number of free net ports. +;Stolen from RMS's LOADP, and prettied up a bit. + +a=1 +b=2 +c=3 +d=4 +e=5 +f=6 +g=7 +h=10 +i=11 +j=12 +k=13 +l=14 +m=15 +n=16 +p=17 +t1=20 +t2=21 +chttyo==1 + +define syscal a,b + .call [setz ? sixbit/a/ ? b ((setz))] +termin +DEFINE TCAL OP,ARGS + .CALL [SETZ ? SIXBIT /OP/ ? ARGS ((SETZ))] +TERMIN +DEFINE TYPE CHNL,&STRING + MOVEI T1,<.LENGTH STRING> + MOVE T2,[440700,,[ASCII STRING]] + TCAL SIOT,[%CLIMM,,CHNL ? T2 ? T1] + .LOSE %LSFIL +TERMIN + + + +beg: move p,[-lpdl,,pdl] + .open chttyo,[.uao,,'tty] + .lose + movei b,0 ;B indexes which tty we are looking at. + setzm nfstys ;Initialize counters: # of free stys +count: syscal ttyget,[%climm,,400000(b) ;D gets TTYST var - negative for free tty. + %clout,,a ? %clout,,a ? %clout,,d] + jrst print ;Error means we have run out of tty numbers. + syscal ttyvar,[%climm,,400000(b) ? [sixbit/ttytyp/] + %clout,,a] + .lose %lsfil + trnn a,%tysty ;If it's a sty, is it free? + jrst notfre + jumpge d,notfre + aos nfstys +notfre: aoja b,count ;ok, it isn't free, ignore it. + +ascout: hrli a,440700 +ascou1: ildb b,a + jumpe b,cpopj + .iot chttyo,b + jrst ascou1 + +decout: idivi a,10. + hrlm b,(p) + skipe a + pushj p,decout + hlrz b,(p) + addi b,"0 + .iot chttyo,b +cpopj: popj p, + +;Having collected the data, print it out. +print: move a,nfstys + cain a,0 + jrst print0 + cain a,1 + jrst print1 + movei a,[asciz/There are /] + pushj p,ascout + move a,nfstys + pushj p,decout + movei a,[asciz/ free net ports. +/] + pushj p,ascout + .logout 1, + + +print1: movei a,[asciz/There is 1 free net port. +/] + pushj p,ascout + .logout 1, + +print0: movei a,[asciz/There are no free net ports. +/] + pushj p,ascout + .logout 1, + + +nfstys: 0 + +pat: patch: + block 40 +epatch: -1 + +lpdl=10 +pdl: block lpdl + + end beg