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
omega-mv / apps / interplane-site / native / site.om
| 1 | text trcgate "translation-check" |
| 2 | text trcsp "headers-check" |
| 3 | note SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | note native/site.om: builder and policy checker for interplane.io and hopbot.org, in seeded Omega. |
| 5 | note Composed after native/lib/sha2.om with a leading om2 line (scripts/build-native.sh). |
| 6 | note site build OUT HOPOUT release mode: assemble, check and write both sites; both directories must be new |
| 7 | note site verify OUT HOPOUT re-check written output: the exact file set this source builds, every digest, |
| 8 | note policy, local links, fragments, and the receipts chain from the output bytes |
| 9 | note site build --test-data OUT HOPOUT, site verify --test-data OUT HOPOUT |
| 10 | note the only mode that accepts made-up data; every page carries a TEST DATA banner |
| 11 | note and each output root a TEST-DATA file, which the publisher refuses |
| 12 | note site contrast print the button colour arithmetic from public/style.css |
| 13 | note Run from the repository root. Exit 0 pass, 1 refused, 2 usage. A trap (exit 101..114) is also a refusal. |
| 14 | note Inputs: content/routes.txt names every page and file. A page is a front-matter block, a line |
| 15 | note of three dashes, then HTML that is placed in the site layout. Placeholders are {{name}}, |
| 16 | note {{#flag}}..{{/flag}} (kept when the flag is set) and {{^flag}}..{{/flag}} (kept when it is not). |
| 17 | note Optional inputs: content/hop.release.txt (the Hop page and the hopbot.org output) and |
| 18 | note content/receipts/ledger.tsv with content/receipts/payload/<sha256>.txt (the receipts page). |
| 19 | note content/hop.copy.txt holds one line, "describes <commit>": the Hop commit the Hop page wording was |
| 20 | note written against. A release build refuses Hop data whose commit is another one. |
| 21 | note content/live.txt holds one line, "map yes" or "map no". Absent or no: the flag map stays unset |
| 22 | note and every link to the forge map is left out. |
| 23 | note Required input: content/papers.snapshot (the papers page, papers.json and papers.bib), written |
| 24 | note by scripts/fetch-papers.sh. Optional: content/papers.sources (source links on Interplane). |
| 25 | note Optional: page routes under /zh-CN/ (Simplified Chinese twins of English routes), placed in |
| 26 | note content/_layout.zh-CN.html and content/_layout-hopbot.zh-CN.html; see "Simplified Chinese pages". |
| 27 | note This is a bounded policy checker for reviewed sources. It is not an HTML sanitizer. |
| 28 | |
| 29 | const TOP ulong 0 |
| 30 | const OBN ulong 1 |
| 31 | const NV ulong 2 |
| 32 | const NR ulong 3 |
| 33 | const PBL ulong 4 |
| 34 | const R0L ulong 5 |
| 35 | const R1L ulong 6 |
| 36 | const FHOP ulong 7 |
| 37 | const FRC ulong 8 |
| 38 | const SITE ulong 9 |
| 39 | const LCHK ulong 10 |
| 40 | const FLEN ulong 11 |
| 41 | const NREC ulong 12 |
| 42 | const CXO ulong 13 |
| 43 | const CXL ulong 14 |
| 44 | const MANL ulong 15 |
| 45 | const NFILE ulong 16 |
| 46 | const NPAGE ulong 17 |
| 47 | const L0O ulong 18 |
| 48 | const L0N ulong 19 |
| 49 | const L1O ulong 20 |
| 50 | const L1N ulong 21 |
| 51 | const NVB ulong 22 |
| 52 | const TOPB ulong 23 |
| 53 | const SIOK ulong 24 |
| 54 | const OWNO ulong 25 |
| 55 | const OWNL ulong 26 |
| 56 | const LDGO ulong 28 |
| 57 | const LDGN ulong 29 |
| 58 | const NFLD ulong 30 |
| 59 | const BADC ulong 31 |
| 60 | const PERM ulong 32 |
| 61 | const TESTD ulong 33 |
| 62 | const DRY ulong 34 |
| 63 | const FINS ulong 35 |
| 64 | const PAYO ulong 36 |
| 65 | const MNO ulong 37 |
| 66 | const MNL ulong 38 |
| 67 | const DRO ulong 39 |
| 68 | const DRL ulong 40 |
| 69 | const NSD ulong 41 |
| 70 | const PST ulong 42 |
| 71 | const PNR ulong 43 |
| 72 | const PDECL ulong 44 |
| 73 | const PFO ulong 45 |
| 74 | const POO ulong 46 |
| 75 | const PNRESP ulong 47 |
| 76 | const PHE ulong 48 |
| 77 | const PSO ulong 49 |
| 78 | const PSHA ulong 50 |
| 79 | const PATT ulong 51 |
| 80 | const PNSRC ulong 52 |
| 81 | const MEMSZ ulong 12582912 |
| 82 | const OBSZ ulong 4194304 |
| 83 | const FCAP ulong 2097153 |
| 84 | const RTCAP ulong 500 |
| 85 | |
| 86 | global mem uchar 12582912 |
| 87 | global obuf uchar 4194304 |
| 88 | global st ulong 64 |
| 89 | global vars ulong 2048 |
| 90 | global rt ulong 4096 |
| 91 | global rcs ulong 4096 |
| 92 | global fb ulong 32 |
| 93 | global pb uchar 2048 |
| 94 | global sy uchar 1024 |
| 95 | global hx uchar 64 |
| 96 | global ph uchar 64 |
| 97 | global man uchar 524288 |
| 98 | global root0 uchar 512 |
| 99 | global root1 uchar 512 |
| 100 | global lum ulong 256 |
| 101 | global arg uchar 64 |
| 102 | global dbuf uchar 4096 |
| 103 | global nst ulong 256 |
| 104 | global pr ulong 2048 |
| 105 | |
| 106 | text tusage "usage: site build [--test-data] OUT HOPOUT | site verify [--test-data] OUT HOPOUT | site contrast\n" |
| 107 | text ctestd "--test-data" |
| 108 | text ktestd "test_data" |
| 109 | text ftestd "TEST-DATA" |
| 110 | text ttestd "TEST DATA. This directory was built with --test-data. Its Hop values and receipts may be made up. Never publish it.\n" |
| 111 | text fhins "content/hop.install.sh" |
| 112 | text fhcopy "content/hop.copy.txt" |
| 113 | text tdescr "describes " |
| 114 | text erhcopy "content/hop.copy.txt must hold one line, describes COMMIT, and COMMIT must be the commit in content/hop.release.txt: the Hop page wording is written against one Hop commit" |
| 115 | text mhcopy "hop copy: the page wording is pinned to the release commit\n" |
| 116 | text mhcopyt "hop copy: not compared with the release commit in TEST DATA mode\n" |
| 117 | text khins "hop_install" |
| 118 | text nins "hop.install_sha256" |
| 119 | text hkins "install_sha256" |
| 120 | text kinst "install" |
| 121 | text fhead "content/receipts/head.txt" |
| 122 | text fvsh "content/receipts-page/verify.sh" |
| 123 | text vrvsh "receipts.verify_sh" |
| 124 | text vhok1 "hop_ok1" |
| 125 | text vhok2 "hop_ok2" |
| 126 | text vhok3 "hop_ok3" |
| 127 | text vhok4 "hop_ok4" |
| 128 | text vhbadge "hop_badge" |
| 129 | text vhdbase "hop.download_base" |
| 130 | text pfix "fixture" |
| 131 | text pfixu "FIXTURE" |
| 132 | text pfixd "fixture-desk" |
| 133 | text hip "https://interplane.io/" |
| 134 | text hhb "https://hopbot.org/" |
| 135 | text ttm "(TM)" |
| 136 | text ptml "(tm)" |
| 137 | text vtmeta "meta" |
| 138 | text vtlink "link" |
| 139 | text vtbr "br" |
| 140 | text vtimg "img" |
| 141 | text vthr "hr" |
| 142 | text vtwbr "wbr" |
| 143 | text vtinput "input" |
| 144 | text vtsource "source" |
| 145 | text vtcol "col" |
| 146 | text erhins "content/hop.install.sh and the keys install_sha256 and install_base go together, the SHA-256 of the file must equal install_sha256, and zip_name must be Hop-VERSION.zip, the name the installer fetches from install_base" |
| 147 | text finsout "install.sh" |
| 148 | text rinst "/install.sh" |
| 149 | text thopp "Hop-" |
| 150 | text xzipx ".zip" |
| 151 | text errel "release mode refuses made-up data: a repeated-digit fingerprint, the word fixture, or an address outside interplane.io and hopbot.org. Test data needs --test-data" |
| 152 | text erhead "content/receipts/head.txt must hold the head of the ledger: 64 hex digits and a line feed" |
| 153 | text erset "output differs from what this source builds: a file is missing, extra, changed or not a plain file" |
| 154 | text ernest "HTML elements are not properly nested or closed" |
| 155 | text mtest "TEST DATA mode: every page carries the banner and each output root a TEST-DATA file; never publish this output\n" |
| 156 | text minsno "install: content/hop.install.sh is absent; the terminal install section and /install.sh are omitted\n" |
| 157 | text minsyes "install: content/hop.install.sh matches install_sha256; hopbot.org gets /install.sh, copied as it is (the one file the content scan skips)\n" |
| 158 | text mbadge "badge: rows backed by a receipt that holds the same value: " |
| 159 | text mbadgeof " of 3\n" |
| 160 | text tfail "site: refused: " |
| 161 | text tnl "\n" |
| 162 | text tin " in: " |
| 163 | text tnear " near: " |
| 164 | text tsp " " |
| 165 | text tslash "/" |
| 166 | text tindex "index.html" |
| 167 | text cbuild "build" |
| 168 | text cverify "verify" |
| 169 | text ccontr "contrast" |
| 170 | |
| 171 | text erread "missing, empty, oversized or unreadable file" |
| 172 | text erwrite "output write failed" |
| 173 | text erdir "output directory must be new and its parent must exist" |
| 174 | text erarg "invalid output path" |
| 175 | text erfull "input does not fit the builder memory" |
| 176 | text erbig "generated output is too large" |
| 177 | text erpath "path is too long" |
| 178 | text ervars "too many placeholders" |
| 179 | text ertag "placeholder is not closed" |
| 180 | text erunk "unknown placeholder" |
| 181 | text erblock "conditional block is not closed" |
| 182 | text erdeep "placeholders nest too deeply" |
| 183 | text erfront "page needs a front-matter block ending with a line of three dashes" |
| 184 | text erhtml "incomplete HTML document, title or local stylesheet" |
| 185 | text ermark "malformed or forbidden markup (script, style block, frame, object or animation)" |
| 186 | text erattr "forbidden or malformed attribute (inline style, event handler, srcset or similar)" |
| 187 | text erurl "forbidden URL: outside resources, plain http and unsafe local paths are refused" |
| 188 | text erlink "local link target is missing from the output" |
| 189 | text erfrag "link fragment has no matching id in its target" |
| 190 | text ercss "forbidden CSS: outside resource, import, escape, or a colour outside the root tokens" |
| 191 | text ertext "control byte or non-ASCII byte in a site text file" |
| 192 | text eremail "email address in site output" |
| 193 | text erpriv "private host name or path in site output" |
| 194 | text erdash "em dash, en dash, numeric character reference or registered-mark entity" |
| 195 | text ersuper "the phrase is allowed only in the one sentence that says SI does not mean it" |
| 196 | text ertm "the first Sovereign Intelligence on a page needs the trade mark sign, and never a registered mark" |
| 197 | text erroute "content/routes.txt has a malformed line" |
| 198 | text erdupr "content/routes.txt names the same address on the same site twice" |
| 199 | text erfullr "content/routes.txt has more rows than the route table holds (RTCAP 500); raise RTCAP and size rt to 8 times it" |
| 200 | text eryard "content/yard.snapshot.tsv has a malformed line" |
| 201 | text erhop "content/hop.release.txt has a missing, unknown or malformed key" |
| 202 | text erlive "content/live.txt takes exactly one line, map yes or map no" |
| 203 | text erhopr "receipt_seqs names a record that the receipts ledger does not hold" |
| 204 | text erledg "receipts ledger does not verify" |
| 205 | text erpayl "receipts payload file is missing or its SHA-256 does not equal its name" |
| 206 | text ercon "button colour contrast is below 4.5 to 1, or a button token pair is missing" |
| 207 | text erman "output file differs from the manifest" |
| 208 | text errobot "robots.txt for interplane.io differs from the pinned crawl rules" |
| 209 | |
| 210 | text tdoctype "<!doctype html>" |
| 211 | text thtmlo "<html" |
| 212 | text thtmle "</html>" |
| 213 | text theade "</head>" |
| 214 | text tbodyo "<body" |
| 215 | text tbodye "</body>" |
| 216 | text ttitleo "<title>" |
| 217 | text ttitlee "</title>" |
| 218 | text tstylea "href=\"/public/style.css\"" |
| 219 | text trelst "stylesheet" |
| 220 | text tgscript "script" |
| 221 | text tgiframe "iframe" |
| 222 | text tgobject "object" |
| 223 | text tgembed "embed" |
| 224 | text tgapplet "applet" |
| 225 | text tgframe "frame" |
| 226 | text tgfrset "frameset" |
| 227 | text tgbase "base" |
| 228 | text tgstyle "style" |
| 229 | text tgforgn "foreignobject" |
| 230 | text tganim "animate" |
| 231 | text tganimt "animatetransform" |
| 232 | text tganimm "animatemotion" |
| 233 | text tgset "set" |
| 234 | text tgform "form" |
| 235 | text tga "a" |
| 236 | text tglink "link" |
| 237 | text tasrc "src" |
| 238 | text taposter "poster" |
| 239 | text tabackg "background" |
| 240 | text tahref "href" |
| 241 | text taxhref "xlink:href" |
| 242 | text tasrcset "srcset" |
| 243 | text tasrcdoc "srcdoc" |
| 244 | text tahttpeq "http-equiv" |
| 245 | text taaction "action" |
| 246 | text taformac "formaction" |
| 247 | text taping "ping" |
| 248 | text tahidden "hidden" |
| 249 | text taopen "open" |
| 250 | text tachk "checked" |
| 251 | text tareq "required" |
| 252 | text tadown "download" |
| 253 | text tadis "disabled" |
| 254 | text thttps "https://" |
| 255 | text tbase0 "https://interplane.io/" |
| 256 | text tbase1 "https://hopbot.org/" |
| 257 | text tcmo "<!--" |
| 258 | text tcme "-->" |
| 259 | |
| 260 | text cimport "@import" |
| 261 | text curl "url(" |
| 262 | text cimgset "image-set(" |
| 263 | text cproto "//" |
| 264 | text chttp "http:" |
| 265 | text cjs "javascript:" |
| 266 | text cmoz "-moz-binding" |
| 267 | text cexpr "expression(" |
| 268 | text cbehav "behavior:" |
| 269 | text crgb "rgb(" |
| 270 | text crgba "rgba(" |
| 271 | text chsl "hsl(" |
| 272 | text chsla "hsla(" |
| 273 | text croot ":root{" |
| 274 | text cface "@font-face{" |
| 275 | text cbtn "--btn-" |
| 276 | text cink "-ink:#" |
| 277 | text csbg "-bg" |
| 278 | text cshov "-hover" |
| 279 | text cspress "-press" |
| 280 | |
| 281 | text pmailto "mailto:" |
| 282 | text phome "/home/" |
| 283 | text pusers "/users/" |
| 284 | text pvarwww "/var/www" |
| 285 | text ptmp "/tmp/" |
| 286 | text prootd "/root/" |
| 287 | text ptilde "~/" |
| 288 | text ptsnet ".ts.net" |
| 289 | text plocalh "localhost" |
| 290 | text ploop "127.0.0.1" |
| 291 | text pcgnat "100.64." |
| 292 | text plan "192.168." |
| 293 | text ptail "tail987627" |
| 294 | text pspark "spark-b87b" |
| 295 | text pfile "file://" |
| 296 | text pmdash "—" |
| 297 | text pndash "–" |
| 298 | text pnumref "&#" |
| 299 | text preg "®" |
| 300 | text psup1 "super intelligence" |
| 301 | text psup2 "superintelligence" |
| 302 | text psup3 "super-intelligence" |
| 303 | text psupok "sovereign intelligence™, not " |
| 304 | text psi "sovereign intelligence" |
| 305 | text psireg "sovereign intelligence(r)" |
| 306 | text ptrade "™" |
| 307 | |
| 308 | text froutes "content/routes.txt" |
| 309 | text flay0 "content/_layout.html" |
| 310 | text flay1 "content/_layout-hopbot.html" |
| 311 | text fyard "content/yard.snapshot.tsv" |
| 312 | text fhop "content/hop.release.txt" |
| 313 | text flive "content/live.txt" |
| 314 | text kmap "map" |
| 315 | text lmapyes "map yes" |
| 316 | text lmapno "map no" |
| 317 | text fledger "content/receipts/ledger.tsv" |
| 318 | text fpayd "content/receipts/payload/" |
| 319 | text fcss "public/style.css" |
| 320 | text ftxt ".txt" |
| 321 | text frobots "robots.txt" |
| 322 | text fsitemap "sitemap.xml" |
| 323 | text fmanif "manifest.sha256" |
| 324 | text fledout "receipts/ledger.tsv" |
| 325 | text fpayout "receipts/payload/" |
| 326 | |
| 327 | text kpage "page" |
| 328 | text kcss "css" |
| 329 | text ksvg "svg" |
| 330 | text kraw "raw" |
| 331 | text kmain "main" |
| 332 | text khopbot "hopbot" |
| 333 | text khop "hop" |
| 334 | text krcpt "receipts" |
| 335 | text kasof "asof" |
| 336 | text kowner "owner" |
| 337 | |
| 338 | text vtitle "title" |
| 339 | text vcanon "canonical" |
| 340 | text vroute "route" |
| 341 | text vmain "main" |
| 342 | text vip "ip" |
| 343 | text vipurl "https://interplane.io" |
| 344 | text vone "1" |
| 345 | text vismain "is_main" |
| 346 | text vishop "is_hopbot" |
| 347 | text vyrows "yard.rows" |
| 348 | text vycount "yard.count" |
| 349 | text vyasof "yard.asof" |
| 350 | text vysha "yard.sha256" |
| 351 | text vrrows "receipts.rows" |
| 352 | text vrcount "receipts.count" |
| 353 | text vrhead "receipts.head" |
| 354 | text vrlast "receipts.last_payload" |
| 355 | text vrlseq "receipts.last_seq" |
| 356 | text vhoppre "hop." |
| 357 | text vhrepro "hop_repro" |
| 358 | text vhverif "hop_verify" |
| 359 | text vhbase "hop.install_base" |
| 360 | text vhbased "https://hopbot.org" |
| 361 | text vhr1 "hop.r1" |
| 362 | text vhr2 "hop.r2" |
| 363 | text vhr3 "hop.r3" |
| 364 | text vhr4 "hop.r4" |
| 365 | text vhshort "hop.commit_short" |
| 366 | |
| 367 | text hkver "version" |
| 368 | text hkcommit "commit" |
| 369 | text hkrid "rid" |
| 370 | text hkzip "zip_name" |
| 371 | text hkzsha "zip_sha256" |
| 372 | text hkesha "exe_sha256" |
| 373 | text hkbuilt "built" |
| 374 | text hkmacos "macos" |
| 375 | text hkdl "download_url" |
| 376 | text hksrc "source_url" |
| 377 | text hkrepro "reproducible" |
| 378 | text hkcheck "checked_utc" |
| 379 | text hkseqs "receipt_seqs" |
| 380 | text hkverif "hop_verify" |
| 381 | text hkbase "install_base" |
| 382 | text tyes "yes" |
| 383 | text tno "no" |
| 384 | text tgenesis "GENESIS" |
| 385 | |
| 386 | text hamp "&" |
| 387 | text hlt "<" |
| 388 | text hgt ">" |
| 389 | text hquot """ |
| 390 | text y1 "<li class=\"yard-row\"><a class=\"yard-name\" href=\"https://interplane.io/" |
| 391 | text y2 "\">" |
| 392 | text y4 "</a><span class=\"yard-head mono\">head " |
| 393 | text y5 "</span><span class=\"yard-date\">recorded " |
| 394 | text y6 "</span></li>\n" |
| 395 | text r1 "<tr id=\"r" |
| 396 | text r2 "\"><td data-label=\"Record\">" |
| 397 | text r3 "</td><td data-label=\"Time (UTC)\">" |
| 398 | text r4 "</td><td data-label=\"Kind\">" |
| 399 | text r5 "</td><td data-label=\"Who\">" |
| 400 | text r6 "</td><td data-label=\"What\">" |
| 401 | text r7 "</td><td data-label=\"Evidence file\"><a class=\"mono\" href=\"/receipts/payload/" |
| 402 | text r8 ".txt\">" |
| 403 | text r9 "</a></td></tr>\n" |
| 404 | text s1 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n" |
| 405 | text s2 " <url><loc>" |
| 406 | text s3 "</loc></url>\n" |
| 407 | text s4 "</urlset>\n" |
| 408 | |
| 409 | note ---- retired Chinese copies, and texts shared with the translation unit |
| 410 | text tzhb "/zh" |
| 411 | text erzh "translated copies are retired: a route under /zh-, /zh/ or /zh is refused; readers translate pages with their own tools (see /translate/)" |
| 412 | text erlang "a page needs <html lang=\"en\">" |
| 413 | text hlen "<html lang=\"en\">" |
| 414 | text zhead "</head>" |
| 415 | text zfoot "</div></footer>" |
| 416 | text zen "en" |
| 417 | text probots "ad930287db6907604886f6bd7bbd00511b1ee4e8255916c562151eb6f33a2b23" |
| 418 | |
| 419 | text mhopno "hop: content/hop.release.txt is absent; the /hop/ page and the hopbot.org output are omitted\n" |
| 420 | text mhopyes "hop: release data found; building /hop/ and the hopbot.org output\n" |
| 421 | text mrcno "receipts: content/receipts/ledger.tsv is absent; the /receipts/ page and its links are omitted\n" |
| 422 | text mrcyes "receipts: ledger verifies; records " |
| 423 | text mmapno "map: content/live.txt does not say map yes; every link to the forge map is left out\n" |
| 424 | text mmapyes "map: content/live.txt says map yes; the links to the forge map are built\n" |
| 425 | text mrchead " head " |
| 426 | text myard "yard: public projects " |
| 427 | text mysha " snapshot sha256 " |
| 428 | text mbuilt0 "built interplane.io: pages " |
| 429 | text mbuilt1 "built hopbot.org: pages " |
| 430 | text mfiles " files " |
| 431 | text mmsha " manifest sha256 " |
| 432 | text mbpass "BUILD PASS: assembled, checked, written and re-read\n" |
| 433 | text mvpass "VERIFY PASS: the output is exactly the file set this source builds; digests, policy, links, fragments and the receipts chain hold\n" |
| 434 | text mver0 "verified interplane.io: files " |
| 435 | text mver1 "verified hopbot.org: files " |
| 436 | text mc1 "contrast " |
| 437 | text mc2 " on " |
| 438 | text mc3 "\n channels 0..255: background " |
| 439 | text mc4 ", text " |
| 440 | text mc5 "\n linear value x 1e9 (table from the WCAG 2.1 sRGB formula): background " |
| 441 | text mc6 "\n luminance x 1e13 = 2126 R + 7152 G + 722 B: background " |
| 442 | text mc7 "\n ratio = (lighter + 0.05) / (darker + 0.05) = " |
| 443 | text mc8 " (rounded down), needed 4.50: " |
| 444 | text mcpass "PASS\n" |
| 445 | text mcfail "FAIL\n" |
| 446 | text mcsum "contrast pairs checked: " |
| 447 | text tdot "." |
| 448 | text thash "#" |
| 449 | text tcomma ", " |
| 450 | text ktpl "tpl" |
| 451 | text rcontrib "/contribute/" |
| 452 | text pperm "publishing is permanent" |
| 453 | text erperm "the contribute page must exist and carry the notice: Publishing is permanent" |
| 454 | text vpages "pages" |
| 455 | text vdesc "description" |
| 456 | text fllms "llms.txt" |
| 457 | text promptdir "/agents/prompts/" |
| 458 | text erprompt "agent prompt must be one nonempty line of plain text followed by a line feed" |
| 459 | text lexplore "explore" |
| 460 | text lexplorej "explore.json" |
| 461 | text lowner "drakestapleton" |
| 462 | text lownerp "drakestapleton/" |
| 463 | text lledger "receipts/ledger.tsv" |
| 464 | text lpayp "receipts/payload/" |
| 465 | text pl1 "- [" |
| 466 | text pl2 "](" |
| 467 | text pl3 "): " |
| 468 | text erllms "llms.txt names an interplane.io path that is neither in the built output nor a verified forge route" |
| 469 | text erllmp "llms.txt does not list every page and data file of the site" |
| 470 | text tcbrace "}" |
| 471 | text tbadl "BAD line " |
| 472 | text nver "hop.version" |
| 473 | text nrid "hop.rid" |
| 474 | text nzsha "hop.zip_sha256" |
| 475 | text nbuilt "hop.built" |
| 476 | text ndl "hop.download_url" |
| 477 | text nrepro "hop.reproducible" |
| 478 | text nseqs "hop.receipt_seqs" |
| 479 | text xhtml ".html" |
| 480 | text xsvg ".svg" |
| 481 | text ncommit "hop.commit" |
| 482 | text nesha "hop.exe_sha256" |
| 483 | text nsrc "hop.source_url" |
| 484 | text nverif "hop.hop_verify" |
| 485 | text xcss ".css" |
| 486 | text xotf ".otf" |
| 487 | text tfonts "/public/fonts/" |
| 488 | text kdata "data" |
| 489 | text kfont "font" |
| 490 | text erfont "a font route must hold an OpenType file: the bytes OTTO first" |
| 491 | text kpng "png" |
| 492 | text xpng ".png" |
| 493 | text tpubl "/public/" |
| 494 | text erpng "a png route must hold a PNG file: the eight PNG signature bytes first" |
| 495 | text kgzip "gzip" |
| 496 | text xgzip ".tar.gz" |
| 497 | text odloads "omega/downloads/" |
| 498 | text ergzip "a gzip route must start with a gzip header" |
| 499 | text odloadsums "omega-3086ed3ca106.sha256" |
| 500 | text odloadpin "b30366023e11969408948ae21847cffc6739326c626d73670c3f8d79ccd29842" |
| 501 | text erodload "Omega downloads must match the pinned checksum file and its registered routes" |
| 502 | text erodextra "Omega download directory must contain only the three pinned release routes" |
| 503 | text odcommit "3086ed3ca1061b2625a48d175cd5ac990e783655" |
| 504 | text odhome "/omega/" |
| 505 | text odtitle "<h2 id=\"downloads\">package details</h2>" |
| 506 | text odhref "href=\"/omega/downloads/" |
| 507 | text odend "\" download" |
| 508 | text odguide "compiler preview and installer for 64-bit arm linux: https://interplane.io/omega/" |
| 509 | text odkarch "omega.archive" |
| 510 | text odkinst "omega.installer" |
| 511 | text odksums "omega.checksums" |
| 512 | text odkcommit "omega.commit" |
| 513 | text erodcopy "Omega download page must name its pinned compiler and offer all three release files" |
| 514 | text erodguide "llms.txt must list the Omega compiler preview and installer" |
| 515 | text kforge "forge" |
| 516 | text kdash "-" |
| 517 | text nzip "hop.zip_name" |
| 518 | text ncheck "hop.checked_utc" |
| 519 | text nmacos "hop.macos" |
| 520 | |
| 521 | note ---- accessors: one global load per expression keeps every function inside the register pool |
| 522 | |
| 523 | fn mg i ulong to uchar |
| 524 | ret get mem i |
| 525 | end |
| 526 | |
| 527 | fn og i ulong to uchar |
| 528 | ret get obuf i |
| 529 | end |
| 530 | |
| 531 | fn sg k ulong to ulong |
| 532 | ret get st k |
| 533 | end |
| 534 | |
| 535 | fn fg k ulong to ulong |
| 536 | ret get fb k |
| 537 | end |
| 538 | |
| 539 | fn rg k ulong to ulong |
| 540 | ret get rt k |
| 541 | end |
| 542 | |
| 543 | fn vg k ulong to ulong |
| 544 | ret get vars k |
| 545 | end |
| 546 | |
| 547 | fn cg k ulong to ulong |
| 548 | ret get rcs k |
| 549 | end |
| 550 | |
| 551 | note ---- terminal output |
| 552 | |
| 553 | fn sayfd fd int t view uchar * to void |
| 554 | p = ulong 0 |
| 555 | while lt p len t bound 1048576 |
| 556 | k = write fd t p sub len t p |
| 557 | if le k 0 |
| 558 | exit 1 |
| 559 | end |
| 560 | p = add p ulong k |
| 561 | end |
| 562 | end |
| 563 | |
| 564 | fn say t view uchar * to void |
| 565 | sayfd 1 t |
| 566 | end |
| 567 | |
| 568 | fn sayerr t view uchar * to void |
| 569 | sayfd 2 t |
| 570 | end |
| 571 | |
| 572 | fn saym off ulong n ulong to void |
| 573 | p = ulong 0 |
| 574 | while lt p n bound 16777216 |
| 575 | k = write 1 mem add off p sub n p |
| 576 | if le k 0 |
| 577 | exit 1 |
| 578 | end |
| 579 | p = add p ulong k |
| 580 | end |
| 581 | end |
| 582 | |
| 583 | fn sayob off ulong n ulong to void |
| 584 | p = ulong 0 |
| 585 | while lt p n bound 16777216 |
| 586 | k = write 1 obuf add off p sub n p |
| 587 | if le k 0 |
| 588 | exit 1 |
| 589 | end |
| 590 | p = add p ulong k |
| 591 | end |
| 592 | end |
| 593 | |
| 594 | fn sayhx to void |
| 595 | k = write 1 hx 0 64 |
| 596 | if ne k 64 |
| 597 | exit 1 |
| 598 | end |
| 599 | end |
| 600 | |
| 601 | fn sayn v ulong to void |
| 602 | d = new uchar 20 0 |
| 603 | i = ulong 20 |
| 604 | x = v |
| 605 | if eq x 0 |
| 606 | i = 19 |
| 607 | put d 19 48 |
| 608 | end |
| 609 | while gt x 0 bound 20 |
| 610 | i = sub i 1 |
| 611 | put d i uchar add 48 rem x 10 |
| 612 | x = div x 10 |
| 613 | end |
| 614 | k = write 1 d i sub 20 i |
| 615 | if le k 0 |
| 616 | exit 1 |
| 617 | end |
| 618 | end |
| 619 | |
| 620 | fn die m view uchar * to void |
| 621 | sayerr tfail |
| 622 | sayerr m |
| 623 | sayerr tnl |
| 624 | n = sg CXL |
| 625 | if gt n 0 |
| 626 | sayerr tin |
| 627 | k = write 2 mem sg CXO n |
| 628 | sayerr tnl |
| 629 | end |
| 630 | exit 1 |
| 631 | end |
| 632 | |
| 633 | fn dieat m view uchar * pos ulong to void |
| 634 | sayerr tfail |
| 635 | sayerr m |
| 636 | sayerr tnl |
| 637 | n = sg CXL |
| 638 | if gt n 0 |
| 639 | sayerr tin |
| 640 | k = write 2 mem sg CXO n |
| 641 | sayerr tnl |
| 642 | end |
| 643 | sayerr tnear |
| 644 | lim = sg OBN |
| 645 | s = pos |
| 646 | if gt s 24 |
| 647 | s = sub s 24 |
| 648 | else |
| 649 | s = 0 |
| 650 | end |
| 651 | e = add pos 72 |
| 652 | if gt e lim |
| 653 | e = lim |
| 654 | end |
| 655 | i = s |
| 656 | while lt i e bound 128 |
| 657 | c = og i |
| 658 | if or lt c 32 gt c 126 |
| 659 | c = 32 |
| 660 | end |
| 661 | put sy sub i s c |
| 662 | i = add i 1 |
| 663 | end |
| 664 | if gt e s |
| 665 | k = write 2 sy 0 sub e s |
| 666 | end |
| 667 | sayerr tnl |
| 668 | exit 1 |
| 669 | end |
| 670 | |
| 671 | note ---- path buffer pb |
| 672 | |
| 673 | fn pbset t view uchar * to void |
| 674 | for j ulong len t bound 2048 |
| 675 | put pb j get t j |
| 676 | end |
| 677 | put st PBL len t |
| 678 | end |
| 679 | |
| 680 | fn pbadd t view uchar * to void |
| 681 | n = sg PBL |
| 682 | if gt add n len t 2000 |
| 683 | die erpath |
| 684 | end |
| 685 | for j ulong len t bound 2048 |
| 686 | put pb add n j get t j |
| 687 | end |
| 688 | put st PBL add n len t |
| 689 | end |
| 690 | |
| 691 | fn pbaddm off ulong k ulong to void |
| 692 | n = sg PBL |
| 693 | if gt add n k 2000 |
| 694 | die erpath |
| 695 | end |
| 696 | for j ulong k bound 2048 |
| 697 | put pb add n j mg add off j |
| 698 | end |
| 699 | put st PBL add n k |
| 700 | end |
| 701 | |
| 702 | fn pbroot site ulong to void |
| 703 | note pb = the site's output root, with no trailing slash |
| 704 | if eq site 0 |
| 705 | n = sg R0L |
| 706 | for j ulong n bound 512 |
| 707 | put pb j get root0 j |
| 708 | end |
| 709 | put st PBL n |
| 710 | else |
| 711 | n = sg R1L |
| 712 | for j ulong n bound 512 |
| 713 | put pb j get root1 j |
| 714 | end |
| 715 | put st PBL n |
| 716 | end |
| 717 | end |
| 718 | |
| 719 | fn rootlen site ulong to ulong |
| 720 | if eq site 0 |
| 721 | ret sg R0L |
| 722 | end |
| 723 | ret sg R1L |
| 724 | end |
| 725 | |
| 726 | note ---- files |
| 727 | |
| 728 | fn isfile to bool |
| 729 | fd = fopen pb 0 sg PBL 34816 0 |
| 730 | if lt fd 0 |
| 731 | ret false |
| 732 | end |
| 733 | r = fclose int fd |
| 734 | ret true |
| 735 | end |
| 736 | |
| 737 | fn slurp to ulong |
| 738 | note loads the regular file named by pb into the arena; returns its offset, st FLEN its length. |
| 739 | note readlnk gives -22 for a path that is not a symbolic link; 34816 is O_RDONLY, O_NONBLOCK and |
| 740 | note O_NOFOLLOW on Linux AArch64, so a final-component link or a FIFO cannot stand in for a file. |
| 741 | p = readlnk pb 0 sg PBL sy 0 1024 |
| 742 | if ne p -22 |
| 743 | die erread |
| 744 | end |
| 745 | fd = fopen pb 0 sg PBL 34816 0 |
| 746 | if lt fd 0 |
| 747 | die erread |
| 748 | end |
| 749 | base = sg TOP |
| 750 | if gt add base FCAP MEMSZ |
| 751 | die erfull |
| 752 | end |
| 753 | tot = ulong 0 |
| 754 | k = long 1 |
| 755 | while gt k 0 bound 4194304 |
| 756 | if ge tot FCAP |
| 757 | break |
| 758 | end |
| 759 | k = read int fd mem add base tot sub FCAP tot |
| 760 | if gt k 0 |
| 761 | tot = add tot ulong k |
| 762 | end |
| 763 | end |
| 764 | r = fclose int fd |
| 765 | if lt k 0 |
| 766 | die erread |
| 767 | end |
| 768 | if or eq tot 0 ge tot FCAP |
| 769 | die erread |
| 770 | end |
| 771 | put st TOP add base tot |
| 772 | put st FLEN tot |
| 773 | ret base |
| 774 | end |
| 775 | |
| 776 | fn wrraw to void |
| 777 | note writes obuf to the new file named by pb. 193 is O_WRONLY, O_CREAT and O_EXCL. |
| 778 | fd = fopen pb 0 sg PBL 193 420 |
| 779 | if lt fd 0 |
| 780 | die erwrite |
| 781 | end |
| 782 | p = ulong 0 |
| 783 | n = sg OBN |
| 784 | while lt p n bound 4194304 |
| 785 | k = write int fd obuf p sub n p |
| 786 | if le k 0 |
| 787 | r = fclose int fd |
| 788 | die erwrite |
| 789 | end |
| 790 | p = add p ulong k |
| 791 | end |
| 792 | r = fsync int fd |
| 793 | if ne r 0 |
| 794 | die erwrite |
| 795 | end |
| 796 | r = fclose int fd |
| 797 | if ne r 0 |
| 798 | die erwrite |
| 799 | end |
| 800 | end |
| 801 | |
| 802 | fn mkpar site ulong to void |
| 803 | note creates every directory above the file named by pb, below the site root |
| 804 | n = sg PBL |
| 805 | i = add rootlen site 1 |
| 806 | while lt i n bound 2048 |
| 807 | if eq get pb i 47 |
| 808 | k = makedir pb 0 i 493 |
| 809 | if lt k 0 |
| 810 | if ne k -17 |
| 811 | die erdir |
| 812 | end |
| 813 | end |
| 814 | end |
| 815 | i = add i 1 |
| 816 | end |
| 817 | end |
| 818 | |
| 819 | note ---- output buffer obuf |
| 820 | |
| 821 | fn ob c uchar to void |
| 822 | n = sg OBN |
| 823 | if ge n OBSZ |
| 824 | die erbig |
| 825 | end |
| 826 | put obuf n c |
| 827 | put st OBN add n 1 |
| 828 | end |
| 829 | |
| 830 | fn ot t view uchar * to void |
| 831 | for j ulong len t bound 1048576 |
| 832 | ob get t j |
| 833 | end |
| 834 | end |
| 835 | |
| 836 | fn om off ulong n ulong to void |
| 837 | for j ulong n bound 16777216 |
| 838 | ob mg add off j |
| 839 | end |
| 840 | end |
| 841 | |
| 842 | fn oesc off ulong n ulong to void |
| 843 | for j ulong n bound 16777216 |
| 844 | c = mg add off j |
| 845 | if eq c 38 |
| 846 | ot hamp |
| 847 | else |
| 848 | if eq c 60 |
| 849 | ot hlt |
| 850 | else |
| 851 | if eq c 62 |
| 852 | ot hgt |
| 853 | else |
| 854 | if eq c 34 |
| 855 | ot hquot |
| 856 | else |
| 857 | ob c |
| 858 | end |
| 859 | end |
| 860 | end |
| 861 | end |
| 862 | end |
| 863 | end |
| 864 | |
| 865 | fn onum v ulong to void |
| 866 | d = new uchar 20 0 |
| 867 | i = ulong 20 |
| 868 | x = v |
| 869 | if eq x 0 |
| 870 | i = 19 |
| 871 | put d 19 48 |
| 872 | end |
| 873 | while gt x 0 bound 20 |
| 874 | i = sub i 1 |
| 875 | put d i uchar add 48 rem x 10 |
| 876 | x = div x 10 |
| 877 | end |
| 878 | while lt i 20 bound 20 |
| 879 | ob get d i |
| 880 | i = add i 1 |
| 881 | end |
| 882 | end |
| 883 | |
| 884 | fn ohx to void |
| 885 | for j ulong 64 |
| 886 | ob get hx j |
| 887 | end |
| 888 | end |
| 889 | |
| 890 | fn stash to ulong |
| 891 | note moves obuf into the arena; returns its offset, st FLEN its length |
| 892 | base = sg TOP |
| 893 | n = sg OBN |
| 894 | if gt add base n MEMSZ |
| 895 | die erfull |
| 896 | end |
| 897 | for j ulong n bound 16777216 |
| 898 | put mem add base j og j |
| 899 | end |
| 900 | put st TOP add base n |
| 901 | put st FLEN n |
| 902 | put st OBN 0 |
| 903 | ret base |
| 904 | end |
| 905 | |
| 906 | fn keep t view uchar * to ulong |
| 907 | base = sg TOP |
| 908 | if gt add base len t MEMSZ |
| 909 | die erfull |
| 910 | end |
| 911 | for j ulong len t bound 1048576 |
| 912 | put mem add base j get t j |
| 913 | end |
| 914 | put st TOP add base len t |
| 915 | ret base |
| 916 | end |
| 917 | |
| 918 | note ---- SHA-256 (native/lib/sha2.om) of arena or output bytes, as 64 hex digits in hx |
| 919 | |
| 920 | fn hexc v ulong to uchar |
| 921 | if lt v 10 |
| 922 | ret uchar add 48 v |
| 923 | end |
| 924 | ret uchar add 87 v |
| 925 | end |
| 926 | |
| 927 | fn hxput d view uchar 32 to void |
| 928 | for j ulong 32 |
| 929 | b = ulong get d j |
| 930 | put hx mul j 2 hexc shr b 4 |
| 931 | put hx add mul j 2 1 hexc and b 15 |
| 932 | end |
| 933 | end |
| 934 | |
| 935 | fn hashm off ulong n ulong to void |
| 936 | c = new ulong 40 0 |
| 937 | t = new uchar 4096 0 |
| 938 | d = new uchar 32 0 |
| 939 | sha256_init c |
| 940 | done = ulong 0 |
| 941 | while lt done n bound 16777216 |
| 942 | k = sub n done |
| 943 | if gt k 4096 |
| 944 | k = 4096 |
| 945 | end |
| 946 | for j ulong k bound 4096 |
| 947 | put t j mg add add off done j |
| 948 | end |
| 949 | sha256_update c part t 0 k |
| 950 | done = add done k |
| 951 | end |
| 952 | sha256_final c d |
| 953 | hxput d |
| 954 | end |
| 955 | |
| 956 | fn hasho to void |
| 957 | c = new ulong 40 0 |
| 958 | t = new uchar 4096 0 |
| 959 | d = new uchar 32 0 |
| 960 | sha256_init c |
| 961 | n = sg OBN |
| 962 | done = ulong 0 |
| 963 | while lt done n bound 16777216 |
| 964 | k = sub n done |
| 965 | if gt k 4096 |
| 966 | k = 4096 |
| 967 | end |
| 968 | for j ulong k bound 4096 |
| 969 | put t j og add done j |
| 970 | end |
| 971 | sha256_update c part t 0 k |
| 972 | done = add done k |
| 973 | end |
| 974 | sha256_final c d |
| 975 | hxput d |
| 976 | end |
| 977 | |
| 978 | fn hxkeep to ulong |
| 979 | note copies hx into the arena; returns its offset (64 bytes) |
| 980 | base = sg TOP |
| 981 | if gt add base 64 MEMSZ |
| 982 | die erfull |
| 983 | end |
| 984 | for j ulong 64 |
| 985 | put mem add base j get hx j |
| 986 | end |
| 987 | put st TOP add base 64 |
| 988 | ret base |
| 989 | end |
| 990 | |
| 991 | fn hxis off ulong to bool |
| 992 | note hx equals the 64 arena bytes at off |
| 993 | for j ulong 64 |
| 994 | if ne get hx j mg add off j |
| 995 | ret false |
| 996 | end |
| 997 | end |
| 998 | ret true |
| 999 | end |
| 1000 | |
| 1001 | note ---- placeholders |
| 1002 | |
| 1003 | fn mcmp a ulong b ulong n ulong to bool |
| 1004 | for j ulong n bound 16777216 |
| 1005 | if ne mg add a j mg add b j |
| 1006 | ret false |
| 1007 | end |
| 1008 | end |
| 1009 | ret true |
| 1010 | end |
| 1011 | |
| 1012 | fn mist off ulong n ulong t view uchar * to bool |
| 1013 | note arena bytes off..off+n equal the text t |
| 1014 | if ne n len t |
| 1015 | ret false |
| 1016 | end |
| 1017 | for j ulong n bound 1048576 |
| 1018 | if ne mg add off j get t j |
| 1019 | ret false |
| 1020 | end |
| 1021 | end |
| 1022 | ret true |
| 1023 | end |
| 1024 | |
| 1025 | fn mistf off ulong t view uchar * fold bool to bool |
| 1026 | note the arena bytes at off start with the text t; fold compares their lower case with t |
| 1027 | for j ulong len t bound 4096 |
| 1028 | c = mg add off j |
| 1029 | if fold |
| 1030 | c = low c |
| 1031 | end |
| 1032 | if ne c get t j |
| 1033 | ret false |
| 1034 | end |
| 1035 | end |
| 1036 | ret true |
| 1037 | end |
| 1038 | |
| 1039 | fn mhas off ulong n ulong t view uchar * fold bool to bool |
| 1040 | note arena off..off+n holds the text t somewhere |
| 1041 | pl = len t |
| 1042 | if gt pl n |
| 1043 | ret false |
| 1044 | end |
| 1045 | last = sub n pl |
| 1046 | i = ulong 0 |
| 1047 | while le i last bound 4194304 |
| 1048 | if mistf add off i t fold |
| 1049 | ret true |
| 1050 | end |
| 1051 | i = add i 1 |
| 1052 | end |
| 1053 | ret false |
| 1054 | end |
| 1055 | |
| 1056 | fn mfind off ulong n ulong po ulong pl ulong to bool |
| 1057 | note arena off..off+n holds the arena bytes po..po+pl somewhere |
| 1058 | if or eq pl 0 gt pl n |
| 1059 | ret false |
| 1060 | end |
| 1061 | last = sub n pl |
| 1062 | i = ulong 0 |
| 1063 | while le i last bound 4194304 |
| 1064 | if mcmp add off i po pl |
| 1065 | ret true |
| 1066 | end |
| 1067 | i = add i 1 |
| 1068 | end |
| 1069 | ret false |
| 1070 | end |
| 1071 | |
| 1072 | fn fewdig vo ulong vl ulong to bool |
| 1073 | note fewer than six different bytes: a placeholder such as all zeros, not a real fingerprint |
| 1074 | seen = new uchar 256 0 |
| 1075 | d = ulong 0 |
| 1076 | for j ulong vl bound 128 |
| 1077 | c = ulong mg add vo j |
| 1078 | if eq get seen c 0 |
| 1079 | put seen c 1 |
| 1080 | d = add d 1 |
| 1081 | end |
| 1082 | end |
| 1083 | ret lt d 6 |
| 1084 | end |
| 1085 | |
| 1086 | fn setvm ko ulong kl ulong vo ulong vl ulong to void |
| 1087 | n = sg NV |
| 1088 | if ge n 512 |
| 1089 | die ervars |
| 1090 | end |
| 1091 | b = mul n 4 |
| 1092 | put vars b ko |
| 1093 | put vars add b 1 kl |
| 1094 | put vars add b 2 vo |
| 1095 | put vars add b 3 vl |
| 1096 | put st NV add n 1 |
| 1097 | end |
| 1098 | |
| 1099 | fn setv k view uchar * vo ulong vl ulong to void |
| 1100 | ko = keep k |
| 1101 | setvm ko len k vo vl |
| 1102 | end |
| 1103 | |
| 1104 | fn setvt k view uchar * v view uchar * to void |
| 1105 | vo = keep v |
| 1106 | setv k vo len v |
| 1107 | end |
| 1108 | |
| 1109 | fn findv off ulong n ulong to ulong |
| 1110 | note 1 + index of the newest placeholder with this name, 0 when there is none |
| 1111 | i = sg NV |
| 1112 | while gt i 0 bound 1024 |
| 1113 | i = sub i 1 |
| 1114 | b = mul i 4 |
| 1115 | if eq vg add b 1 n |
| 1116 | if mcmp vg b off n |
| 1117 | ret add i 1 |
| 1118 | end |
| 1119 | end |
| 1120 | end |
| 1121 | ret 0 |
| 1122 | end |
| 1123 | |
| 1124 | fn vlook k view uchar * to ulong |
| 1125 | ko = keep k |
| 1126 | v = findv ko len k |
| 1127 | put st TOP ko |
| 1128 | ret v |
| 1129 | end |
| 1130 | |
| 1131 | fn vset k view uchar * to bool |
| 1132 | note the placeholder exists and is not empty |
| 1133 | v = vlook k |
| 1134 | if eq v 0 |
| 1135 | ret false |
| 1136 | end |
| 1137 | ret gt vg add mul sub v 1 4 3 0 |
| 1138 | end |
| 1139 | |
| 1140 | fn tagend s ulong lim ulong to ulong |
| 1141 | i = s |
| 1142 | while lt add i 1 lim bound 512 |
| 1143 | if gt sub i s 200 |
| 1144 | die ertag |
| 1145 | end |
| 1146 | if eq mg i 125 |
| 1147 | if eq mg add i 1 125 |
| 1148 | ret i |
| 1149 | end |
| 1150 | end |
| 1151 | i = add i 1 |
| 1152 | end |
| 1153 | die ertag |
| 1154 | ret lim |
| 1155 | end |
| 1156 | |
| 1157 | fn iscl i ulong no ulong nl ulong to bool |
| 1158 | if ne mg add i 1 123 |
| 1159 | ret false |
| 1160 | end |
| 1161 | if ne mg add i 2 47 |
| 1162 | ret false |
| 1163 | end |
| 1164 | if not mcmp add i 3 no nl |
| 1165 | ret false |
| 1166 | end |
| 1167 | if ne mg add add i 3 nl 125 |
| 1168 | ret false |
| 1169 | end |
| 1170 | if ne mg add add i 4 nl 125 |
| 1171 | ret false |
| 1172 | end |
| 1173 | ret true |
| 1174 | end |
| 1175 | |
| 1176 | fn skipto p ulong lim ulong no ulong nl ulong to ulong |
| 1177 | note first index after the closing tag of block NAME (arena no..no+nl), searching from p |
| 1178 | i = p |
| 1179 | need = add nl 5 |
| 1180 | while le add i need lim bound 16777216 |
| 1181 | if eq mg i 123 |
| 1182 | if iscl i no nl |
| 1183 | ret add i need |
| 1184 | end |
| 1185 | end |
| 1186 | i = add i 1 |
| 1187 | end |
| 1188 | die erblock |
| 1189 | ret lim |
| 1190 | end |
| 1191 | |
| 1192 | fn dotag i ulong lim ulong depth ulong to ulong |
| 1193 | s = add i 2 |
| 1194 | e = tagend s lim |
| 1195 | k = mg s |
| 1196 | if eq k 47 |
| 1197 | ret add e 2 |
| 1198 | end |
| 1199 | if or eq k 35 eq k 94 |
| 1200 | no = add s 1 |
| 1201 | nl = sub e no |
| 1202 | v = findv no nl |
| 1203 | have = ulong 0 |
| 1204 | if gt v 0 |
| 1205 | if gt vg add mul sub v 1 4 3 0 |
| 1206 | have = 1 |
| 1207 | end |
| 1208 | end |
| 1209 | want = ulong 0 |
| 1210 | if eq k 35 |
| 1211 | want = 1 |
| 1212 | end |
| 1213 | if eq have want |
| 1214 | ret add e 2 |
| 1215 | end |
| 1216 | ret skipto add e 2 lim no nl |
| 1217 | end |
| 1218 | v = findv s sub e s |
| 1219 | if eq v 0 |
| 1220 | put st CXO s |
| 1221 | put st CXL sub e s |
| 1222 | die erunk |
| 1223 | end |
| 1224 | b = mul sub v 1 4 |
| 1225 | expand vg add b 2 vg add b 3 add depth 1 |
| 1226 | ret add e 2 |
| 1227 | end |
| 1228 | |
| 1229 | fn expand off ulong n ulong depth ulong to void |
| 1230 | if gt depth 6 |
| 1231 | die erdeep |
| 1232 | end |
| 1233 | lim = add off n |
| 1234 | i = off |
| 1235 | while lt i lim bound 16777216 |
| 1236 | c = mg i |
| 1237 | tag = false |
| 1238 | if eq c 123 |
| 1239 | if lt add i 1 lim |
| 1240 | if eq mg add i 1 123 |
| 1241 | tag = true |
| 1242 | end |
| 1243 | end |
| 1244 | end |
| 1245 | if tag |
| 1246 | i = dotag i lim depth |
| 1247 | else |
| 1248 | ob c |
| 1249 | i = add i 1 |
| 1250 | end |
| 1251 | end |
| 1252 | end |
| 1253 | |
| 1254 | note ---- small parsers over the arena |
| 1255 | |
| 1256 | fn eol i ulong lim ulong to ulong |
| 1257 | j = i |
| 1258 | while lt j lim bound 16777216 |
| 1259 | if eq mg j 10 |
| 1260 | ret j |
| 1261 | end |
| 1262 | j = add j 1 |
| 1263 | end |
| 1264 | ret lim |
| 1265 | end |
| 1266 | |
| 1267 | fn split s ulong e ulong sep uchar to ulong |
| 1268 | note field k of arena s..e is fb 2k .. fb 2k+1; returns the field count (at most 16) |
| 1269 | n = ulong 0 |
| 1270 | a = s |
| 1271 | i = s |
| 1272 | while le i e bound 16777216 |
| 1273 | stop = false |
| 1274 | if eq i e |
| 1275 | stop = true |
| 1276 | else |
| 1277 | if eq mg i sep |
| 1278 | stop = true |
| 1279 | end |
| 1280 | end |
| 1281 | if stop |
| 1282 | if ge n 16 |
| 1283 | ret 99 |
| 1284 | end |
| 1285 | put fb mul n 2 a |
| 1286 | put fb add mul n 2 1 i |
| 1287 | n = add n 1 |
| 1288 | a = add i 1 |
| 1289 | end |
| 1290 | i = add i 1 |
| 1291 | end |
| 1292 | ret n |
| 1293 | end |
| 1294 | |
| 1295 | fn alnum c uchar to bool |
| 1296 | if and ge c 48 le c 57 |
| 1297 | ret true |
| 1298 | end |
| 1299 | if and ge c 65 le c 90 |
| 1300 | ret true |
| 1301 | end |
| 1302 | ret and ge c 97 le c 122 |
| 1303 | end |
| 1304 | |
| 1305 | fn inset c uchar mode ulong to bool |
| 1306 | note sets: 1 name (A-Z a-z 0-9 . _ -), 2 lowercase hex, 3 time (0-9 T Z : -), 4 Radicle id |
| 1307 | note (alphanumeric and colon), 5 digits, 6 printable ASCII without markup or placeholder bytes, |
| 1308 | note 7 URL bytes, 8 digits and spaces |
| 1309 | dig = and ge c 48 le c 57 |
| 1310 | if eq mode 1 |
| 1311 | if alnum c |
| 1312 | ret true |
| 1313 | end |
| 1314 | ret or eq c 46 or eq c 95 eq c 45 |
| 1315 | end |
| 1316 | if eq mode 2 |
| 1317 | if dig |
| 1318 | ret true |
| 1319 | end |
| 1320 | ret and ge c 97 le c 102 |
| 1321 | end |
| 1322 | if eq mode 3 |
| 1323 | if dig |
| 1324 | ret true |
| 1325 | end |
| 1326 | ret or eq c 84 or eq c 90 or eq c 58 eq c 45 |
| 1327 | end |
| 1328 | if eq mode 4 |
| 1329 | if alnum c |
| 1330 | ret true |
| 1331 | end |
| 1332 | ret eq c 58 |
| 1333 | end |
| 1334 | if eq mode 5 |
| 1335 | ret dig |
| 1336 | end |
| 1337 | if eq mode 6 |
| 1338 | if or lt c 32 gt c 126 |
| 1339 | ret false |
| 1340 | end |
| 1341 | if or eq c 60 or eq c 62 eq c 38 |
| 1342 | ret false |
| 1343 | end |
| 1344 | if or eq c 34 or eq c 123 eq c 125 |
| 1345 | ret false |
| 1346 | end |
| 1347 | ret true |
| 1348 | end |
| 1349 | if eq mode 7 |
| 1350 | if alnum c |
| 1351 | ret true |
| 1352 | end |
| 1353 | if or eq c 46 or eq c 95 or eq c 45 eq c 47 |
| 1354 | ret true |
| 1355 | end |
| 1356 | ret or eq c 58 or eq c 126 or eq c 63 or eq c 61 eq c 43 |
| 1357 | end |
| 1358 | if eq mode 8 |
| 1359 | ret or dig eq c 32 |
| 1360 | end |
| 1361 | ret false |
| 1362 | end |
| 1363 | |
| 1364 | fn okset s ulong e ulong mode ulong to bool |
| 1365 | note every byte of the nonempty arena range s..e is in the set (see inset) |
| 1366 | if ge s e |
| 1367 | ret false |
| 1368 | end |
| 1369 | i = s |
| 1370 | while lt i e bound 16777216 |
| 1371 | if not inset mg i mode |
| 1372 | ret false |
| 1373 | end |
| 1374 | i = add i 1 |
| 1375 | end |
| 1376 | ret true |
| 1377 | end |
| 1378 | |
| 1379 | fn mnum s ulong e ulong to ulong |
| 1380 | note the decimal number in arena s..e; 0 when it is not 1 to 9 digits or has a leading zero |
| 1381 | if ge s e |
| 1382 | ret 0 |
| 1383 | end |
| 1384 | if gt sub e s 9 |
| 1385 | ret 0 |
| 1386 | end |
| 1387 | if eq mg s 48 |
| 1388 | ret 0 |
| 1389 | end |
| 1390 | v = ulong 0 |
| 1391 | i = s |
| 1392 | while lt i e bound 16 |
| 1393 | c = mg i |
| 1394 | if or lt c 48 gt c 57 |
| 1395 | ret 0 |
| 1396 | end |
| 1397 | v = add mul v 10 ulong sub c 48 |
| 1398 | i = add i 1 |
| 1399 | end |
| 1400 | ret v |
| 1401 | end |
| 1402 | |
| 1403 | note ---- text policy on obuf |
| 1404 | |
| 1405 | fn low c uchar to uchar |
| 1406 | if and ge c 65 le c 90 |
| 1407 | ret add c 32 |
| 1408 | end |
| 1409 | ret c |
| 1410 | end |
| 1411 | |
| 1412 | fn space c uchar to bool |
| 1413 | ret or eq c 32 or eq c 9 or eq c 10 eq c 13 |
| 1414 | end |
| 1415 | |
| 1416 | fn namechar c uchar to bool |
| 1417 | d = low c |
| 1418 | ret or and ge d 97 le d 122 or and ge d 48 le d 57 or eq d 45 eq d 58 |
| 1419 | end |
| 1420 | |
| 1421 | fn omatch pos ulong pat view uchar * to bool |
| 1422 | if gt add pos len pat sg OBN |
| 1423 | ret false |
| 1424 | end |
| 1425 | for j ulong len pat bound 4096 |
| 1426 | if ne low og add pos j get pat j |
| 1427 | ret false |
| 1428 | end |
| 1429 | end |
| 1430 | ret true |
| 1431 | end |
| 1432 | |
| 1433 | fn otoken pos ulong size ulong pat view uchar * to bool |
| 1434 | if ne size len pat |
| 1435 | ret false |
| 1436 | end |
| 1437 | ret omatch pos pat |
| 1438 | end |
| 1439 | |
| 1440 | fn ofind from ulong pat view uchar * to ulong |
| 1441 | n = sg OBN |
| 1442 | j = from |
| 1443 | while lt j n bound 16777216 |
| 1444 | if omatch j pat |
| 1445 | ret j |
| 1446 | end |
| 1447 | j = add j 1 |
| 1448 | end |
| 1449 | ret n |
| 1450 | end |
| 1451 | |
| 1452 | fn ohas pat view uchar * to bool |
| 1453 | ret lt ofind 0 pat sg OBN |
| 1454 | end |
| 1455 | |
| 1456 | fn emailc c uchar to bool |
| 1457 | d = low c |
| 1458 | ret or and ge d 97 le d 122 or and ge d 48 le d 57 or eq d 46 or eq d 95 or eq d 43 eq d 45 |
| 1459 | end |
| 1460 | |
| 1461 | fn labelc c uchar to bool |
| 1462 | d = low c |
| 1463 | ret or and ge d 97 le d 122 or and ge d 48 le d 57 eq d 45 |
| 1464 | end |
| 1465 | |
| 1466 | fn isemail i ulong to bool |
| 1467 | note obuf i is an at sign with a name byte before it and "label.letter" after it |
| 1468 | n = sg OBN |
| 1469 | if eq i 0 |
| 1470 | ret false |
| 1471 | end |
| 1472 | if not emailc og sub i 1 |
| 1473 | ret false |
| 1474 | end |
| 1475 | j = add i 1 |
| 1476 | while lt j n bound 16777216 |
| 1477 | if not labelc og j |
| 1478 | break |
| 1479 | end |
| 1480 | j = add j 1 |
| 1481 | end |
| 1482 | if eq j add i 1 |
| 1483 | ret false |
| 1484 | end |
| 1485 | if ge add j 1 n |
| 1486 | ret false |
| 1487 | end |
| 1488 | if ne og j 46 |
| 1489 | ret false |
| 1490 | end |
| 1491 | d = low og add j 1 |
| 1492 | ret and ge d 97 le d 122 |
| 1493 | end |
| 1494 | |
| 1495 | fn polpath i ulong c uchar to void |
| 1496 | if eq c 47 |
| 1497 | if or omatch i phome or omatch i pusers or omatch i pvarwww or omatch i ptmp omatch i prootd |
| 1498 | dieat erpriv i |
| 1499 | end |
| 1500 | end |
| 1501 | if eq c 126 |
| 1502 | if omatch i ptilde |
| 1503 | dieat erpriv i |
| 1504 | end |
| 1505 | end |
| 1506 | if eq c 46 |
| 1507 | if omatch i ptsnet |
| 1508 | dieat erpriv i |
| 1509 | end |
| 1510 | end |
| 1511 | if eq c 108 |
| 1512 | if omatch i plocalh |
| 1513 | dieat erpriv i |
| 1514 | end |
| 1515 | end |
| 1516 | if eq c 49 |
| 1517 | if or omatch i ploop or omatch i pcgnat omatch i plan |
| 1518 | dieat erpriv i |
| 1519 | end |
| 1520 | end |
| 1521 | if eq c 116 |
| 1522 | if omatch i ptail |
| 1523 | dieat erpriv i |
| 1524 | end |
| 1525 | end |
| 1526 | if eq c 102 |
| 1527 | if omatch i pfile |
| 1528 | dieat erpriv i |
| 1529 | end |
| 1530 | end |
| 1531 | end |
| 1532 | |
| 1533 | fn polword i ulong c uchar to void |
| 1534 | if eq c 64 |
| 1535 | if isemail i |
| 1536 | dieat eremail i |
| 1537 | end |
| 1538 | end |
| 1539 | if eq c 109 |
| 1540 | if omatch i pmailto |
| 1541 | dieat eremail i |
| 1542 | end |
| 1543 | end |
| 1544 | if eq c 38 |
| 1545 | if or omatch i pmdash or omatch i pndash or omatch i pnumref omatch i preg |
| 1546 | dieat erdash i |
| 1547 | end |
| 1548 | end |
| 1549 | if eq c 115 |
| 1550 | if omatch i pspark |
| 1551 | dieat erpriv i |
| 1552 | end |
| 1553 | if omatch i psireg |
| 1554 | dieat ertm i |
| 1555 | end |
| 1556 | if or omatch i psup1 or omatch i psup2 omatch i psup3 |
| 1557 | ok = false |
| 1558 | if ge i len psupok |
| 1559 | if omatch sub i len psupok psupok |
| 1560 | if eq sg SIOK 0 |
| 1561 | ok = true |
| 1562 | end |
| 1563 | end |
| 1564 | end |
| 1565 | if not ok |
| 1566 | dieat ersuper i |
| 1567 | end |
| 1568 | put st SIOK 1 |
| 1569 | end |
| 1570 | end |
| 1571 | end |
| 1572 | |
| 1573 | fn polscan strict bool to void |
| 1574 | note strict: printable ASCII |
| 1575 | put st SIOK 0 |
| 1576 | n = sg OBN |
| 1577 | i = ulong 0 |
| 1578 | while lt i n bound 16777216 |
| 1579 | c = og i |
| 1580 | k = ulong 1 |
| 1581 | if strict |
| 1582 | if lt c 32 |
| 1583 | if not space c |
| 1584 | dieat ertext i |
| 1585 | end |
| 1586 | end |
| 1587 | if gt c 126 |
| 1588 | dieat ertext i |
| 1589 | end |
| 1590 | end |
| 1591 | if eq k 1 |
| 1592 | d = low c |
| 1593 | polpath i d |
| 1594 | polword i d |
| 1595 | end |
| 1596 | i = add i k |
| 1597 | end |
| 1598 | end |
| 1599 | |
| 1600 | fn oeq i ulong t view uchar * to bool |
| 1601 | note obuf i.. starts with the text t, compared exactly |
| 1602 | if gt add i len t sg OBN |
| 1603 | ret false |
| 1604 | end |
| 1605 | for j ulong len t bound 4096 |
| 1606 | if ne og add i j get t j |
| 1607 | ret false |
| 1608 | end |
| 1609 | end |
| 1610 | ret true |
| 1611 | end |
| 1612 | |
| 1613 | fn ohasx t view uchar * to bool |
| 1614 | note obuf holds the text t, compared exactly |
| 1615 | n = sg OBN |
| 1616 | i = ulong 0 |
| 1617 | while lt i n bound 16777216 |
| 1618 | if oeq i t |
| 1619 | ret true |
| 1620 | end |
| 1621 | i = add i 1 |
| 1622 | end |
| 1623 | ret false |
| 1624 | end |
| 1625 | |
| 1626 | fn chklang to void |
| 1627 | note a page declares <html lang="en"> |
| 1628 | if not ohasx hlen |
| 1629 | die erlang |
| 1630 | end |
| 1631 | end |
| 1632 | |
| 1633 | note ---- markup checks on obuf |
| 1634 | |
| 1635 | fn badtag pos ulong size ulong to bool |
| 1636 | if or otoken pos size tgscript or otoken pos size tgiframe or otoken pos size tgobject otoken pos size tgembed |
| 1637 | ret true |
| 1638 | end |
| 1639 | if or otoken pos size tgapplet or otoken pos size tgframe or otoken pos size tgfrset otoken pos size tgbase |
| 1640 | ret true |
| 1641 | end |
| 1642 | if or otoken pos size tgstyle or otoken pos size tgforgn or otoken pos size tganim otoken pos size tgset |
| 1643 | ret true |
| 1644 | end |
| 1645 | if or otoken pos size tganimt or otoken pos size tganimm otoken pos size tgform |
| 1646 | ret true |
| 1647 | end |
| 1648 | ret false |
| 1649 | end |
| 1650 | |
| 1651 | fn badattr pos ulong size ulong to bool |
| 1652 | if ge size 2 |
| 1653 | if and eq low og pos 111 eq low og add pos 1 110 |
| 1654 | ret true |
| 1655 | end |
| 1656 | end |
| 1657 | if or otoken pos size tgstyle or otoken pos size tasrcset or otoken pos size tasrcdoc otoken pos size tahttpeq |
| 1658 | ret true |
| 1659 | end |
| 1660 | if or otoken pos size taaction or otoken pos size taformac otoken pos size taping |
| 1661 | ret true |
| 1662 | end |
| 1663 | ret false |
| 1664 | end |
| 1665 | |
| 1666 | fn boolattr pos ulong size ulong to bool |
| 1667 | if or otoken pos size tahidden or otoken pos size taopen otoken pos size tachk |
| 1668 | ret true |
| 1669 | end |
| 1670 | ret or otoken pos size tareq or otoken pos size tadown otoken pos size tadis |
| 1671 | end |
| 1672 | |
| 1673 | fn skipsp pos ulong to ulong |
| 1674 | n = sg OBN |
| 1675 | i = pos |
| 1676 | while lt i n bound 16777216 |
| 1677 | if not space og i |
| 1678 | break |
| 1679 | end |
| 1680 | i = add i 1 |
| 1681 | end |
| 1682 | ret i |
| 1683 | end |
| 1684 | |
| 1685 | fn fragat i ulong fo ulong fl ulong to bool |
| 1686 | note arena i.. is id="FRAG" where FRAG is obuf fo..fo+fl |
| 1687 | if ne mg add i 1 100 |
| 1688 | ret false |
| 1689 | end |
| 1690 | if ne mg add i 2 61 |
| 1691 | ret false |
| 1692 | end |
| 1693 | if ne mg add i 3 34 |
| 1694 | ret false |
| 1695 | end |
| 1696 | for j ulong fl bound 1024 |
| 1697 | if ne mg add add i 4 j og add fo j |
| 1698 | ret false |
| 1699 | end |
| 1700 | end |
| 1701 | ret eq mg add add i 4 fl 34 |
| 1702 | end |
| 1703 | |
| 1704 | fn fragmem base ulong n ulong fo ulong fl ulong to bool |
| 1705 | need = add fl 5 |
| 1706 | i = base |
| 1707 | lim = add base n |
| 1708 | while le add i need lim bound 16777216 |
| 1709 | if eq mg i 105 |
| 1710 | if fragat i fo fl |
| 1711 | ret true |
| 1712 | end |
| 1713 | end |
| 1714 | i = add i 1 |
| 1715 | end |
| 1716 | ret false |
| 1717 | end |
| 1718 | |
| 1719 | fn fragself fo ulong fl ulong pos ulong to void |
| 1720 | note the page in obuf must hold id="FRAG" |
| 1721 | if eq fl 0 |
| 1722 | ret |
| 1723 | end |
| 1724 | base = sg TOP |
| 1725 | n = sg OBN |
| 1726 | if gt add base n MEMSZ |
| 1727 | die erfull |
| 1728 | end |
| 1729 | for j ulong n bound 16777216 |
| 1730 | put mem add base j og j |
| 1731 | end |
| 1732 | if not fragmem base n fo fl |
| 1733 | dieat erfrag pos |
| 1734 | end |
| 1735 | end |
| 1736 | |
| 1737 | fn fragfile fo ulong fl ulong pos ulong to void |
| 1738 | note the output file named by pb must hold id="FRAG" |
| 1739 | if eq fl 0 |
| 1740 | ret |
| 1741 | end |
| 1742 | mark = sg TOP |
| 1743 | base = slurp |
| 1744 | ok = fragmem base sg FLEN fo fl |
| 1745 | put st TOP mark |
| 1746 | if not ok |
| 1747 | dieat erfrag pos |
| 1748 | end |
| 1749 | end |
| 1750 | |
| 1751 | fn urlpath pos ulong size ulong to ulong |
| 1752 | note appends the path part of the local URL to pb (after the site root); returns its length |
| 1753 | pbroot sg SITE |
| 1754 | n = sg PBL |
| 1755 | cnt = ulong 0 |
| 1756 | while lt cnt size bound 1024 |
| 1757 | c = og add pos cnt |
| 1758 | if or eq c 35 eq c 63 |
| 1759 | break |
| 1760 | end |
| 1761 | if or le c 32 or eq c 92 or eq c 38 or eq c 37 eq c 58 |
| 1762 | dieat erurl pos |
| 1763 | end |
| 1764 | if eq c 46 |
| 1765 | if lt add cnt 1 size |
| 1766 | if eq og add add pos cnt 1 46 |
| 1767 | dieat erurl pos |
| 1768 | end |
| 1769 | end |
| 1770 | end |
| 1771 | put pb add n cnt c |
| 1772 | cnt = add cnt 1 |
| 1773 | end |
| 1774 | put st PBL add n cnt |
| 1775 | if eq get pb sub add n cnt 1 47 |
| 1776 | pbadd tindex |
| 1777 | end |
| 1778 | ret cnt |
| 1779 | end |
| 1780 | |
| 1781 | fn linkchk pos ulong size ulong cnt ulong to void |
| 1782 | p = readlnk pb 0 sg PBL sy 0 1024 |
| 1783 | if ne p -22 |
| 1784 | dieat erlink pos |
| 1785 | end |
| 1786 | fd = fopen pb 0 sg PBL 34816 0 |
| 1787 | if lt fd 0 |
| 1788 | dieat erlink pos |
| 1789 | end |
| 1790 | r = fclose int fd |
| 1791 | if lt cnt size |
| 1792 | if eq og add pos cnt 35 |
| 1793 | fragfile add add pos cnt 1 sub sub size cnt 1 pos |
| 1794 | end |
| 1795 | end |
| 1796 | end |
| 1797 | |
| 1798 | fn localurl pos ulong size ulong to void |
| 1799 | c = og pos |
| 1800 | if eq c 35 |
| 1801 | if eq sg LCHK 1 |
| 1802 | fragself add pos 1 sub size 1 pos |
| 1803 | end |
| 1804 | ret |
| 1805 | end |
| 1806 | if ne c 47 |
| 1807 | dieat erurl pos |
| 1808 | end |
| 1809 | if gt size 1 |
| 1810 | if eq og add pos 1 47 |
| 1811 | dieat erurl pos |
| 1812 | end |
| 1813 | end |
| 1814 | cnt = urlpath pos size |
| 1815 | if eq sg LCHK 1 |
| 1816 | linkchk pos size cnt |
| 1817 | end |
| 1818 | end |
| 1819 | |
| 1820 | fn checkurl pos ulong size ulong ext bool to void |
| 1821 | if or eq size 0 gt size 768 |
| 1822 | dieat erurl pos |
| 1823 | end |
| 1824 | if ext |
| 1825 | if omatch pos thttps |
| 1826 | if le size len thttps |
| 1827 | dieat erurl pos |
| 1828 | end |
| 1829 | ret |
| 1830 | end |
| 1831 | end |
| 1832 | localurl pos size |
| 1833 | end |
| 1834 | |
| 1835 | fn ownbase pos ulong to bool |
| 1836 | note the value starts with the current site's own address |
| 1837 | if eq sg SITE 0 |
| 1838 | ret omatch pos tbase0 |
| 1839 | end |
| 1840 | ret omatch pos tbase1 |
| 1841 | end |
| 1842 | |
| 1843 | fn attrurl start ulong size ulong as ulong az ulong to void |
| 1844 | note resource attributes take local targets only |
| 1845 | if or otoken as az tasrc otoken as az taposter |
| 1846 | checkurl start size false |
| 1847 | end |
| 1848 | if or otoken as az tabackg otoken as az taxhref |
| 1849 | checkurl start size false |
| 1850 | end |
| 1851 | end |
| 1852 | |
| 1853 | fn hrefurl start ulong size ulong tp ulong tz ulong to void |
| 1854 | note a link may leave the site; a link element may name only this site; anything else is local |
| 1855 | ext = otoken tp tz tga |
| 1856 | if otoken tp tz tglink |
| 1857 | ext = ownbase start |
| 1858 | end |
| 1859 | checkurl start size ext |
| 1860 | end |
| 1861 | |
| 1862 | fn attrval pos ulong as ulong az ulong tp ulong tz ulong to ulong |
| 1863 | i = skipsp pos |
| 1864 | n = sg OBN |
| 1865 | if ge i n |
| 1866 | dieat erattr pos |
| 1867 | end |
| 1868 | if ne og i 61 |
| 1869 | if boolattr as az |
| 1870 | ret pos |
| 1871 | end |
| 1872 | dieat erattr as |
| 1873 | end |
| 1874 | i = skipsp add i 1 |
| 1875 | if ge i n |
| 1876 | dieat erattr as |
| 1877 | end |
| 1878 | q = og i |
| 1879 | if not or eq q 34 eq q 39 |
| 1880 | dieat erattr as |
| 1881 | end |
| 1882 | start = add i 1 |
| 1883 | i = start |
| 1884 | while lt i n bound 16777216 |
| 1885 | if eq og i q |
| 1886 | break |
| 1887 | end |
| 1888 | if eq og i 60 |
| 1889 | dieat erattr as |
| 1890 | end |
| 1891 | i = add i 1 |
| 1892 | end |
| 1893 | if ge i n |
| 1894 | dieat erattr as |
| 1895 | end |
| 1896 | size = sub i start |
| 1897 | attrurl start size as az |
| 1898 | if otoken as az tahref |
| 1899 | hrefurl start size tp tz |
| 1900 | end |
| 1901 | ret add i 1 |
| 1902 | end |
| 1903 | |
| 1904 | fn starttag pos ulong to ulong |
| 1905 | n = sg OBN |
| 1906 | i = pos |
| 1907 | while lt i n bound 16777216 |
| 1908 | if not namechar og i |
| 1909 | break |
| 1910 | end |
| 1911 | i = add i 1 |
| 1912 | end |
| 1913 | sz = sub i pos |
| 1914 | if eq sz 0 |
| 1915 | dieat ermark pos |
| 1916 | end |
| 1917 | if badtag pos sz |
| 1918 | dieat ermark pos |
| 1919 | end |
| 1920 | while lt i n bound 16777216 |
| 1921 | c = og i |
| 1922 | if eq c 62 |
| 1923 | ret add i 1 |
| 1924 | end |
| 1925 | if eq c 47 |
| 1926 | i = add i 1 |
| 1927 | if lt i n |
| 1928 | if eq og i 62 |
| 1929 | ret add i 1 |
| 1930 | end |
| 1931 | end |
| 1932 | dieat ermark pos |
| 1933 | end |
| 1934 | if not space c |
| 1935 | dieat erattr i |
| 1936 | end |
| 1937 | i = skipsp i |
| 1938 | if ge i n |
| 1939 | dieat ermark pos |
| 1940 | end |
| 1941 | c2 = og i |
| 1942 | if or eq c2 62 eq c2 47 |
| 1943 | continue |
| 1944 | end |
| 1945 | as = i |
| 1946 | while lt i n bound 16777216 |
| 1947 | if not namechar og i |
| 1948 | break |
| 1949 | end |
| 1950 | i = add i 1 |
| 1951 | end |
| 1952 | az = sub i as |
| 1953 | if eq az 0 |
| 1954 | dieat erattr as |
| 1955 | end |
| 1956 | if badattr as az |
| 1957 | dieat erattr as |
| 1958 | end |
| 1959 | i = attrval i as az pos sz |
| 1960 | end |
| 1961 | dieat ermark pos |
| 1962 | ret i |
| 1963 | end |
| 1964 | |
| 1965 | fn endtag pos ulong to ulong |
| 1966 | n = sg OBN |
| 1967 | i = pos |
| 1968 | while lt i n bound 16777216 |
| 1969 | if not namechar og i |
| 1970 | break |
| 1971 | end |
| 1972 | i = add i 1 |
| 1973 | end |
| 1974 | if eq i pos |
| 1975 | dieat ermark pos |
| 1976 | end |
| 1977 | if badtag pos sub i pos |
| 1978 | dieat ermark pos |
| 1979 | end |
| 1980 | i = skipsp i |
| 1981 | if ge i n |
| 1982 | dieat ermark pos |
| 1983 | end |
| 1984 | if ne og i 62 |
| 1985 | dieat ermark pos |
| 1986 | end |
| 1987 | ret add i 1 |
| 1988 | end |
| 1989 | |
| 1990 | fn chkhead to void |
| 1991 | if not and ohas tdoctype and ohas thtmlo and ohas thtmle and ohas theade and ohas tbodyo ohas tbodye |
| 1992 | die erhtml |
| 1993 | end |
| 1994 | if not and ohas ttitleo ohas ttitlee |
| 1995 | die erhtml |
| 1996 | end |
| 1997 | if le ofind 0 ttitlee add ofind 0 ttitleo len ttitleo |
| 1998 | die erhtml |
| 1999 | end |
| 2000 | if not and ohas trelst ohas tstylea |
| 2001 | die erhtml |
| 2002 | end |
| 2003 | note every Sovereign Intelligence in the document, head and body, carries the trade mark sign |
| 2004 | n = sg OBN |
| 2005 | p = ofind 0 psi |
| 2006 | while lt p n bound 100000 |
| 2007 | if not omatch add p len psi ptrade |
| 2008 | dieat ertm p |
| 2009 | end |
| 2010 | p = ofind add p 1 psi |
| 2011 | end |
| 2012 | end |
| 2013 | |
| 2014 | fn tmtext to void |
| 2015 | note llms.txt is plain text: every Sovereign Intelligence is followed by (TM) |
| 2016 | n = sg OBN |
| 2017 | p = ofind 0 psi |
| 2018 | while lt p n bound 100000 |
| 2019 | if not omatch add p len psi ptml |
| 2020 | dieat ertm p |
| 2021 | end |
| 2022 | p = ofind add p 1 psi |
| 2023 | end |
| 2024 | end |
| 2025 | |
| 2026 | fn isvoid pos ulong sz ulong to bool |
| 2027 | note an HTML element that never has an end tag |
| 2028 | if or otoken pos sz vtmeta or otoken pos sz vtlink or otoken pos sz vtbr otoken pos sz vtimg |
| 2029 | ret true |
| 2030 | end |
| 2031 | if or otoken pos sz vthr or otoken pos sz vtwbr or otoken pos sz vtinput or otoken pos sz vtsource otoken pos sz vtcol |
| 2032 | ret true |
| 2033 | end |
| 2034 | ret false |
| 2035 | end |
| 2036 | |
| 2037 | fn namelen pos ulong to ulong |
| 2038 | n = sg OBN |
| 2039 | i = pos |
| 2040 | while lt i n bound 16777216 |
| 2041 | if not namechar og i |
| 2042 | break |
| 2043 | end |
| 2044 | i = add i 1 |
| 2045 | end |
| 2046 | ret sub i pos |
| 2047 | end |
| 2048 | |
| 2049 | fn nopen pos ulong after ulong to void |
| 2050 | note a start tag at obuf pos that ended at after: push it unless it is void or closes itself |
| 2051 | sz = namelen pos |
| 2052 | if isvoid pos sz |
| 2053 | ret |
| 2054 | end |
| 2055 | if ge after 2 |
| 2056 | if eq og sub after 2 47 |
| 2057 | ret |
| 2058 | end |
| 2059 | end |
| 2060 | d = sg NSD |
| 2061 | if ge d 120 |
| 2062 | dieat ernest pos |
| 2063 | end |
| 2064 | put nst mul d 2 pos |
| 2065 | put nst add mul d 2 1 sz |
| 2066 | put st NSD add d 1 |
| 2067 | end |
| 2068 | |
| 2069 | fn nclose pos ulong to void |
| 2070 | note an end tag at obuf pos: it must close the element opened last |
| 2071 | sz = namelen pos |
| 2072 | d = sg NSD |
| 2073 | if eq d 0 |
| 2074 | dieat ernest pos |
| 2075 | end |
| 2076 | d = sub d 1 |
| 2077 | op = get nst mul d 2 |
| 2078 | if ne get nst add mul d 2 1 sz |
| 2079 | dieat ernest pos |
| 2080 | end |
| 2081 | for j ulong sz bound 64 |
| 2082 | if ne low og add op j low og add pos j |
| 2083 | dieat ernest pos |
| 2084 | end |
| 2085 | end |
| 2086 | put st NSD d |
| 2087 | end |
| 2088 | |
| 2089 | fn chkmark html bool to void |
| 2090 | if html |
| 2091 | chkhead |
| 2092 | end |
| 2093 | put st NSD 0 |
| 2094 | n = sg OBN |
| 2095 | i = ulong 0 |
| 2096 | while lt i n bound 16777216 |
| 2097 | if eq og i 60 |
| 2098 | if omatch i tcmo |
| 2099 | i = ofind i tcme |
| 2100 | if ge i n |
| 2101 | die ermark |
| 2102 | end |
| 2103 | i = add i len tcme |
| 2104 | continue |
| 2105 | end |
| 2106 | if omatch i tdoctype |
| 2107 | if not html |
| 2108 | dieat ermark i |
| 2109 | end |
| 2110 | i = add i len tdoctype |
| 2111 | continue |
| 2112 | end |
| 2113 | i = add i 1 |
| 2114 | if ge i n |
| 2115 | die ermark |
| 2116 | end |
| 2117 | if eq og i 47 |
| 2118 | t0 = add i 1 |
| 2119 | i = endtag t0 |
| 2120 | nclose t0 |
| 2121 | else |
| 2122 | t1 = i |
| 2123 | i = starttag t1 |
| 2124 | nopen t1 i |
| 2125 | end |
| 2126 | else |
| 2127 | i = add i 1 |
| 2128 | end |
| 2129 | end |
| 2130 | if ne sg NSD 0 |
| 2131 | d = sub sg NSD 1 |
| 2132 | dieat ernest get nst mul d 2 |
| 2133 | end |
| 2134 | end |
| 2135 | |
| 2136 | fn cssban pat view uchar * to void |
| 2137 | p = ofind 0 pat |
| 2138 | if lt p sg OBN |
| 2139 | dieat ercss p |
| 2140 | end |
| 2141 | end |
| 2142 | |
| 2143 | fn cssbehav to void |
| 2144 | note the old behavior property is refused; scroll-behavior is an ordinary property |
| 2145 | n = sg OBN |
| 2146 | p = ofind 0 cbehav |
| 2147 | while lt p n bound 100000 |
| 2148 | if eq p 0 |
| 2149 | dieat ercss p |
| 2150 | end |
| 2151 | if ne og sub p 1 45 |
| 2152 | dieat ercss p |
| 2153 | end |
| 2154 | p = ofind add p 1 cbehav |
| 2155 | end |
| 2156 | end |
| 2157 | |
| 2158 | fn chkcss to void |
| 2159 | cssban cimport |
| 2160 | cssban chttp |
| 2161 | cssban cjs |
| 2162 | cssban cmoz |
| 2163 | cssban cexpr |
| 2164 | cssban cimgset |
| 2165 | cssban cproto |
| 2166 | cssurl |
| 2167 | cssban crgb |
| 2168 | cssban crgba |
| 2169 | cssban chsl |
| 2170 | cssban chsla |
| 2171 | cssbehav |
| 2172 | if not omatch 0 croot |
| 2173 | die ercss |
| 2174 | end |
| 2175 | n = sg OBN |
| 2176 | seen = false |
| 2177 | for j ulong n bound 16777216 |
| 2178 | c = og j |
| 2179 | if eq c 92 |
| 2180 | dieat ercss j |
| 2181 | end |
| 2182 | if eq c 125 |
| 2183 | seen = true |
| 2184 | end |
| 2185 | if eq c 35 |
| 2186 | if seen |
| 2187 | dieat ercss j |
| 2188 | end |
| 2189 | end |
| 2190 | end |
| 2191 | end |
| 2192 | |
| 2193 | fn obeqm p ulong e ulong mo ulong ml ulong to bool |
| 2194 | note obuf p..e equals the arena bytes mo..mo+ml |
| 2195 | if ne sub e p ml |
| 2196 | ret false |
| 2197 | end |
| 2198 | for j ulong ml bound 4096 |
| 2199 | if ne og add p j mg add mo j |
| 2200 | ret false |
| 2201 | end |
| 2202 | end |
| 2203 | ret true |
| 2204 | end |
| 2205 | |
| 2206 | fn urlstop c uchar to bool |
| 2207 | note a byte that ends a URL in plain text |
| 2208 | if or le c 32 or eq c 41 or eq c 62 eq c 60 |
| 2209 | ret true |
| 2210 | end |
| 2211 | ret or eq c 34 or eq c 39 or eq c 35 or eq c 63 eq c 44 |
| 2212 | end |
| 2213 | |
| 2214 | fn isroute p ulong e ulong to bool |
| 2215 | note obuf p..e is the route (without its leading slash) of an enabled interplane.io entry |
| 2216 | nr = sg NR |
| 2217 | r = ulong 0 |
| 2218 | while lt r nr bound RTCAP |
| 2219 | b = mul r 8 |
| 2220 | if eq rg add b 1 0 |
| 2221 | if enabled r |
| 2222 | if obeqm p e add rg add b 2 1 sub rg add b 3 1 |
| 2223 | ret true |
| 2224 | end |
| 2225 | end |
| 2226 | end |
| 2227 | r = add r 1 |
| 2228 | end |
| 2229 | ret false |
| 2230 | end |
| 2231 | |
| 2232 | fn llmspath p ulong e ulong to bool |
| 2233 | if eq p e |
| 2234 | ret true |
| 2235 | end |
| 2236 | if isroute p e |
| 2237 | ret true |
| 2238 | end |
| 2239 | size = sub e p |
| 2240 | if or otoken p size fsitemap or otoken p size lexplore or otoken p size lexplorej otoken p size lowner |
| 2241 | ret true |
| 2242 | end |
| 2243 | if omatch p lownerp |
| 2244 | ret true |
| 2245 | end |
| 2246 | if eq sg FRC 1 |
| 2247 | if or otoken p size lledger omatch p lpayp |
| 2248 | ret true |
| 2249 | end |
| 2250 | end |
| 2251 | ret false |
| 2252 | end |
| 2253 | |
| 2254 | fn llmspage r ulong to bool |
| 2255 | note the address of page route r is in obuf, ended by a URL stop byte |
| 2256 | b = mul r 8 |
| 2257 | ro = add rg add b 2 1 |
| 2258 | rl = sub rg add b 3 1 |
| 2259 | n = sg OBN |
| 2260 | i = ofind 0 tbase0 |
| 2261 | while lt i n bound 100000 |
| 2262 | p = add i len tbase0 |
| 2263 | e = add p rl |
| 2264 | if le e n |
| 2265 | if obeqm p e ro rl |
| 2266 | if eq e n |
| 2267 | ret true |
| 2268 | end |
| 2269 | if urlstop og e |
| 2270 | ret true |
| 2271 | end |
| 2272 | end |
| 2273 | end |
| 2274 | i = ofind add i 1 tbase0 |
| 2275 | end |
| 2276 | ret false |
| 2277 | end |
| 2278 | |
| 2279 | fn llmschk to void |
| 2280 | note every interplane.io address in obuf is real, and every enabled page is listed |
| 2281 | n = sg OBN |
| 2282 | i = ofind 0 tbase0 |
| 2283 | while lt i n bound 100000 |
| 2284 | p = add i len tbase0 |
| 2285 | e = p |
| 2286 | while lt e n bound 4096 |
| 2287 | if urlstop og e |
| 2288 | break |
| 2289 | end |
| 2290 | e = add e 1 |
| 2291 | end |
| 2292 | if not llmspath p e |
| 2293 | dieat erllms i |
| 2294 | end |
| 2295 | i = ofind add i 1 tbase0 |
| 2296 | end |
| 2297 | nr = sg NR |
| 2298 | r = ulong 0 |
| 2299 | while lt r nr bound RTCAP |
| 2300 | b = mul r 8 |
| 2301 | if and or eq rg b 1 eq rg b 7 eq rg add b 1 0 |
| 2302 | if enabled r |
| 2303 | if not llmspage r |
| 2304 | put st CXO rg add b 2 |
| 2305 | put st CXL rg add b 3 |
| 2306 | die erllmp |
| 2307 | end |
| 2308 | end |
| 2309 | end |
| 2310 | r = add r 1 |
| 2311 | end |
| 2312 | end |
| 2313 | |
| 2314 | fn lint kind ulong to void |
| 2315 | if eq kind 5 |
| 2316 | polscan false |
| 2317 | ret |
| 2318 | end |
| 2319 | if eq kind 8 |
| 2320 | chkfont |
| 2321 | ret |
| 2322 | end |
| 2323 | if eq kind 9 |
| 2324 | chkpng |
| 2325 | ret |
| 2326 | end |
| 2327 | if eq kind 11 |
| 2328 | if lt sg OBN 18 |
| 2329 | die ergzip |
| 2330 | end |
| 2331 | if not and eq og 0 31 and eq og 1 139 eq og 2 8 |
| 2332 | die ergzip |
| 2333 | end |
| 2334 | ret |
| 2335 | end |
| 2336 | polscan true |
| 2337 | if eq kind 1 |
| 2338 | chkmark true |
| 2339 | chklang |
| 2340 | trcheck |
| 2341 | end |
| 2342 | if eq kind 2 |
| 2343 | chkcss |
| 2344 | end |
| 2345 | if eq kind 3 |
| 2346 | chkmark false |
| 2347 | end |
| 2348 | if eq kind 6 |
| 2349 | llmschk |
| 2350 | tmtext |
| 2351 | end |
| 2352 | end |
| 2353 | |
| 2354 | fn chkfont to void |
| 2355 | note a font route holds an OpenType file with CFF outlines: it starts with the tag OTTO |
| 2356 | if lt sg OBN 12 |
| 2357 | die erfont |
| 2358 | end |
| 2359 | if not and and eq og 0 79 eq og 1 84 and eq og 2 84 eq og 3 79 |
| 2360 | die erfont |
| 2361 | end |
| 2362 | end |
| 2363 | |
| 2364 | fn chkpng to void |
| 2365 | note a png route holds a PNG image: it starts with the signature 137 80 78 71 13 10 26 10 |
| 2366 | if lt sg OBN 8 |
| 2367 | die erpng |
| 2368 | end |
| 2369 | if not and and eq og 0 137 eq og 1 80 and eq og 2 78 eq og 3 71 |
| 2370 | die erpng |
| 2371 | end |
| 2372 | if not and and eq og 4 13 eq og 5 10 and eq og 6 26 eq og 7 10 |
| 2373 | die erpng |
| 2374 | end |
| 2375 | end |
| 2376 | |
| 2377 | fn isfont p ulong e ulong to bool |
| 2378 | note obuf p..e is the route (without its leading slash) of an enabled font route of the site in work |
| 2379 | nr = sg NR |
| 2380 | site = sg SITE |
| 2381 | r = ulong 0 |
| 2382 | while lt r nr bound RTCAP |
| 2383 | b = mul r 8 |
| 2384 | if and eq rg b 8 eq rg add b 1 site |
| 2385 | if enabled r |
| 2386 | if obeqm p e add rg add b 2 1 sub rg add b 3 1 |
| 2387 | ret true |
| 2388 | end |
| 2389 | end |
| 2390 | end |
| 2391 | r = add r 1 |
| 2392 | end |
| 2393 | ret false |
| 2394 | end |
| 2395 | |
| 2396 | fn cssurl to void |
| 2397 | note url() may name only a font route of the same site: url(/public/fonts/NAME.otf) |
| 2398 | n = sg OBN |
| 2399 | p = ofind 0 curl |
| 2400 | while lt p n bound 100000 |
| 2401 | q = add p len curl |
| 2402 | e = q |
| 2403 | while lt e n bound 512 |
| 2404 | if not inset og e 7 |
| 2405 | break |
| 2406 | end |
| 2407 | e = add e 1 |
| 2408 | end |
| 2409 | if ge e n |
| 2410 | dieat ercss p |
| 2411 | end |
| 2412 | if ne og e 41 |
| 2413 | dieat ercss p |
| 2414 | end |
| 2415 | if not omatch q tfonts |
| 2416 | dieat ercss p |
| 2417 | end |
| 2418 | if not isfont add q 1 e |
| 2419 | dieat ercss p |
| 2420 | end |
| 2421 | p = ofind add p 1 curl |
| 2422 | end |
| 2423 | end |
| 2424 | |
| 2425 | note ---- button contrast (WCAG 2.1 relative luminance), integer arithmetic over a Wolfram table |
| 2426 | |
| 2427 | fn hexv c uchar to ulong |
| 2428 | d = low c |
| 2429 | if and ge d 48 le d 57 |
| 2430 | ret ulong sub d 48 |
| 2431 | end |
| 2432 | if and ge d 97 le d 102 |
| 2433 | ret ulong sub d 87 |
| 2434 | end |
| 2435 | ret 99 |
| 2436 | end |
| 2437 | |
| 2438 | fn ishex6 pos ulong to bool |
| 2439 | if gt add pos 6 sg OBN |
| 2440 | ret false |
| 2441 | end |
| 2442 | for j ulong 6 |
| 2443 | if eq hexv og add pos j 99 |
| 2444 | ret false |
| 2445 | end |
| 2446 | end |
| 2447 | ret true |
| 2448 | end |
| 2449 | |
| 2450 | fn chan pos ulong to ulong |
| 2451 | ret add mul hexv og pos 16 hexv og add pos 1 |
| 2452 | end |
| 2453 | |
| 2454 | fn lumat pos ulong to ulong |
| 2455 | note relative luminance x 1e13 of the colour whose six hex digits start at obuf pos |
| 2456 | r = get lum chan pos |
| 2457 | g = get lum chan add pos 2 |
| 2458 | b = get lum chan add pos 4 |
| 2459 | ret add add mul 2126 r mul 7152 g mul 722 b |
| 2460 | end |
| 2461 | |
| 2462 | fn obcmp a ulong b ulong n ulong to bool |
| 2463 | for j ulong n bound 4096 |
| 2464 | if ne og add a j og add b j |
| 2465 | ret false |
| 2466 | end |
| 2467 | end |
| 2468 | ret true |
| 2469 | end |
| 2470 | |
| 2471 | fn inkval i ulong pl ulong rbe ulong to ulong |
| 2472 | note position of the six hex digits of the -ink token whose prefix is obuf i..i+pl; 0 when missing |
| 2473 | j = ulong 0 |
| 2474 | while le add add j pl 12 rbe bound 1048576 |
| 2475 | if obcmp j i pl |
| 2476 | if omatch add j pl cink |
| 2477 | if ishex6 add add j pl len cink |
| 2478 | ret add add j pl len cink |
| 2479 | end |
| 2480 | end |
| 2481 | end |
| 2482 | j = add j 1 |
| 2483 | end |
| 2484 | ret 0 |
| 2485 | end |
| 2486 | |
| 2487 | fn saychan pos ulong to void |
| 2488 | sayn chan pos |
| 2489 | say tsp |
| 2490 | sayn chan add pos 2 |
| 2491 | say tsp |
| 2492 | sayn chan add pos 4 |
| 2493 | end |
| 2494 | |
| 2495 | fn saylin pos ulong to void |
| 2496 | sayn get lum chan pos |
| 2497 | say tsp |
| 2498 | sayn get lum chan add pos 2 |
| 2499 | say tsp |
| 2500 | sayn get lum chan add pos 4 |
| 2501 | end |
| 2502 | |
| 2503 | fn showpair i ulong e ulong bp ulong ip ulong to bool |
| 2504 | note prints the arithmetic for one background token (name obuf i..e, digits at bp) and its text colour |
| 2505 | lb = lumat bp |
| 2506 | li = lumat ip |
| 2507 | hi = add lb 500000000000 |
| 2508 | lo = add li 500000000000 |
| 2509 | if lt hi lo |
| 2510 | t = hi |
| 2511 | hi = lo |
| 2512 | lo = t |
| 2513 | end |
| 2514 | say mc1 |
| 2515 | sayob i sub e i |
| 2516 | say tsp |
| 2517 | say thash |
| 2518 | sayob bp 6 |
| 2519 | say mc2 |
| 2520 | say thash |
| 2521 | sayob ip 6 |
| 2522 | say mc3 |
| 2523 | saychan bp |
| 2524 | say mc4 |
| 2525 | saychan ip |
| 2526 | say mc5 |
| 2527 | saylin bp |
| 2528 | say mc4 |
| 2529 | saylin ip |
| 2530 | say mc6 |
| 2531 | sayn lb |
| 2532 | say mc4 |
| 2533 | sayn li |
| 2534 | say mc7 |
| 2535 | q = div mul hi 100 lo |
| 2536 | sayn div q 100 |
| 2537 | say tdot |
| 2538 | sayn div rem q 100 10 |
| 2539 | sayn rem q 10 |
| 2540 | say mc8 |
| 2541 | pass = ge mul hi 2 mul lo 9 |
| 2542 | if pass |
| 2543 | say mcpass |
| 2544 | else |
| 2545 | say mcfail |
| 2546 | end |
| 2547 | ret pass |
| 2548 | end |
| 2549 | |
| 2550 | fn btnrole i ulong e ulong to ulong |
| 2551 | note length of the role suffix of the token name obuf i..e: 3 for -bg, 6 for -hover, else 0 |
| 2552 | if gt sub e i 9 |
| 2553 | if omatch sub e 3 csbg |
| 2554 | ret 3 |
| 2555 | end |
| 2556 | if omatch sub e 6 cshov |
| 2557 | ret 6 |
| 2558 | end |
| 2559 | if omatch sub e 6 cspress |
| 2560 | ret 6 |
| 2561 | end |
| 2562 | end |
| 2563 | ret 0 |
| 2564 | end |
| 2565 | |
| 2566 | fn contrast to void |
| 2567 | note obuf holds the stylesheet; every --btn-NAME-bg, --btn-NAME-hover and --btn-NAME-press is checked against --btn-NAME-ink |
| 2568 | rbe = ofind 0 tcbrace |
| 2569 | pairs = ulong 0 |
| 2570 | bad = ulong 0 |
| 2571 | i = len croot |
| 2572 | while lt i rbe bound 1048576 |
| 2573 | if omatch i cbtn |
| 2574 | p = og sub i 1 |
| 2575 | if or eq p 59 eq p 123 |
| 2576 | e = i |
| 2577 | while lt e rbe bound 256 |
| 2578 | if eq og e 58 |
| 2579 | break |
| 2580 | end |
| 2581 | e = add e 1 |
| 2582 | end |
| 2583 | role = btnrole i e |
| 2584 | if gt role 0 |
| 2585 | ip = inkval i sub sub e i role rbe |
| 2586 | ok = false |
| 2587 | if gt ip 0 |
| 2588 | if eq og add e 1 35 |
| 2589 | if ishex6 add e 2 |
| 2590 | t = og add e 8 |
| 2591 | if or eq t 59 eq t 125 |
| 2592 | ok = showpair i e add e 2 ip |
| 2593 | end |
| 2594 | end |
| 2595 | end |
| 2596 | end |
| 2597 | pairs = add pairs 1 |
| 2598 | if not ok |
| 2599 | bad = add bad 1 |
| 2600 | end |
| 2601 | end |
| 2602 | end |
| 2603 | end |
| 2604 | i = add i 1 |
| 2605 | end |
| 2606 | say mcsum |
| 2607 | sayn pairs |
| 2608 | say tnl |
| 2609 | if or eq pairs 0 gt bad 0 |
| 2610 | die ercon |
| 2611 | end |
| 2612 | end |
| 2613 | |
| 2614 | |
| 2615 | fn luminit to void |
| 2616 | put lum 0 0 |
| 2617 | put lum 1 303527 |
| 2618 | put lum 2 607054 |
| 2619 | put lum 3 910581 |
| 2620 | put lum 4 1214108 |
| 2621 | put lum 5 1517635 |
| 2622 | put lum 6 1821162 |
| 2623 | put lum 7 2124689 |
| 2624 | put lum 8 2428216 |
| 2625 | put lum 9 2731743 |
| 2626 | put lum 10 3035270 |
| 2627 | put lum 11 3346536 |
| 2628 | put lum 12 3676507 |
| 2629 | put lum 13 4024717 |
| 2630 | put lum 14 4391442 |
| 2631 | put lum 15 4776953 |
| 2632 | put lum 16 5181517 |
| 2633 | put lum 17 5605392 |
| 2634 | put lum 18 6048833 |
| 2635 | put lum 19 6512091 |
| 2636 | put lum 20 6995410 |
| 2637 | put lum 21 7499032 |
| 2638 | put lum 22 8023193 |
| 2639 | put lum 23 8568126 |
| 2640 | put lum 24 9134059 |
| 2641 | put lum 25 9721217 |
| 2642 | put lum 26 10329823 |
| 2643 | put lum 27 10960094 |
| 2644 | put lum 28 11612245 |
| 2645 | put lum 29 12286488 |
| 2646 | put lum 30 12983032 |
| 2647 | put lum 31 13702083 |
| 2648 | put lum 32 14443844 |
| 2649 | put lum 33 15208514 |
| 2650 | put lum 34 15996293 |
| 2651 | put lum 35 16807376 |
| 2652 | put lum 36 17641954 |
| 2653 | put lum 37 18500220 |
| 2654 | put lum 38 19382361 |
| 2655 | put lum 39 20288563 |
| 2656 | put lum 40 21219010 |
| 2657 | put lum 41 22173885 |
| 2658 | put lum 42 23153366 |
| 2659 | put lum 43 24157632 |
| 2660 | put lum 44 25186860 |
| 2661 | put lum 45 26241222 |
| 2662 | put lum 46 27320892 |
| 2663 | put lum 47 28426040 |
| 2664 | put lum 48 29556834 |
| 2665 | put lum 49 30713444 |
| 2666 | put lum 50 31896033 |
| 2667 | put lum 51 33104767 |
| 2668 | put lum 52 34339807 |
| 2669 | put lum 53 35601315 |
| 2670 | put lum 54 36889450 |
| 2671 | put lum 55 38204372 |
| 2672 | put lum 56 39546235 |
| 2673 | put lum 57 40915197 |
| 2674 | put lum 58 42311411 |
| 2675 | put lum 59 43735029 |
| 2676 | put lum 60 45186204 |
| 2677 | put lum 61 46665086 |
| 2678 | put lum 62 48171824 |
| 2679 | put lum 63 49706566 |
| 2680 | put lum 64 51269458 |
| 2681 | put lum 65 52860647 |
| 2682 | put lum 66 54480276 |
| 2683 | put lum 67 56128490 |
| 2684 | put lum 68 57805430 |
| 2685 | put lum 69 59511238 |
| 2686 | put lum 70 61246054 |
| 2687 | put lum 71 63010018 |
| 2688 | put lum 72 64803267 |
| 2689 | put lum 73 66625939 |
| 2690 | put lum 74 68478170 |
| 2691 | put lum 75 70360096 |
| 2692 | put lum 76 72271851 |
| 2693 | put lum 77 74213568 |
| 2694 | put lum 78 76185381 |
| 2695 | put lum 79 78187422 |
| 2696 | put lum 80 80219820 |
| 2697 | put lum 81 82282707 |
| 2698 | put lum 82 84376212 |
| 2699 | put lum 83 86500462 |
| 2700 | put lum 84 88655586 |
| 2701 | put lum 85 90841711 |
| 2702 | put lum 86 93058963 |
| 2703 | put lum 87 95307467 |
| 2704 | put lum 88 97587347 |
| 2705 | put lum 89 99898728 |
| 2706 | put lum 90 102241733 |
| 2707 | put lum 91 104616484 |
| 2708 | put lum 92 107023103 |
| 2709 | put lum 93 109461711 |
| 2710 | put lum 94 111932428 |
| 2711 | put lum 95 114435374 |
| 2712 | put lum 96 116970668 |
| 2713 | put lum 97 119538428 |
| 2714 | put lum 98 122138772 |
| 2715 | put lum 99 124771818 |
| 2716 | put lum 100 127437680 |
| 2717 | put lum 101 130136477 |
| 2718 | put lum 102 132868322 |
| 2719 | put lum 103 135633330 |
| 2720 | put lum 104 138431615 |
| 2721 | put lum 105 141263291 |
| 2722 | put lum 106 144128471 |
| 2723 | put lum 107 147027266 |
| 2724 | put lum 108 149959790 |
| 2725 | put lum 109 152926152 |
| 2726 | put lum 110 155926464 |
| 2727 | put lum 111 158960835 |
| 2728 | put lum 112 162029376 |
| 2729 | put lum 113 165132195 |
| 2730 | put lum 114 168269400 |
| 2731 | put lum 115 171441101 |
| 2732 | put lum 116 174647404 |
| 2733 | put lum 117 177888416 |
| 2734 | put lum 118 181164244 |
| 2735 | put lum 119 184474995 |
| 2736 | put lum 120 187820772 |
| 2737 | put lum 121 191201683 |
| 2738 | put lum 122 194617830 |
| 2739 | put lum 123 198069320 |
| 2740 | put lum 124 201556254 |
| 2741 | put lum 125 205078736 |
| 2742 | put lum 126 208636870 |
| 2743 | put lum 127 212230757 |
| 2744 | put lum 128 215860500 |
| 2745 | put lum 129 219526200 |
| 2746 | put lum 130 223227957 |
| 2747 | put lum 131 226965874 |
| 2748 | put lum 132 230740049 |
| 2749 | put lum 133 234550582 |
| 2750 | put lum 134 238397574 |
| 2751 | put lum 135 242281122 |
| 2752 | put lum 136 246201327 |
| 2753 | put lum 137 250158285 |
| 2754 | put lum 138 254152094 |
| 2755 | put lum 139 258182853 |
| 2756 | put lum 140 262250658 |
| 2757 | put lum 141 266355605 |
| 2758 | put lum 142 270497791 |
| 2759 | put lum 143 274677312 |
| 2760 | put lum 144 278894263 |
| 2761 | put lum 145 283148740 |
| 2762 | put lum 146 287440838 |
| 2763 | put lum 147 291770650 |
| 2764 | put lum 148 296138271 |
| 2765 | put lum 149 300543794 |
| 2766 | put lum 150 304987314 |
| 2767 | put lum 151 309468923 |
| 2768 | put lum 152 313988713 |
| 2769 | put lum 153 318546778 |
| 2770 | put lum 154 323143209 |
| 2771 | put lum 155 327778098 |
| 2772 | put lum 156 332451536 |
| 2773 | put lum 157 337163615 |
| 2774 | put lum 158 341914425 |
| 2775 | put lum 159 346704056 |
| 2776 | put lum 160 351532600 |
| 2777 | put lum 161 356400144 |
| 2778 | put lum 162 361306780 |
| 2779 | put lum 163 366252596 |
| 2780 | put lum 164 371237680 |
| 2781 | put lum 165 376262123 |
| 2782 | put lum 166 381326011 |
| 2783 | put lum 167 386429434 |
| 2784 | put lum 168 391572478 |
| 2785 | put lum 169 396755231 |
| 2786 | put lum 170 401977780 |
| 2787 | put lum 171 407240212 |
| 2788 | put lum 172 412542613 |
| 2789 | put lum 173 417885071 |
| 2790 | put lum 174 423267670 |
| 2791 | put lum 175 428690497 |
| 2792 | put lum 176 434153636 |
| 2793 | put lum 177 439657174 |
| 2794 | put lum 178 445201195 |
| 2795 | put lum 179 450785783 |
| 2796 | put lum 180 456411023 |
| 2797 | put lum 181 462077000 |
| 2798 | put lum 182 467783796 |
| 2799 | put lum 183 473531496 |
| 2800 | put lum 184 479320183 |
| 2801 | put lum 185 485149940 |
| 2802 | put lum 186 491020850 |
| 2803 | put lum 187 496932995 |
| 2804 | put lum 188 502886458 |
| 2805 | put lum 189 508881321 |
| 2806 | put lum 190 514917665 |
| 2807 | put lum 191 520995573 |
| 2808 | put lum 192 527115126 |
| 2809 | put lum 193 533276404 |
| 2810 | put lum 194 539479489 |
| 2811 | put lum 195 545724461 |
| 2812 | put lum 196 552011402 |
| 2813 | put lum 197 558340390 |
| 2814 | put lum 198 564711506 |
| 2815 | put lum 199 571124829 |
| 2816 | put lum 200 577580440 |
| 2817 | put lum 201 584078418 |
| 2818 | put lum 202 590618841 |
| 2819 | put lum 203 597201788 |
| 2820 | put lum 204 603827339 |
| 2821 | put lum 205 610495571 |
| 2822 | put lum 206 617206562 |
| 2823 | put lum 207 623960392 |
| 2824 | put lum 208 630757136 |
| 2825 | put lum 209 637596874 |
| 2826 | put lum 210 644479682 |
| 2827 | put lum 211 651405637 |
| 2828 | put lum 212 658374817 |
| 2829 | put lum 213 665387298 |
| 2830 | put lum 214 672443157 |
| 2831 | put lum 215 679542470 |
| 2832 | put lum 216 686685312 |
| 2833 | put lum 217 693871761 |
| 2834 | put lum 218 701101892 |
| 2835 | put lum 219 708375780 |
| 2836 | put lum 220 715693501 |
| 2837 | put lum 221 723055129 |
| 2838 | put lum 222 730460740 |
| 2839 | put lum 223 737910409 |
| 2840 | put lum 224 745404210 |
| 2841 | put lum 225 752942217 |
| 2842 | put lum 226 760524505 |
| 2843 | put lum 227 768151147 |
| 2844 | put lum 228 775822218 |
| 2845 | put lum 229 783537792 |
| 2846 | put lum 230 791297940 |
| 2847 | put lum 231 799102738 |
| 2848 | put lum 232 806952258 |
| 2849 | put lum 233 814846572 |
| 2850 | put lum 234 822785754 |
| 2851 | put lum 235 830769877 |
| 2852 | put lum 236 838799012 |
| 2853 | put lum 237 846873232 |
| 2854 | put lum 238 854992608 |
| 2855 | put lum 239 863157213 |
| 2856 | put lum 240 871367119 |
| 2857 | put lum 241 879622397 |
| 2858 | put lum 242 887923118 |
| 2859 | put lum 243 896269353 |
| 2860 | put lum 244 904661174 |
| 2861 | put lum 245 913098652 |
| 2862 | put lum 246 921581856 |
| 2863 | put lum 247 930110858 |
| 2864 | put lum 248 938685728 |
| 2865 | put lum 249 947306537 |
| 2866 | put lum 250 955973353 |
| 2867 | put lum 251 964686248 |
| 2868 | put lum 252 973445290 |
| 2869 | put lum 253 982250550 |
| 2870 | put lum 254 991102097 |
| 2871 | put lum 255 1000000000 |
| 2872 | end |
| 2873 | |
| 2874 | fn cssload to void |
| 2875 | note obuf = public/style.css |
| 2876 | mark = sg TOP |
| 2877 | pbset fcss |
| 2878 | off = slurp |
| 2879 | put st OBN 0 |
| 2880 | om off sg FLEN |
| 2881 | put st TOP mark |
| 2882 | end |
| 2883 | |
| 2884 | note ---- the yard: content/yard.snapshot.tsv, a snapshot of the public project registry |
| 2885 | |
| 2886 | fn yardrow to void |
| 2887 | note fb holds name, rid, branch, head, recorded time of one snapshot row; the rid is checked, not printed |
| 2888 | ot y1 |
| 2889 | om sg OWNO sg OWNL |
| 2890 | ob 47 |
| 2891 | om fg 0 sub fg 1 fg 0 |
| 2892 | ot y2 |
| 2893 | om fg 0 sub fg 1 fg 0 |
| 2894 | ot y4 |
| 2895 | om fg 6 8 |
| 2896 | ot y5 |
| 2897 | om fg 8 10 |
| 2898 | ot y6 |
| 2899 | end |
| 2900 | |
| 2901 | fn yardok to bool |
| 2902 | if not okset fg 0 fg 1 1 |
| 2903 | ret false |
| 2904 | end |
| 2905 | if not okset fg 2 fg 3 4 |
| 2906 | ret false |
| 2907 | end |
| 2908 | if not okset fg 4 fg 5 1 |
| 2909 | ret false |
| 2910 | end |
| 2911 | if ne sub fg 7 fg 6 40 |
| 2912 | ret false |
| 2913 | end |
| 2914 | if not okset fg 6 fg 7 2 |
| 2915 | ret false |
| 2916 | end |
| 2917 | if ne sub fg 9 fg 8 20 |
| 2918 | ret false |
| 2919 | end |
| 2920 | ret okset fg 8 fg 9 3 |
| 2921 | end |
| 2922 | |
| 2923 | fn yardscan off ulong lim ulong to ulong |
| 2924 | note emits the rows of the snapshot at arena off..lim into obuf and returns how many |
| 2925 | count = ulong 0 |
| 2926 | i = off |
| 2927 | while lt i lim bound 100000 |
| 2928 | e = eol i lim |
| 2929 | if gt e i |
| 2930 | if ne mg i 35 |
| 2931 | nf = split i e 9 |
| 2932 | if eq nf 2 |
| 2933 | if fbis 0 kasof |
| 2934 | if not okset fg 2 fg 3 3 |
| 2935 | die eryard |
| 2936 | end |
| 2937 | setv vyasof fg 2 sub fg 3 fg 2 |
| 2938 | else |
| 2939 | if not fbis 0 kowner |
| 2940 | die eryard |
| 2941 | end |
| 2942 | if not okset fg 2 fg 3 1 |
| 2943 | die eryard |
| 2944 | end |
| 2945 | put st OWNO fg 2 |
| 2946 | put st OWNL sub fg 3 fg 2 |
| 2947 | end |
| 2948 | else |
| 2949 | if or ne nf 5 eq sg OWNL 0 |
| 2950 | die eryard |
| 2951 | end |
| 2952 | if not yardok |
| 2953 | die eryard |
| 2954 | end |
| 2955 | yardrow |
| 2956 | count = add count 1 |
| 2957 | end |
| 2958 | end |
| 2959 | end |
| 2960 | i = add e 1 |
| 2961 | end |
| 2962 | ret count |
| 2963 | end |
| 2964 | |
| 2965 | fn yard to void |
| 2966 | pbset fyard |
| 2967 | put st CXO keep fyard |
| 2968 | put st CXL len fyard |
| 2969 | off = slurp |
| 2970 | n = sg FLEN |
| 2971 | hashm off n |
| 2972 | ho = hxkeep |
| 2973 | setv vysha ho 64 |
| 2974 | say myard |
| 2975 | lim = add off n |
| 2976 | put st OBN 0 |
| 2977 | count = yardscan off lim |
| 2978 | if or eq count 0 not vset vyasof |
| 2979 | die eryard |
| 2980 | end |
| 2981 | ro = stash |
| 2982 | setv vyrows ro sg FLEN |
| 2983 | onum count |
| 2984 | co = stash |
| 2985 | setv vycount co sg FLEN |
| 2986 | sayn count |
| 2987 | say mysha |
| 2988 | sayhx |
| 2989 | say tnl |
| 2990 | end |
| 2991 | |
| 2992 | note ---- papers: content/papers.snapshot holds the Zenodo records of one ORCID iD, written by |
| 2993 | note scripts/fetch-papers.sh; content/papers.sources names the papers whose source is an Interplane |
| 2994 | note project. Header lines: orcid, fetched, response (one or more, numbered from 1), records. Then one |
| 2995 | note block per record, newest first, fields in this order: record concept title date type [version] |
| 2996 | note license creator.. orcid_attached file.. [related..]. The builder reads files only; no network. |
| 2997 | note Record table pr, 32 slots per record: 0,1 DOI; 2,3 concept DOI; 4,5 title; 6 date; 8,9 type; |
| 2998 | note 10,11 version (length 0: none); 12,13 licence; 14 ORCID attached; 16,17 block start and end; |
| 2999 | note 18,19 Interplane source address (length 0: none). Pairs are arena offset and length. |
| 3000 | |
| 3001 | text fpapers "content/papers.snapshot" |
| 3002 | text fpsrc "content/papers.sources" |
| 3003 | text erpap "content/papers.snapshot has a missing, unknown, out-of-order or malformed line" |
| 3004 | text erpdoi "content/papers.snapshot: a DOI must be 10.5281/zenodo. followed by digits" |
| 3005 | text erptit "content/papers.snapshot: a record has no title" |
| 3006 | text erpesc "content/papers.snapshot: an escaped character that the builder cannot write" |
| 3007 | text erpord "content/papers.snapshot: records must run newest first, as many as the records line says" |
| 3008 | text erpsrc "content/papers.sources: a line must name a record of the snapshot, an interplane.io address and the checksum of one of that record's files" |
| 3009 | text erpdup "content/papers.snapshot: a record DOI or a concept DOI appears twice" |
| 3010 | text kprec "record" |
| 3011 | text kpcon "concept" |
| 3012 | text kptit "title" |
| 3013 | text kpdate "date" |
| 3014 | text kptype "type" |
| 3015 | text kpver "version" |
| 3016 | text kplic "license" |
| 3017 | text kpcre "creator" |
| 3018 | text kpatt "orcid_attached" |
| 3019 | text kpfile "file" |
| 3020 | text kprel "related" |
| 3021 | text kporc "orcid" |
| 3022 | text kpfet "fetched" |
| 3023 | text kpresp "response" |
| 3024 | text kprecs "records" |
| 3025 | text kpsrc "source" |
| 3026 | text tnone "none" |
| 3027 | text tdoipre "10.5281/zenodo." |
| 3028 | text tmd5 "md5:" |
| 3029 | text tsha2 "sha256:" |
| 3030 | text tescom "u03a9" |
| 3031 | text tomega "Omega" |
| 3032 | text tmonths "janfebmaraprmayjunjulaugsepoctnovdec" |
| 3033 | text vprows "papers.rows" |
| 3034 | text vpcount "papers.count" |
| 3035 | text vpasof "papers.asof" |
| 3036 | text vporcid "papers.orcid" |
| 3037 | text vpsha "papers.sha256" |
| 3038 | text vpnsrc "papers.sources" |
| 3039 | text vpjson "papers.json" |
| 3040 | text vpbib "papers.bib" |
| 3041 | text mpap "papers: records " |
| 3042 | text mpsrc " sources " |
| 3043 | text ph1 "<li class=\"paper\" id=\"zenodo-" |
| 3044 | text ph2 "\"><h2 class=\"paper-title\">" |
| 3045 | text ph3 "</h2>\n<p class=\"paper-meta\">" |
| 3046 | text pmid " · " |
| 3047 | text pverw "version " |
| 3048 | text plicw "licence " |
| 3049 | text ph4 "</p>\n<p class=\"paper-links\"><a href=\"https://doi.org/" |
| 3050 | text ph5 "\">DOI " |
| 3051 | text ph6 "</a> <a href=\"https://doi.org/" |
| 3052 | text ph7 "\">Version history, " |
| 3053 | text ph7b "</a>" |
| 3054 | text ph8 " <a href=\"" |
| 3055 | text ph9 "\">Source on Interplane for " |
| 3056 | text ph10 "</p>\n<ul class=\"paper-files\">\n" |
| 3057 | text ph11 "</ul></li>\n" |
| 3058 | text pf1 "<li><span class=\"mono\">" |
| 3059 | text pf2 "</span> " |
| 3060 | text pf3 " bytes, <span class=\"mono\">" |
| 3061 | text pf4 "</span></li>\n" |
| 3062 | text pomega "Ω" |
| 3063 | text pj1 "{\n \"source\": \"https://zenodo.org/api/records\",\n \"orcid\": \"" |
| 3064 | text pj2 "\",\n \"fetched\": \"" |
| 3065 | text pj3 "\",\n \"snapshot_sha256\": \"" |
| 3066 | text pj4 "\",\n \"responses\": [" |
| 3067 | text pj5 "],\n \"count\": " |
| 3068 | text pj6 ",\n \"papers\": [\n" |
| 3069 | text pj7 "\n ]\n}\n" |
| 3070 | text pjr1 "{\"page\": " |
| 3071 | text pjr2 ", \"sha256\": \"" |
| 3072 | text pjr3 "\"}" |
| 3073 | text jr1 " {\n \"doi\": \"" |
| 3074 | text jr2 "\",\n \"doi_url\": \"https://doi.org/" |
| 3075 | text jr3 "\",\n \"concept_doi\": \"" |
| 3076 | text jr4 "\",\n \"concept_doi_url\": \"https://doi.org/" |
| 3077 | text jr5 "\",\n \"title\": \"" |
| 3078 | text jr6 "\",\n \"date\": \"" |
| 3079 | text jr7 "\",\n \"type\": \"" |
| 3080 | text jr8 "\",\n \"version\": " |
| 3081 | text jr9 ",\n \"license\": \"" |
| 3082 | text jr10 "\",\n \"creators\": [" |
| 3083 | text jr11 "],\n \"orcid_attached\": " |
| 3084 | text jr12 ",\n \"source_on_interplane\": " |
| 3085 | text jr13 ",\n \"files\": [\n" |
| 3086 | text jr14 "\n ],\n \"related\": [" |
| 3087 | text jr15 "]\n }" |
| 3088 | text jrnl "\n " |
| 3089 | text jsep ",\n" |
| 3090 | text jnull "null" |
| 3091 | text jtrue "true" |
| 3092 | text jfalse "false" |
| 3093 | text jc1 "{\"name\": \"" |
| 3094 | text jc2 "\", \"orcid\": " |
| 3095 | text jf1 " {\"name\": \"" |
| 3096 | text jf2 "\", \"size\": " |
| 3097 | text jf3 ", \"checksum\": \"" |
| 3098 | text jq2 "\"}" |
| 3099 | text jrl1 "\n {\"relation\": \"" |
| 3100 | text jrl2 "\", \"scheme\": \"" |
| 3101 | text jrl3 "\", \"identifier\": \"" |
| 3102 | text pbh1 "% Papers of ORCID iD " |
| 3103 | text pbh2 ", copied from Zenodo on " |
| 3104 | text pbh3 ".\n% Generated from content/papers.snapshot by the interplane.io builder.\n" |
| 3105 | text bb1 "\n@misc{zenodo" |
| 3106 | text bb2 ",\n author = {" |
| 3107 | text bb3 "},\n title = \"{" |
| 3108 | text bb4 "}\",\n howpublished = {Zenodo},\n year = {" |
| 3109 | text bb5 "},\n month = " |
| 3110 | text bb6 ",\n date = {" |
| 3111 | text bb7 "},\n" |
| 3112 | text bb8 " version = {" |
| 3113 | text bb10 " doi = {" |
| 3114 | text bb11 "},\n url = {https://doi.org/" |
| 3115 | text bb12 "},\n note = {" |
| 3116 | text bb13 ". Licence " |
| 3117 | text bb14 ". Version history: doi " |
| 3118 | text bb15 "}\n}\n" |
| 3119 | text band " and " |
| 3120 | text btilde "textasciitilde{}" |
| 3121 | text bcaret "textasciicircum{}" |
| 3122 | |
| 3123 | fn pg k ulong to ulong |
| 3124 | ret get pr k |
| 3125 | end |
| 3126 | |
| 3127 | fn kvsp s ulong e ulong to ulong |
| 3128 | note the first space in arena s..e, or e when there is none |
| 3129 | i = s |
| 3130 | while lt i e bound 16777216 |
| 3131 | if eq mg i 32 |
| 3132 | ret i |
| 3133 | end |
| 3134 | i = add i 1 |
| 3135 | end |
| 3136 | ret e |
| 3137 | end |
| 3138 | |
| 3139 | fn vstart k ulong e ulong to ulong |
| 3140 | note the value after the key that ends at k |
| 3141 | if lt k e |
| 3142 | ret add k 1 |
| 3143 | end |
| 3144 | ret e |
| 3145 | end |
| 3146 | |
| 3147 | fn pkey s ulong n ulong to ulong |
| 3148 | note record fields 1..11 in their order, header keys 21..24, 0 for an unknown key |
| 3149 | if mist s n kprec |
| 3150 | ret 1 |
| 3151 | end |
| 3152 | if mist s n kpcon |
| 3153 | ret 2 |
| 3154 | end |
| 3155 | if mist s n kptit |
| 3156 | ret 3 |
| 3157 | end |
| 3158 | if mist s n kpdate |
| 3159 | ret 4 |
| 3160 | end |
| 3161 | if mist s n kptype |
| 3162 | ret 5 |
| 3163 | end |
| 3164 | if mist s n kpver |
| 3165 | ret 6 |
| 3166 | end |
| 3167 | if mist s n kplic |
| 3168 | ret 7 |
| 3169 | end |
| 3170 | if mist s n kpcre |
| 3171 | ret 8 |
| 3172 | end |
| 3173 | if mist s n kpatt |
| 3174 | ret 9 |
| 3175 | end |
| 3176 | if mist s n kpfile |
| 3177 | ret 10 |
| 3178 | end |
| 3179 | if mist s n kprel |
| 3180 | ret 11 |
| 3181 | end |
| 3182 | if mist s n kporc |
| 3183 | ret 21 |
| 3184 | end |
| 3185 | if mist s n kpfet |
| 3186 | ret 22 |
| 3187 | end |
| 3188 | if mist s n kpresp |
| 3189 | ret 23 |
| 3190 | end |
| 3191 | if mist s n kprecs |
| 3192 | ret 24 |
| 3193 | end |
| 3194 | ret 0 |
| 3195 | end |
| 3196 | |
| 3197 | fn digok s ulong e ulong max ulong to bool |
| 3198 | note 1 to max decimal digits without a leading zero |
| 3199 | if or ge s e gt sub e s max |
| 3200 | ret false |
| 3201 | end |
| 3202 | if and eq mg s 48 gt sub e s 1 |
| 3203 | ret false |
| 3204 | end |
| 3205 | ret okset s e 5 |
| 3206 | end |
| 3207 | |
| 3208 | fn doiok s ulong e ulong to bool |
| 3209 | note 10.5281/zenodo. and 1 to 12 digits |
| 3210 | if le e s |
| 3211 | ret false |
| 3212 | end |
| 3213 | if le sub e s len tdoipre |
| 3214 | ret false |
| 3215 | end |
| 3216 | if not mistf s tdoipre false |
| 3217 | ret false |
| 3218 | end |
| 3219 | ret digok add s len tdoipre e 12 |
| 3220 | end |
| 3221 | |
| 3222 | fn orcidok s ulong e ulong to bool |
| 3223 | note four groups of four digits joined by hyphens; the last character may be X |
| 3224 | if ne sub e s 19 |
| 3225 | ret false |
| 3226 | end |
| 3227 | for i ulong 19 |
| 3228 | c = mg add s i |
| 3229 | if or eq i 4 or eq i 9 eq i 14 |
| 3230 | if ne c 45 |
| 3231 | ret false |
| 3232 | end |
| 3233 | else |
| 3234 | if or lt c 48 gt c 57 |
| 3235 | if not and eq i 18 eq c 88 |
| 3236 | ret false |
| 3237 | end |
| 3238 | end |
| 3239 | end |
| 3240 | end |
| 3241 | ret true |
| 3242 | end |
| 3243 | |
| 3244 | fn ymdok s ulong e ulong to bool |
| 3245 | note arena s..e is YYYY-MM-DD and names a real day |
| 3246 | if ne sub e s 10 |
| 3247 | ret false |
| 3248 | end |
| 3249 | for i ulong 10 |
| 3250 | c = mg add s i |
| 3251 | if or eq i 4 eq i 7 |
| 3252 | if ne c 45 |
| 3253 | ret false |
| 3254 | end |
| 3255 | else |
| 3256 | if or lt c 48 gt c 57 |
| 3257 | ret false |
| 3258 | end |
| 3259 | end |
| 3260 | end |
| 3261 | m = l2 add s 5 |
| 3262 | if or lt m 1 gt m 12 |
| 3263 | ret false |
| 3264 | end |
| 3265 | d = l2 add s 8 |
| 3266 | y = add mul l2 s 100 l2 add s 2 |
| 3267 | ret and ge d 1 le d ldim y m |
| 3268 | end |
| 3269 | |
| 3270 | fn sumok s ulong e ulong to bool |
| 3271 | note md5: and 32 lowercase hex digits, or sha256: and 64 |
| 3272 | n = sub e s |
| 3273 | if mistf s tmd5 false |
| 3274 | if eq n add len tmd5 32 |
| 3275 | ret okset add s len tmd5 e 2 |
| 3276 | end |
| 3277 | ret false |
| 3278 | end |
| 3279 | if mistf s tsha2 false |
| 3280 | if eq n add len tsha2 64 |
| 3281 | ret okset add s len tsha2 e 2 |
| 3282 | end |
| 3283 | end |
| 3284 | ret false |
| 3285 | end |
| 3286 | |
| 3287 | fn dgt a ulong c ulong to bool |
| 3288 | note the date at arena a is later than the date at arena c (both YYYY-MM-DD) |
| 3289 | for j ulong 10 |
| 3290 | x = mg add a j |
| 3291 | y = mg add c j |
| 3292 | if gt x y |
| 3293 | ret true |
| 3294 | end |
| 3295 | if lt x y |
| 3296 | ret false |
| 3297 | end |
| 3298 | end |
| 3299 | ret false |
| 3300 | end |
| 3301 | |
| 3302 | fn pescok p ulong e ulong to bool |
| 3303 | note the backslash at arena p starts the one escape the builder can write: u03a9, capital omega |
| 3304 | if gt add p 6 e |
| 3305 | ret false |
| 3306 | end |
| 3307 | ret mistf add p 1 tescom false |
| 3308 | end |
| 3309 | |
| 3310 | fn pchars s ulong e ulong max ulong to void |
| 3311 | note a text value: 1 to max printable bytes without markup bytes; a backslash only in a known escape |
| 3312 | if or ge s e gt sub e s max |
| 3313 | die erpap |
| 3314 | end |
| 3315 | i = s |
| 3316 | while lt i e bound 16777216 |
| 3317 | c = mg i |
| 3318 | if eq c 92 |
| 3319 | if not pescok i e |
| 3320 | die erpesc |
| 3321 | end |
| 3322 | i = add i 6 |
| 3323 | else |
| 3324 | if not inset c 6 |
| 3325 | die erpap |
| 3326 | end |
| 3327 | i = add i 1 |
| 3328 | end |
| 3329 | end |
| 3330 | end |
| 3331 | |
| 3332 | fn presp v ulong e ulong to void |
| 3333 | note response N sha256:HEX, numbered from 1 in order |
| 3334 | nf = split v e 32 |
| 3335 | if ne nf 2 |
| 3336 | die erpap |
| 3337 | end |
| 3338 | n = mnum fg 0 fg 1 |
| 3339 | if ne n add sg PNRESP 1 |
| 3340 | die erpap |
| 3341 | end |
| 3342 | a = fg 2 |
| 3343 | if not mistf a tsha2 false |
| 3344 | die erpap |
| 3345 | end |
| 3346 | if ne sub fg 3 a add len tsha2 64 |
| 3347 | die erpap |
| 3348 | end |
| 3349 | if not okset add a len tsha2 fg 3 2 |
| 3350 | die erpap |
| 3351 | end |
| 3352 | put st PNRESP n |
| 3353 | end |
| 3354 | |
| 3355 | fn phead f ulong v ulong e ulong to void |
| 3356 | note a header line, in the order orcid, fetched, response.., records |
| 3357 | p = sg PST |
| 3358 | ok = false |
| 3359 | if and eq f 21 eq p 0 |
| 3360 | ok = true |
| 3361 | end |
| 3362 | if and eq f 22 eq p 21 |
| 3363 | ok = true |
| 3364 | end |
| 3365 | if and eq f 23 or eq p 22 eq p 23 |
| 3366 | ok = true |
| 3367 | end |
| 3368 | if and eq f 24 eq p 23 |
| 3369 | ok = true |
| 3370 | end |
| 3371 | if or not ok gt sg PNR 0 |
| 3372 | die erpap |
| 3373 | end |
| 3374 | if eq f 21 |
| 3375 | if not orcidok v e |
| 3376 | die erpap |
| 3377 | end |
| 3378 | put st POO v |
| 3379 | end |
| 3380 | if eq f 22 |
| 3381 | if not ymdok v e |
| 3382 | die erpap |
| 3383 | end |
| 3384 | put st PFO v |
| 3385 | end |
| 3386 | if eq f 23 |
| 3387 | presp v e |
| 3388 | end |
| 3389 | if eq f 24 |
| 3390 | n = mnum v e |
| 3391 | if or eq n 0 gt n 64 |
| 3392 | die erpap |
| 3393 | end |
| 3394 | put st PDECL n |
| 3395 | end |
| 3396 | put st PST f |
| 3397 | end |
| 3398 | |
| 3399 | fn pclose e ulong to void |
| 3400 | note ends the open record at arena e: it is complete and not newer than the record before it |
| 3401 | n = sg PNR |
| 3402 | p = sg PST |
| 3403 | if eq p 2 |
| 3404 | die erptit |
| 3405 | end |
| 3406 | if lt p 10 |
| 3407 | die erpap |
| 3408 | end |
| 3409 | b = mul sub n 1 32 |
| 3410 | put pr add b 17 e |
| 3411 | if ge n 2 |
| 3412 | if dgt pg add b 6 pg sub add b 6 32 |
| 3413 | die erpord |
| 3414 | end |
| 3415 | end |
| 3416 | end |
| 3417 | |
| 3418 | fn pnew s ulong v ulong e ulong to void |
| 3419 | note a record line: closes the record before it and opens the next slot of pr |
| 3420 | n = sg PNR |
| 3421 | if eq n 0 |
| 3422 | if ne sg PST 24 |
| 3423 | die erpap |
| 3424 | end |
| 3425 | put st PHE s |
| 3426 | else |
| 3427 | pclose s |
| 3428 | end |
| 3429 | if ge n 64 |
| 3430 | die erpap |
| 3431 | end |
| 3432 | if not doiok v e |
| 3433 | die erpdoi |
| 3434 | end |
| 3435 | if pseen n 0 v sub e v |
| 3436 | die erpdup |
| 3437 | end |
| 3438 | b = mul n 32 |
| 3439 | for j ulong 32 |
| 3440 | put pr add b j 0 |
| 3441 | end |
| 3442 | put pr b v |
| 3443 | put pr add b 1 sub e v |
| 3444 | put pr add b 16 s |
| 3445 | put st PNR add n 1 |
| 3446 | put st PST 1 |
| 3447 | put st PATT 0 |
| 3448 | end |
| 3449 | |
| 3450 | fn pnext p ulong f ulong to bool |
| 3451 | note field f may follow field p: the next one, version may be left out, and creator, file and |
| 3452 | note related may repeat |
| 3453 | if eq f add p 1 |
| 3454 | ret true |
| 3455 | end |
| 3456 | if and eq p 5 eq f 7 |
| 3457 | ret true |
| 3458 | end |
| 3459 | ret and eq f p or eq f 8 or eq f 10 eq f 11 |
| 3460 | end |
| 3461 | |
| 3462 | fn pcreat v ulong e ulong to void |
| 3463 | note creator ORCID-or-none NAME; the header's ORCID iD on a creator marks the record attached |
| 3464 | k = kvsp v e |
| 3465 | if ge k e |
| 3466 | die erpap |
| 3467 | end |
| 3468 | if not mist v sub k v tnone |
| 3469 | if not orcidok v k |
| 3470 | die erpap |
| 3471 | end |
| 3472 | if mcmp v sg POO 19 |
| 3473 | put st PATT 1 |
| 3474 | end |
| 3475 | end |
| 3476 | pchars add k 1 e 200 |
| 3477 | end |
| 3478 | |
| 3479 | fn patt v ulong e ulong to void |
| 3480 | note orcid_attached yes or no, in agreement with the creator lines |
| 3481 | b = mul sub sg PNR 1 32 |
| 3482 | want = sg PATT |
| 3483 | if mist v sub e v tyes |
| 3484 | if ne want 1 |
| 3485 | die erpap |
| 3486 | end |
| 3487 | put pr add b 14 1 |
| 3488 | ret |
| 3489 | end |
| 3490 | if not mist v sub e v tno |
| 3491 | die erpap |
| 3492 | end |
| 3493 | if ne want 0 |
| 3494 | die erpap |
| 3495 | end |
| 3496 | end |
| 3497 | |
| 3498 | fn pfiln v ulong e ulong to void |
| 3499 | note file NAME SIZE CHECKSUM |
| 3500 | nf = split v e 32 |
| 3501 | if ne nf 3 |
| 3502 | die erpap |
| 3503 | end |
| 3504 | if or not okset fg 0 fg 1 1 gt sub fg 1 fg 0 128 |
| 3505 | die erpap |
| 3506 | end |
| 3507 | if not digok fg 2 fg 3 12 |
| 3508 | die erpap |
| 3509 | end |
| 3510 | if not sumok fg 4 fg 5 |
| 3511 | die erpap |
| 3512 | end |
| 3513 | end |
| 3514 | |
| 3515 | fn prel v ulong e ulong to void |
| 3516 | note related RELATION SCHEME IDENTIFIER |
| 3517 | nf = split v e 32 |
| 3518 | if ne nf 3 |
| 3519 | die erpap |
| 3520 | end |
| 3521 | if or not okset fg 0 fg 1 1 gt sub fg 1 fg 0 40 |
| 3522 | die erpap |
| 3523 | end |
| 3524 | if or not okset fg 2 fg 3 1 gt sub fg 3 fg 2 20 |
| 3525 | die erpap |
| 3526 | end |
| 3527 | if or not okset fg 4 fg 5 7 gt sub fg 5 fg 4 300 |
| 3528 | die erpap |
| 3529 | end |
| 3530 | end |
| 3531 | |
| 3532 | fn pstore f ulong v ulong e ulong to void |
| 3533 | note checks the value of field f and records it in the open record |
| 3534 | b = mul sub sg PNR 1 32 |
| 3535 | if eq f 2 |
| 3536 | if not doiok v e |
| 3537 | die erpdoi |
| 3538 | end |
| 3539 | if pseen sub sg PNR 1 2 v sub e v |
| 3540 | die erpdup |
| 3541 | end |
| 3542 | put pr add b 2 v |
| 3543 | put pr add b 3 sub e v |
| 3544 | end |
| 3545 | if eq f 3 |
| 3546 | if ge v e |
| 3547 | die erptit |
| 3548 | end |
| 3549 | pchars v e 400 |
| 3550 | put pr add b 4 v |
| 3551 | put pr add b 5 sub e v |
| 3552 | end |
| 3553 | if eq f 4 |
| 3554 | if not ymdok v e |
| 3555 | die erpap |
| 3556 | end |
| 3557 | put pr add b 6 v |
| 3558 | end |
| 3559 | if eq f 5 |
| 3560 | pchars v e 80 |
| 3561 | put pr add b 8 v |
| 3562 | put pr add b 9 sub e v |
| 3563 | end |
| 3564 | if eq f 6 |
| 3565 | pchars v e 80 |
| 3566 | put pr add b 10 v |
| 3567 | put pr add b 11 sub e v |
| 3568 | end |
| 3569 | if eq f 7 |
| 3570 | if or not okset v e 1 gt sub e v 40 |
| 3571 | die erpap |
| 3572 | end |
| 3573 | put pr add b 12 v |
| 3574 | put pr add b 13 sub e v |
| 3575 | end |
| 3576 | if eq f 8 |
| 3577 | pcreat v e |
| 3578 | end |
| 3579 | if eq f 9 |
| 3580 | patt v e |
| 3581 | end |
| 3582 | if eq f 10 |
| 3583 | pfiln v e |
| 3584 | end |
| 3585 | if eq f 11 |
| 3586 | prel v e |
| 3587 | end |
| 3588 | end |
| 3589 | |
| 3590 | fn pfield f ulong v ulong e ulong to void |
| 3591 | note a record field: inside a record, in order; a record that skips its title is named as such |
| 3592 | if eq sg PNR 0 |
| 3593 | die erpap |
| 3594 | end |
| 3595 | p = sg PST |
| 3596 | if and eq p 2 ne f 3 |
| 3597 | die erptit |
| 3598 | end |
| 3599 | if not pnext p f |
| 3600 | die erpap |
| 3601 | end |
| 3602 | pstore f v e |
| 3603 | put st PST f |
| 3604 | end |
| 3605 | |
| 3606 | fn papline s ulong e ulong to void |
| 3607 | k = kvsp s e |
| 3608 | f = pkey s sub k s |
| 3609 | v = vstart k e |
| 3610 | if eq f 0 |
| 3611 | die erpap |
| 3612 | end |
| 3613 | if gt f 20 |
| 3614 | phead f v e |
| 3615 | ret |
| 3616 | end |
| 3617 | if eq f 1 |
| 3618 | pnew s v e |
| 3619 | ret |
| 3620 | end |
| 3621 | pfield f v e |
| 3622 | end |
| 3623 | |
| 3624 | fn pseen n ulong k ulong v ulong l ulong to bool |
| 3625 | note one of the first n records holds arena v..v+l in slot pair k (0 record DOI, 2 concept DOI) |
| 3626 | for r ulong n bound 64 |
| 3627 | b = mul r 32 |
| 3628 | if eq pg add b add k 1 l |
| 3629 | if mcmp pg add b k v l |
| 3630 | ret true |
| 3631 | end |
| 3632 | end |
| 3633 | end |
| 3634 | ret false |
| 3635 | end |
| 3636 | |
| 3637 | fn pfind co ulong cl ulong to ulong |
| 3638 | note 1 + the index of the record whose concept DOI is arena co..co+cl, 0 when there is none |
| 3639 | n = sg PNR |
| 3640 | for r ulong n bound 64 |
| 3641 | b = mul r 32 |
| 3642 | if eq pg add b 3 cl |
| 3643 | if mcmp pg add b 2 co cl |
| 3644 | ret add r 1 |
| 3645 | end |
| 3646 | end |
| 3647 | end |
| 3648 | ret 0 |
| 3649 | end |
| 3650 | |
| 3651 | fn psumin r ulong so ulong sl ulong to bool |
| 3652 | note record r lists a file whose checksum is arena so..so+sl |
| 3653 | b = mul r 32 |
| 3654 | lim = pg add b 17 |
| 3655 | i = pg add b 16 |
| 3656 | while lt i lim bound 16777216 |
| 3657 | e = eol i lim |
| 3658 | k = kvsp i e |
| 3659 | if mist i sub k i kpfile |
| 3660 | nf = split vstart k e e 32 |
| 3661 | if eq nf 3 |
| 3662 | if eq sub fg 5 fg 4 sl |
| 3663 | if mcmp fg 4 so sl |
| 3664 | ret true |
| 3665 | end |
| 3666 | end |
| 3667 | end |
| 3668 | end |
| 3669 | i = add e 1 |
| 3670 | end |
| 3671 | ret false |
| 3672 | end |
| 3673 | |
| 3674 | fn psrcline s ulong e ulong to void |
| 3675 | note source CONCEPT-DOI ADDRESS CHECKSUM |
| 3676 | nf = split s e 32 |
| 3677 | if or ne nf 4 not fbis 0 kpsrc |
| 3678 | die erpsrc |
| 3679 | end |
| 3680 | r = pfind fg 2 sub fg 3 fg 2 |
| 3681 | if eq r 0 |
| 3682 | die erpsrc |
| 3683 | end |
| 3684 | b = mul sub r 1 32 |
| 3685 | uo = fg 4 |
| 3686 | ul = sub fg 5 fg 4 |
| 3687 | so = fg 6 |
| 3688 | sl = sub fg 7 fg 6 |
| 3689 | if gt pg add b 19 0 |
| 3690 | die erpsrc |
| 3691 | end |
| 3692 | if or le ul len tbase0 gt ul 300 |
| 3693 | die erpsrc |
| 3694 | end |
| 3695 | if not mistf uo tbase0 false |
| 3696 | die erpsrc |
| 3697 | end |
| 3698 | if not okset uo add uo ul 7 |
| 3699 | die erpsrc |
| 3700 | end |
| 3701 | if not psumin sub r 1 so sl |
| 3702 | die erpsrc |
| 3703 | end |
| 3704 | put pr add b 18 uo |
| 3705 | put pr add b 19 ul |
| 3706 | put st PNSRC add sg PNSRC 1 |
| 3707 | end |
| 3708 | |
| 3709 | fn psources to void |
| 3710 | note content/papers.sources is optional: without it no paper has a source link |
| 3711 | put st PNSRC 0 |
| 3712 | pbset fpsrc |
| 3713 | if not isfile |
| 3714 | ret |
| 3715 | end |
| 3716 | put st CXO keep fpsrc |
| 3717 | put st CXL len fpsrc |
| 3718 | off = slurp |
| 3719 | lim = add off sg FLEN |
| 3720 | i = off |
| 3721 | while lt i lim bound 100000 |
| 3722 | e = eol i lim |
| 3723 | if gt e i |
| 3724 | if ne mg i 35 |
| 3725 | psrcline i e |
| 3726 | end |
| 3727 | end |
| 3728 | i = add e 1 |
| 3729 | end |
| 3730 | end |
| 3731 | |
| 3732 | fn obib c uchar to void |
| 3733 | note one byte of a BibTeX value; the special characters are escaped |
| 3734 | if or or eq c 37 eq c 36 or eq c 35 eq c 95 |
| 3735 | ob 92 |
| 3736 | ob c |
| 3737 | ret |
| 3738 | end |
| 3739 | if eq c 126 |
| 3740 | ob 92 |
| 3741 | ot btilde |
| 3742 | ret |
| 3743 | end |
| 3744 | if eq c 94 |
| 3745 | ob 92 |
| 3746 | ot bcaret |
| 3747 | ret |
| 3748 | end |
| 3749 | ob c |
| 3750 | end |
| 3751 | |
| 3752 | fn pesc m ulong to void |
| 3753 | note the escape u03a9, capital omega, in HTML (1), JSON (2) or BibTeX (3) |
| 3754 | if eq m 1 |
| 3755 | ot pomega |
| 3756 | ret |
| 3757 | end |
| 3758 | if eq m 3 |
| 3759 | ob 36 |
| 3760 | ob 92 |
| 3761 | ot tomega |
| 3762 | ob 36 |
| 3763 | ret |
| 3764 | end |
| 3765 | ob 92 |
| 3766 | ot tescom |
| 3767 | end |
| 3768 | |
| 3769 | fn ptx o ulong l ulong m ulong to void |
| 3770 | note writes a checked snapshot text value as HTML (1), JSON (2) or BibTeX (3) |
| 3771 | i = o |
| 3772 | lim = add o l |
| 3773 | while lt i lim bound 16777216 |
| 3774 | c = mg i |
| 3775 | if eq c 92 |
| 3776 | pesc m |
| 3777 | i = add i 6 |
| 3778 | else |
| 3779 | if eq m 1 |
| 3780 | oesc i 1 |
| 3781 | else |
| 3782 | if eq m 3 |
| 3783 | obib c |
| 3784 | else |
| 3785 | ob c |
| 3786 | end |
| 3787 | end |
| 3788 | i = add i 1 |
| 3789 | end |
| 3790 | end |
| 3791 | end |
| 3792 | |
| 3793 | fn plic o ulong l ulong to void |
| 3794 | note a licence id for reading: cc-by-4.0 is written CC BY 4.0 |
| 3795 | for j ulong l bound 64 |
| 3796 | c = mg add o j |
| 3797 | if eq c 45 |
| 3798 | ob 32 |
| 3799 | else |
| 3800 | if and ge c 97 le c 122 |
| 3801 | ob sub c 32 |
| 3802 | else |
| 3803 | ob c |
| 3804 | end |
| 3805 | end |
| 3806 | end |
| 3807 | end |
| 3808 | |
| 3809 | fn pver o ulong l ulong to void |
| 3810 | note a version that is a bare number reads "version 3"; a worded one such as "Revision 4" stays |
| 3811 | c = mg o |
| 3812 | if and ge c 48 le c 57 |
| 3813 | ot pverw |
| 3814 | end |
| 3815 | ptx o l 1 |
| 3816 | end |
| 3817 | |
| 3818 | fn onumg s ulong e ulong to void |
| 3819 | note the digits at arena s..e with a comma before each group of three from the right |
| 3820 | n = sub e s |
| 3821 | for j ulong n bound 16 |
| 3822 | if gt j 0 |
| 3823 | if eq rem sub n j 3 0 |
| 3824 | ob 44 |
| 3825 | end |
| 3826 | end |
| 3827 | ob mg add s j |
| 3828 | end |
| 3829 | end |
| 3830 | |
| 3831 | fn jcreat v ulong e ulong cnt ulong to void |
| 3832 | note one creator as a JSON object |
| 3833 | if gt cnt 0 |
| 3834 | ot tcomma |
| 3835 | end |
| 3836 | k = kvsp v e |
| 3837 | ot jc1 |
| 3838 | ptx add k 1 sub e add k 1 2 |
| 3839 | ot jc2 |
| 3840 | if mist v sub k v tnone |
| 3841 | ot jnull |
| 3842 | else |
| 3843 | ob 34 |
| 3844 | om v sub k v |
| 3845 | ob 34 |
| 3846 | end |
| 3847 | ob 125 |
| 3848 | end |
| 3849 | |
| 3850 | fn pitem v ulong e ulong m ulong cnt ulong to void |
| 3851 | note one creator, file or related line: 1 HTML file, 2 JSON creator, 3 JSON file, 4 JSON related, |
| 3852 | note 5 BibTeX author |
| 3853 | if eq m 2 |
| 3854 | jcreat v e cnt |
| 3855 | ret |
| 3856 | end |
| 3857 | if eq m 5 |
| 3858 | if gt cnt 0 |
| 3859 | ot band |
| 3860 | end |
| 3861 | k = kvsp v e |
| 3862 | ptx add k 1 sub e add k 1 3 |
| 3863 | ret |
| 3864 | end |
| 3865 | nf = split v e 32 |
| 3866 | if eq m 1 |
| 3867 | ot pf1 |
| 3868 | om fg 0 sub fg 1 fg 0 |
| 3869 | ot pf2 |
| 3870 | onumg fg 2 fg 3 |
| 3871 | ot pf3 |
| 3872 | om fg 4 sub fg 5 fg 4 |
| 3873 | ot pf4 |
| 3874 | ret |
| 3875 | end |
| 3876 | if eq m 3 |
| 3877 | if gt cnt 0 |
| 3878 | ot jsep |
| 3879 | end |
| 3880 | ot jf1 |
| 3881 | om fg 0 sub fg 1 fg 0 |
| 3882 | ot jf2 |
| 3883 | om fg 2 sub fg 3 fg 2 |
| 3884 | ot jf3 |
| 3885 | om fg 4 sub fg 5 fg 4 |
| 3886 | ot jq2 |
| 3887 | ret |
| 3888 | end |
| 3889 | if gt cnt 0 |
| 3890 | ob 44 |
| 3891 | end |
| 3892 | ot jrl1 |
| 3893 | om fg 0 sub fg 1 fg 0 |
| 3894 | ot jrl2 |
| 3895 | om fg 2 sub fg 3 fg 2 |
| 3896 | ot jrl3 |
| 3897 | om fg 4 sub fg 5 fg 4 |
| 3898 | ot jq2 |
| 3899 | end |
| 3900 | |
| 3901 | fn pwalk r ulong key view uchar * m ulong to ulong |
| 3902 | note pitem for each line of record r with this key; returns how many there were |
| 3903 | b = mul r 32 |
| 3904 | lim = pg add b 17 |
| 3905 | i = pg add b 16 |
| 3906 | cnt = ulong 0 |
| 3907 | while lt i lim bound 16777216 |
| 3908 | e = eol i lim |
| 3909 | k = kvsp i e |
| 3910 | if mist i sub k i key |
| 3911 | pitem vstart k e e m cnt |
| 3912 | cnt = add cnt 1 |
| 3913 | end |
| 3914 | i = add e 1 |
| 3915 | end |
| 3916 | ret cnt |
| 3917 | end |
| 3918 | |
| 3919 | fn prow r ulong to void |
| 3920 | note one entry of the papers page |
| 3921 | b = mul r 32 |
| 3922 | co = pg add b 2 |
| 3923 | cl = pg add b 3 |
| 3924 | ot ph1 |
| 3925 | om add co len tdoipre sub cl len tdoipre |
| 3926 | ot ph2 |
| 3927 | ptx pg add b 4 pg add b 5 1 |
| 3928 | ot ph3 |
| 3929 | om pg add b 6 10 |
| 3930 | ot pmid |
| 3931 | ptx pg add b 8 pg add b 9 1 |
| 3932 | if gt pg add b 11 0 |
| 3933 | ot pmid |
| 3934 | pver pg add b 10 pg add b 11 |
| 3935 | end |
| 3936 | ot pmid |
| 3937 | ot plicw |
| 3938 | plic pg add b 12 pg add b 13 |
| 3939 | ot ph4 |
| 3940 | om pg b pg add b 1 |
| 3941 | ot ph5 |
| 3942 | om pg b pg add b 1 |
| 3943 | ot ph6 |
| 3944 | om co cl |
| 3945 | ot ph7 |
| 3946 | om co cl |
| 3947 | ot ph7b |
| 3948 | if gt pg add b 19 0 |
| 3949 | ot ph8 |
| 3950 | om pg add b 18 pg add b 19 |
| 3951 | ot ph9 |
| 3952 | om co cl |
| 3953 | ot ph7b |
| 3954 | end |
| 3955 | ot ph10 |
| 3956 | x = pwalk r kpfile 1 |
| 3957 | ot ph11 |
| 3958 | end |
| 3959 | |
| 3960 | fn jopt o ulong l ulong to void |
| 3961 | note a JSON string, or null when the value is absent |
| 3962 | if eq l 0 |
| 3963 | ot jnull |
| 3964 | ret |
| 3965 | end |
| 3966 | ob 34 |
| 3967 | ptx o l 2 |
| 3968 | ob 34 |
| 3969 | end |
| 3970 | |
| 3971 | fn jrec r ulong to void |
| 3972 | note one record of papers.json |
| 3973 | b = mul r 32 |
| 3974 | ot jr1 |
| 3975 | om pg b pg add b 1 |
| 3976 | ot jr2 |
| 3977 | om pg b pg add b 1 |
| 3978 | ot jr3 |
| 3979 | om pg add b 2 pg add b 3 |
| 3980 | ot jr4 |
| 3981 | om pg add b 2 pg add b 3 |
| 3982 | ot jr5 |
| 3983 | ptx pg add b 4 pg add b 5 2 |
| 3984 | ot jr6 |
| 3985 | om pg add b 6 10 |
| 3986 | ot jr7 |
| 3987 | ptx pg add b 8 pg add b 9 2 |
| 3988 | ot jr8 |
| 3989 | jopt pg add b 10 pg add b 11 |
| 3990 | ot jr9 |
| 3991 | om pg add b 12 pg add b 13 |
| 3992 | ot jr10 |
| 3993 | x = pwalk r kpcre 2 |
| 3994 | ot jr11 |
| 3995 | if eq pg add b 14 1 |
| 3996 | ot jtrue |
| 3997 | else |
| 3998 | ot jfalse |
| 3999 | end |
| 4000 | ot jr12 |
| 4001 | jopt pg add b 18 pg add b 19 |
| 4002 | ot jr13 |
| 4003 | x = pwalk r kpfile 3 |
| 4004 | ot jr14 |
| 4005 | x = pwalk r kprel 4 |
| 4006 | if gt x 0 |
| 4007 | ot jrnl |
| 4008 | end |
| 4009 | ot jr15 |
| 4010 | end |
| 4011 | |
| 4012 | fn presps to void |
| 4013 | note the response lines of the snapshot header as JSON objects |
| 4014 | i = sg PSO |
| 4015 | lim = sg PHE |
| 4016 | cnt = ulong 0 |
| 4017 | while lt i lim bound 16777216 |
| 4018 | e = eol i lim |
| 4019 | k = kvsp i e |
| 4020 | if mist i sub k i kpresp |
| 4021 | nf = split add k 1 e 32 |
| 4022 | if gt cnt 0 |
| 4023 | ot tcomma |
| 4024 | end |
| 4025 | ot pjr1 |
| 4026 | om fg 0 sub fg 1 fg 0 |
| 4027 | ot pjr2 |
| 4028 | a = add fg 2 len tsha2 |
| 4029 | om a sub fg 3 a |
| 4030 | ot pjr3 |
| 4031 | cnt = add cnt 1 |
| 4032 | end |
| 4033 | i = add e 1 |
| 4034 | end |
| 4035 | end |
| 4036 | |
| 4037 | fn pjson to void |
| 4038 | note the placeholder papers.json: the snapshot as one JSON document |
| 4039 | put st OBN 0 |
| 4040 | ot pj1 |
| 4041 | om sg POO 19 |
| 4042 | ot pj2 |
| 4043 | om sg PFO 10 |
| 4044 | ot pj3 |
| 4045 | om sg PSHA 64 |
| 4046 | ot pj4 |
| 4047 | presps |
| 4048 | ot pj5 |
| 4049 | onum sg PNR |
| 4050 | ot pj6 |
| 4051 | n = sg PNR |
| 4052 | for r ulong n bound 64 |
| 4053 | if gt r 0 |
| 4054 | ot jsep |
| 4055 | end |
| 4056 | jrec r |
| 4057 | end |
| 4058 | ot pj7 |
| 4059 | o = stash |
| 4060 | setv vpjson o sg FLEN |
| 4061 | end |
| 4062 | |
| 4063 | fn brec r ulong to void |
| 4064 | note one BibTeX entry |
| 4065 | b = mul r 32 |
| 4066 | co = pg b |
| 4067 | cl = pg add b 1 |
| 4068 | d = pg add b 6 |
| 4069 | ot bb1 |
| 4070 | om add co len tdoipre sub cl len tdoipre |
| 4071 | ot bb2 |
| 4072 | x = pwalk r kpcre 5 |
| 4073 | ot bb3 |
| 4074 | ptx pg add b 4 pg add b 5 3 |
| 4075 | ot bb4 |
| 4076 | om d 4 |
| 4077 | ot bb5 |
| 4078 | m = l2 add d 5 |
| 4079 | for j ulong 3 |
| 4080 | ob get tmonths add mul sub m 1 3 j |
| 4081 | end |
| 4082 | ot bb6 |
| 4083 | om d 10 |
| 4084 | ot bb7 |
| 4085 | if gt pg add b 11 0 |
| 4086 | ot bb8 |
| 4087 | ptx pg add b 10 pg add b 11 3 |
| 4088 | ot bb7 |
| 4089 | end |
| 4090 | ot bb10 |
| 4091 | om co cl |
| 4092 | ot bb11 |
| 4093 | om co cl |
| 4094 | ot bb12 |
| 4095 | ptx pg add b 8 pg add b 9 3 |
| 4096 | ot bb13 |
| 4097 | ptx pg add b 12 pg add b 13 3 |
| 4098 | ot bb14 |
| 4099 | om pg add b 2 pg add b 3 |
| 4100 | ot bb15 |
| 4101 | end |
| 4102 | |
| 4103 | fn pbib to void |
| 4104 | note the placeholder papers.bib: one BibTeX entry per record |
| 4105 | put st OBN 0 |
| 4106 | ot pbh1 |
| 4107 | om sg POO 19 |
| 4108 | ot pbh2 |
| 4109 | om sg PFO 10 |
| 4110 | ot pbh3 |
| 4111 | n = sg PNR |
| 4112 | for r ulong n bound 64 |
| 4113 | brec r |
| 4114 | end |
| 4115 | o = stash |
| 4116 | setv vpbib o sg FLEN |
| 4117 | end |
| 4118 | |
| 4119 | fn phtml to void |
| 4120 | note the placeholder papers.rows: one list entry per record, in snapshot order |
| 4121 | put st OBN 0 |
| 4122 | n = sg PNR |
| 4123 | for r ulong n bound 64 |
| 4124 | prow r |
| 4125 | end |
| 4126 | o = stash |
| 4127 | setv vprows o sg FLEN |
| 4128 | end |
| 4129 | |
| 4130 | fn papers to void |
| 4131 | pbset fpapers |
| 4132 | put st CXO keep fpapers |
| 4133 | put st CXL len fpapers |
| 4134 | off = slurp |
| 4135 | n = sg FLEN |
| 4136 | hashm off n |
| 4137 | ho = hxkeep |
| 4138 | put st PSHA ho |
| 4139 | put st PSO off |
| 4140 | if eq sg TESTD 0 |
| 4141 | if mhas off n pfix true |
| 4142 | die errel |
| 4143 | end |
| 4144 | end |
| 4145 | put st PST 0 |
| 4146 | put st PNR 0 |
| 4147 | put st PNRESP 0 |
| 4148 | lim = add off n |
| 4149 | i = off |
| 4150 | while lt i lim bound 100000 |
| 4151 | e = eol i lim |
| 4152 | if gt e i |
| 4153 | if ne mg i 35 |
| 4154 | papline i e |
| 4155 | end |
| 4156 | end |
| 4157 | i = add e 1 |
| 4158 | end |
| 4159 | if eq sg PNR 0 |
| 4160 | die erpap |
| 4161 | end |
| 4162 | pclose lim |
| 4163 | if ne sg PNR sg PDECL |
| 4164 | die erpord |
| 4165 | end |
| 4166 | psources |
| 4167 | put st CXL 0 |
| 4168 | phtml |
| 4169 | pjson |
| 4170 | pbib |
| 4171 | onum sg PNR |
| 4172 | co = stash |
| 4173 | setv vpcount co sg FLEN |
| 4174 | setv vpasof sg PFO 10 |
| 4175 | setv vporcid sg POO 19 |
| 4176 | setv vpsha sg PSHA 64 |
| 4177 | onum sg PNSRC |
| 4178 | so = stash |
| 4179 | setv vpnsrc so sg FLEN |
| 4180 | say mpap |
| 4181 | sayn sg PNR |
| 4182 | say mpsrc |
| 4183 | sayn sg PNSRC |
| 4184 | say mysha |
| 4185 | saym sg PSHA 64 |
| 4186 | say tnl |
| 4187 | end |
| 4188 | |
| 4189 | note ---- receipts: the forge chain format (seq utc kind actor subject payload prev) |
| 4190 | |
| 4191 | fn l2 a ulong to ulong |
| 4192 | x = ulong mg a |
| 4193 | y = ulong mg add a 1 |
| 4194 | ret add mul sub x 48 10 sub y 48 |
| 4195 | end |
| 4196 | |
| 4197 | fn ldim y ulong m ulong to ulong |
| 4198 | if eq m 2 |
| 4199 | if and eq rem y 4 0 or ne rem y 100 0 eq rem y 400 0 |
| 4200 | ret 29 |
| 4201 | end |
| 4202 | ret 28 |
| 4203 | end |
| 4204 | if or or eq m 4 eq m 6 or eq m 9 eq m 11 |
| 4205 | ret 30 |
| 4206 | end |
| 4207 | ret 31 |
| 4208 | end |
| 4209 | |
| 4210 | fn utcok a ulong e ulong to bool |
| 4211 | note arena a..e is YYYY-MM-DDTHH:MM:SSZ and names a real date and time |
| 4212 | if ne sub e a 20 |
| 4213 | ret false |
| 4214 | end |
| 4215 | for i ulong 20 |
| 4216 | c = mg add a i |
| 4217 | w = uchar 0 |
| 4218 | if or eq i 4 eq i 7 |
| 4219 | w = 45 |
| 4220 | end |
| 4221 | if eq i 10 |
| 4222 | w = 84 |
| 4223 | end |
| 4224 | if or eq i 13 eq i 16 |
| 4225 | w = 58 |
| 4226 | end |
| 4227 | if eq i 19 |
| 4228 | w = 90 |
| 4229 | end |
| 4230 | if eq w 0 |
| 4231 | if or lt c 48 gt c 57 |
| 4232 | ret false |
| 4233 | end |
| 4234 | else |
| 4235 | if ne c w |
| 4236 | ret false |
| 4237 | end |
| 4238 | end |
| 4239 | end |
| 4240 | m = l2 add a 5 |
| 4241 | if or lt m 1 gt m 12 |
| 4242 | ret false |
| 4243 | end |
| 4244 | d = l2 add a 8 |
| 4245 | y = add mul l2 a 100 l2 add a 2 |
| 4246 | if or lt d 1 gt d ldim y m |
| 4247 | ret false |
| 4248 | end |
| 4249 | if gt l2 add a 11 23 |
| 4250 | ret false |
| 4251 | end |
| 4252 | if gt l2 add a 14 59 |
| 4253 | ret false |
| 4254 | end |
| 4255 | ret le l2 add a 17 59 |
| 4256 | end |
| 4257 | |
| 4258 | fn kindok s ulong e ulong to bool |
| 4259 | if or ge s e gt sub e s 24 |
| 4260 | ret false |
| 4261 | end |
| 4262 | i = s |
| 4263 | while lt i e bound 32 |
| 4264 | c = mg i |
| 4265 | ok = or and ge c 65 le c 90 or and ge c 48 le c 57 eq c 95 |
| 4266 | if not ok |
| 4267 | ret false |
| 4268 | end |
| 4269 | i = add i 1 |
| 4270 | end |
| 4271 | ret true |
| 4272 | end |
| 4273 | |
| 4274 | fn linehash s ulong e ulong to void |
| 4275 | note hx = SHA-256 of the ledger line arena s..e (without its line feed) |
| 4276 | hashm s sub e s |
| 4277 | end |
| 4278 | |
| 4279 | fn phis s ulong e ulong to bool |
| 4280 | note arena s..e equals the 64 hex digits in ph |
| 4281 | if ne sub e s 64 |
| 4282 | ret false |
| 4283 | end |
| 4284 | for j ulong 64 |
| 4285 | if ne mg add s j get ph j |
| 4286 | ret false |
| 4287 | end |
| 4288 | end |
| 4289 | ret true |
| 4290 | end |
| 4291 | |
| 4292 | fn recshape s ulong e ulong to bool |
| 4293 | note exactly six tabs and every other byte printable ASCII |
| 4294 | t = ulong 0 |
| 4295 | i = s |
| 4296 | while lt i e bound 1024 |
| 4297 | c = mg i |
| 4298 | if eq c 9 |
| 4299 | t = add t 1 |
| 4300 | else |
| 4301 | if or lt c 32 gt c 126 |
| 4302 | ret false |
| 4303 | end |
| 4304 | end |
| 4305 | i = add i 1 |
| 4306 | end |
| 4307 | ret eq t 6 |
| 4308 | end |
| 4309 | |
| 4310 | fn reccheck s ulong e ulong n ulong prevu ulong to ulong |
| 4311 | note 0 when arena s..e is the valid record number n; else the chain tool's BAD code |
| 4312 | if gt sub e s 1023 |
| 4313 | ret 6 |
| 4314 | end |
| 4315 | if not recshape s e |
| 4316 | ret 1 |
| 4317 | end |
| 4318 | nf = split s e 9 |
| 4319 | if ne mnum fg 0 fg 1 n |
| 4320 | ret 2 |
| 4321 | end |
| 4322 | if not utcok fg 2 fg 3 |
| 4323 | ret 3 |
| 4324 | end |
| 4325 | if gt prevu 0 |
| 4326 | if utclt fg 2 prevu |
| 4327 | ret 3 |
| 4328 | end |
| 4329 | end |
| 4330 | if not kindok fg 4 fg 5 |
| 4331 | ret 8 |
| 4332 | end |
| 4333 | al = sub fg 7 fg 6 |
| 4334 | if or eq al 0 gt al 64 |
| 4335 | ret 8 |
| 4336 | end |
| 4337 | sl = sub fg 9 fg 8 |
| 4338 | if or eq sl 0 gt sl 128 |
| 4339 | ret 8 |
| 4340 | end |
| 4341 | if ne sub fg 11 fg 10 64 |
| 4342 | ret 4 |
| 4343 | end |
| 4344 | if not okset fg 10 fg 11 2 |
| 4345 | ret 4 |
| 4346 | end |
| 4347 | if eq n 1 |
| 4348 | if not fbis 6 tgenesis |
| 4349 | ret 5 |
| 4350 | end |
| 4351 | else |
| 4352 | if not phis fg 12 fg 13 |
| 4353 | ret 5 |
| 4354 | end |
| 4355 | end |
| 4356 | ret 0 |
| 4357 | end |
| 4358 | |
| 4359 | fn utclt a ulong b ulong to bool |
| 4360 | note the 20-byte time at arena a is earlier than the one at b |
| 4361 | for j ulong 20 |
| 4362 | x = mg add a j |
| 4363 | y = mg add b j |
| 4364 | if lt x y |
| 4365 | ret true |
| 4366 | end |
| 4367 | if gt x y |
| 4368 | ret false |
| 4369 | end |
| 4370 | end |
| 4371 | ret false |
| 4372 | end |
| 4373 | |
| 4374 | fn paycheck po ulong to void |
| 4375 | note the payload file named by the 64 hex digits at arena po exists and hashes to its name. |
| 4376 | note st PAYO 1 reads it from the written output instead of the source tree. |
| 4377 | if eq sg PAYO 1 |
| 4378 | pbroot 0 |
| 4379 | pbadd tslash |
| 4380 | pbadd fpayout |
| 4381 | else |
| 4382 | pbset fpayd |
| 4383 | end |
| 4384 | pbaddm po 64 |
| 4385 | pbadd ftxt |
| 4386 | if not isfile |
| 4387 | put st CXO po |
| 4388 | put st CXL 64 |
| 4389 | die erpayl |
| 4390 | end |
| 4391 | mark = sg TOP |
| 4392 | off = slurp |
| 4393 | hashm off sg FLEN |
| 4394 | fix = false |
| 4395 | if eq sg TESTD 0 |
| 4396 | fix = mhas off sg FLEN pfixu false |
| 4397 | end |
| 4398 | put st TOP mark |
| 4399 | if not hxis po |
| 4400 | put st CXO po |
| 4401 | put st CXL 64 |
| 4402 | die erpayl |
| 4403 | end |
| 4404 | if fix |
| 4405 | put st CXO po |
| 4406 | put st CXL 64 |
| 4407 | die errel |
| 4408 | end |
| 4409 | end |
| 4410 | |
| 4411 | fn recrow s ulong n ulong to void |
| 4412 | note emits the table row of the record whose line starts at arena s; fb is refilled |
| 4413 | e = eol s add s 1024 |
| 4414 | nf = split s e 9 |
| 4415 | ot r1 |
| 4416 | onum n |
| 4417 | ot r2 |
| 4418 | onum n |
| 4419 | ot r3 |
| 4420 | om fg 2 sub fg 3 fg 2 |
| 4421 | ot r4 |
| 4422 | om fg 4 sub fg 5 fg 4 |
| 4423 | ot r5 |
| 4424 | oesc fg 6 sub fg 7 fg 6 |
| 4425 | ot r6 |
| 4426 | oesc fg 8 sub fg 9 fg 8 |
| 4427 | ot r7 |
| 4428 | om fg 10 64 |
| 4429 | ot r8 |
| 4430 | om fg 10 16 |
| 4431 | ot r9 |
| 4432 | end |
| 4433 | |
| 4434 | fn errnum v ulong to void |
| 4435 | i = ulong 20 |
| 4436 | x = v |
| 4437 | if eq x 0 |
| 4438 | i = 19 |
| 4439 | put sy 19 48 |
| 4440 | end |
| 4441 | while gt x 0 bound 20 |
| 4442 | i = sub i 1 |
| 4443 | put sy i uchar add 48 rem x 10 |
| 4444 | x = div x 10 |
| 4445 | end |
| 4446 | w = write 2 sy i sub 20 i |
| 4447 | end |
| 4448 | |
| 4449 | fn rcsay code ulong line ulong to void |
| 4450 | note the chain tool's wording: BAD line N code |
| 4451 | sayerr tbadl |
| 4452 | errnum line |
| 4453 | sayerr tsp |
| 4454 | errnum code |
| 4455 | sayerr tnl |
| 4456 | end |
| 4457 | |
| 4458 | fn rcloop off ulong lim ulong to ulong |
| 4459 | note checks every record and its payload file; returns the record count, st BADC the last payload offset |
| 4460 | count = ulong 0 |
| 4461 | prevu = ulong 0 |
| 4462 | i = off |
| 4463 | while lt i lim bound 2000 |
| 4464 | e = eol i lim |
| 4465 | count = add count 1 |
| 4466 | if gt count 1999 |
| 4467 | die erledg |
| 4468 | end |
| 4469 | code = reccheck i e count prevu |
| 4470 | if ne code 0 |
| 4471 | rcsay code count |
| 4472 | die erledg |
| 4473 | end |
| 4474 | prevu = fg 2 |
| 4475 | put st BADC fg 10 |
| 4476 | put rcs count i |
| 4477 | linehash i e |
| 4478 | for j ulong 64 |
| 4479 | put ph j get hx j |
| 4480 | end |
| 4481 | paycheck sg BADC |
| 4482 | i = add e 1 |
| 4483 | end |
| 4484 | ret count |
| 4485 | end |
| 4486 | |
| 4487 | fn rcvars count ulong to void |
| 4488 | note the head is the digest of the last line, held in ph |
| 4489 | for j ulong 64 |
| 4490 | put hx j get ph j |
| 4491 | end |
| 4492 | ho = hxkeep |
| 4493 | setv vrhead ho 64 |
| 4494 | setv vrlast sg BADC 64 |
| 4495 | put st OBN 0 |
| 4496 | onum count |
| 4497 | co = stash |
| 4498 | setv vrcount co sg FLEN |
| 4499 | setv vrlseq co sg FLEN |
| 4500 | k = ulong 1 |
| 4501 | while le k count bound 2000 |
| 4502 | recrow cg k k |
| 4503 | k = add k 1 |
| 4504 | end |
| 4505 | ro = stash |
| 4506 | setv vrrows ro sg FLEN |
| 4507 | setvt krcpt vone |
| 4508 | say mrcyes |
| 4509 | sayn count |
| 4510 | say mrchead |
| 4511 | sayhx |
| 4512 | say tnl |
| 4513 | end |
| 4514 | |
| 4515 | fn receipts to void |
| 4516 | pbset fledger |
| 4517 | if not isfile |
| 4518 | put st FRC 0 |
| 4519 | say mrcno |
| 4520 | ret |
| 4521 | end |
| 4522 | put st FRC 1 |
| 4523 | put st CXO keep fledger |
| 4524 | put st CXL len fledger |
| 4525 | off = slurp |
| 4526 | n = sg FLEN |
| 4527 | put st LDGO off |
| 4528 | put st LDGN n |
| 4529 | lim = add off n |
| 4530 | if ne mg sub lim 1 10 |
| 4531 | rcsay 7 1 |
| 4532 | die erledg |
| 4533 | end |
| 4534 | if eq sg TESTD 0 |
| 4535 | if or mhas off n pfixu false mhas off n pfixd false |
| 4536 | die errel |
| 4537 | end |
| 4538 | end |
| 4539 | count = rcloop off lim |
| 4540 | if eq count 0 |
| 4541 | die erledg |
| 4542 | end |
| 4543 | put st NREC count |
| 4544 | note the head is also written down in the source, so the signed history of this repository records it |
| 4545 | pbset fhead |
| 4546 | put st CXO keep fhead |
| 4547 | put st CXL len fhead |
| 4548 | if not isfile |
| 4549 | die erhead |
| 4550 | end |
| 4551 | mark = sg TOP |
| 4552 | ho = slurp |
| 4553 | okh = false |
| 4554 | if eq sg FLEN 65 |
| 4555 | if eq mg add ho 64 10 |
| 4556 | okh = phis ho add ho 64 |
| 4557 | end |
| 4558 | end |
| 4559 | put st TOP mark |
| 4560 | if not okh |
| 4561 | die erhead |
| 4562 | end |
| 4563 | rcvars count |
| 4564 | pbset fvsh |
| 4565 | put st CXO keep fvsh |
| 4566 | put st CXL len fvsh |
| 4567 | so = slurp |
| 4568 | put st OBN 0 |
| 4569 | oesc so sg FLEN |
| 4570 | vo = stash |
| 4571 | setv vrvsh vo sg FLEN |
| 4572 | put st CXL 0 |
| 4573 | end |
| 4574 | |
| 4575 | note ---- Hop release data: content/hop.release.txt, one "key value" per line |
| 4576 | |
| 4577 | fn hopkey ko ulong kl ulong vo ulong ve ulong to bool |
| 4578 | note checks one key's value; false for an unknown key or a value outside its rule |
| 4579 | vl = sub ve vo |
| 4580 | if mist ko kl hkver |
| 4581 | ret okset vo ve 1 |
| 4582 | end |
| 4583 | if mist ko kl hkcommit |
| 4584 | ret and eq vl 40 okset vo ve 2 |
| 4585 | end |
| 4586 | if mist ko kl hkrid |
| 4587 | ret okset vo ve 4 |
| 4588 | end |
| 4589 | if mist ko kl hkzip |
| 4590 | ret okset vo ve 1 |
| 4591 | end |
| 4592 | if or mist ko kl hkzsha or mist ko kl hkesha mist ko kl hkins |
| 4593 | ret and eq vl 64 okset vo ve 2 |
| 4594 | end |
| 4595 | if or mist ko kl hkbuilt mist ko kl hkmacos |
| 4596 | ret okset vo ve 6 |
| 4597 | end |
| 4598 | if or mist ko kl hkdl or mist ko kl hksrc mist ko kl hkbase |
| 4599 | if lt vl 12 |
| 4600 | ret false |
| 4601 | end |
| 4602 | if not mist vo 8 thttps |
| 4603 | ret false |
| 4604 | end |
| 4605 | ret okset vo ve 7 |
| 4606 | end |
| 4607 | if or mist ko kl hkrepro mist ko kl hkverif |
| 4608 | ret or mist vo vl tyes mist vo vl tno |
| 4609 | end |
| 4610 | if mist ko kl hkcheck |
| 4611 | ret and eq vl 20 utcok vo ve |
| 4612 | end |
| 4613 | if mist ko kl hkseqs |
| 4614 | ret okset vo ve 8 |
| 4615 | end |
| 4616 | ret false |
| 4617 | end |
| 4618 | |
| 4619 | fn hopline s ulong e ulong to void |
| 4620 | c = s |
| 4621 | while lt c e bound 16777216 |
| 4622 | if eq mg c 32 |
| 4623 | break |
| 4624 | end |
| 4625 | c = add c 1 |
| 4626 | end |
| 4627 | if or eq c s or ge add c 1 e gt sub c s 40 |
| 4628 | die erhop |
| 4629 | end |
| 4630 | if not hopkey s sub c s add c 1 e |
| 4631 | put st CXO s |
| 4632 | put st CXL sub e s |
| 4633 | die erhop |
| 4634 | end |
| 4635 | ko = keep vhoppre |
| 4636 | base = sg TOP |
| 4637 | if gt add base 64 MEMSZ |
| 4638 | die erfull |
| 4639 | end |
| 4640 | for j ulong sub c s bound 64 |
| 4641 | put mem add base j mg add s j |
| 4642 | end |
| 4643 | put st TOP add base sub c s |
| 4644 | setvm ko add len vhoppre sub c s add c 1 sub e add c 1 |
| 4645 | end |
| 4646 | |
| 4647 | fn hopneed k view uchar * to void |
| 4648 | if not vset k |
| 4649 | put st CXO keep k |
| 4650 | put st CXL len k |
| 4651 | die erhop |
| 4652 | end |
| 4653 | end |
| 4654 | |
| 4655 | |
| 4656 | fn visyes k view uchar * to bool |
| 4657 | v = vlook k |
| 4658 | if eq v 0 |
| 4659 | ret false |
| 4660 | end |
| 4661 | b = mul sub v 1 4 |
| 4662 | ret mist vg add b 2 vg add b 3 tyes |
| 4663 | end |
| 4664 | |
| 4665 | fn hopseq idx ulong s ulong e ulong to void |
| 4666 | note receipt record number idx (1..4) is the decimal in arena s..e |
| 4667 | v = mnum s e |
| 4668 | if or eq v 0 gt v sg NREC |
| 4669 | die erhopr |
| 4670 | end |
| 4671 | if eq idx 1 |
| 4672 | setv vhr1 s sub e s |
| 4673 | end |
| 4674 | if eq idx 2 |
| 4675 | setv vhr2 s sub e s |
| 4676 | end |
| 4677 | if eq idx 3 |
| 4678 | setv vhr3 s sub e s |
| 4679 | end |
| 4680 | if eq idx 4 |
| 4681 | setv vhr4 s sub e s |
| 4682 | end |
| 4683 | end |
| 4684 | |
| 4685 | fn hopseqs to void |
| 4686 | v = vlook nseqs |
| 4687 | if eq v 0 |
| 4688 | ret |
| 4689 | end |
| 4690 | b = mul sub v 1 4 |
| 4691 | s = vg add b 2 |
| 4692 | e = add s vg add b 3 |
| 4693 | nf = split s e 32 |
| 4694 | if or eq nf 0 gt nf 4 |
| 4695 | die erhopr |
| 4696 | end |
| 4697 | if eq sg FRC 0 |
| 4698 | die erhopr |
| 4699 | end |
| 4700 | hopseq 1 fg 0 fg 1 |
| 4701 | if gt nf 1 |
| 4702 | hopseq 2 fg 2 fg 3 |
| 4703 | end |
| 4704 | if gt nf 2 |
| 4705 | hopseq 3 fg 4 fg 5 |
| 4706 | end |
| 4707 | if gt nf 3 |
| 4708 | hopseq 4 fg 6 fg 7 |
| 4709 | end |
| 4710 | end |
| 4711 | |
| 4712 | fn relval k view uchar * to void |
| 4713 | note release mode: the value of key k is not a repeated-digit placeholder |
| 4714 | v = vlook k |
| 4715 | if eq v 0 |
| 4716 | ret |
| 4717 | end |
| 4718 | b = mul sub v 1 4 |
| 4719 | if fewdig vg add b 2 vg add b 3 |
| 4720 | put st CXO keep k |
| 4721 | put st CXL len k |
| 4722 | die errel |
| 4723 | end |
| 4724 | end |
| 4725 | |
| 4726 | fn relhost k view uchar * both bool to void |
| 4727 | note release mode: the address of key k is on interplane.io or, when both is set, on hopbot.org |
| 4728 | v = vlook k |
| 4729 | if eq v 0 |
| 4730 | ret |
| 4731 | end |
| 4732 | b = mul sub v 1 4 |
| 4733 | vo = vg add b 2 |
| 4734 | vl = vg add b 3 |
| 4735 | ok = false |
| 4736 | if ge vl len hip |
| 4737 | ok = mistf vo hip false |
| 4738 | end |
| 4739 | if both |
| 4740 | if ge vl len hhb |
| 4741 | if mistf vo hhb false |
| 4742 | ok = true |
| 4743 | end |
| 4744 | end |
| 4745 | if mist vo vl vhbased |
| 4746 | ok = true |
| 4747 | end |
| 4748 | end |
| 4749 | if not ok |
| 4750 | put st CXO keep k |
| 4751 | put st CXL len k |
| 4752 | die errel |
| 4753 | end |
| 4754 | end |
| 4755 | |
| 4756 | fn hopzipn to bool |
| 4757 | note the installer fetches Hop-VERSION.zip from install_base, so zip_name must be exactly that |
| 4758 | z = vlook nzip |
| 4759 | w = vlook nver |
| 4760 | if or eq z 0 eq w 0 |
| 4761 | ret false |
| 4762 | end |
| 4763 | zb = mul sub z 1 4 |
| 4764 | wb = mul sub w 1 4 |
| 4765 | zo = vg add zb 2 |
| 4766 | zl = vg add zb 3 |
| 4767 | wl = vg add wb 3 |
| 4768 | if ne zl add wl 8 |
| 4769 | ret false |
| 4770 | end |
| 4771 | if not mistf zo thopp false |
| 4772 | ret false |
| 4773 | end |
| 4774 | if not mcmp add zo 4 vg add wb 2 wl |
| 4775 | ret false |
| 4776 | end |
| 4777 | ret mistf add add zo 4 wl xzipx false |
| 4778 | end |
| 4779 | |
| 4780 | fn hopinst to void |
| 4781 | note content/hop.install.sh, install_sha256 and install_base come together or not at all, and must agree |
| 4782 | put st FINS 0 |
| 4783 | pbset fhins |
| 4784 | has = isfile |
| 4785 | key = vset nins |
| 4786 | base = vset vhbase |
| 4787 | if and not has and not key not base |
| 4788 | say minsno |
| 4789 | ret |
| 4790 | end |
| 4791 | put st CXO keep fhins |
| 4792 | put st CXL len fhins |
| 4793 | if or not has or not key not base |
| 4794 | die erhins |
| 4795 | end |
| 4796 | mark = sg TOP |
| 4797 | off = slurp |
| 4798 | hashm off sg FLEN |
| 4799 | put st TOP mark |
| 4800 | v = vlook nins |
| 4801 | if not hxis vg add mul sub v 1 4 2 |
| 4802 | die erhins |
| 4803 | end |
| 4804 | if not hopzipn |
| 4805 | die erhins |
| 4806 | end |
| 4807 | put st FINS 1 |
| 4808 | setvt khins vone |
| 4809 | say minsyes |
| 4810 | end |
| 4811 | |
| 4812 | fn insroute r ulong to bool |
| 4813 | note route r is the one installer route: hopbot.org /install.sh from content/hop.install.sh, with the install flag |
| 4814 | b = mul r 8 |
| 4815 | if or ne rg add b 6 3 ne rg add b 1 1 |
| 4816 | ret false |
| 4817 | end |
| 4818 | if ne sg FINS 1 |
| 4819 | ret false |
| 4820 | end |
| 4821 | if not mist rg add b 2 rg add b 3 rinst |
| 4822 | ret false |
| 4823 | end |
| 4824 | ret mist rg add b 4 rg add b 5 fhins |
| 4825 | end |
| 4826 | |
| 4827 | fn inspin to bool |
| 4828 | note hx, the SHA-256 just taken, equals install_sha256 |
| 4829 | v = vlook nins |
| 4830 | if eq v 0 |
| 4831 | ret false |
| 4832 | end |
| 4833 | ret hxis vg add mul sub v 1 4 2 |
| 4834 | end |
| 4835 | |
| 4836 | fn insfile s ulong e ulong site ulong to bool |
| 4837 | note verify: the hopbot.org file install.sh whose SHA-256 (in hx) equals install_sha256. |
| 4838 | note It is the one file whose content is not scanned; its bytes are fixed by that fingerprint. |
| 4839 | if or ne site 1 ne sg FINS 1 |
| 4840 | ret false |
| 4841 | end |
| 4842 | if not mist s sub e s finsout |
| 4843 | ret false |
| 4844 | end |
| 4845 | ret inspin |
| 4846 | end |
| 4847 | |
| 4848 | fn hoppay rk view uchar * to ulong |
| 4849 | note arena offset of the evidence name (64 hex digits) of the receipt whose number is in placeholder rk; 0 for none |
| 4850 | r = vlook rk |
| 4851 | if eq r 0 |
| 4852 | ret 0 |
| 4853 | end |
| 4854 | rb = mul sub r 1 4 |
| 4855 | n = mnum vg add rb 2 add vg add rb 2 vg add rb 3 |
| 4856 | s = cg n |
| 4857 | nf = split s eol s add s 1024 9 |
| 4858 | ret fg 10 |
| 4859 | end |
| 4860 | |
| 4861 | fn hopproof rk view uchar * vk view uchar * fk view uchar * to ulong |
| 4862 | note 1 when the receipt named for this row exists and its evidence file holds the row's value |
| 4863 | po = hoppay rk |
| 4864 | v = vlook vk |
| 4865 | if or eq po 0 eq v 0 |
| 4866 | ret 0 |
| 4867 | end |
| 4868 | pbset fpayd |
| 4869 | pbaddm po 64 |
| 4870 | pbadd ftxt |
| 4871 | mark = sg TOP |
| 4872 | off = slurp |
| 4873 | vb = mul sub v 1 4 |
| 4874 | found = mfind off sg FLEN vg add vb 2 vg add vb 3 |
| 4875 | put st TOP mark |
| 4876 | if not found |
| 4877 | ret 0 |
| 4878 | end |
| 4879 | setvt fk vone |
| 4880 | ret 1 |
| 4881 | end |
| 4882 | |
| 4883 | fn hopdbase to void |
| 4884 | note hop.download_base: the folder the zip is served from, when download_url ends in a slash and zip_name |
| 4885 | u = vlook ndl |
| 4886 | z = vlook nzip |
| 4887 | if or eq u 0 eq z 0 |
| 4888 | ret |
| 4889 | end |
| 4890 | ub = mul sub u 1 4 |
| 4891 | uo = vg add ub 2 |
| 4892 | ul = vg add ub 3 |
| 4893 | zb = mul sub z 1 4 |
| 4894 | zl = vg add zb 3 |
| 4895 | if le ul add zl 1 |
| 4896 | ret |
| 4897 | end |
| 4898 | if and eq mg sub sub add uo ul zl 1 47 mcmp sub add uo ul zl vg add zb 2 zl |
| 4899 | setv vhdbase uo sub sub ul zl 1 |
| 4900 | end |
| 4901 | end |
| 4902 | |
| 4903 | fn hopbadge to void |
| 4904 | note the badge needs all three fingerprint rows backed by a receipt that holds the same value |
| 4905 | got = hopproof vhr1 ncommit vhok1 |
| 4906 | got = add got hopproof vhr2 nzsha vhok2 |
| 4907 | got = add got hopproof vhr3 nesha vhok3 |
| 4908 | k4 = hopproof vhr4 ncheck vhok4 |
| 4909 | if eq got 3 |
| 4910 | setvt vhbadge vone |
| 4911 | end |
| 4912 | say mbadge |
| 4913 | sayn got |
| 4914 | say mbadgeof |
| 4915 | end |
| 4916 | |
| 4917 | fn hopcopy to void |
| 4918 | note content/hop.copy.txt names the Hop commit the page wording describes; a release must be that commit |
| 4919 | pbset fhcopy |
| 4920 | put st CXO keep fhcopy |
| 4921 | put st CXL len fhcopy |
| 4922 | if not isfile |
| 4923 | die erhcopy |
| 4924 | end |
| 4925 | mark = sg TOP |
| 4926 | off = slurp |
| 4927 | lim = add off sg FLEN |
| 4928 | seen = ulong 0 |
| 4929 | co = ulong 0 |
| 4930 | i = off |
| 4931 | while lt i lim bound 100000 |
| 4932 | e = eol i lim |
| 4933 | if gt e i |
| 4934 | if ne mg i 35 |
| 4935 | seen = add seen 1 |
| 4936 | if ne sub e i 50 |
| 4937 | die erhcopy |
| 4938 | end |
| 4939 | if not mistf i tdescr false |
| 4940 | die erhcopy |
| 4941 | end |
| 4942 | co = add i 10 |
| 4943 | if not okset co e 2 |
| 4944 | die erhcopy |
| 4945 | end |
| 4946 | end |
| 4947 | end |
| 4948 | i = add e 1 |
| 4949 | end |
| 4950 | if ne seen 1 |
| 4951 | die erhcopy |
| 4952 | end |
| 4953 | if eq sg TESTD 1 |
| 4954 | put st TOP mark |
| 4955 | say mhcopyt |
| 4956 | ret |
| 4957 | end |
| 4958 | v = vlook ncommit |
| 4959 | same = mcmp co vg add mul sub v 1 4 2 40 |
| 4960 | put st TOP mark |
| 4961 | if not same |
| 4962 | die erhcopy |
| 4963 | end |
| 4964 | say mhcopy |
| 4965 | end |
| 4966 | |
| 4967 | fn hoprel off ulong n ulong to void |
| 4968 | note release mode: no fixture word, no placeholder fingerprint, and addresses on our own two sites |
| 4969 | if mhas off n pfix true |
| 4970 | die errel |
| 4971 | end |
| 4972 | relval ncommit |
| 4973 | relval nzsha |
| 4974 | relval nesha |
| 4975 | relval nins |
| 4976 | relhost ndl true |
| 4977 | relhost nsrc false |
| 4978 | relhost vhbase true |
| 4979 | end |
| 4980 | |
| 4981 | fn hop to void |
| 4982 | pbset fhop |
| 4983 | if not isfile |
| 4984 | put st FHOP 0 |
| 4985 | say mhopno |
| 4986 | ret |
| 4987 | end |
| 4988 | put st FHOP 1 |
| 4989 | put st CXO keep fhop |
| 4990 | put st CXL len fhop |
| 4991 | off = slurp |
| 4992 | lim = add off sg FLEN |
| 4993 | i = off |
| 4994 | while lt i lim bound 100000 |
| 4995 | e = eol i lim |
| 4996 | if gt e i |
| 4997 | if ne mg i 35 |
| 4998 | hopline i e |
| 4999 | end |
| 5000 | end |
| 5001 | i = add e 1 |
| 5002 | end |
| 5003 | put st CXO keep fhop |
| 5004 | put st CXL len fhop |
| 5005 | hopneed nver |
| 5006 | hopneed ncommit |
| 5007 | hopneed nrid |
| 5008 | hopneed nzip |
| 5009 | hopneed nzsha |
| 5010 | hopneed nesha |
| 5011 | hopneed nbuilt |
| 5012 | hopneed nmacos |
| 5013 | hopneed ndl |
| 5014 | hopneed nsrc |
| 5015 | hopneed nrepro |
| 5016 | hopneed ncheck |
| 5017 | if visyes nrepro |
| 5018 | setvt vhrepro vone |
| 5019 | end |
| 5020 | if visyes nverif |
| 5021 | setvt vhverif vone |
| 5022 | end |
| 5023 | if eq sg TESTD 0 |
| 5024 | hoprel off sub lim off |
| 5025 | end |
| 5026 | hopcopy |
| 5027 | put st CXO keep fhop |
| 5028 | put st CXL len fhop |
| 5029 | v = vlook ncommit |
| 5030 | setv vhshort vg add mul sub v 1 4 2 12 |
| 5031 | hopdbase |
| 5032 | hopseqs |
| 5033 | hopinst |
| 5034 | hopbadge |
| 5035 | put st CXL 0 |
| 5036 | setvt khop vone |
| 5037 | say mhopyes |
| 5038 | end |
| 5039 | |
| 5040 | note ---- live switches: content/live.txt, one line "map yes" or "map no"; lines starting with # are skipped |
| 5041 | |
| 5042 | fn live to void |
| 5043 | pbset flive |
| 5044 | if not isfile |
| 5045 | say mmapno |
| 5046 | ret |
| 5047 | end |
| 5048 | put st CXO keep flive |
| 5049 | put st CXL len flive |
| 5050 | off = slurp |
| 5051 | lim = add off sg FLEN |
| 5052 | on = ulong 0 |
| 5053 | seen = ulong 0 |
| 5054 | i = off |
| 5055 | while lt i lim bound 100000 |
| 5056 | e = eol i lim |
| 5057 | if ne mg i 35 |
| 5058 | seen = add seen 1 |
| 5059 | on = 2 |
| 5060 | if mist i sub e i lmapyes |
| 5061 | on = 1 |
| 5062 | end |
| 5063 | if mist i sub e i lmapno |
| 5064 | on = 0 |
| 5065 | end |
| 5066 | if or eq on 2 gt seen 1 |
| 5067 | die erlive |
| 5068 | end |
| 5069 | end |
| 5070 | i = add e 1 |
| 5071 | end |
| 5072 | if ne seen 1 |
| 5073 | die erlive |
| 5074 | end |
| 5075 | if eq on 1 |
| 5076 | setvt kmap vone |
| 5077 | say mmapyes |
| 5078 | ret |
| 5079 | end |
| 5080 | say mmapno |
| 5081 | end |
| 5082 | |
| 5083 | note ---- routes: content/routes.txt, "kind site route source [hop|receipts|install]" per line. |
| 5084 | note Kinds: 1 page, 2 css, 3 svg, 4 raw, 5 receipts payload (verify only), 6 tpl (llms.txt), |
| 5085 | note 7 data (a text template, such as papers.json), 8 font (an OpenType file copied as it is), |
| 5086 | note 9 png (a PNG image under /public/), 10 forge (sitemap only), |
| 5087 | note 11 gzip (an Omega download archive, copied as it is). |
| 5088 | |
| 5089 | fn rkind s ulong n ulong to ulong |
| 5090 | if mist s n kpage |
| 5091 | ret 1 |
| 5092 | end |
| 5093 | if mist s n kcss |
| 5094 | ret 2 |
| 5095 | end |
| 5096 | if mist s n ksvg |
| 5097 | ret 3 |
| 5098 | end |
| 5099 | if mist s n kraw |
| 5100 | ret 4 |
| 5101 | end |
| 5102 | if mist s n ktpl |
| 5103 | ret 6 |
| 5104 | end |
| 5105 | if mist s n kdata |
| 5106 | ret 7 |
| 5107 | end |
| 5108 | if mist s n kfont |
| 5109 | ret 8 |
| 5110 | end |
| 5111 | if mist s n kpng |
| 5112 | ret 9 |
| 5113 | end |
| 5114 | if mist s n kforge |
| 5115 | ret 10 |
| 5116 | end |
| 5117 | if mist s n kgzip |
| 5118 | ret 11 |
| 5119 | end |
| 5120 | ret 0 |
| 5121 | end |
| 5122 | |
| 5123 | fn fbis k ulong t view uchar * to bool |
| 5124 | note field k of the last split equals the text t |
| 5125 | a = fg mul k 2 |
| 5126 | ret mist a sub fg add mul k 2 1 a t |
| 5127 | end |
| 5128 | |
| 5129 | fn rsite to ulong |
| 5130 | if fbis 1 kmain |
| 5131 | ret 0 |
| 5132 | end |
| 5133 | if fbis 1 khopbot |
| 5134 | ret 1 |
| 5135 | end |
| 5136 | ret 9 |
| 5137 | end |
| 5138 | |
| 5139 | fn rflag nf ulong to ulong |
| 5140 | if ne nf 5 |
| 5141 | ret 0 |
| 5142 | end |
| 5143 | if fbis 4 khop |
| 5144 | ret 1 |
| 5145 | end |
| 5146 | if fbis 4 krcpt |
| 5147 | ret 2 |
| 5148 | end |
| 5149 | if fbis 4 kinst |
| 5150 | ret 3 |
| 5151 | end |
| 5152 | ret 9 |
| 5153 | end |
| 5154 | |
| 5155 | fn route1 nr ulong nf ulong to void |
| 5156 | note stores the route whose fields are in fb as entry nr |
| 5157 | b = mul nr 8 |
| 5158 | kind = rkind fg 0 sub fg 1 fg 0 |
| 5159 | site = rsite |
| 5160 | flag = rflag nf |
| 5161 | if or eq kind 0 or eq site 9 eq flag 9 |
| 5162 | die erroute |
| 5163 | end |
| 5164 | if ne mg fg 4 47 |
| 5165 | die erroute |
| 5166 | end |
| 5167 | if eq kind 8 |
| 5168 | if not fontrt fg 4 fg 5 |
| 5169 | die erroute |
| 5170 | end |
| 5171 | end |
| 5172 | if eq kind 9 |
| 5173 | if not pngrt fg 4 fg 5 |
| 5174 | die erroute |
| 5175 | end |
| 5176 | end |
| 5177 | if eq kind 10 |
| 5178 | if or ne site 0 or ne nf 4 not mist fg 6 sub fg 7 fg 6 kdash |
| 5179 | die erroute |
| 5180 | end |
| 5181 | if not forgert fg 4 fg 5 |
| 5182 | die erroute |
| 5183 | end |
| 5184 | end |
| 5185 | if eq kind 11 |
| 5186 | if or ne site 0 or ne nf 4 not gziprt add fg 4 1 fg 5 |
| 5187 | die erroute |
| 5188 | end |
| 5189 | end |
| 5190 | rdup nr site fg 4 sub fg 5 fg 4 |
| 5191 | put rt b kind |
| 5192 | put rt add b 1 site |
| 5193 | put rt add b 2 fg 4 |
| 5194 | put rt add b 3 sub fg 5 fg 4 |
| 5195 | put rt add b 4 fg 6 |
| 5196 | put rt add b 5 sub fg 7 fg 6 |
| 5197 | put rt add b 6 flag |
| 5198 | end |
| 5199 | |
| 5200 | fn rdup nr ulong site ulong s ulong n ulong to void |
| 5201 | note refuses a route whose site and address equal those of one of the first nr routes |
| 5202 | for j ulong nr bound RTCAP |
| 5203 | rb = mul j 8 |
| 5204 | gs = get rt add rb 1 |
| 5205 | gn = get rt add rb 3 |
| 5206 | if and eq gs site eq gn n |
| 5207 | gp = get rt add rb 2 |
| 5208 | if mcmp gp s n |
| 5209 | die erdupr |
| 5210 | end |
| 5211 | end |
| 5212 | end |
| 5213 | end |
| 5214 | |
| 5215 | fn forgert s ulong e ulong to bool |
| 5216 | note a forge route is /explore or /drakestapleton/NAME, NAME in A-Z a-z 0-9 . _ - and not starting |
| 5217 | note with a dot: a page the forge serves at that address, which this site only lists in its sitemap |
| 5218 | p = add s 1 |
| 5219 | if mist p sub e p lexplore |
| 5220 | ret true |
| 5221 | end |
| 5222 | if le sub e p len lownerp |
| 5223 | ret false |
| 5224 | end |
| 5225 | if not mistf p lownerp false |
| 5226 | ret false |
| 5227 | end |
| 5228 | q = add p len lownerp |
| 5229 | if eq mg q 46 |
| 5230 | ret false |
| 5231 | end |
| 5232 | ret okset q e 1 |
| 5233 | end |
| 5234 | |
| 5235 | fn fontrt s ulong e ulong to bool |
| 5236 | note a font route is /public/fonts/NAME.otf with NAME in A-Z a-z 0-9 . _ - |
| 5237 | n = sub e s |
| 5238 | if le n add len tfonts len xotf |
| 5239 | ret false |
| 5240 | end |
| 5241 | if not mistf s tfonts false |
| 5242 | ret false |
| 5243 | end |
| 5244 | if not mist sub e len xotf len xotf xotf |
| 5245 | ret false |
| 5246 | end |
| 5247 | ret okset add s len tfonts e 1 |
| 5248 | end |
| 5249 | |
| 5250 | fn pngrt s ulong e ulong to bool |
| 5251 | note a png route is /public/NAME.png with NAME in A-Z a-z 0-9 . _ - |
| 5252 | n = sub e s |
| 5253 | if le n add len tpubl len xpng |
| 5254 | ret false |
| 5255 | end |
| 5256 | if not mistf s tpubl false |
| 5257 | ret false |
| 5258 | end |
| 5259 | if not mist sub e len xpng len xpng xpng |
| 5260 | ret false |
| 5261 | end |
| 5262 | ret okset add s len tpubl e 1 |
| 5263 | end |
| 5264 | |
| 5265 | fn gziprt s ulong e ulong to bool |
| 5266 | note a gzip route is /omega/downloads/NAME.tar.gz without subdirectories |
| 5267 | n = sub e s |
| 5268 | if le n add len odloads len xgzip |
| 5269 | ret false |
| 5270 | end |
| 5271 | if not mistf s odloads false |
| 5272 | ret false |
| 5273 | end |
| 5274 | if not mist sub e len xgzip len xgzip xgzip |
| 5275 | ret false |
| 5276 | end |
| 5277 | p = add s len odloads |
| 5278 | if eq mg p 46 |
| 5279 | ret false |
| 5280 | end |
| 5281 | ret okset p e 1 |
| 5282 | end |
| 5283 | |
| 5284 | fn routes to void |
| 5285 | pbset froutes |
| 5286 | put st CXO keep froutes |
| 5287 | put st CXL len froutes |
| 5288 | off = slurp |
| 5289 | lim = add off sg FLEN |
| 5290 | nr = ulong 0 |
| 5291 | i = off |
| 5292 | while lt i lim bound 100000 |
| 5293 | e = eol i lim |
| 5294 | if gt e i |
| 5295 | if ne mg i 35 |
| 5296 | nf = split i e 32 |
| 5297 | if ge nr RTCAP |
| 5298 | die erfullr |
| 5299 | end |
| 5300 | if or lt nf 4 gt nf 5 |
| 5301 | die erroute |
| 5302 | end |
| 5303 | route1 nr nf |
| 5304 | nr = add nr 1 |
| 5305 | end |
| 5306 | end |
| 5307 | i = add e 1 |
| 5308 | end |
| 5309 | if eq nr 0 |
| 5310 | die erroute |
| 5311 | end |
| 5312 | put st NR nr |
| 5313 | end |
| 5314 | |
| 5315 | fn omdlread name ulong n ulong kind ulong to ulong |
| 5316 | note read the registered source file, so hashes bind the bytes that will actually be published |
| 5317 | nr = sg NR |
| 5318 | r = ulong 0 |
| 5319 | while lt r nr bound RTCAP |
| 5320 | b = mul r 8 |
| 5321 | a = add rg add b 2 1 |
| 5322 | if and eq rg b kind and eq rg add b 1 0 eq rg add b 6 0 |
| 5323 | if eq rg add b 3 add add n len odloads 1 |
| 5324 | if and mistf a odloads false mcmp add a len odloads name n |
| 5325 | put st PBL 0 |
| 5326 | pbaddm rg add b 4 rg add b 5 |
| 5327 | put st CXO rg add b 4 |
| 5328 | put st CXL rg add b 5 |
| 5329 | ret slurp |
| 5330 | end |
| 5331 | end |
| 5332 | end |
| 5333 | r = add r 1 |
| 5334 | end |
| 5335 | put st CXO keep froutes |
| 5336 | put st CXL len froutes |
| 5337 | die erodload |
| 5338 | ret 0 |
| 5339 | end |
| 5340 | |
| 5341 | fn omdownloads to void |
| 5342 | note the checksum file is pinned like robots.txt; its two rows name the archive and installer |
| 5343 | name = keep odloadsums |
| 5344 | start = omdlread name len odloadsums 4 |
| 5345 | n = sg FLEN |
| 5346 | hashm start n |
| 5347 | for j ulong 64 |
| 5348 | if ne get hx j get odloadpin j |
| 5349 | die erodload |
| 5350 | end |
| 5351 | end |
| 5352 | stop = add start n |
| 5353 | pos = start |
| 5354 | for row ulong 2 |
| 5355 | last = eol pos stop |
| 5356 | name = add pos 66 |
| 5357 | size = sub last name |
| 5358 | kind = ulong 11 |
| 5359 | if eq row 0 |
| 5360 | setv odkarch name size |
| 5361 | else |
| 5362 | kind = 4 |
| 5363 | setv odkinst name size |
| 5364 | end |
| 5365 | mark = sg TOP |
| 5366 | off = omdlread name size kind |
| 5367 | if eq row 0 |
| 5368 | put st OBN 0 |
| 5369 | om off sg FLEN |
| 5370 | lint 11 |
| 5371 | end |
| 5372 | hashm off sg FLEN |
| 5373 | if not hxis pos |
| 5374 | die erodload |
| 5375 | end |
| 5376 | put st TOP mark |
| 5377 | pos = add last 1 |
| 5378 | end |
| 5379 | setvt odksums odloadsums |
| 5380 | setvt odkcommit odcommit |
| 5381 | note every route in the download directory is either one of those three or a release error |
| 5382 | count = ulong 0 |
| 5383 | nr = sg NR |
| 5384 | for r ulong nr bound RTCAP |
| 5385 | b = mul r 8 |
| 5386 | if ge rg add b 3 add len odloads 1 |
| 5387 | if mistf add rg add b 2 1 odloads false |
| 5388 | count = add count 1 |
| 5389 | end |
| 5390 | end |
| 5391 | end |
| 5392 | if ne count 3 |
| 5393 | put st CXO keep froutes |
| 5394 | put st CXL len froutes |
| 5395 | die erodextra |
| 5396 | end |
| 5397 | end |
| 5398 | |
| 5399 | fn omdllink key view uchar * to bool |
| 5400 | note find a download anchor targeting the file name read from the pinned release |
| 5401 | v = mul sub vlook key 1 4 |
| 5402 | name = vg add v 2 |
| 5403 | n = vg add v 3 |
| 5404 | i = ofind 0 odhref |
| 5405 | while lt i sg OBN bound 100000 |
| 5406 | p = add i len odhref |
| 5407 | e = add p n |
| 5408 | if le e sg OBN |
| 5409 | if and obeqm p e name n omatch e odend |
| 5410 | ret true |
| 5411 | end |
| 5412 | end |
| 5413 | i = ofind add i 1 odhref |
| 5414 | end |
| 5415 | ret false |
| 5416 | end |
| 5417 | |
| 5418 | fn omdlcopy r ulong to void |
| 5419 | b = mul r 8 |
| 5420 | if ne rg add b 1 0 |
| 5421 | ret |
| 5422 | end |
| 5423 | a = rg add b 2 |
| 5424 | n = rg add b 3 |
| 5425 | if mist a n odhome |
| 5426 | if not and ohas odtitle and ohas odcommit and omdllink odkarch and omdllink odkinst omdllink odksums |
| 5427 | die erodcopy |
| 5428 | end |
| 5429 | end |
| 5430 | if mist add a 1 sub n 1 fllms |
| 5431 | if not ohas odguide |
| 5432 | die erodguide |
| 5433 | end |
| 5434 | end |
| 5435 | end |
| 5436 | |
| 5437 | fn enabled r ulong to bool |
| 5438 | b = mul r 8 |
| 5439 | if eq rg b 10 |
| 5440 | ret false |
| 5441 | end |
| 5442 | if eq rg add b 1 1 |
| 5443 | if eq sg FHOP 0 |
| 5444 | ret false |
| 5445 | end |
| 5446 | end |
| 5447 | flag = rg add b 6 |
| 5448 | if eq flag 1 |
| 5449 | ret eq sg FHOP 1 |
| 5450 | end |
| 5451 | if eq flag 2 |
| 5452 | ret eq sg FRC 1 |
| 5453 | end |
| 5454 | if eq flag 3 |
| 5455 | ret and eq sg FHOP 1 eq sg FINS 1 |
| 5456 | end |
| 5457 | ret true |
| 5458 | end |
| 5459 | |
| 5460 | fn outpb r ulong to void |
| 5461 | note pb = output path of route r: site root, the route, and index.html for a directory route |
| 5462 | b = mul r 8 |
| 5463 | pbroot rg add b 1 |
| 5464 | ro = rg add b 2 |
| 5465 | rl = rg add b 3 |
| 5466 | pbaddm ro rl |
| 5467 | if eq mg sub add ro rl 1 47 |
| 5468 | pbadd tindex |
| 5469 | end |
| 5470 | end |
| 5471 | |
| 5472 | fn manadd site ulong to void |
| 5473 | note records "<sha256> <path below the root>" for the file named by pb, whose bytes are in obuf |
| 5474 | hasho |
| 5475 | m = sg MANL |
| 5476 | s = add rootlen site 1 |
| 5477 | n = sg PBL |
| 5478 | if gt add add m 70 sub n s 524000 |
| 5479 | die erbig |
| 5480 | end |
| 5481 | for j ulong 64 |
| 5482 | put man add m j get hx j |
| 5483 | end |
| 5484 | put man add m 64 32 |
| 5485 | put man add m 65 32 |
| 5486 | m = add m 66 |
| 5487 | for j ulong sub n s bound 2048 |
| 5488 | put man add m j get pb add s j |
| 5489 | end |
| 5490 | m = add m sub n s |
| 5491 | put man m 10 |
| 5492 | put st MANL add m 1 |
| 5493 | put st NFILE add sg NFILE 1 |
| 5494 | end |
| 5495 | |
| 5496 | fn wrfile site ulong to void |
| 5497 | note st DRY 1 (verify) records the digest without writing, to rebuild the expected manifest |
| 5498 | if eq sg DRY 0 |
| 5499 | mkpar site |
| 5500 | wrraw |
| 5501 | end |
| 5502 | manadd site |
| 5503 | end |
| 5504 | |
| 5505 | note ---- retired Chinese copies: readers translate pages with their own tools (/translate/), so a |
| 5506 | note route under /zh-CN/ is refused; the helpers below are shared by pages and the translation unit. |
| 5507 | |
| 5508 | fn zhpath r ulong to bool |
| 5509 | note route r lies under /zh-..., /zh/ or is /zh (letter case ignored) |
| 5510 | b = mul r 8 |
| 5511 | n = rg add b 3 |
| 5512 | p = rg add b 2 |
| 5513 | if lt n len tzhb |
| 5514 | ret false |
| 5515 | end |
| 5516 | if not mistf p tzhb true |
| 5517 | ret false |
| 5518 | end |
| 5519 | if eq n len tzhb |
| 5520 | ret true |
| 5521 | end |
| 5522 | c = mg add p len tzhb |
| 5523 | ret or eq c 45 eq c 47 |
| 5524 | end |
| 5525 | |
| 5526 | fn zhnone to void |
| 5527 | note translated copies are retired: no route of either site may lie under a Chinese path |
| 5528 | nr = sg NR |
| 5529 | r = ulong 0 |
| 5530 | while lt r nr bound RTCAP |
| 5531 | if zhpath r |
| 5532 | b = mul r 8 |
| 5533 | put st CXO rg add b 2 |
| 5534 | put st CXL rg add b 3 |
| 5535 | die erzh |
| 5536 | end |
| 5537 | r = add r 1 |
| 5538 | end |
| 5539 | end |
| 5540 | |
| 5541 | fn zurl r ulong to void |
| 5542 | note the address of route r: its site's base and its path |
| 5543 | b = mul r 8 |
| 5544 | if eq rg add b 1 0 |
| 5545 | ot tbase0 |
| 5546 | else |
| 5547 | ot tbase1 |
| 5548 | end |
| 5549 | om add rg add b 2 1 sub rg add b 3 1 |
| 5550 | end |
| 5551 | |
| 5552 | fn mfirst s ulong e ulong t view uchar * to ulong |
| 5553 | note the first arena offset in s..e where the text t starts, e when there is none |
| 5554 | i = s |
| 5555 | while le add i len t e bound 16777216 |
| 5556 | if mistf i t false |
| 5557 | ret i |
| 5558 | end |
| 5559 | i = add i 1 |
| 5560 | end |
| 5561 | ret e |
| 5562 | end |
| 5563 | |
| 5564 | fn mlast s ulong e ulong t view uchar * to ulong |
| 5565 | note the last arena offset in s..e where the text t starts, e when there is none |
| 5566 | if lt sub e s len t |
| 5567 | ret e |
| 5568 | end |
| 5569 | i = sub e len t |
| 5570 | while ge i s bound 16777216 |
| 5571 | if mistf i t false |
| 5572 | ret i |
| 5573 | end |
| 5574 | if eq i s |
| 5575 | ret e |
| 5576 | end |
| 5577 | i = sub i 1 |
| 5578 | end |
| 5579 | ret e |
| 5580 | end |
| 5581 | |
| 5582 | note ---- pages |
| 5583 | |
| 5584 | fn isdash i ulong e ulong to bool |
| 5585 | if ne sub e i 3 |
| 5586 | ret false |
| 5587 | end |
| 5588 | ret and eq mg i 45 and eq mg add i 1 45 eq mg add i 2 45 |
| 5589 | end |
| 5590 | |
| 5591 | fn front off ulong n ulong to ulong |
| 5592 | note one placeholder per "key: value" line; returns the offset of the body after the dashes line |
| 5593 | lim = add off n |
| 5594 | i = off |
| 5595 | while lt i lim bound 200 |
| 5596 | e = eol i lim |
| 5597 | if isdash i e |
| 5598 | ret add e 1 |
| 5599 | end |
| 5600 | c = i |
| 5601 | while lt add c 1 e bound 16777216 |
| 5602 | if eq mg c 58 |
| 5603 | break |
| 5604 | end |
| 5605 | c = add c 1 |
| 5606 | end |
| 5607 | if or eq c i or ge add c 2 e gt sub c i 40 |
| 5608 | die erfront |
| 5609 | end |
| 5610 | if ne mg add c 1 32 |
| 5611 | die erfront |
| 5612 | end |
| 5613 | setvm i sub c i add c 2 sub e add c 2 |
| 5614 | i = add e 1 |
| 5615 | end |
| 5616 | die erfront |
| 5617 | ret lim |
| 5618 | end |
| 5619 | |
| 5620 | fn sitevars site ulong to void |
| 5621 | if eq site 0 |
| 5622 | setv vip 0 0 |
| 5623 | setvt vismain vone |
| 5624 | setv vishop 0 0 |
| 5625 | else |
| 5626 | setvt vip vipurl |
| 5627 | setv vismain 0 0 |
| 5628 | setvt vishop vone |
| 5629 | end |
| 5630 | end |
| 5631 | |
| 5632 | fn page r ulong to void |
| 5633 | note assembles page route r into obuf |
| 5634 | b = mul r 8 |
| 5635 | site = rg add b 1 |
| 5636 | put st PBL 0 |
| 5637 | pbaddm rg add b 4 rg add b 5 |
| 5638 | off = slurp |
| 5639 | n = sg FLEN |
| 5640 | body = front off n |
| 5641 | setv vmain body sub add off n body |
| 5642 | setv vroute rg add b 2 rg add b 3 |
| 5643 | put st OBN 0 |
| 5644 | if eq site 0 |
| 5645 | ot tbase0 |
| 5646 | else |
| 5647 | ot tbase1 |
| 5648 | end |
| 5649 | om add rg add b 2 1 sub rg add b 3 1 |
| 5650 | co = stash |
| 5651 | setv vcanon co sg FLEN |
| 5652 | sitevars site |
| 5653 | if eq site 0 |
| 5654 | expand sg L0O sg L0N 0 |
| 5655 | else |
| 5656 | expand sg L1O sg L1N 0 |
| 5657 | end |
| 5658 | trpage r |
| 5659 | end |
| 5660 | |
| 5661 | fn sitefont site ulong to bool |
| 5662 | note the site builds at least one enabled font route |
| 5663 | nr = sg NR |
| 5664 | r = ulong 0 |
| 5665 | while lt r nr bound RTCAP |
| 5666 | b = mul r 8 |
| 5667 | if and eq rg b 8 eq rg add b 1 site |
| 5668 | if enabled r |
| 5669 | ret true |
| 5670 | end |
| 5671 | end |
| 5672 | r = add r 1 |
| 5673 | end |
| 5674 | ret false |
| 5675 | end |
| 5676 | |
| 5677 | fn omcss off ulong n ulong to void |
| 5678 | note the stylesheet of a site that builds no font: every byte except each "@font-face{...}" block |
| 5679 | note and the line feed after it, so it names no font the site leaves out; a block left open is refused |
| 5680 | e = add off n |
| 5681 | j = off |
| 5682 | while lt j e bound 16777216 |
| 5683 | hit = false |
| 5684 | if le add j len cface e |
| 5685 | hit = mistf j cface false |
| 5686 | end |
| 5687 | if hit |
| 5688 | k = add j len cface |
| 5689 | while lt k e bound 16777216 |
| 5690 | if eq mg k 125 |
| 5691 | break |
| 5692 | end |
| 5693 | k = add k 1 |
| 5694 | end |
| 5695 | if ge k e |
| 5696 | die ercss |
| 5697 | end |
| 5698 | j = add k 1 |
| 5699 | if lt j e |
| 5700 | if eq mg j 10 |
| 5701 | j = add j 1 |
| 5702 | end |
| 5703 | end |
| 5704 | else |
| 5705 | ob mg j |
| 5706 | j = add j 1 |
| 5707 | end |
| 5708 | end |
| 5709 | end |
| 5710 | |
| 5711 | fn produce r ulong to void |
| 5712 | note obuf = the bytes of route r, assembled or copied, and checked |
| 5713 | b = mul r 8 |
| 5714 | kind = rg add b 0 |
| 5715 | put st SITE rg add b 1 |
| 5716 | put st CXO rg add b 4 |
| 5717 | put st CXL rg add b 5 |
| 5718 | if eq kind 1 |
| 5719 | page r |
| 5720 | else |
| 5721 | put st PBL 0 |
| 5722 | pbaddm rg add b 4 rg add b 5 |
| 5723 | off = slurp |
| 5724 | put st OBN 0 |
| 5725 | if or eq kind 6 eq kind 7 |
| 5726 | sitevars rg add b 1 |
| 5727 | expand off sg FLEN 0 |
| 5728 | else |
| 5729 | if and eq kind 2 not sitefont rg add b 1 |
| 5730 | omcss off sg FLEN |
| 5731 | else |
| 5732 | om off sg FLEN |
| 5733 | end |
| 5734 | end |
| 5735 | end |
| 5736 | if insroute r |
| 5737 | note the released installer is copied as it is and never scanned: its bytes must be the pinned ones |
| 5738 | hasho |
| 5739 | if not inspin |
| 5740 | die erhins |
| 5741 | end |
| 5742 | ret |
| 5743 | end |
| 5744 | lint kind |
| 5745 | omdlcopy r |
| 5746 | end |
| 5747 | |
| 5748 | fn permchk r ulong to void |
| 5749 | note the page at /contribute/ on interplane.io must tell the publisher that publishing is permanent |
| 5750 | b = mul r 8 |
| 5751 | if or ne rg b 1 ne rg add b 1 0 |
| 5752 | ret |
| 5753 | end |
| 5754 | if not mist rg add b 2 rg add b 3 rcontrib |
| 5755 | ret |
| 5756 | end |
| 5757 | if not ohas pperm |
| 5758 | die erperm |
| 5759 | end |
| 5760 | put st PERM 1 |
| 5761 | end |
| 5762 | |
| 5763 | fn robotchk r ulong to void |
| 5764 | note the crawl rules of interplane.io are pinned: the bytes that Radicle main 4968bc8 generated |
| 5765 | b = mul r 8 |
| 5766 | if ne rg add b 1 0 |
| 5767 | ret |
| 5768 | end |
| 5769 | if ne rg add b 3 11 |
| 5770 | ret |
| 5771 | end |
| 5772 | ko = keep frobots |
| 5773 | same = mcmp add rg add b 2 1 ko 10 |
| 5774 | put st TOP ko |
| 5775 | if not same |
| 5776 | ret |
| 5777 | end |
| 5778 | hasho |
| 5779 | for j ulong 64 |
| 5780 | if ne get hx j get probots j |
| 5781 | die errobot |
| 5782 | end |
| 5783 | end |
| 5784 | end |
| 5785 | |
| 5786 | fn preflight to void |
| 5787 | note assembles and checks every enabled route of both sites; nothing is written |
| 5788 | nr = sg NR |
| 5789 | r = ulong 0 |
| 5790 | while lt r nr bound RTCAP |
| 5791 | if enabled r |
| 5792 | put st NV sg NVB |
| 5793 | put st TOP sg TOPB |
| 5794 | produce r |
| 5795 | robotchk r |
| 5796 | permchk r |
| 5797 | end |
| 5798 | r = add r 1 |
| 5799 | end |
| 5800 | put st NV sg NVB |
| 5801 | put st TOP sg TOPB |
| 5802 | put st CXL 0 |
| 5803 | if eq sg PERM 0 |
| 5804 | die erperm |
| 5805 | end |
| 5806 | end |
| 5807 | |
| 5808 | fn sitemap site ulong to void |
| 5809 | put st OBN 0 |
| 5810 | ot s1 |
| 5811 | nr = sg NR |
| 5812 | r = ulong 0 |
| 5813 | while lt r nr bound RTCAP |
| 5814 | b = mul r 8 |
| 5815 | if eq rg add b 1 site |
| 5816 | if or eq rg b 10 and or eq rg b 1 eq rg b 7 enabled r |
| 5817 | ot s2 |
| 5818 | if eq site 0 |
| 5819 | ot tbase0 |
| 5820 | else |
| 5821 | ot tbase1 |
| 5822 | end |
| 5823 | om add rg add b 2 1 sub rg add b 3 1 |
| 5824 | ot s3 |
| 5825 | end |
| 5826 | end |
| 5827 | r = add r 1 |
| 5828 | end |
| 5829 | ot s4 |
| 5830 | pbroot site |
| 5831 | pbadd tslash |
| 5832 | pbadd fsitemap |
| 5833 | put st CXL 0 |
| 5834 | put st SITE site |
| 5835 | lint 4 |
| 5836 | wrfile site |
| 5837 | end |
| 5838 | |
| 5839 | fn payfirst k ulong po ulong to bool |
| 5840 | note no earlier record names the payload at arena po |
| 5841 | j = ulong 1 |
| 5842 | while lt j k bound 2000 |
| 5843 | sj = cg j |
| 5844 | ej = eol sj add sj 1024 |
| 5845 | nj = split sj ej 9 |
| 5846 | if mcmp fg 10 po 64 |
| 5847 | ret false |
| 5848 | end |
| 5849 | j = add j 1 |
| 5850 | end |
| 5851 | ret true |
| 5852 | end |
| 5853 | |
| 5854 | fn paycopy po ulong to void |
| 5855 | mark = sg TOP |
| 5856 | pbset fpayd |
| 5857 | pbaddm po 64 |
| 5858 | pbadd ftxt |
| 5859 | put st CXO po |
| 5860 | put st CXL 64 |
| 5861 | off = slurp |
| 5862 | put st OBN 0 |
| 5863 | om off sg FLEN |
| 5864 | put st TOP mark |
| 5865 | lint 5 |
| 5866 | pbroot 0 |
| 5867 | pbadd tslash |
| 5868 | pbadd fpayout |
| 5869 | pbaddm po 64 |
| 5870 | pbadd ftxt |
| 5871 | wrfile 0 |
| 5872 | end |
| 5873 | |
| 5874 | fn rcfiles to void |
| 5875 | note copies the ledger and every payload file named in it, unchanged, into the main output |
| 5876 | if eq sg FRC 0 |
| 5877 | ret |
| 5878 | end |
| 5879 | put st SITE 0 |
| 5880 | put st CXO keep fledger |
| 5881 | put st CXL len fledger |
| 5882 | put st OBN 0 |
| 5883 | om sg LDGO sg LDGN |
| 5884 | lint 4 |
| 5885 | pbroot 0 |
| 5886 | pbadd tslash |
| 5887 | pbadd fledout |
| 5888 | wrfile 0 |
| 5889 | k = ulong 1 |
| 5890 | n = sg NREC |
| 5891 | while le k n bound 2000 |
| 5892 | s = cg k |
| 5893 | e = eol s add s 1024 |
| 5894 | nf = split s e 9 |
| 5895 | po = fg 10 |
| 5896 | if payfirst k po |
| 5897 | paycopy po |
| 5898 | end |
| 5899 | k = add k 1 |
| 5900 | end |
| 5901 | end |
| 5902 | |
| 5903 | fn mancmp site ulong to void |
| 5904 | note verify: the manifest in the output equals, byte for byte, the one this source builds |
| 5905 | m = sg MANL |
| 5906 | pbroot site |
| 5907 | pbadd tslash |
| 5908 | pbadd fmanif |
| 5909 | put st CXL 0 |
| 5910 | mark = sg TOP |
| 5911 | off = slurp |
| 5912 | same = eq sg FLEN m |
| 5913 | if same |
| 5914 | for j ulong m bound 524288 |
| 5915 | if ne mg add off j get man j |
| 5916 | same = false |
| 5917 | end |
| 5918 | end |
| 5919 | end |
| 5920 | put st TOP mark |
| 5921 | put st MANL 0 |
| 5922 | put st NFILE 0 |
| 5923 | put st NPAGE 0 |
| 5924 | if not same |
| 5925 | put st CXO keep fmanif |
| 5926 | put st CXL len fmanif |
| 5927 | die erset |
| 5928 | end |
| 5929 | end |
| 5930 | |
| 5931 | fn manwrite site ulong to void |
| 5932 | note writes manifest.sha256 (sha256sum -c format) and prints the site summary |
| 5933 | if eq sg DRY 1 |
| 5934 | mancmp site |
| 5935 | ret |
| 5936 | end |
| 5937 | put st OBN 0 |
| 5938 | m = sg MANL |
| 5939 | for j ulong m bound 524288 |
| 5940 | ob get man j |
| 5941 | end |
| 5942 | hasho |
| 5943 | pbroot site |
| 5944 | pbadd tslash |
| 5945 | pbadd fmanif |
| 5946 | wrraw |
| 5947 | if eq site 0 |
| 5948 | say mbuilt0 |
| 5949 | else |
| 5950 | say mbuilt1 |
| 5951 | end |
| 5952 | sayn sg NPAGE |
| 5953 | say mfiles |
| 5954 | sayn sg NFILE |
| 5955 | say mmsha |
| 5956 | sayhx |
| 5957 | say tnl |
| 5958 | put st MANL 0 |
| 5959 | put st NFILE 0 |
| 5960 | put st NPAGE 0 |
| 5961 | end |
| 5962 | |
| 5963 | fn mkroot site ulong to void |
| 5964 | pbroot site |
| 5965 | k = makedir pb 0 sg PBL 493 |
| 5966 | if ne k 0 |
| 5967 | put st CXL 0 |
| 5968 | die erdir |
| 5969 | end |
| 5970 | end |
| 5971 | |
| 5972 | fn writesite site ulong to void |
| 5973 | note pass 1 for one site: every enabled route of that site, then generated files and the manifest |
| 5974 | nr = sg NR |
| 5975 | r = ulong 0 |
| 5976 | while lt r nr bound RTCAP |
| 5977 | if eq rg add mul r 8 1 site |
| 5978 | if enabled r |
| 5979 | put st NV sg NVB |
| 5980 | put st TOP sg TOPB |
| 5981 | produce r |
| 5982 | outpb r |
| 5983 | wrfile site |
| 5984 | if eq rg mul r 8 1 |
| 5985 | put st NPAGE add sg NPAGE 1 |
| 5986 | trforms r |
| 5987 | end |
| 5988 | end |
| 5989 | end |
| 5990 | r = add r 1 |
| 5991 | end |
| 5992 | put st NV sg NVB |
| 5993 | put st TOP sg TOPB |
| 5994 | if eq site 0 |
| 5995 | rcfiles |
| 5996 | end |
| 5997 | if eq sg TESTD 1 |
| 5998 | put st OBN 0 |
| 5999 | ot ttestd |
| 6000 | pbroot site |
| 6001 | pbadd tslash |
| 6002 | pbadd ftestd |
| 6003 | put st CXL 0 |
| 6004 | put st SITE site |
| 6005 | lint 4 |
| 6006 | wrfile site |
| 6007 | end |
| 6008 | sitemap site |
| 6009 | manwrite site |
| 6010 | end |
| 6011 | |
| 6012 | fn kindof s ulong e ulong site ulong to ulong |
| 6013 | note check kind of an output path (arena s..e) by its ending |
| 6014 | n = sub e s |
| 6015 | if mist s n fllms |
| 6016 | ret 6 |
| 6017 | end |
| 6018 | if ge n 5 |
| 6019 | if mist sub e 5 5 xhtml |
| 6020 | ret 1 |
| 6021 | end |
| 6022 | end |
| 6023 | if ge n 4 |
| 6024 | if mist sub e 4 4 xcss |
| 6025 | ret 2 |
| 6026 | end |
| 6027 | if mist sub e 4 4 xsvg |
| 6028 | ret 3 |
| 6029 | end |
| 6030 | end |
| 6031 | if gt n 17 |
| 6032 | if mist s 17 fpayout |
| 6033 | ret 5 |
| 6034 | end |
| 6035 | end |
| 6036 | if ge n 4 |
| 6037 | if mist sub e 4 4 xotf |
| 6038 | ret 8 |
| 6039 | end |
| 6040 | end |
| 6041 | if ge n 4 |
| 6042 | if mist sub e 4 4 xpng |
| 6043 | ret 9 |
| 6044 | end |
| 6045 | end |
| 6046 | if and eq site 0 gziprt s e |
| 6047 | ret 11 |
| 6048 | end |
| 6049 | ret 4 |
| 6050 | end |
| 6051 | |
| 6052 | |
| 6053 | fn inman po ulong pl ulong dir bool to bool |
| 6054 | note the manifest (arena st MNO..st MNL) names the file at arena po..po+pl, or, for a directory, a file inside it |
| 6055 | lim = sg MNL |
| 6056 | i = sg MNO |
| 6057 | while lt i lim bound 100000 |
| 6058 | e = eol i lim |
| 6059 | s = add i 66 |
| 6060 | n = sub e s |
| 6061 | if dir |
| 6062 | if gt n pl |
| 6063 | if mcmp s po pl |
| 6064 | if eq mg add s pl 47 |
| 6065 | ret true |
| 6066 | end |
| 6067 | end |
| 6068 | end |
| 6069 | else |
| 6070 | if eq n pl |
| 6071 | if mcmp s po pl |
| 6072 | ret true |
| 6073 | end |
| 6074 | end |
| 6075 | end |
| 6076 | i = add e 1 |
| 6077 | end |
| 6078 | ret false |
| 6079 | end |
| 6080 | |
| 6081 | fn lsone site ulong ns ulong nl ulong ty uchar to void |
| 6082 | note one directory entry (name at dbuf ns, length nl, type ty) of the directory st DRO, st DRL |
| 6083 | dl = sg DRL |
| 6084 | base = sg TOP |
| 6085 | if gt add add base dl add nl 2 MEMSZ |
| 6086 | die erfull |
| 6087 | end |
| 6088 | p = base |
| 6089 | if gt dl 0 |
| 6090 | for j ulong dl bound 2048 |
| 6091 | put mem add p j mg add sg DRO j |
| 6092 | end |
| 6093 | p = add p dl |
| 6094 | put mem p 47 |
| 6095 | p = add p 1 |
| 6096 | end |
| 6097 | for j ulong nl bound 4096 |
| 6098 | put mem add p j get dbuf add ns j |
| 6099 | end |
| 6100 | p = add p nl |
| 6101 | pl = sub p base |
| 6102 | ok = false |
| 6103 | if eq ty 8 |
| 6104 | ok = inman base pl false |
| 6105 | if eq dl 0 |
| 6106 | if mist base pl fmanif |
| 6107 | ok = true |
| 6108 | end |
| 6109 | end |
| 6110 | end |
| 6111 | if eq ty 4 |
| 6112 | ok = inman base pl true |
| 6113 | end |
| 6114 | if not ok |
| 6115 | put st CXO base |
| 6116 | put st CXL pl |
| 6117 | die erset |
| 6118 | end |
| 6119 | end |
| 6120 | |
| 6121 | fn dnlen e ulong rl ulong to ulong |
| 6122 | note length of the name in the getdents64 record at dbuf e, whose record length is rl |
| 6123 | nl = ulong 0 |
| 6124 | while lt add 19 nl rl bound 4096 |
| 6125 | if eq get dbuf add add e 19 nl 0 |
| 6126 | break |
| 6127 | end |
| 6128 | nl = add nl 1 |
| 6129 | end |
| 6130 | ret nl |
| 6131 | end |
| 6132 | |
| 6133 | fn dotdir e ulong nl ulong to bool |
| 6134 | note the entry is . or .. |
| 6135 | if ne get dbuf add e 19 46 |
| 6136 | ret false |
| 6137 | end |
| 6138 | if eq nl 1 |
| 6139 | ret true |
| 6140 | end |
| 6141 | if eq nl 2 |
| 6142 | ret eq get dbuf add e 20 46 |
| 6143 | end |
| 6144 | ret false |
| 6145 | end |
| 6146 | |
| 6147 | fn lsrecs site ulong r ulong to void |
| 6148 | note walks the getdents64 records in dbuf: inode 8, offset 8, record length 2, type 1, name ending in a zero |
| 6149 | e = ulong 0 |
| 6150 | while lt e r bound 4097 |
| 6151 | lo = ulong get dbuf add e 16 |
| 6152 | hi = ulong get dbuf add e 17 |
| 6153 | rl = add lo mul hi 256 |
| 6154 | if or eq rl 0 gt add e rl r |
| 6155 | die erset |
| 6156 | end |
| 6157 | nl = dnlen e rl |
| 6158 | if not dotdir e nl |
| 6159 | lsone site add e 19 nl get dbuf add e 18 |
| 6160 | end |
| 6161 | e = add e rl |
| 6162 | end |
| 6163 | end |
| 6164 | |
| 6165 | fn lsdir site ulong to void |
| 6166 | note every entry of one output directory is a file the manifest names or a directory that holds one. |
| 6167 | note 49152 is O_RDONLY, O_DIRECTORY and O_NOFOLLOW on Linux AArch64. |
| 6168 | pbroot site |
| 6169 | if gt sg DRL 0 |
| 6170 | pbadd tslash |
| 6171 | pbaddm sg DRO sg DRL |
| 6172 | end |
| 6173 | put st CXL 0 |
| 6174 | fd = fopen pb 0 sg PBL 49152 0 |
| 6175 | if lt fd 0 |
| 6176 | die erset |
| 6177 | end |
| 6178 | go = true |
| 6179 | while go bound 100000 |
| 6180 | r = getdnts int fd dbuf 0 4096 |
| 6181 | if lt r 0 |
| 6182 | k = fclose int fd |
| 6183 | die erset |
| 6184 | end |
| 6185 | if eq r 0 |
| 6186 | go = false |
| 6187 | else |
| 6188 | lsrecs site ulong r |
| 6189 | end |
| 6190 | end |
| 6191 | k = fclose int fd |
| 6192 | end |
| 6193 | |
| 6194 | fn lsall site ulong mo ulong lim ulong to void |
| 6195 | note the root and every directory above a manifest entry; an entry the manifest does not explain refuses |
| 6196 | put st MNO mo |
| 6197 | put st MNL lim |
| 6198 | put st DRO 0 |
| 6199 | put st DRL 0 |
| 6200 | lsdir site |
| 6201 | i = mo |
| 6202 | while lt i lim bound 100000 |
| 6203 | e = eol i lim |
| 6204 | s = add i 66 |
| 6205 | j = s |
| 6206 | while lt j e bound 2048 |
| 6207 | if eq mg j 47 |
| 6208 | put st DRO s |
| 6209 | put st DRL sub j s |
| 6210 | lsdir site |
| 6211 | end |
| 6212 | j = add j 1 |
| 6213 | end |
| 6214 | i = add e 1 |
| 6215 | end |
| 6216 | end |
| 6217 | |
| 6218 | fn rewalk to void |
| 6219 | note walks the receipts chain again from the bytes in the output, with the evidence files in the output |
| 6220 | put st TOP sg TOPB |
| 6221 | put st CXO keep fledout |
| 6222 | put st CXL len fledout |
| 6223 | pbroot 0 |
| 6224 | pbadd tslash |
| 6225 | pbadd fledout |
| 6226 | off = slurp |
| 6227 | n = sg FLEN |
| 6228 | if ne mg sub add off n 1 10 |
| 6229 | rcsay 7 1 |
| 6230 | die erledg |
| 6231 | end |
| 6232 | put st PAYO 1 |
| 6233 | count = rcloop off add off n |
| 6234 | put st PAYO 0 |
| 6235 | v = vlook vrhead |
| 6236 | ho = vg add mul sub v 1 4 2 |
| 6237 | same = and eq count sg NREC phis ho add ho 64 |
| 6238 | put st TOP sg TOPB |
| 6239 | put st CXL 0 |
| 6240 | note the record offsets go back to the source ledger, which the expected-manifest pass reads |
| 6241 | count = rcloop sg LDGO add sg LDGO sg LDGN |
| 6242 | if not same |
| 6243 | die erledg |
| 6244 | end |
| 6245 | put st CXL 0 |
| 6246 | end |
| 6247 | |
| 6248 | fn nohop to void |
| 6249 | note without Hop data there is no second site: an output directory for it is an extra |
| 6250 | pbroot 1 |
| 6251 | fd = fopen pb 0 sg PBL 49152 0 |
| 6252 | if ge fd 0 |
| 6253 | k = fclose int fd |
| 6254 | put st CXL 0 |
| 6255 | die erset |
| 6256 | end |
| 6257 | end |
| 6258 | |
| 6259 | fn versite site ulong to void |
| 6260 | note re-reads the site's manifest and every file it names: digest, policy, links, fragments |
| 6261 | put st SITE site |
| 6262 | put st CXL 0 |
| 6263 | pbroot site |
| 6264 | pbadd tslash |
| 6265 | pbadd fmanif |
| 6266 | mo = slurp |
| 6267 | mn = sg FLEN |
| 6268 | put st TOPB sg TOP |
| 6269 | lim = add mo mn |
| 6270 | files = ulong 0 |
| 6271 | i = mo |
| 6272 | while lt i lim bound 100000 |
| 6273 | e = eol i lim |
| 6274 | if lt sub e i 67 |
| 6275 | die erman |
| 6276 | end |
| 6277 | put st TOP sg TOPB |
| 6278 | pbroot site |
| 6279 | pbadd tslash |
| 6280 | pbaddm add i 66 sub e add i 66 |
| 6281 | put st CXO add i 66 |
| 6282 | put st CXL sub e add i 66 |
| 6283 | off = slurp |
| 6284 | n = sg FLEN |
| 6285 | hashm off n |
| 6286 | if not hxis i |
| 6287 | die erman |
| 6288 | end |
| 6289 | put st OBN 0 |
| 6290 | om off n |
| 6291 | put st TOP sg TOPB |
| 6292 | if not insfile add i 66 e site |
| 6293 | if not trformpath add i 66 e |
| 6294 | lint kindof add i 66 e site |
| 6295 | end |
| 6296 | end |
| 6297 | files = add files 1 |
| 6298 | i = add e 1 |
| 6299 | end |
| 6300 | if eq files 0 |
| 6301 | die erman |
| 6302 | end |
| 6303 | put st TOP sg TOPB |
| 6304 | lsall site mo lim |
| 6305 | if eq site 0 |
| 6306 | if eq sg FRC 1 |
| 6307 | rewalk |
| 6308 | end |
| 6309 | end |
| 6310 | if eq site 0 |
| 6311 | say mver0 |
| 6312 | else |
| 6313 | say mver1 |
| 6314 | end |
| 6315 | sayn files |
| 6316 | say tnl |
| 6317 | end |
| 6318 | |
| 6319 | note ---- commands |
| 6320 | |
| 6321 | fn argis t view uchar * n ulong to bool |
| 6322 | if ne n len t |
| 6323 | ret false |
| 6324 | end |
| 6325 | for j ulong n bound 64 |
| 6326 | if ne get arg j get t j |
| 6327 | ret false |
| 6328 | end |
| 6329 | end |
| 6330 | ret true |
| 6331 | end |
| 6332 | |
| 6333 | fn rootok n ulong site ulong to void |
| 6334 | note the output path has no space, backslash or dot-dot and does not end in a slash |
| 6335 | for j ulong n bound 512 |
| 6336 | c = uchar 0 |
| 6337 | if eq site 0 |
| 6338 | c = get root0 j |
| 6339 | else |
| 6340 | c = get root1 j |
| 6341 | end |
| 6342 | if or le c 32 eq c 92 |
| 6343 | die erarg |
| 6344 | end |
| 6345 | if eq c 46 |
| 6346 | if lt add j 1 n |
| 6347 | d = uchar 0 |
| 6348 | if eq site 0 |
| 6349 | d = get root0 add j 1 |
| 6350 | else |
| 6351 | d = get root1 add j 1 |
| 6352 | end |
| 6353 | if eq d 46 |
| 6354 | die erarg |
| 6355 | end |
| 6356 | end |
| 6357 | end |
| 6358 | if eq add j 1 n |
| 6359 | if eq c 47 |
| 6360 | die erarg |
| 6361 | end |
| 6362 | end |
| 6363 | end |
| 6364 | end |
| 6365 | |
| 6366 | fn rootargs to void |
| 6367 | note the two output directories follow the command, or the --test-data flag when it is given |
| 6368 | k = argread 2 root0 0 512 |
| 6369 | if eq sg TESTD 1 |
| 6370 | k = argread 3 root0 0 512 |
| 6371 | end |
| 6372 | if or le k 0 ge k 500 |
| 6373 | die erarg |
| 6374 | end |
| 6375 | put st R0L ulong k |
| 6376 | rootok ulong k 0 |
| 6377 | k = argread 3 root1 0 512 |
| 6378 | if eq sg TESTD 1 |
| 6379 | k = argread 4 root1 0 512 |
| 6380 | end |
| 6381 | if or le k 0 ge k 500 |
| 6382 | die erarg |
| 6383 | end |
| 6384 | put st R1L ulong k |
| 6385 | rootok ulong k 1 |
| 6386 | end |
| 6387 | |
| 6388 | fn omtxt off ulong n ulong to void |
| 6389 | note copies arena text into obuf for a plain-text file: the trade mark entity becomes (TM) |
| 6390 | i = ulong 0 |
| 6391 | while lt i n bound 8192 |
| 6392 | tm = false |
| 6393 | if le add i 7 n |
| 6394 | tm = mistf add off i ptrade false |
| 6395 | end |
| 6396 | if tm |
| 6397 | ot ttm |
| 6398 | i = add i 7 |
| 6399 | else |
| 6400 | ob mg add off i |
| 6401 | i = add i 1 |
| 6402 | end |
| 6403 | end |
| 6404 | end |
| 6405 | |
| 6406 | fn pageline r ulong to void |
| 6407 | note one llms.txt line for page route r: - [title](address): description |
| 6408 | b = mul r 8 |
| 6409 | put st PBL 0 |
| 6410 | pbaddm rg add b 4 rg add b 5 |
| 6411 | put st CXO rg add b 4 |
| 6412 | put st CXL rg add b 5 |
| 6413 | off = slurp |
| 6414 | body = front off sg FLEN |
| 6415 | t = vlook vtitle |
| 6416 | d = vlook vdesc |
| 6417 | if or eq t 0 eq d 0 |
| 6418 | die erfront |
| 6419 | end |
| 6420 | ot pl1 |
| 6421 | tb = mul sub t 1 4 |
| 6422 | omtxt vg add tb 2 vg add tb 3 |
| 6423 | ot pl2 |
| 6424 | ot tbase0 |
| 6425 | om add rg add b 2 1 sub rg add b 3 1 |
| 6426 | ot pl3 |
| 6427 | db = mul sub d 1 4 |
| 6428 | omtxt vg add db 2 vg add db 3 |
| 6429 | ob 10 |
| 6430 | end |
| 6431 | |
| 6432 | fn pagelist to void |
| 6433 | note the placeholder pages: every enabled interplane.io page, in routes order |
| 6434 | put st OBN 0 |
| 6435 | nr = sg NR |
| 6436 | r = ulong 0 |
| 6437 | while lt r nr bound RTCAP |
| 6438 | b = mul r 8 |
| 6439 | if and eq rg b 1 eq rg add b 1 0 |
| 6440 | if enabled r |
| 6441 | mark = sg TOP |
| 6442 | nv = sg NV |
| 6443 | pageline r |
| 6444 | put st TOP mark |
| 6445 | put st NV nv |
| 6446 | end |
| 6447 | end |
| 6448 | r = add r 1 |
| 6449 | end |
| 6450 | po = stash |
| 6451 | setv vpages po sg FLEN |
| 6452 | end |
| 6453 | |
| 6454 | fn agentprompts to void |
| 6455 | note Bind each plain-text prompt route as a template variable without the leading slash. |
| 6456 | note Mode 6 excludes HTML and template delimiters so the displayed text stays literal. |
| 6457 | for r ulong sg NR bound RTCAP |
| 6458 | b = mul r 8 |
| 6459 | ro = rg add b 2 |
| 6460 | rl = rg add b 3 |
| 6461 | if and eq rg b 4 eq rg add b 1 0 |
| 6462 | if and gt rl len promptdir mistf ro promptdir false |
| 6463 | if enabled r |
| 6464 | so = rg add b 4 |
| 6465 | sl = rg add b 5 |
| 6466 | put st CXO so |
| 6467 | put st CXL sl |
| 6468 | put st PBL 0 |
| 6469 | pbaddm so sl |
| 6470 | off = slurp |
| 6471 | e = sub add off sg FLEN 1 |
| 6472 | if not and eq mg e 10 okset off e 6 |
| 6473 | die erprompt |
| 6474 | end |
| 6475 | setvm add ro 1 sub rl 1 off sub e off |
| 6476 | end |
| 6477 | end |
| 6478 | end |
| 6479 | end |
| 6480 | end |
| 6481 | |
| 6482 | fn setup to void |
| 6483 | note loads everything a build or a verify needs: data, flags, layouts and routes |
| 6484 | luminit |
| 6485 | put st TOP 0 |
| 6486 | put st NV 0 |
| 6487 | put st CXL 0 |
| 6488 | if eq sg TESTD 1 |
| 6489 | setvt ktestd vone |
| 6490 | say mtest |
| 6491 | end |
| 6492 | yard |
| 6493 | papers |
| 6494 | receipts |
| 6495 | hop |
| 6496 | live |
| 6497 | routes |
| 6498 | agentprompts |
| 6499 | omdownloads |
| 6500 | zhnone |
| 6501 | pbset flay0 |
| 6502 | put st CXO keep flay0 |
| 6503 | put st CXL len flay0 |
| 6504 | lo = slurp |
| 6505 | put st L0O lo |
| 6506 | put st L0N sg FLEN |
| 6507 | pbset flay1 |
| 6508 | put st CXO keep flay1 |
| 6509 | put st CXL len flay1 |
| 6510 | lo = slurp |
| 6511 | put st L1O lo |
| 6512 | put st L1N sg FLEN |
| 6513 | put st CXL 0 |
| 6514 | pagelist |
| 6515 | put st CXL 0 |
| 6516 | put st NVB sg NV |
| 6517 | put st TOPB sg TOP |
| 6518 | end |
| 6519 | |
| 6520 | fn dobuild to void |
| 6521 | rootargs |
| 6522 | setup |
| 6523 | cssload |
| 6524 | contrast |
| 6525 | put st LCHK 0 |
| 6526 | preflight |
| 6527 | mkroot 0 |
| 6528 | writesite 0 |
| 6529 | if eq sg FHOP 1 |
| 6530 | mkroot 1 |
| 6531 | writesite 1 |
| 6532 | end |
| 6533 | put st LCHK 1 |
| 6534 | versite 0 |
| 6535 | if eq sg FHOP 1 |
| 6536 | versite 1 |
| 6537 | end |
| 6538 | say mbpass |
| 6539 | end |
| 6540 | |
| 6541 | fn doverify to void |
| 6542 | rootargs |
| 6543 | setup |
| 6544 | put st LCHK 1 |
| 6545 | versite 0 |
| 6546 | if eq sg FHOP 1 |
| 6547 | versite 1 |
| 6548 | else |
| 6549 | nohop |
| 6550 | end |
| 6551 | note the expected manifest of each site, rebuilt from the source without writing, equals the one found |
| 6552 | put st LCHK 0 |
| 6553 | put st DRY 1 |
| 6554 | put st MANL 0 |
| 6555 | put st NFILE 0 |
| 6556 | put st NPAGE 0 |
| 6557 | writesite 0 |
| 6558 | if eq sg FHOP 1 |
| 6559 | writesite 1 |
| 6560 | end |
| 6561 | put st DRY 0 |
| 6562 | say mvpass |
| 6563 | end |
| 6564 | |
| 6565 | fn main to int |
| 6566 | ac = argcnt |
| 6567 | if lt ac 2 |
| 6568 | say tusage |
| 6569 | ret 2 |
| 6570 | end |
| 6571 | n = argread 1 arg 0 64 |
| 6572 | if le n 0 |
| 6573 | say tusage |
| 6574 | ret 2 |
| 6575 | end |
| 6576 | if argis trcgate ulong n |
| 6577 | if ne ac 3 |
| 6578 | ret 2 |
| 6579 | end |
| 6580 | trcli |
| 6581 | ret 0 |
| 6582 | end |
| 6583 | if argis trcsp ulong n |
| 6584 | if ne ac 3 |
| 6585 | ret 2 |
| 6586 | end |
| 6587 | trheaders |
| 6588 | ret 0 |
| 6589 | end |
| 6590 | if argis ccontr ulong n |
| 6591 | if ne ac 2 |
| 6592 | say tusage |
| 6593 | ret 2 |
| 6594 | end |
| 6595 | luminit |
| 6596 | put st TOP 0 |
| 6597 | put st CXL 0 |
| 6598 | cssload |
| 6599 | contrast |
| 6600 | ret 0 |
| 6601 | end |
| 6602 | cmd = ulong 0 |
| 6603 | if argis cbuild ulong n |
| 6604 | cmd = 1 |
| 6605 | end |
| 6606 | if argis cverify ulong n |
| 6607 | cmd = 2 |
| 6608 | end |
| 6609 | if eq cmd 0 |
| 6610 | say tusage |
| 6611 | ret 2 |
| 6612 | end |
| 6613 | put st TESTD 0 |
| 6614 | put st DRY 0 |
| 6615 | put st PAYO 0 |
| 6616 | if eq ac 5 |
| 6617 | n = argread 2 arg 0 64 |
| 6618 | if le n 0 |
| 6619 | say tusage |
| 6620 | ret 2 |
| 6621 | end |
| 6622 | if not argis ctestd ulong n |
| 6623 | say tusage |
| 6624 | ret 2 |
| 6625 | end |
| 6626 | put st TESTD 1 |
| 6627 | else |
| 6628 | if ne ac 4 |
| 6629 | say tusage |
| 6630 | ret 2 |
| 6631 | end |
| 6632 | end |
| 6633 | if eq cmd 1 |
| 6634 | dobuild |
| 6635 | else |
| 6636 | doverify |
| 6637 | end |
| 6638 | ret 0 |
| 6639 | end |