interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / core / hive-view / src / page.om

2749 lines · 48000 bytes Raw Blame History
1note ==== page.om: every page and panel is drawn here, by Omega, as escaped HTML. The browser runs
2note no script at all (CSP has no script source): panels are iframes that re-fetch themselves with
3note <meta http-equiv=refresh>, and typing goes through a plain HTML form to POST /send.
4note All text that came from outside (pane captures, files, command output, query values) goes
5note through vwhe, which writes & < > " ' as entities and drops control bytes.
6global gh uchar 262144
7global ghl ulong 1
8global gix uchar 32768
9global gixl ulong 1
10global gq uchar 1024
11global gql ulong 1
12global gnow ulong 1
13global gcsrf uchar 64
14global gcsrfk ulong 1
15global gst ulong 4
16global gsp ulong 4
17global gsv ulong 16
18global gsvn ulong 1
19global gtl uchar 4096
20global gtll ulong 1
21global gpp ulong 8
22global gks uchar 768
23global gksl ulong 16
24global gkc ulong 16
25global gkn ulong 1
26global glan uchar 3072
27global glanl ulong 64
28global glann ulong 1
29text thamp "&amp;"
30text thlt "&lt;"
31text thgt "&gt;"
32text thquo "&quot;"
33text thapo "&#39;"
34text tdoc1 "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta http-equiv=\"refresh\" content=\""
35text tdoc2 "\"><link rel=\"stylesheet\" href=\"/app.css\"><link rel=\"stylesheet\" href=\"/palette.css\"></head><body class=\"frame\"><div class=\"lost l"
36text tdoc3 "\">NOT LIVE: this panel has not refreshed for a while (server down, or the browser paused it). Reload the page.</div>\n"
37text tdocend "</body></html>\n"
38text tpage1 "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>"
39text tpage2 "</title><link rel=\"stylesheet\" href=\"/app.css\"><link rel=\"stylesheet\" href=\"/palette.css\"></head><body>\n"
40text tspage0 "<span class=\"age"
41text tcdown " down"
42text tcstale " stale"
43text tqgt "\">"
44text tspend "</span>"
45text tago " ago"
46text tsago "s ago"
47text tafail " · last refresh failed ("
48text tastale " · STALE"
49text tefile "file missing"
50text teperm "permission denied"
51text tetmo "command timed out"
52text tenost "command could not start"
53text tesig "command killed by a signal"
54text texit "command exit "
55text terr "error "
56text tspc "<span class=\""
57text tspf "f"
58text tspb " b"
59text tspbo " B"
60text tspdi " D"
61text tspit " I"
62text tspun " U"
63text tsnone "No sessions in this group right now."
64text ttile1 "<a class=\"tile\" target=\"_top\" href=\"/s/"
65text ttile2 "\"><div class=\"head\"><span class=\"name\">"
66text ttile3 "</span> "
67text tdivc "</div>"
68text tptitle "<div class=\"ptitle\">"
69text tpstl "<div class=\"pstatus\">"
70text tpmeta "<div class=\"meta\">"
71text tpterm "<pre class=\"term\">"
72text tpterb "<pre class=\"term big\">"
73text tpreend "</pre>"
74text tpreo "<pre>"
75text taend "</a>\n"
76text tdot " · "
77text tattach " · attached"
78text tphead "<div class=\"phead\"><span class=\"name\">"
79text tnosessn "No tmux session has that name right now."
80text tpane "/p/pane"
81text ttiles "/p/tiles"
82text thermp "/p/hermes"
83text tmachp "/p/machine"
84text tboardp "/p/board"
85text tentp "/p/entries"
86text tstatp "/p/status"
87text tpalp "/palette.css"
88text tqn "n"
89text tqg "g"
90text tqf "f"
91text tqlane "lane"
92text tqq "q"
93text tqm "m"
94text tqa "a"
95text tqb "b"
96text tqs "s"
97text tpalc1 ".f"
98text tpalc2 "{color:#"
99text tpalc3 "}.b"
100text tpalc4 "{background:#"
101text tpalc5 "}\n"
102text tbase16 "000000cd31310dbc79e5e5102472c8bc3fbc11a8cde5e5e5666666f14c4c23d18bf5f5433b8eead670d629b8dbffffff"
103text tcube "005f87afd7ff"
104text th3 "<h3>"
105text th3e "</h3>\n"
106text tkv1 "<div class=\"kv\"><div class=\"k\">"
107text tkv2 "</div><div class=\"v"
108text tkv3 "</div></div>\n"
109text tkverr " err"
110text tgateway "Gateway"
111text tup "up"
112text tdownc "DOWN"
113text tqpause "Queen PAUSE"
114text tpaused "PAUSED: "
115text tnotp "not paused"
116text tkanh "Kanban (aien-hive board)"
117text tchip1 "<span class=\"chip "
118text tchip2 "\">"
119text tchips "<div class=\"chips\">"
120text trunh "Running cards"
121text tnorun "No running cards."
122text tcard1 "<div class=\"card\"><code>"
123text tcard2 "</code> "
124text trunning "running"
125text tmuted "<div class=\"muted\">"
126text thmach "Machine"
127text tload "Load (1/5/15 min)"
128text tmemk "Memory"
129text tgibu " GiB used of "
130text tgiba " GiB ("
131text tgibv " GiB available)"
132text tcpuk "CPU busy (all cores)"
133text tcpuv "% over the last 10 s"
134text tmeas "measuring"
135text thgpu "GPU"
136text tpowk "Power"
137text twatt " W"
138text tutilk "Utilization"
139text tpct " %"
140text tsampk "Sample"
141text tsamp "spark-sensors row "
142text tnosamp "no spark-sensors sample found"
143text tpowu "Power / utilization"
144text ttempk "Temperature"
145text ttempv "not shown: hive-view never queries the GPU itself (only spark-window holders may)"
146text tgproc "GPU processes"
147text tnone "none"
148text tpidk "pid "
149text thwin "spark-window"
150text topenw "Open window"
151text tqueued "queued"
152text tgone " (waiter gone)"
153text thalive "holder alive"
154text thpool "Pool locks"
155text tcores "cores "
156text tpidm " · pid "
157text thledg "Pearl ledger (newest first, verbatim)"
158text tledgk "Ledger"
159text tnoledg "none yet (~/work/pearl/economics/ledger.jsonl does not exist)"
160text tvfull "<div class=\"v full\">"
161text tolb "<ol class=\"board\">"
162text tole "</ol>\n"
163text tli1 "<li><span class=\"ts\">"
164text tli2 "</span> <span class=\"lane\">"
165text tli3 "</span> "
166text tli "<li>"
167text tlie "</li>\n"
168text tnomatch "No BOARD line matches this filter."
169text tdoc1q "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta http-equiv=\"refresh\" content=\"10;url=/p/board?lane="
170text tampq "&amp;q="
171text tent1 "<div class=\"entry\"><h4>"
172text tent2 "</h4><pre>"
173text tent3 "</pre></div>\n"
174text tqfile "questions"
175text tdfile "decisions"
176text tcfile "claims"
177text tlive "<span class=\"badge live\">live</span> server time "
178text tzsp "Z · "
179text tpok "poller ok"
180text tpstall "<span class=\"badge down\">poller stalled "
181text ttfail "<span class=\"badge down\">tmux list failed</span>"
182text tnoix "<span class=\"badge down\">no poller data yet</span>"
183text ttrunc "\n… (shortened)"
184note ---- the HTML builder: gh[0, ghl), flushed to the connection by vwflush
185fn vwhc c uchar to void
186n = get ghl 0
187if lt n 262144
188put gh n c
189put ghl 0 add n 1
190end
191end
192fn vwht t view uchar * to void
193for i ulong len t
194vwhc get t i
195end
196end
197fn vwhd v ulong to void
198if ge v 10
199vwhd div v 10
200end
201vwhc uchar add rem v 10 48
202end
203fn vwhd2 v ulong to void
204if lt v 10
205vwhc 48
206end
207vwhd v
208end
209note vwhe: one untrusted byte as HTML text (also safe inside a quoted attribute)
210fn vwhe c uchar to void
211if eq c 38
212vwht thamp
213ret
214end
215if eq c 60
216vwht thlt
217ret
218end
219if eq c 62
220vwht thgt
221ret
222end
223if eq c 34
224vwht thquo
225ret
226end
227if eq c 39
228vwht thapo
229ret
230end
231if or lt c 32 eq c 127
232if or eq c 10 eq c 9
233vwhc c
234end
235ret
236end
237vwhc c
238end
239fn vwheo a ulong n ulong to void
240for i ulong n
241vwhe get gob add a i
242end
243end
244fn vwhei a ulong n ulong to void
245for i ulong n
246vwhe get gix add a i
247end
248end
249fn vwheq to void
250for i ulong get gql 0
251vwhe get gq i
252end
253end
254fn vwhet t view uchar * to void
255for i ulong len t
256vwhe get t i
257end
258end
259fn vwflush cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
260n = get ghl 0
261for i ulong n
262put buf i get gh i
263end
264put ghl 0 0
265if eq n 0
266ret 0
267end
268ret hput cs io view part buf 0 n
269end
270fn vwfin cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
271r = vwflush cs io buf
272ret hfe r hwfin cs io
273end
274note vwhtml: a 200 text/html response with the security headers, body chunked (or close-delimited)
275fn vwhtml cs edit ulong 320 io edit uchar 131072 to long
276put ghl 0 0
277put gnow 0 vwnowms
278r = hrspst cs io 200
279r = hfe r vwsech cs io
280r = hfe r hhname cs io tctype
281r = hfe r hhval cs io tthtml
282ret hfe r hhend cs io 1 0
283end
284note vwdoc: a self-refreshing panel document; the "lost" banner fades in by CSS alone after lost s
285fn vwdoc refr ulong lost ulong to void
286vwht tdoc1
287vwhd refr
288vwht tdoc2
289vwhd lost
290vwht tdoc3
291end
292fn vwpage t view uchar * to void
293vwht tpage1
294vwhet t
295vwht tpage2
296end
297note ---- ages
298fn vwhagt ms ulong to void
299s = div add ms 500 1000
300if lt s 60
301vwhd s
302vwht tsago
303ret
304end
305if lt s 3600
306vwhd div s 60
307vwhc 109
308vwhc 32
309vwhd rem s 60
310vwht tsago
311ret
312end
313vwhd div s 3600
314vwhc 104
315vwhc 32
316vwhd div rem s 3600 60
317vwhc 109
318vwht tago
319end
320fn vwherr st ulong to void
321if eq st 2
322vwht tefile
323ret
324end
325if eq st 13
326vwht teperm
327ret
328end
329if ge st 1000
330if eq st 1009
331vwht tetmo
332ret
333end
334if eq st 1008
335vwht tenost
336ret
337end
338if eq st 1007
339vwht tesig
340ret
341end
342vwht texit
343if ge st 1010
344vwhd sub st 1010
345ret
346end
347vwhc 45
348vwhd sub 1010 st
349ret
350end
351vwht terr
352vwhd st
353end
354note vwage: the age badge for refresh time t (ms) and status st; stale past lim ms
355fn vwage t ulong st ulong lim ulong to void
356ag = ulong 0
357if gt get gnow 0 t
358ag = sub get gnow 0 t
359end
360bad = gt ag lim
361vwht tspage0
362if ne st 0
363vwht tcdown
364else
365if bad
366vwht tcstale
367end
368end
369vwht tqgt
370vwhagt ag
371if ne st 0
372vwht tafail
373vwherr st
374vwhc 41
375end
376if bad
377vwht tastale
378end
379vwht tspend
380end
381note ---- the poller's index: "P<TAB>now<TAB>tmux_st<TAB>tick" then "SLOT<TAB>GEN<TAB>TMS<TAB>ST<TAB>KIND<TAB>NAME"
382fn vwrdix to bool
383put gixl 0 0
384vwpb
385vwpr
386vwpt tindex
387fd = vwfopen
388if lt fd 0
389ret false
390end
391for it ulong 1000
392n = get gixl 0
393if ge n 32768
394break
395end
396r = read int fd gix n sub 32768 n
397if le r 0
398break
399end
400put gixl 0 add n ulong r
401end
402x = fclose int fd
403ret gt get gixl 0 0
404end
405fn vwixe a ulong to ulong
406n = get gixl 0
407for i ulong sub n a
408if eq get gix add a i 10
409ret add a i
410end
411end
412ret n
413end
414note vwixf: start of tab-separated field k of the index line [a, e)
415fn vwixf a ulong e ulong k ulong to ulong
416if eq k 0
417ret a
418end
419c = ulong 0
420for i ulong sub e a
421if eq get gix add a i 9
422c = add c 1
423if eq c k
424ret add add a i 1
425end
426end
427end
428ret e
429end
430fn vwixn p ulong to ulong
431v = ulong 0
432for i ulong 20
433if ge add p i get gixl 0
434ret v
435end
436c = get gix add p i
437if not vwdig c
438ret v
439end
440v = add mul v 10 ulong sub c 48
441end
442ret v
443end
444note vwixis: the index line [a, e) field k equals t
445fn vwixis a ulong e ulong k ulong t view uchar * to bool
446p = vwixf a e k
447q = vwixf a e add k 1
448if lt q e
449q = sub q 1
450end
451if ne sub q p len t
452ret false
453end
454for i ulong len t
455if ne get gix add p i get t i
456ret false
457end
458end
459ret true
460end
461note vwixisq: field k equals the decoded query value gq
462fn vwixisq a ulong e ulong k ulong to bool
463p = vwixf a e k
464q = vwixf a e add k 1
465if lt q e
466q = sub q 1
467end
468if ne sub q p get gql 0
469ret false
470end
471for i ulong get gql 0
472if ne get gix add p i get gq i
473ret false
474end
475end
476ret true
477end
478note vwixfind: the index line of section or session named gq (kind sec when sec), else gixl
479fn vwixfind sec bool to ulong
480a = vwixe 0
481a = add a 1
482for it ulong 128
483if ge a get gixl 0
484break
485end
486e = vwixe a
487if vwixisq a e 5
488if eq sec vwixis a e 4 tksec
489ret a
490end
491end
492a = add e 1
493end
494ret get gixl 0
495end
496fn vwixage a ulong lim ulong to void
497e = vwixe a
498vwage vwixn vwixf a e 2 vwixn vwixf a e 3 lim
499end
500note vwsnap: read the snapshot of the slot on index line a into gob; returns the body start
501note (just past the "NAME<TAB>KIND<TAB>GEN" line) or gol when unreadable
502fn vwsnap a ulong to ulong
503vwpslot vwixn a
504r = vwrdall 262144
505if lt r 0
506put gol 0 0
507ret 0
508end
509ret vwlend 0 get gol 0
510end
511note vwsecq: look up section t (as gq) and read it; returns the index line or gixl
512fn vwsecq t view uchar * to ulong
513n = hmin len t 1024
514for i ulong n
515put gq i get t i
516end
517put gql 0 n
518ret vwixfind true
519end
520note ---- query strings: ?name=value&... ; values are percent-decoded ('+' is a space) into gq
521fn vwamp io edit uchar 131072 p ulong e ulong to ulong
522for i ulong sub e p
523if eq get io add p i 38
524ret add p i
525end
526end
527ret e
528end
529fn vwqnm io edit uchar 131072 p ulong q ulong nm view uchar * to bool
530k = len nm
531if le sub q p k
532ret false
533end
534for i ulong k
535if ne get io add p i get nm i
536ret false
537end
538end
539ret eq get io add p k 61
540end
541fn vwqdec io edit uchar 131072 p ulong q ulong to bool
542n = ulong 0
543i = p
544for it ulong 4096
545if ge i q
546break
547end
548if ge n 1024
549ret false
550end
551c = get io i
552if eq c 43
553c = 32
554end
555if eq c 37
556if gt add i 3 q
557ret false
558end
559h = hhexv get io add i 1
560l = hhexv get io add i 2
561if or gt h 15 gt l 15
562ret false
563end
564c = uchar add mul h 16 l
565i = add i 2
566end
567put gq n c
568n = add n 1
569i = add i 1
570end
571put gql 0 n
572ret true
573end
574fn vwqget cs edit ulong 320 io edit uchar 131072 nm view uchar * to bool
575put gql 0 0
576tg = get cs HTOFF
577tl = get cs HTLEN
578pl = hplen cs io
579if ge pl tl
580ret false
581end
582p = add add tg pl 1
583e = add tg tl
584for it ulong 64
585if ge p e
586ret false
587end
588q = vwamp io p e
589if vwqnm io p q nm
590ret vwqdec io add add p len nm 1 q
591end
592p = add q 1
593end
594ret false
595end
596fn vwqis t view uchar * to bool
597if ne get gql 0 len t
598ret false
599end
600for i ulong len t
601if ne get gq i get t i
602ret false
603end
604end
605ret true
606end
607note vwqname: gq is a session name the dashboard may address (1..63 of [A-Za-z0-9_-])
608fn vwqname to bool
609n = get gql 0
610if or eq n 0 gt n 63
611ret false
612end
613for i ulong n
614if not vwnamec get gq i
615ret false
616end
617end
618ret true
619end
620note vwqnum: gq as a small decimal (0 when absent or not a number)
621fn vwqnum to ulong
622v = ulong 0
623for i ulong hmin get gql 0 9
624c = get gq i
625if not vwdig c
626ret 0
627end
628v = add mul v 10 ulong sub c 48
629end
630ret v
631end
632note ---- ANSI SGR to classes. gst: 0 fg (0 default, else 1 + xterm-256 index), 1 bg, 2 flags
633note (1 bold, 2 dim, 4 italic, 8 underline, 16 reverse). gsp: the span now open (fg, bg, flags, open).
634note Truecolor is drawn with the nearest colour of the xterm-256 cube.
635fn vwcubei v ulong to ulong
636if lt v 48
637ret 0
638end
639if lt v 115
640ret 1
641end
642ret hmin 5 div sub v 35 40
643end
644fn vwsgrc c ulong to void
645f = get gst 2
646if eq c 0
647put gst 0 0
648put gst 1 0
649put gst 2 0
650ret
651end
652if eq c 1
653put gst 2 or f 1
654end
655if eq c 2
656put gst 2 or f 2
657end
658if eq c 3
659put gst 2 or f 4
660end
661if eq c 4
662put gst 2 or f 8
663end
664if eq c 7
665put gst 2 or f 16
666end
667if eq c 22
668put gst 2 and f 28
669end
670if eq c 23
671put gst 2 and f 27
672end
673if eq c 24
674put gst 2 and f 23
675end
676if eq c 27
677put gst 2 and f 15
678end
679if and ge c 30 le c 37
680put gst 0 sub c 29
681end
682if and ge c 90 le c 97
683put gst 0 sub c 81
684end
685if and ge c 40 le c 47
686put gst 1 sub c 39
687end
688if and ge c 100 le c 107
689put gst 1 sub c 91
690end
691if eq c 39
692put gst 0 0
693end
694if eq c 49
695put gst 1 0
696end
697end
698note vwsgrx: 38/48 extended colour at parameter i; returns how many parameters it used after i
699fn vwsgrx i ulong to ulong
700n = get gsvn 0
701w = ulong 0
702if eq get gsv i 48
703w = 1
704end
705v = ulong 0
706used = ulong 0
707if and lt add i 2 n eq get gsv add i 1 5
708v = add and get gsv add i 2 255 1
709used = 2
710end
711if and lt add i 4 n eq get gsv add i 1 2
712r = vwcubei and get gsv add i 2 255
713g = vwcubei and get gsv add i 3 255
714b = vwcubei and get gsv add i 4 255
715v = add add add 16 add mul r 36 mul g 6 b 1
716used = 4
717end
718put gst w v
719ret used
720end
721fn vwsgr to void
722n = get gsvn 0
723if eq n 0
724vwsgrc 0
725ret
726end
727i = ulong 0
728for it ulong 16
729if ge i n
730ret
731end
732c = get gsv i
733if or eq c 38 eq c 48
734i = add i vwsgrx i
735else
736vwsgrc c
737end
738i = add i 1
739end
740end
741fn vwspclose to void
742if eq get gsp 3 1
743vwht tspend
744put gsp 3 0
745end
746end
747note vwspan: make the open span match gst before the next text byte
748fn vwspan to void
749fg = get gst 0
750bg = get gst 1
751f = get gst 2
752if ne and f 16 0
753fg = get gst 1
754bg = get gst 0
755if eq fg 0
756fg = 1
757end
758if eq bg 0
759bg = 8
760end
761end
762f = and f 15
763op = ne add add fg bg f 0
764if eq get gsp 3 1
765if and and eq get gsp 0 fg eq get gsp 1 bg eq get gsp 2 f
766ret
767end
768end
769vwspclose
770if not op
771ret
772end
773vwht tspc
774if ne fg 0
775vwht tspf
776vwhd sub fg 1
777end
778if ne bg 0
779vwht tspb
780vwhd sub bg 1
781end
782vwspfl f
783vwht tqgt
784put gsp 0 fg
785put gsp 1 bg
786put gsp 2 f
787put gsp 3 1
788end
789fn vwspfl f ulong to void
790if ne and f 1 0
791vwht tspbo
792end
793if ne and f 2 0
794vwht tspdi
795end
796if ne and f 4 0
797vwht tspit
798end
799if ne and f 8 0
800vwht tspun
801end
802end
803note vwesc: the escape sequence starting at gob[i] (ESC); applies SGR; returns the index after it
804fn vwesc i ulong b ulong to ulong
805if ge add i 1 b
806ret b
807end
808c = get gob add i 1
809if eq c 91
810ret vwcsi add i 2 b
811end
812if eq c 93
813for k ulong sub b add i 2
814p = add add i 2 k
815d = get gob p
816if eq d 7
817ret add p 1
818end
819if and eq d 27 lt add p 1 b
820if eq get gob add p 1 92
821ret add p 2
822end
823ret p
824end
825end
826ret b
827end
828ret add i 2
829end
830fn vwcsi p ulong b ulong to ulong
831put gsvn 0 0
832v = ulong 0
833dig = false
834for k ulong sub b p
835c = get gob add p k
836if and ge c 64 le c 126
837if dig
838vwsvpush v
839end
840if eq c 109
841vwsgr
842end
843ret add add p k 1
844end
845if vwdig c
846v = add mul v 10 ulong sub c 48
847if gt v 100000
848v = 100000
849end
850dig = true
851else
852if dig
853vwsvpush v
854end
855v = 0
856dig = false
857end
858end
859ret b
860end
861fn vwsvpush v ulong to void
862n = get gsvn 0
863if lt n 16
864put gsv n v
865put gsvn 0 add n 1
866end
867end
868note vwansi: gob[a, b) as escaped HTML text with colour spans
869fn vwansi a ulong b ulong to void
870put gst 0 0
871put gst 1 0
872put gst 2 0
873put gsp 3 0
874i = a
875for it ulong 1000000
876if ge i b
877break
878end
879c = get gob i
880if eq c 27
881i = vwesc i b
882continue
883end
884if eq c 10
885vwhc 10
886else
887if and ge c 32 ne c 127
888vwspan
889vwhe c
890end
891end
892i = add i 1
893end
894vwspclose
895end
896note ---- pane parts: title and status lines taken from the plain (escape-free) text
897note vwplain: gob[a, b) without escapes and control bytes into gtl; spaces trimmed
898fn vwplain a ulong b ulong to void
899put gtll 0 0
900i = a
901for it ulong 100000
902if ge i b
903break
904end
905c = get gob i
906if eq c 27
907i = vwesc2 i b
908continue
909end
910if and ge c 32 ne c 127
911n = get gtll 0
912if lt n 4096
913put gtl n c
914put gtll 0 add n 1
915end
916end
917i = add i 1
918end
919vwtltrim
920end
921note vwesc2: like vwesc but without touching the SGR state
922fn vwesc2 i ulong b ulong to ulong
923s0 = get gst 0
924s1 = get gst 1
925s2 = get gst 2
926r = vwesc i b
927put gst 0 s0
928put gst 1 s1
929put gst 2 s2
930ret r
931end
932fn vwtltrim to void
933n = get gtll 0
934s = ulong 0
935for i ulong n
936if ne get gtl s 32
937break
938end
939s = add s 1
940end
941e = n
942for i ulong n
943if le e s
944break
945end
946if ne get gtl sub e 1 32
947break
948end
949e = sub e 1
950end
951for i ulong sub e s
952put gtl i get gtl add s i
953end
954put gtll 0 sub e s
955end
956note vwruleat: 1 or 3 when gtl[i] starts a rule character ('-', U+2500, U+2501), else 0
957fn vwruleat i ulong to ulong
958n = get gtll 0
959if ge i n
960ret 0
961end
962if eq get gtl i 45
963ret 1
964end
965if and lt add i 2 n eq get gtl i 226
966if and eq get gtl add i 1 148 le get gtl add i 2 129
967if ge get gtl add i 2 128
968ret 3
969end
970end
971end
972ret 0
973end
974fn vwruleend e ulong to ulong
975if eq e 0
976ret 0
977end
978if eq get gtl sub e 1 45
979ret 1
980end
981if ge e 3
982if eq vwruleat sub e 3 3
983ret 3
984end
985end
986ret 0
987end
988note vwisrule: gtl starts with 3 rule characters and has a letter or digit; then strip the rule
989fn vwisrule to bool
990i = ulong 0
991for k ulong 3
992w = vwruleat i
993if eq w 0
994ret false
995end
996i = add i w
997end
998an = false
999for k ulong get gtll 0
1000c = get gtl k
1001if or vwdig c or and ge c 65 le c 90 and ge c 97 le c 122
1002an = true
1003end
1004end
1005if not an
1006ret false
1007end
1008s = ulong 0
1009for k ulong get gtll 0
1010w = vwruleat s
1011if and eq w 0 ne get gtl s 32
1012break
1013end
1014s = add s hmax w 1
1015end
1016e = get gtll 0
1017for k ulong get gtll 0
1018if le e s
1019break
1020end
1021w = vwruleend e
1022if and eq w 0 ne get gtl sub e 1 32
1023break
1024end
1025e = sub e hmax w 1
1026end
1027for k ulong sub e s
1028put gtl k get gtl add s k
1029end
1030put gtll 0 sub e s
1031ret true
1032end
1033fn hmax a ulong b ulong to ulong
1034if gt a b
1035ret a
1036end
1037ret b
1038end
1039note vwlstart: the start of the gob line that ends at p (p is at its LF or the end)
1040fn vwlstart c0 ulong p ulong to ulong
1041q = p
1042for it ulong 1000000
1043if le q c0
1044ret c0
1045end
1046if eq get gob sub q 1 10
1047ret q
1048end
1049q = sub q 1
1050end
1051ret c0
1052end
1053note vwparts: capture gob[c0, n): gpp 0/1 status line, 2/3 title line (plain text is redone by
1054note vwplain when drawn), 4 end of the last non-blank line, 5 status found, 6 title is a rule
1055fn vwparts c0 ulong n ulong to void
1056for i ulong 8
1057put gpp i 0
1058end
1059put gpp 4 c0
1060p = n
1061if and gt p c0 eq get gob sub p 1 10
1062p = sub p 1
1063end
1064for it ulong 400
1065s = vwlstart c0 p
1066vwplain s p
1067if gt get gtll 0 0
1068put gpp 0 s
1069put gpp 1 p
1070put gpp 4 p
1071put gpp 5 1
1072vwtitle c0 s
1073ret
1074end
1075if le s c0
1076ret
1077end
1078p = sub s 1
1079end
1080end
1081fn vwtitle c0 ulong s0 ulong to void
1082if le s0 c0
1083ret
1084end
1085p = sub s0 1
1086fb = false
1087for it ulong 8
1088s = vwlstart c0 p
1089vwplain s p
1090if gt get gtll 0 0
1091if vwisrule
1092put gpp 2 s
1093put gpp 3 p
1094put gpp 6 1
1095ret
1096end
1097if not fb
1098put gpp 2 s
1099put gpp 3 p
1100fb = true
1101end
1102end
1103if le s c0
1104ret
1105end
1106p = sub s 1
1107end
1108end
1109note vwhtitle / vwhstat: the title (rule stripped) and status line as escaped text
1110fn vwhtitle to void
1111if eq get gpp 3 0
1112ret
1113end
1114vwplain get gpp 2 get gpp 3
1115if eq get gpp 6 1
1116b = vwisrule
1117end
1118for i ulong get gtll 0
1119vwhe get gtl i
1120end
1121end
1122fn vwhstat to void
1123if eq get gpp 5 0
1124ret
1125end
1126vwplain get gpp 0 get gpp 1
1127for i ulong get gtll 0
1128vwhe get gtl i
1129end
1130end
1131note vwlomp: the status line looks like omp's (ctx:, (adv), [high]/[medium]/[low])
1132text tmk1 "ctx:"
1133text tmk2 "(adv)"
1134text tmk3 "[high]"
1135text tmk4 "[medium]"
1136text tmk5 "[low]"
1137fn vwtlhas t view uchar * to bool
1138n = get gtll 0
1139if lt n len t
1140ret false
1141end
1142for i ulong add sub n len t 1
1143ok = true
1144for k ulong len t
1145if ne get gtl add i k get t k
1146ok = false
1147break
1148end
1149end
1150if ok
1151ret true
1152end
1153end
1154ret false
1155end
1156fn vwlomp to bool
1157if eq get gpp 5 0
1158ret false
1159end
1160vwplain get gpp 0 get gpp 1
1161if or vwtlhas tmk1 vwtlhas tmk2
1162ret true
1163end
1164ret or vwtlhas tmk3 or vwtlhas tmk4 vwtlhas tmk5
1165end
1166note vwback: the start of the last k lines that end at p (content start c0)
1167fn vwback c0 ulong p ulong k ulong to ulong
1168q = p
1169for i ulong k
1170s = vwlstart c0 q
1171if le s c0
1172ret c0
1173end
1174q = sub s 1
1175end
1176ret add q 1
1177end
1178note ---- panes and tiles
1179note vwgf: start of '|'-field k of gob[a, e)
1180fn vwgf a ulong e ulong k ulong to ulong
1181if eq k 0
1182ret a
1183end
1184c = ulong 0
1185for i ulong sub e a
1186if eq get gob add a i 124
1187c = add c 1
1188if eq c k
1189ret add add a i 1
1190end
1191end
1192end
1193ret e
1194end
1195fn vwgfe a ulong e ulong k ulong to ulong
1196q = vwgf a e add k 1
1197if lt q e
1198ret sub q 1
1199end
1200ret e
1201end
1202note vwmeta: "cmd · WxH[ · attached]" from the list line gob[a, e)
1203fn vwmeta a ulong e ulong to void
1204p = vwgf a e 1
1205vwheo p sub vwgfe a e 1 p
1206vwht tdot
1207p = vwgf a e 4
1208vwheo p sub vwgfe a e 4 p
1209p = vwgf a e 2
1210if lt p e
1211if ne get gob p 48
1212vwht tattach
1213end
1214end
1215end
1216note vwpanebd: for the snapshot in gob (body at b0): sets gpp and returns the capture start
1217fn vwpanebd b0 ulong to ulong
1218n = get gol 0
1219c0 = vwlend b0 n
1220vwparts c0 n
1221ret c0
1222end
1223note vwtile: one session tile for index line a (snapshot already in gob, body at b0)
1224fn vwtile a ulong b0 ulong c0 ulong to void
1225e = vwixe a
1226p = vwixf a e 5
1227vwht ttile1
1228vwhei p sub e p
1229vwht ttile2
1230vwhei p sub e p
1231vwht ttile3
1232vwixage a 10000
1233vwht tdivc
1234vwht tptitle
1235vwhtitle
1236vwht tdivc
1237vwht tpstl
1238vwhstat
1239vwht tdivc
1240vwht tpmeta
1241vwmeta b0 sub c0 1
1242vwht tdivc
1243vwht tpterm
1244x = get gpp 4
1245vwansi vwback c0 x 14 x
1246vwht tpreend
1247vwht taend
1248end
1249note vwgroup: which tile group index line a belongs in: 1 omp, 2 lead, 3 other, 0 none (queen, sections)
1250fn vwgroup a ulong e ulong to ulong
1251if vwixis a e 4 tkomp
1252ret 1
1253end
1254if vwixis a e 4 tklead
1255ret 2
1256end
1257if vwixis a e 4 tkother
1258if vwlomp
1259ret 1
1260end
1261ret 3
1262end
1263ret 0
1264end
1265note GET /p/tiles?g=omp|lead|other
1266fn vwptiles cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
1267want = ulong 3
1268if vwqget cs io tqg
1269if vwqis tkomp
1270want = 1
1271end
1272if vwqis tklead
1273want = 2
1274end
1275end
1276r = vwhtml cs io
1277vwdoc 3 12
1278shown = ulong 0
1279if vwrdix
1280a = add vwixe 0 1
1281for it ulong 128
1282if ge a get gixl 0
1283break
1284end
1285e = vwixe a
1286if not vwixis a e 4 tksec
1287b0 = vwsnap a
1288c0 = vwpanebd b0
1289if eq vwgroup a e want
1290vwtile a b0 c0
1291shown = add shown 1
1292r = hfe r vwflush cs io buf
1293end
1294end
1295a = add e 1
1296end
1297end
1298if eq shown 0
1299vwht tmuted
1300vwht tsnone
1301vwht tdivc
1302end
1303vwht tdocend
1304r = hfe r vwfin cs io buf
1305ret r
1306end
1307note GET /p/pane?n=NAME: one session's whole screen
1308fn vwppane cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
1309have = vwqget cs io tqn
1310r = vwhtml cs io
1311vwdoc 2 8
1312a = get gixl 0
1313if and have vwrdix
1314a = vwixfind false
1315end
1316if ge a get gixl 0
1317vwht tmuted
1318vwht tnosessn
1319vwht tdivc
1320else
1321b0 = vwsnap a
1322c0 = vwpanebd b0
1323vwht tphead
1324vwheq
1325vwht ttile3
1326vwixage a 10000
1327vwht tdot
1328vwmeta b0 sub c0 1
1329vwht tdivc
1330vwht tptitle
1331vwhtitle
1332vwht tdivc
1333vwht tpstl
1334vwhstat
1335vwht tdivc
1336vwht tpterb
1337vwansi c0 get gpp 4
1338vwht tpreend
1339end
1340vwht tdocend
1341ret hfe r vwfin cs io buf
1342end
1343note GET /p/status: the feed's own heartbeat; a browser error page here means the server is down
1344fn vwpstat cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
1345r = vwhtml cs io
1346vwdoc 2 8
1347vwht tlive
1348s = rem div get gnow 0 1000 86400
1349vwhd2 div s 3600
1350vwhc 58
1351vwhd2 div rem s 3600 60
1352vwhc 58
1353vwhd2 rem s 60
1354vwht tzsp
1355if vwrdix
1356e = vwixe 0
1357t = vwixn vwixf 0 e 1
1358ts = vwixn vwixf 0 e 2
1359ag = ulong 0
1360if gt get gnow 0 t
1361ag = sub get gnow 0 t
1362end
1363if gt ag 12000
1364vwht tpstall
1365vwhagt ag
1366vwht tspend
1367else
1368if ne ts 0
1369vwht ttfail
1370else
1371vwht tpok
1372end
1373end
1374else
1375vwht tnoix
1376end
1377vwht tdocend
1378ret hfe r vwfin cs io buf
1379end
1380note ---- sections
1381fn vwgsp p ulong e ulong to ulong
1382x = p
1383for s ulong 65536
1384if ge x e
1385ret x
1386end
1387c = get gob x
1388if and ne c 32 ne c 9
1389ret x
1390end
1391x = add x 1
1392end
1393ret x
1394end
1395fn vwgtok p ulong e ulong to ulong
1396x = p
1397for s ulong 65536
1398if ge x e
1399ret x
1400end
1401c = get gob x
1402if or eq c 32 eq c 9
1403ret x
1404end
1405x = add x 1
1406end
1407ret x
1408end
1409note vwtabf: start of tab field k of gob[a, e)
1410fn vwtabf a ulong e ulong k ulong to ulong
1411if eq k 0
1412ret a
1413end
1414c = ulong 0
1415for i ulong sub e a
1416if eq get gob add a i 9
1417c = add c 1
1418if eq c k
1419ret add add a i 1
1420end
1421end
1422end
1423ret e
1424end
1425fn vwtabe a ulong e ulong k ulong to ulong
1426q = vwtabf a e add k 1
1427if lt q e
1428ret sub q 1
1429end
1430ret e
1431end
1432fn vwgis p ulong q ulong t view uchar * to bool
1433if ne sub q p len t
1434ret false
1435end
1436for i ulong len t
1437if ne get gob add p i get t i
1438ret false
1439end
1440end
1441ret true
1442end
1443fn vwkvo k view uchar * err bool to void
1444vwht tkv1
1445vwhet k
1446vwht tkv2
1447if err
1448vwht tkverr
1449end
1450vwht tqgt
1451end
1452fn vwkvoo a ulong n ulong to void
1453vwht tkv1
1454vwheo a n
1455vwht tkv2
1456vwht tqgt
1457end
1458fn vwkve to void
1459vwht tkv3
1460end
1461fn vwkvt k view uchar * v view uchar * err bool to void
1462vwkvo k err
1463vwhet v
1464vwkve
1465end
1466fn vwh3 t view uchar * a ulong lim ulong to void
1467vwht th3
1468vwhet t
1469vwhc 32
1470if lt a get gixl 0
1471vwixage a lim
1472end
1473vwht th3e
1474end
1475note vwsecrd: index line and body start for section t; gob holds it (gol 0 when absent)
1476fn vwsecrd t view uchar * to ulong
1477a = vwsecq t
1478put gol 0 0
1479if lt a get gixl 0
1480b = vwsnap a
1481put goa 0 b
1482end
1483ret a
1484end
1485text tgwkey "gateway"
1486text tpkey "pause"
1487text tabsent2 "absent"
1488fn vwhermes2 to void
1489a = vwsecrd tnherm
1490vwh3 tnherm a 45000
1491b0 = get goa 0
1492n = get gol 0
1493p = b0
1494for it ulong 16
1495if ge p n
1496break
1497end
1498e = sub vwlend p n 1
1499f1 = vwtabf p e 1
1500if vwgis p sub f1 1 tgwkey
1501up = vwgis f1 vwtabe p e 1 tup
1502vwkvo tgateway not up
1503if up
1504vwht tup
1505else
1506vwht tdownc
1507end
1508vwkve
1509end
1510if vwgis p sub f1 1 tpkey
1511yes = vwgis f1 vwtabe p e 1 tyes
1512vwkvo tqpause yes
1513if yes
1514vwht tpaused
1515f2 = vwtabf p e 2
1516vwheo f2 sub e f2
1517else
1518vwht tnotp
1519end
1520vwkve
1521end
1522p = add e 1
1523end
1524end
1525note ---- kanban: lines "<marker> t_<id> <status> <assignee> <title>"; counts kept sorted by name
1526fn vwkline p ulong e ulong to ulong
1527a = vwgtok vwgsp p e e
1528s1 = vwgsp a e
1529if gt add s1 2 e
1530ret e
1531end
1532if or ne get gob s1 116 ne get gob add s1 1 95
1533ret e
1534end
1535ret s1
1536end
1537fn vwkcount p ulong q ulong to void
1538n = get gkn 0
1539l = hmin sub q p 47
1540for i ulong n
1541if vwkseq i p l
1542put gkc i add get gkc i 1
1543ret
1544end
1545end
1546if ge n 16
1547ret
1548end
1549ix = n
1550for i ulong n
1551if vwkslt p l i
1552ix = i
1553break
1554end
1555end
1556k = n
1557for it ulong 16
1558if le k ix
1559break
1560end
1561vwkmove sub k 1 k
1562k = sub k 1
1563end
1564for i ulong l
1565put gks add mul ix 48 i get gob add p i
1566end
1567put gksl ix l
1568put gkc ix 1
1569put gkn 0 add n 1
1570end
1571fn vwkmove s ulong d ulong to void
1572for i ulong 48
1573put gks add mul d 48 i get gks add mul s 48 i
1574end
1575put gksl d get gksl s
1576put gkc d get gkc s
1577end
1578fn vwkseq i ulong p ulong l ulong to bool
1579if ne get gksl i l
1580ret false
1581end
1582for k ulong l
1583if ne get gks add mul i 48 k get gob add p k
1584ret false
1585end
1586end
1587ret true
1588end
1589note vwkslt: gob[p, p+l) sorts before entry i
1590fn vwkslt p ulong l ulong i ulong to bool
1591m = get gksl i
1592for k ulong hmin l m
1593a = get gob add p k
1594b = get gks add mul i 48 k
1595if ne a b
1596ret lt a b
1597end
1598end
1599ret lt l m
1600end
1601fn vwkchips to void
1602vwht tchips
1603for i ulong get gkn 0
1604vwht tchip1
1605vwkname i
1606vwht tchip2
1607vwkname i
1608vwhc 32
1609vwhd get gkc i
1610vwht tspend
1611end
1612end
1613fn vwkname i ulong to void
1614b = mul i 48
1615for k ulong get gksl i
1616vwhe get gks add b k
1617end
1618end
1619fn vwkanb2 to void
1620put gkn 0 0
1621a = vwsecrd tnkan
1622vwh3 tkanh a 45000
1623b0 = get goa 0
1624n = get gol 0
1625p = b0
1626for it ulong 4096
1627if ge p n
1628break
1629end
1630e = sub vwlend p n 1
1631s1 = vwkline p e
1632if lt s1 e
1633s2 = vwgsp vwgtok s1 e e
1634vwkcount s2 vwgtok s2 e
1635end
1636p = add e 1
1637end
1638vwkchips
1639if and eq get gkn 0 0 gt n b0
1640vwheo b0 hmin sub n b0 300
1641end
1642vwht tdivc
1643vwkrun b0 n
1644end
1645fn vwkrun b0 ulong n ulong to void
1646vwht th3
1647vwht trunh
1648vwht th3e
1649p = b0
1650c = ulong 0
1651for it ulong 4096
1652if ge p n
1653break
1654end
1655e = sub vwlend p n 1
1656s1 = vwkline p e
1657if lt s1 e
1658t1 = vwgtok s1 e
1659s2 = vwgsp t1 e
1660t2 = vwgtok s2 e
1661if vwgis s2 t2 trunning
1662vwht tcard1
1663vwheo s1 sub t1 s1
1664vwht tcard2
1665s3 = vwgsp t2 e
1666vwheo s3 sub e s3
1667vwht tdivc
1668c = add c 1
1669end
1670end
1671p = add e 1
1672end
1673if eq c 0
1674vwht tmuted
1675vwht tnorun
1676vwht tdivc
1677end
1678end
1679note GET /p/hermes: gateway, queen PAUSE, kanban counts and running cards
1680fn vwphermes cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
1681r = vwhtml cs io
1682vwdoc 10 35
1683ok = vwrdix
1684vwhermes2
1685r = hfe r vwflush cs io buf
1686vwkanb2
1687vwht tdocend
1688ret hfe r vwfin cs io buf
1689end
1690note ---- machine, GPU, spark-window, pools, ledger
1691note vwhash: the line after "#name" in gob[b0, n) (its start), or n
1692fn vwhash b0 ulong n ulong t view uchar * to ulong
1693p = b0
1694for it ulong 4096
1695if ge p n
1696ret n
1697end
1698e = sub vwlend p n 1
1699if and gt sub e p 0 eq get gob p 35
1700if vwgis add p 1 e t
1701ret add e 1
1702end
1703end
1704p = add e 1
1705end
1706ret n
1707end
1708fn vwlinee p ulong n ulong to ulong
1709if ge p n
1710ret n
1711end
1712ret sub vwlend p n 1
1713end
1714note vwgib: kB as GiB with one decimal
1715fn vwgib kb ulong to void
1716t = div add mul kb 10 524288 1048576
1717vwhd div t 10
1718vwhc 46
1719vwhd rem t 10
1720end
1721fn vwmemv p ulong n ulong t view uchar * to ulong
1722q = p
1723for it ulong 8
1724if ge q n
1725ret 0
1726end
1727e = vwlinee q n
1728if vwgis q add q len t t
1729s = vwgsp add q len t e
1730v = ulong 0
1731for i ulong sub e s
1732c = get gob add s i
1733if not vwdig c
1734break
1735end
1736v = add mul v 10 ulong sub c 48
1737end
1738ret v
1739end
1740q = add e 1
1741end
1742ret 0
1743end
1744text tmtot "MemTotal:"
1745text tmavl "MemAvailable:"
1746text tcpu "cpu"
1747text tload2 "load"
1748text tmem2 "mem"
1749text tsens2 "sensors"
1750text tapps2 "apps"
1751fn vwmach2 to void
1752a = vwsecrd tnmach
1753vwh3 thmach a 45000
1754b0 = get goa 0
1755n = get gol 0
1756p = vwhash b0 n tload2
1757if lt p n
1758vwkvo tload false
1759e = vwlinee p n
1760q = p
1761for k ulong 3
1762t = vwgtok q e
1763vwheo q sub t q
1764vwhc 32
1765vwhc 32
1766q = vwgsp t e
1767end
1768vwkve
1769end
1770p = vwhash b0 n tmem2
1771tot = vwmemv p n tmtot
1772av = vwmemv p n tmavl
1773if gt tot 0
1774vwkvo tmemk false
1775vwgib sub tot hmin av tot
1776vwht tgibu
1777vwgib tot
1778vwht tgiba
1779vwgib av
1780vwht tgibv
1781vwkve
1782end
1783p = vwhash b0 n tcpu
1784vwkvo tcpuk false
1785e = vwlinee p n
1786if and lt p n vwdig get gob p
1787vwheo p sub e p
1788vwht tcpuv
1789else
1790vwht tmeas
1791end
1792vwkve
1793end
1794fn vwgpu2 to void
1795a = vwsecrd tngpu
1796vwh3 thgpu a 45000
1797b0 = get goa 0
1798n = get gol 0
1799p = vwhash b0 n tsens2
1800e = vwlinee p n
1801f3 = vwcsvf p e 3
1802if and lt p n lt f3 e
1803vwkvo tpowk false
1804vwheo f3 sub vwcsve p e 3 f3
1805vwht twatt
1806vwkve
1807f4 = vwcsvf p e 4
1808vwkvo tutilk false
1809vwheo f4 sub vwcsve p e 4 f4
1810vwht tpct
1811vwkve
1812vwsensag p e
1813else
1814vwkvt tpowu tnosamp true
1815end
1816vwkvt ttempk ttempv false
1817p = vwhash b0 n tapps2
1818c = ulong 0
1819for it ulong 64
1820if ge p n
1821break
1822end
1823e = vwlinee p n
1824if or eq e p eq get gob p 35
1825break
1826end
1827t = vwtabe p e 0
1828vwht tkv1
1829vwht tpidk
1830vwheo p sub t p
1831vwht tkv2
1832vwht tqgt
1833f1 = vwtabf p e 1
1834vwheo f1 sub e f1
1835vwkve
1836c = add c 1
1837p = add e 1
1838end
1839if eq c 0
1840vwkvt tgproc tnone false
1841end
1842end
1843fn vwsensag p ulong e ulong to void
1844ep = ulong 0
1845for i ulong sub vwcsve p e 0 p
1846c = get gob add p i
1847if not vwdig c
1848break
1849end
1850ep = add mul ep 10 ulong sub c 48
1851end
1852ms = mul ep 1000
1853ag = ulong 0
1854if gt get gnow 0 ms
1855ag = sub get gnow 0 ms
1856end
1857bad = gt ag 15000
1858vwkvo tsampk bad
1859vwht tsamp
1860vwhagt ag
1861if bad
1862vwht tastale
1863end
1864vwkve
1865end
1866fn vwcsvf a ulong e ulong k ulong to ulong
1867if eq k 0
1868ret a
1869end
1870c = ulong 0
1871for i ulong sub e a
1872if eq get gob add a i 44
1873c = add c 1
1874if eq c k
1875ret add add a i 1
1876end
1877end
1878end
1879ret e
1880end
1881fn vwcsve a ulong e ulong k ulong to ulong
1882q = vwcsvf a e add k 1
1883if lt q e
1884ret sub q 1
1885end
1886ret e
1887end
1888text twqk "queue"
1889text twok "open"
1890text twak "alive"
1891text twnk "none"
1892text tpoolk "pool"
1893fn vwwin2 to void
1894a = vwsecrd tnwin
1895vwh3 thwin a 45000
1896b0 = get goa 0
1897n = get gol 0
1898p = b0
1899for it ulong 64
1900if ge p n
1901break
1902end
1903e = vwlinee p n
1904vwwinl p e
1905p = add e 1
1906end
1907end
1908fn vwwinl p ulong e ulong to void
1909if eq e p
1910ret
1911end
1912k = vwtabe p e 0
1913f1 = vwtabf p e 1
1914e1 = vwtabe p e 1
1915if vwgis p k twqk
1916vwkvo tqueued false
1917f3 = vwtabf p e 3
1918if lt f3 e
1919vwheo f3 sub e f3
1920else
1921vwheo f1 sub e1 f1
1922end
1923f2 = vwtabf p e 2
1924if not vwgis f2 vwtabe p e 2 tyes
1925vwht tgone
1926end
1927vwkve
1928ret
1929end
1930if vwgis p k twok
1931vwkvo topenw false
1932vwheo f1 sub e1 f1
1933vwkve
1934ret
1935end
1936if vwgis p k twak
1937vwkvo thalive not vwgis f1 e1 tyes
1938vwheo f1 sub e1 f1
1939vwkve
1940ret
1941end
1942if vwgis p k twnk
1943ret
1944end
1945vwkvoo p sub k p
1946for i ulong sub e f1
1947c = get gob add f1 i
1948if eq c 9
1949c = 32
1950end
1951vwhe c
1952end
1953vwkve
1954end
1955fn vwpool2 to void
1956a = vwsecrd tnpool
1957vwh3 thpool a 45000
1958b0 = get goa 0
1959n = get gol 0
1960p = b0
1961for it ulong 128
1962if ge p n
1963break
1964end
1965e = vwlinee p n
1966if vwgis p vwtabe p e 0 tpoolk
1967vwpooll p e
1968end
1969p = add e 1
1970end
1971end
1972fn vwpooll p ulong e ulong to void
1973f1 = vwtabf p e 1
1974e1 = vwtabe p e 1
1975s = f1
1976if gt sub e1 s 5
1977if vwgis s add s 5 tpoolp
1978s = add s 5
1979end
1980end
1981x = e1
1982if gt sub x s 5
1983if vwgis sub x 5 x tlockx
1984x = sub x 5
1985end
1986end
1987vwht tkv1
1988vwht tcores
1989vwheo s sub x s
1990vwht tkv2
1991vwht tqgt
1992f2 = vwtabf p e 2
1993e2 = vwtabe p e 2
1994vwheo f2 sub e2 f2
1995if not vwgis f2 e2 tfree
1996vwht tpidm
1997f3 = vwtabf p e 3
1998vwheo f3 sub vwtabe p e 3 f3
1999vwht tdot
2000f4 = vwtabf p e 4
2001vwheo f4 sub e f4
2002end
2003vwkve
2004end
2005fn vwledg2 to void
2006a = vwsecrd tnledg
2007vwh3 thledg a 45000
2008b0 = get goa 0
2009n = get gol 0
2010if vwgis b0 vwlinee b0 n tabsent2
2011vwkvt tledgk tnoledg false
2012ret
2013end
2014e = n
2015c = ulong 0
2016for it ulong 4096
2017if or le e b0 ge c 8
2018break
2019end
2020if eq get gob sub e 1 10
2021e = sub e 1
2022continue
2023end
2024s = vwlstart b0 e
2025vwht tvfull
2026vwheo s sub e s
2027vwht tdivc
2028c = add c 1
2029e = s
2030end
2031end
2032note GET /p/machine
2033fn vwpmach cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
2034r = vwhtml cs io
2035vwdoc 10 35
2036ok = vwrdix
2037vwmach2
2038vwgpu2
2039r = hfe r vwflush cs io buf
2040vwwin2
2041vwpool2
2042r = hfe r vwflush cs io buf
2043vwledg2
2044vwht tdocend
2045ret hfe r vwfin cs io buf
2046end
2047note ---- BOARD: newest first, filtered by lane and by text (case-insensitive)
2048global glq uchar 64
2049global glql ulong 1
2050global gqq uchar 256
2051global gqql ulong 1
2052global gbp ulong 4
2053fn vwlower c uchar to uchar
2054if and ge c 65 le c 90
2055ret uchar add c 32
2056end
2057ret c
2058end
2059note vwbparse: "TIMESTAMP LANE rest" in gob[s, e): gbp 0 ts end, 1 lane start, 2 lane end, 3 rest
2060fn vwbparse s ulong e ulong to bool
2061t = vwgtok s e
2062if lt sub t s 11
2063ret false
2064end
2065for i ulong 4
2066if not vwdig get gob add s i
2067ret false
2068end
2069end
2070if or ne get gob add s 4 45 ne get gob add s 10 84
2071ret false
2072end
2073l0 = vwgsp t e
2074l1 = vwgtok l0 e
2075if eq l0 l1
2076ret false
2077end
2078put gbp 0 t
2079put gbp 1 l0
2080x = l1
2081if eq get gob sub x 1 58
2082x = sub x 1
2083end
2084put gbp 2 x
2085r = l1
2086if lt r e
2087r = add r 1
2088end
2089put gbp 3 r
2090ret true
2091end
2092fn vwblane to bool
2093n = get glql 0
2094if eq n 0
2095ret true
2096end
2097p = get gbp 1
2098if ne sub get gbp 2 p n
2099ret false
2100end
2101for i ulong n
2102if ne get gob add p i get glq i
2103ret false
2104end
2105end
2106ret true
2107end
2108fn vwbtext s ulong e ulong to bool
2109n = get gqql 0
2110if eq n 0
2111ret true
2112end
2113if lt sub e s n
2114ret false
2115end
2116for i ulong add sub sub e s n 1
2117ok = true
2118for k ulong n
2119if ne vwlower get gob add add s i k get gqq k
2120ok = false
2121break
2122end
2123end
2124if ok
2125ret true
2126end
2127end
2128ret false
2129end
2130fn vwbli s ulong e ulong to void
2131if vwbparse s e
2132vwht tli1
2133vwheo s sub get gbp 0 s
2134vwht tli2
2135p = get gbp 1
2136vwheo p sub get gbp 2 p
2137vwht tli3
2138p = get gbp 3
2139vwheo p sub e p
2140else
2141vwht tli
2142vwheo s sub e s
2143end
2144vwht tlie
2145end
2146fn vwbshow s ulong e ulong to bool
2147if gt get glql 0 0
2148if not vwbparse s e
2149ret false
2150end
2151if not vwblane
2152ret false
2153end
2154end
2155ret vwbtext s e
2156end
2157fn vwpct c uchar to void
2158if or vwdig c or and ge c 65 le c 90 and ge c 97 le c 122
2159vwhc c
2160ret
2161end
2162vwhc 37
2163vwhc hhexd shr ulong c 4
2164vwhc hhexd and ulong c 15
2165end
2166fn vwbdoc to void
2167vwht tdoc1q
2168for i ulong get glql 0
2169vwpct get glq i
2170end
2171vwht tampq
2172for i ulong get gqql 0
2173vwpct get gqq i
2174end
2175vwht tdoc2
2176vwhd 35
2177vwht tdoc3
2178end
2179fn vwbq cs edit ulong 320 io edit uchar 131072 to void
2180put glql 0 0
2181put gqql 0 0
2182if vwqget cs io tqlane
2183n = hmin get gql 0 64
2184for i ulong n
2185put glq i get gq i
2186end
2187put glql 0 n
2188end
2189if vwqget cs io tqq
2190n = hmin get gql 0 256
2191for i ulong n
2192put gqq i vwlower get gq i
2193end
2194put gqql 0 n
2195end
2196end
2197note GET /p/board?lane=LANE&q=TEXT
2198fn vwpboard cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
2199vwbq cs io
2200r = vwhtml cs io
2201vwbdoc
2202ok = vwrdix
2203a = vwsecrd tnboard
2204vwh3 tnboard a 45000
2205b0 = get goa 0
2206e = get gol 0
2207vwht tolb
2208c = ulong 0
2209for it ulong 100000
2210if or le e b0 ge c 300
2211break
2212end
2213if eq get gob sub e 1 10
2214e = sub e 1
2215continue
2216end
2217s = vwlstart b0 e
2218if vwbshow s e
2219vwbli s e
2220c = add c 1
2221if eq rem c 40 0
2222r = hfe r vwflush cs io buf
2223end
2224end
2225e = s
2226end
2227vwht tole
2228if eq c 0
2229vwht tmuted
2230vwht tnomatch
2231vwht tdivc
2232end
2233vwht tdocend
2234ret hfe r vwfin cs io buf
2235end
2236note vwlanes: the distinct BOARD lanes (sorted) for the filter's list; from gob (board section)
2237fn vwlanes to void
2238put glann 0 0
2239b0 = get goa 0
2240n = get gol 0
2241p = b0
2242for it ulong 100000
2243if ge p n
2244break
2245end
2246e = vwlinee p n
2247if vwbparse p e
2248vwlanead get gbp 1 get gbp 2
2249end
2250p = add e 1
2251end
2252end
2253fn vwlanead p ulong q ulong to void
2254l = sub q p
2255if or eq l 0 gt l 47
2256ret
2257end
2258n = get glann 0
2259ix = n
2260for i ulong n
2261c = vwlancmp i p l
2262if eq c 0
2263ret
2264end
2265if eq c 1
2266ix = i
2267break
2268end
2269end
2270if ge n 64
2271ret
2272end
2273k = n
2274for it ulong 64
2275if le k ix
2276break
2277end
2278vwlanmv sub k 1 k
2279k = sub k 1
2280end
2281for i ulong l
2282put glan add mul ix 48 i get gob add p i
2283end
2284put glanl ix l
2285put glann 0 add n 1
2286end
2287fn vwlanmv s ulong d ulong to void
2288for i ulong 48
2289put glan add mul d 48 i get glan add mul s 48 i
2290end
2291put glanl d get glanl s
2292end
2293note vwlancmp: 0 equal, 1 gob[p, p+l) sorts before lane i, 2 after
2294fn vwlancmp i ulong p ulong l ulong to ulong
2295m = get glanl i
2296for k ulong hmin l m
2297a = get gob add p k
2298b = get glan add mul i 48 k
2299if lt a b
2300ret 1
2301end
2302if gt a b
2303ret 2
2304end
2305end
2306if eq l m
2307ret 0
2308end
2309if lt l m
2310ret 1
2311end
2312ret 2
2313end
2314text topt1 "<option value=\""
2315text topt2 "</option>"
2316fn vwlanopt to void
2317for i ulong get glann 0
2318vwht topt1
2319vwlanname i
2320vwht tqgt
2321vwlanname i
2322vwht topt2
2323end
2324end
2325fn vwlanname i ulong to void
2326b = mul i 48
2327for k ulong get glanl i
2328vwhe get glan add b k
2329end
2330end
2331note ---- QUESTIONS / DECISIONS (latest 6 "## " entries, newest first) and CLAIMS (whole file)
2332fn vwisent p ulong n ulong to bool
2333if gt add p 3 n
2334ret false
2335end
2336if ne get gob p 35
2337ret false
2338end
2339if ne get gob add p 1 35
2340ret false
2341end
2342ret eq get gob add p 2 32
2343end
2344fn vwent1 s ulong x ulong to void
2345e = vwlinee s x
2346vwht tent1
2347vwheo add s 3 sub e add s 3
2348vwht tent2
2349b = vwgsp2 add e 1 x
2350t = x
2351for it ulong 100000
2352if le t b
2353break
2354end
2355c = get gob sub t 1
2356if and and ne c 10 ne c 32 ne c 13
2357break
2358end
2359t = sub t 1
2360end
2361if lt b t
2362if gt sub t b 16384
2363vwheo b 16384
2364vwht ttrunc
2365else
2366vwheo b sub t b
2367end
2368end
2369vwht tent3
2370end
2371fn vwgsp2 p ulong x ulong to ulong
2372q = p
2373for it ulong 100000
2374if ge q x
2375ret x
2376end
2377c = get gob q
2378if and and ne c 10 ne c 32 ne c 13
2379ret q
2380end
2381q = add q 1
2382end
2383ret q
2384end
2385fn vwents cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
2386st = new ulong 1024 0
2387b0 = get goa 0
2388n = get gol 0
2389k = ulong 0
2390p = b0
2391for it ulong 100000
2392if ge p n
2393break
2394end
2395if and vwisent p n lt k 1024
2396put st k p
2397k = add k 1
2398end
2399p = add vwlinee p n 1
2400end
2401r = long 0
2402if eq k 0
2403vwht tpreo
2404if gt n b0
2405s = sub n hmin sub n b0 4000
2406vwheo s sub n s
2407end
2408vwht tpreend
2409ret r
2410end
2411for i ulong hmin k 6
2412j = sub sub k 1 i
2413x = n
2414if lt add j 1 k
2415x = get st add j 1
2416end
2417vwent1 get st j x
2418r = hfe r vwflush cs io buf
2419end
2420ret r
2421end
2422note GET /p/entries?f=questions|decisions|claims
2423fn vwpents cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
2424w = ulong 0
2425if vwqget cs io tqf
2426if vwqis tqfile
2427w = 1
2428end
2429if vwqis tdfile
2430w = 2
2431end
2432if vwqis tcfile
2433w = 3
2434end
2435end
2436r = vwhtml cs io
2437vwdoc 10 35
2438ok = vwrdix
2439if eq w 0
2440vwht tmuted
2441vwht tnosessn
2442vwht tdivc
2443end
2444if eq w 1
2445a = vwsecrd tnques
2446vwh3 tnques a 45000
2447r = hfe r vwents cs io buf
2448end
2449if eq w 2
2450a = vwsecrd tndec
2451vwh3 tndec a 45000
2452r = hfe r vwents cs io buf
2453end
2454if eq w 3
2455a = vwsecrd tnclaim
2456vwh3 tnclaim a 45000
2457vwht tpreo
2458b0 = get goa 0
2459vwheo b0 sub get gol 0 b0
2460vwht tpreend
2461end
2462vwht tdocend
2463ret hfe r vwfin cs io buf
2464end
2465note ---- GET /palette.css: the xterm-256 colours as classes .fN (text) and .bN (background)
2466fn vwhex2 v ulong to void
2467vwhc hhexd shr v 4
2468vwhc hhexd and v 15
2469end
2470fn vwcol n ulong to void
2471if lt n 16
2472for i ulong 6
2473vwhc get tbase16 add mul n 6 i
2474end
2475ret
2476end
2477if lt n 232
2478m = sub n 16
2479vwcubeh div m 36
2480vwcubeh rem div m 6 6
2481vwcubeh rem m 6
2482ret
2483end
2484g = add 8 mul 10 sub n 232
2485vwhex2 g
2486vwhex2 g
2487vwhex2 g
2488end
2489fn vwcubeh k ulong to void
2490vwhc get tcube mul k 2
2491vwhc get tcube add mul k 2 1
2492end
2493fn vwpal cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
2494put ghl 0 0
2495for n ulong 256
2496vwht tpalc1
2497vwhd n
2498vwht tpalc2
2499vwcol n
2500vwht tpalc3
2501vwhd n
2502vwht tpalc4
2503vwcol n
2504vwht tpalc5
2505end
2506m = get ghl 0
2507for i ulong m
2508put buf i get gh i
2509end
2510put ghl 0 0
2511r = hrspst cs io 200
2512r = hfe r vwsech cs io
2513r = hfe r hhname cs io tctype
2514r = hfe r hhval cs io ttcss
2515r = hfe r hhend cs io 0 m
2516r = hfe r hput cs io view part buf 0 m
2517ret hfe r hwfin cs io
2518end
2519note ---- the pages Drake opens: / (every hive) and /s/NAME (one session with its input box)
2520text ttitle "hive-view"
2521text ttop1 "<header class=\"top\"><h1>hive-view</h1><iframe class=\"fstatus\" src=\"/p/status\" title=\"feed status\"></iframe></header>\n<p class=\"note\">Every panel refreshes itself: session screens every 2 to 3 seconds, everything else every 10 seconds. A panel that stops refreshing says NOT LIVE. If panels show a browser error page, the server is down: reload this page when it is back.</p>\n"
2522text ttop2 "<section class=\"panel queen\"><h2>Queen · omp-queen <a href=\"/s/omp-queen\">open on its own page</a></h2><iframe class=\"fqueen\" src=\"/p/pane?n=omp-queen\" title=\"omp-queen\"></iframe>\n"
2523text ttop3 "</section>\n<section class=\"panel\"><h2>omp sessions <span class=\"muted\">click a tile to open that session with its own input box</span></h2><iframe class=\"ftiles\" src=\"/p/tiles?g=omp\" title=\"omp sessions\"></iframe></section>\n<div class=\"cols\"><section class=\"panel\"><h2>Hermes</h2><iframe class=\"fhermes\" src=\"/p/hermes\" title=\"Hermes\"></iframe><h2>lead sessions</h2><iframe class=\"fleads\" src=\"/p/tiles?g=lead\" title=\"lead sessions\"></iframe></section>\n<section class=\"panel\"><h2>Machine</h2><iframe class=\"fmach\" src=\"/p/machine\" title=\"machine\"></iframe></section></div>\n"
2524text ttop4 "<section class=\"panel\"><h2>BOARD <span class=\"muted\">newest first</span></h2><form class=\"filter\" method=\"get\" action=\"/p/board\" target=\"board\"><select name=\"lane\"><option value=\"\">all lanes</option>"
2525text ttop5 "</select><input name=\"q\" placeholder=\"text filter\" autocomplete=\"off\"><button>Filter</button></form><iframe name=\"board\" class=\"fboard\" src=\"/p/board\" title=\"BOARD\"></iframe></section>\n<div class=\"cols\"><section class=\"panel\"><h2>Latest QUESTIONS</h2><iframe class=\"fent\" src=\"/p/entries?f=questions\" title=\"questions\"></iframe></section>\n<section class=\"panel\"><h2>Latest DECISIONS</h2><iframe class=\"fent\" src=\"/p/entries?f=decisions\" title=\"decisions\"></iframe></section></div>\n<section class=\"panel\"><h2>CLAIMS</h2><iframe class=\"fent\" src=\"/p/entries?f=claims\" title=\"claims\"></iframe></section>\n<section class=\"panel\"><h2>Other tmux sessions</h2><iframe class=\"ftiles\" src=\"/p/tiles?g=other\" title=\"other sessions\"></iframe></section>\n</body></html>\n"
2526text tses1 "<header class=\"top\"><a class=\"back\" href=\"/\">← all hives</a><h1>"
2527text tses2 "</h1><iframe class=\"fstatus\" src=\"/p/status\" title=\"feed status\"></iframe></header>\n"
2528text tses3 "<section class=\"panel\"><iframe class=\"fbig\" src=\"/p/pane?n="
2529text tses4 "\" title=\"session screen\"></iframe>\n"
2530text tses5 "</section>\n</body></html>\n"
2531text tfrm1 "<form class=\"send\" method=\"post\" action=\"/send\"><input type=\"hidden\" name=\"s\" value=\""
2532text tfrm2 "\"><input type=\"hidden\" name=\"k\" value=\""
2533text tfrm3 "\"><input type=\"hidden\" name=\"r\" value=\""
2534text tfrm4 "\"><div class=\"target\">Types into tmux session “"
2535text tfrm5 "” exactly as written, then presses Enter.</div><div class=\"row\"><input class=\"text\" name=\"t\" maxlength=\"4096\" autocomplete=\"off\" spellcheck=\"false\" placeholder=\"type here, then Send\"><button name=\"a\" value=\"line\">Send + Enter</button><button name=\"a\" value=\"enter\">Enter</button><button name=\"a\" value=\"escape\">Escape</button></div></form>\n"
2536text tsignout "<header class=\"top\"><h1>hive-view</h1></header><div class=\"msg bad\">Not signed in on this device. Open the one-time link (it contains the access token) once on this device, then this page works.</div></body></html>\n"
2537text tmsgok "<div class=\"msg ok\">"
2538text tmsgbad "<div class=\"msg bad\">"
2539text tsentn "Sent "
2540text tsentb " bytes to "
2541text tsente ", then pressed Enter."
2542text tpressen "Pressed Enter in "
2543text tpresesc "Pressed Escape in "
2544text tdotend "."
2545text tqr "q"
2546text tsr "s"
2547text tcsrfp "hive-view form key\n"
2548fn vwcsrfk to void
2549if eq get gcsrfk 0 1
2550ret
2551end
2552src = new uchar 96 0
2553pre = ulong 0
2554for i ulong len tcsrfp
2555put src i get tcsrfp i
2556pre = add pre 1
2557end
2558for i ulong 64
2559put src add pre i get gtok i
2560end
2561dg = new uchar 32 0
2562k = sha2_digest 256 view part src 0 add pre 64 dg
2563for i ulong 32
2564c = get dg i
2565put gcsrf mul i 2 get thexd shr c 4
2566put gcsrf add mul i 2 1 get thexd and c 15
2567end
2568put gcsrfk 0 1
2569end
2570fn vwform r view uchar * to void
2571vwcsrfk
2572vwht tfrm1
2573vwheq
2574vwht tfrm2
2575for i ulong 64
2576vwhc get gcsrf i
2577end
2578vwht tfrm3
2579vwht r
2580vwht tfrm4
2581vwheq
2582vwht tfrm5
2583end
2584note vwmsg: the result of the last send, from ?m=CODE&a=ACTION&b=BYTES&s=NAME (all checked)
2585fn vwmsg cs edit ulong 320 io edit uchar 131072 to void
2586if not vwqget cs io tqm
2587ret
2588end
2589m = vwqnum
2590if gt get gql 0 2
2591ret
2592end
2593if eq get gql 0 0
2594ret
2595end
2596act = ulong 0
2597if vwqget cs io tqa
2598act = vwqnum
2599end
2600nb = ulong 0
2601if vwqget cs io tqb
2602nb = vwqnum
2603end
2604if not vwqget cs io tqs
2605put gql 0 0
2606end
2607if not vwqname
2608put gql 0 0
2609end
2610if eq m 0
2611vwht tmsgok
2612vwmsgok act nb
2613else
2614vwht tmsgbad
2615vwmsgbad m
2616end
2617vwht tdivc
2618end
2619fn vwmsgok act ulong nb ulong to void
2620if eq act 0
2621vwht tsentn
2622vwhd nb
2623vwht tsentb
2624vwheq
2625vwht tsente
2626ret
2627end
2628if eq act 1
2629vwht tpressen
2630else
2631vwht tpresesc
2632end
2633vwheq
2634vwht tdotend
2635end
2636fn vwmsgbad m ulong to void
2637if eq m 1
2638vwhet tbadbody
2639end
2640if eq m 2
2641vwhet tbadname
2642end
2643if eq m 3
2644vwhet tbadact
2645end
2646if eq m 4
2647vwhet tbadtext
2648end
2649if eq m 5
2650vwhet tnosess
2651end
2652if eq m 6
2653vwhet ttmuxbad
2654end
2655if eq m 7
2656vwhet tbigbody
2657end
2658if eq m 8
2659vwhet tlogbad
2660end
2661if gt m 8
2662vwhet tbadbody
2663end
2664end
2665note GET / (signed in): every hive on one page
2666fn vwptop cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
2667r = vwhtml cs io
2668vwpage ttitle
2669vwht ttop1
2670vwmsg cs io
2671vwht ttop2
2672n = len tompq
2673for i ulong n
2674put gq i get tompq i
2675end
2676put gql 0 n
2677vwform tqr
2678vwht ttop3
2679vwht ttop4
2680ok = vwrdix
2681a = vwsecrd tnboard
2682vwlanes
2683vwlanopt
2684vwht ttop5
2685ret hfe r vwfin cs io buf
2686end
2687fn vwpsignout cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
2688put ghl 0 0
2689r = hrspst cs io 403
2690r = hfe r vwsech cs io
2691r = hfe r hhname cs io tctype
2692r = hfe r hhval cs io tthtml
2693r = hfe r hhend cs io 1 0
2694vwpage ttitle
2695vwht tsignout
2696ret hfe r vwfin cs io buf
2697end
2698note GET /s/NAME: one session, large, with its own input box. gq holds the checked NAME.
2699fn vwpsess cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
2700keep = new uchar 64 0
2701n = get gql 0
2702for i ulong n
2703put keep i get gq i
2704end
2705r = vwhtml cs io
2706vwht tpage1
2707vwheq
2708vwht tpage2
2709vwht tses1
2710vwheq
2711vwht tses2
2712vwmsg cs io
2713for i ulong n
2714put gq i get keep i
2715end
2716put gql 0 n
2717vwht tses3
2718vwheq
2719vwht tses4
2720vwform tsr
2721vwht tses5
2722ret hfe r vwfin cs io buf
2723end
2724note vwsname: the path is /s/NAME with a valid NAME; it is left in gq
2725fn vwsname cs edit ulong 320 io edit uchar 131072 to bool
2726tg = get cs HTOFF
2727pl = hplen cs io
2728if lt pl 4
2729ret false
2730end
2731if ne get io tg 47
2732ret false
2733end
2734if ne get io add tg 1 115
2735ret false
2736end
2737if ne get io add tg 2 47
2738ret false
2739end
2740n = sub pl 3
2741if gt n 63
2742ret false
2743end
2744for i ulong n
2745put gq i get io add add tg 3 i
2746end
2747put gql 0 n
2748ret vwqname
2749end