interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / patch / p5page.om

614 lines · 10498 bytes Raw Blame History
1note patch/p5page.om: reading the store back, the HTML pages (list, one patch, how to open one) and
2note the raw routes (.patch: the stored mbox bytes; .diff: the diff the forge made when it applied them).
3note ---- reading a stored patch
4note pafp t: fpth = the file <t> of patch gpid, for frdall
5fn pafp t view uchar * to void
6papid t
7fpb
8for i ulong get gppl 0 bound 4096
9fpc get gpp i
10end
11end
12note pamnum: the decimal number at fxo[gpcur] up to its line feed; gpcur moves past the line feed;
13note gpbad is set when it is not 1..18 digits followed by a line feed
14fn pamnum to ulong
15p = get gpcur 0
16n = get fxol 0
17v = ulong 0
18k = ulong 0
19while lt p n bound 32
20c = get fxo p
21if eq c 10
22break
23end
24if or not fisdig c ge k 18
25put gpbad 0 1
26ret 0
27end
28v = add mul v 10 ulong sub c 48
29k = add k 1
30p = add p 1
31end
32if or eq k 0 ge p n
33put gpbad 0 1
34end
35put gpcur 0 add p 1
36ret v
37end
38note pameld: the meta file into gpmdid, gpmts, gpmcm, gpmfl, gpmby, gpmsha
39fn pameld to bool
40pafp tpfme
41n = frdall
42if or lt n 80 gt n 250
43ret false
44end
45e = ulong 0
46while lt e ulong n bound 256
47if eq get fxo e 10
48break
49end
50e = add e 1
51end
52if or lt e 9 gt e 120
53ret false
54end
55for i ulong e bound 128
56put gpmdid i get fxo i
57end
58put gpmdidl 0 e
59put gpbad 0 0
60put gpcur 0 add e 1
61put gpmts 0 pamnum
62put gpmcm 0 pamnum
63put gpmfl 0 pamnum
64put gpmby 0 pamnum
65p = get gpcur 0
66if or ne get gpbad 0 0 ne add p 65 ulong n
67ret false
68end
69for i ulong 64
70put gpmsha i get fxo add p i
71end
72ret true
73end
74note pastld: the statement into gpst and its base line into gpbase (the statement ends with base,
75note line feed, two lines of 64 hex and a line feed each: the base is 171 bytes before the end)
76fn pastld to bool
77pafp tpfst
78n = frdall
79if or lt n 180 gt n 511
80ret false
81end
82for i ulong ulong n bound 512
83put gpst i get fxo i
84end
85put gpstl 0 ulong n
86o = sub ulong n 171
87for i ulong 40
88c = get fxo add o i
89if lt sohexv c 0
90ret false
91end
92put gpbase i c
93end
94ret true
95end
96note paload: patch gpid of this repository into the globals; false when it is not a whole stored patch
97fn paload to bool
98if not pameld
99ret false
100end
101pafp tpftt
102n = frdall
103if or lt n 1 gt n 256
104ret false
105end
106for i ulong ulong n bound 256
107put gpttl i get fxo i
108end
109put gpttll 0 ulong n
110if not pastld
111ret false
112end
113pafp tpfhd
114n = frdall
115if lt n 0
116ret false
117end
118ret pahex40
119end
120note paany: item gpid of this repository into the globals, signed (its meta file exists: paload) or
121note imported (patch/p5imp.om paiload); false when it is neither a whole signed patch nor a loadable
122note imported item
123fn paany to bool
124put gpimp 0 0
125put gpist 0 0
126put gpider 0 0
127put gpicode 0 1
128put gpihb 0 1
129put gpnum 0 0
130papid tpfme
131e = paexist
132if e
133ret paload
134end
135ret paiload
136end
137note paqst: the state of item gpid for the list head: 0 open, 1 closed, 2 merged when its page loader
138note loads it (paany: paload for a signed patch, which is open; paiload for an imported item), 9 when
139note it does not. The loaders read through fxo, so the caller keeps the index in gpix
140fn paqst to ulong
141if not paany
142ret 9
143end
144ret get gpist 0
145end
146note pastcnt tot: the items of the index in gpix (tot lines) that load, by state, into gpsc: exactly
147note the items a list page shows. A line that is not an id, or whose folder does not load as an item,
148note is in no count (palist: damaged = tot less the three counts)
149fn pastcnt tot ulong to void
150for s ulong 3
151put gpsc s 0
152end
153for r ulong tot bound 1048576
154if paidrow mul r 17
155s = paqst
156if lt s 3
157put gpsc s add get gpsc s 1
158end
159end
160end
161end
162note paidrow o: gpid = gpix[o, o+16) when it is 16 lowercase hex
163fn paidrow o ulong to bool
164for i ulong 16
165c = get gpix add o i
166if lt sohexv c 0
167ret false
168end
169put gpid i c
170end
171ret true
172end
173note pardf t: the file <t> of patch gpid into fxo; its length, 0 when it cannot be read
174fn pardf t view uchar * to ulong
175pafp t
176n = frdall
177if lt n 0
178ret 0
179end
180ret ulong n
181end
182note ---- pieces
183note padid: the social store's id of the author DID in gpmdid, 0 when it holds no such account
184fn padid to ulong
185sokclr
186for i ulong get gpmdidl 0 bound 128
187sokc get gpmdid i
188end
189ret sofind
190end
191note paauth: the author as the pages show an account (its name linked, else the shortened DID
192note linked; social/50route.om souser); the full DID in code when the store has no such account
193fn paauth to void
194d = padid
195if ne d 0
196souser d
197ret
198end
199fput tphcode
200for i ulong get gpmdidl 0 bound 128
201fescc get gpmdid i
202end
203fput tphcodz
204end
205fn paputid to void
206for i ulong 16
207fputc get gpid i
208end
209end
210note papath: the page path of patch gpid: <base><owner>/<repo>/patches/<id>
211fn papath to void
212fputrl
213fput tppats
214fputc 47
215paputid
216end
217fn paput40 w ulong to void
218for i ulong 40
219if eq w 0
220fputc get gpbase i
221else
222fputc get gphead i
223end
224end
225end
226note pacnts: "N commits &middot; M files"
227fn pacnts to void
228c = get gpmcm 0
229fnum c
230if eq c 1
231fput tphc1
232else
233fput tphc2
234end
235fput tphm3
236f = get gpmfl 0
237fnum f
238if eq f 1
239fput tphf1
240else
241fput tphf2
242end
243end
244fn paesct to void
245for i ulong get gpttll 0 bound 1024
246fescc get gpttl i
247end
248end
249note ---- the list: the index file holds one line "<16 hex>\n" per patch, oldest first; a page shows
250note 30, newest first
251note paidxn: the index into fxo; the number of patches
252fn paidxn to ulong
253paprepo
254papt tpindex
255fpb
256for i ulong get gppl 0 bound 4096
257fpc get gpp i
258end
259n = frdall
260if lt n 0
261ret 0
262end
263if ne get fxotr 0 0
264fincut
265end
266ret div ulong n 17
267end
268note pacount: the patches the store holds for the repository fridx (growth/g1prep.om grpatch)
269fn pacount to ulong
270ret paidxn
271end
272note papage: the ?page= number, 1 when absent or not a number of 1 to 9 digits above zero
273fn papage to ulong
274n = fqget tpqpage
275if or lt n 1 gt n 9
276ret 1
277end
278v = ulong 0
279for i ulong ulong n bound 9
280c = get fval i
281if not fisdig c
282ret 1
283end
284v = add mul v 10 ulong sub c 48
285end
286if eq v 0
287ret 1
288end
289ret v
290end
291note paixld: the index into gpix (read through fxo, paidxn); the number of its lines
292fn paixld to ulong
293tot = paidxn
294for i ulong mul tot 17 bound 16777216
295put gpix i get fxo i
296end
297ret tot
298end
299note papick: the ids of page pg (of tot lines in gpix) into gpids, newest first; how many
300fn papick tot ulong pg ulong to ulong
301a = mul sub pg 1 30
302c = ulong 0
303for j ulong 30
304k = add a j
305if ge k tot
306break
307end
308o = mul sub sub tot 1 k 17
309for i ulong 16
310put gpids add mul c 16 i get gpix add o i
311end
312c = add c 1
313end
314ret c
315end
316note paidset: gpid = row j of gpids; false when it is not 16 lowercase hex
317fn paidset j ulong to bool
318for i ulong 16
319c = get gpids add mul j 16 i
320if lt sohexv c 0
321ret false
322end
323put gpid i c
324end
325ret true
326end
327fn parow to void
328fput tphli
329papath
330fput tphq
331paesct
332fput tphae
333fput tphm1
334paputid
335fput tphm2
336fjday get gpmts 0
337fput tphby
338paauth
339fput tphm3
340pacnts
341fput tphm4
342end
343fn papgln pg ulong t view uchar * to void
344fput tph2
345fputrl
346fput tphqp
347fnum pg
348fput t
349end
350note padmg n: the list head's words for n index lines whose folder does not load as an item
351fn padmg n ulong to void
352fput tpdmg1
353fnum n
354if eq n 1
355fput tpdmg2
356ret
357end
358fput tpdmg3
359end
360note palist: the list. tot: the lines of the index (the pages go by index position, 30 lines each);
361note lst: the items that load (count; gpsc by state); dmg: the lines that do not (damaged)
362fn palist to long
363tot = paixld
364if ne get fobtr 0 0
365ret 500
366end
367pg = papage
368pages = div add tot 29 30
369if eq pages 0
370pages = 1
371end
372if gt pg pages
373ret 404
374end
375cnt = papick tot pg
376pastcnt tot
377lst = add add get gpsc 0 get gpsc 1 get gpsc 2
378dmg = sub tot lst
379if fjwant
380ret pajlist lst dmg pg pages cnt
381end
382fyalt
383fsetti tptlist
384frepohd 5
385fput tph1
386fnum lst
387if eq lst 1
388fput tph1a
389else
390fput tph1b
391end
392fput tpsth
393fnum get gpsc 0
394fput tpsto
395fnum get gpsc 1
396fput tpstc
397fnum get gpsc 2
398fput tpstm
399if gt dmg 0
400padmg dmg
401end
402fput tph2
403fputrl
404fput tph2n
405if eq tot 0
406fput tphnone
407ret 200
408end
409fput tphul
410for j ulong cnt bound 30
411if paidset j
412if paany
413if eq get gpimp 0 0
414parow
415else
416pairow
417end
418end
419end
420end
421fput tphule
422fput tphpg1
423if gt pg 1
424papgln sub pg 1 tphpgn
425end
426if lt pg pages
427papgln add pg 1 tphpgo
428end
429fput tphpg2
430ret 200
431end
432note ---- one patch
433fn paorig to void
434if eq get fbasel 0 1
435fput tppor1
436ret
437end
438fput tppor2
439end
440note patitl: the page title: the patch title when it is at most 200 bytes, else "Patches"
441fn patitl to void
442n = get gpttll 0
443if gt n 200
444fsetti tptlist
445ret
446end
447put ftil 0 0
448for i ulong n bound 200
449ftic get gpttl i
450end
451end
452note pashdf: the stored diff of the loaded patch, as pashdn shows it
453fn pashdf to void
454n = pardf tpfdf
455if eq n 0
456ret
457end
458pashdn n
459end
460note pashdn n: the diff fxo[0, n), at most 400000 bytes of it cut at a line's end, with a note when it
461note is cut
462fn pashdn n ulong to void
463m = n
464if gt n 400000
465m = ulong 400000
466for it ulong 400000
467if eq m 0
468break
469end
470if eq get fxo sub m 1 10
471break
472end
473m = sub m 1
474end
475end
476fput tphdf1
477fxesc 0 m
478fput tphpre
479if lt m n
480fput tphdfc
481end
482end
483fn pashow2 to void
484fput tphap1
485paputid
486fputc 32
487paput40 0
488fput tphap2
489paorig
490papath
491fput tpsfxp
492fput tphap3
493papath
494fput tpsfxp
495fput tphap4
496papath
497fput tpsfxd
498fput tphap5
499fput tphsg1
500for i ulong get gpmdidl 0 bound 128
501fescc get gpmdid i
502end
503fput tphsg2
504for i ulong get gpstl 0 bound 512
505fescc get gpst i
506end
507fput tphpre
508n = pardf tpfsg
509fput tphsg3
510fxesc 0 n
511fput tphpre
512fput tphdv
513pashdf
514end
515fn pashow to long
516if not paany
517ret 404
518end
519if fjwant
520ret pajone
521end
522if ne get gpimp 0 0
523ret paishow
524end
525fyalt
526patitl
527frepohd 5
528fput tphp1
529paesct
530fput tphp2
531paputid
532fput tphm2
533fjday get gpmts 0
534fput tphby
535paauth
536fput tphp3
537pacnts
538fput tphm3
539fnum get gpmby 0
540fput tphp4
541fputrl
542fput tphcm
543paput40 0
544fput tphq
545fput tphcode
546paput40 0
547fput tphp5
548paput40 1
549fput tphp6
550n = pardf tpfds
551if gt n 0
552fput tphds1
553fxesc 0 n
554fput tphpre
555end
556pashow2
557ret 200
558end
559note panewpg: GET .../patches/new: how to open a patch (the upload itself is the POST)
560fn panewpg to long
561fsetti tptnew
562frepohd 5
563fput tphn1
564fput tfowner
565fputc 47
566fputrnm
567fput tphn2
568ret 200
569end
570note ---- raw: w 0 <id>.patch (the stored mbox), 1 <id>.diff (the stored diff; else the bundle diff of
571note an imported item, patch/p5imp.om pabraw), 2 <id>.bundle (head.bundle). Streamed from the store or
572note the diff cache (kind 3) under the sandbox policy; no JSON form. An item without a meta file must
573note load as an imported item first.
574fn paraws w ulong to long
575papid tpfme
576e = paexist
577if not e
578if not paiload
579ret 404
580end
581end
582if eq w 0
583papid tpfmb
584end
585if eq w 1
586papid tpfdf
587end
588if eq w 2
589papid tpfbn
590end
591e = paexist
592if not e
593if ne w 1
594ret 404
595end
596r = pabraw
597if ne r 0
598ret r
599end
600end
601put ffilel 0 0
602for i ulong get gppl 0 bound 4096
603ffilc get gpp i
604end
605put fobl 0 0
606put fkind 0 3
607if eq w 2
608fsetct tpctbin
609else
610fsetct tpctxt
611end
612fsetsbx
613ret 200
614end