Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/dl/dl.om # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / dl / dl.om` 2127 lines ยท 38561 bytes Raw Blame History 1 note dl/dl.om: ForgeDownloads unit of forged (fns dl*, globals gd*, texts td*). Contract v1. 2 note Routes under // (fridx set by the server, GET and HEAD only): 3 note /archive/refs/heads/.zip|.tar.gz /archive/refs/tags/.zip|.tar.gz 4 note /archive/.zip|.tar.gz (7..40 hex: a commit reachable from a canonical ref) 5 note /releases /releases/latest /releases/tag/ /releases/download// 6 note Refs resolve at the storage root first (refs/heads, refs/tags), then in the delegate namespace 7 note refs/namespaces//refs/... . git runs as an argv exec (fkgit), never through a shell. 8 note Archives: git archive into ~/forge-data/archives//-., h16 = the first 16 hex 9 note of sha256(prefix), because the prefix -/ is inside the bytes. Total cache cap 5 GiB 10 note (`5368709120` bytes), one file at most 512 MiB (`536870912`); eviction is least recently used by 11 note ctime (a cache hit chmods the file, which sets its ctime). Release assets (files in the tag's 12 note release-assets/ dir) are cached as .blob the same way. Every cached file gets a sidecar 13 note .sha256 (64 hex) computed in Omega by om/tls/sha2.om. 14 note dlclone (dl/dlclone.om) appends the clone panel (no public Git URL yet, archive links) for the 15 note repo header; the store-reading build composes store/clone.om in its place (run.sh units). 16 global gdp uchar 4096 17 global gdpl ulong 1 18 global gdf uchar 4096 19 global gdfl ulong 1 20 global gdref uchar 256 21 global gdrefl ulong 1 22 global gdkind ulong 1 23 global gdfmt ulong 1 24 global gdsha uchar 40 25 global gdh16 uchar 16 26 global gdpre uchar 512 27 global gdprel ulong 1 28 global gdst uchar 128 29 global gdsize ulong 1 30 global gdws uchar 4 31 global gdent uchar 16384 32 global gdent2 uchar 16384 33 global gdold uchar 4096 34 global gdoldl ulong 1 35 global gdoldc ulong 1 36 global gdtot ulong 1 37 global gdsub uchar 256 38 global gdsubl ulong 1 39 global gdhex uchar 64 40 note the tag list (dltags): every tag, no message text (dlmsg reads the subject and notes of one tag on 41 note its own), so no tag message cuts the list. 16 MiB of records is about 150,000 tags; a longer list 42 note is the whole 500 of fincut, never a shorter list. Record tables hold 262,144 records, more than 43 note 16 MiB of records can hold (a record is at least 64 bytes). 44 global gdtl uchar `16777216` 45 global gdtll ulong 1 46 global gdrec ulong 262144 47 global gdrend ulong 262144 48 global gdrn ulong 1 49 global gdso ulong 262144 50 global gdsl ulong 262144 51 global gdco ulong 262144 52 global gdkeep ulong 262144 53 global gdkn ulong 1 54 global gdlat ulong 1 55 global gdfa ulong 1 56 global gdfn ulong 1 57 note release-assets/ listing (dllsa): offsets into fxo (sha, name), name length and size per asset, and 58 note the count of entries that are not offered (gdaskip) 59 global gdan ulong 1 60 global gdabo ulong 131072 61 global gdasz ulong 131072 62 global gdano ulong 131072 63 global gdanl ulong 131072 64 global gdaskip ulong 1 65 global gdasn uchar 128 66 global gdasnl ulong 1 67 global gdwant uchar 128 68 global gdwantl ulong 1 69 global gdcold ulong 2 70 note gdht: open-addressing set of kept tag records (record + 1) keyed by the short name, for dlkeep1 71 global gdht ulong 524288 72 note dlmsg: subject fxo[gdmsa, +gdmsn) and notes fxo[gdmba, +gdmbn) of one tag 73 global gdmsa ulong 1 74 global gdmsn ulong 1 75 global gdmba ulong 1 76 global gdmbn ulong 1 77 note DLNONE: no record / no asset (larger than any index of the tables above) 78 const DLNONE ulong `16777216` 79 text tdarch "/archive/" 80 text tdheads "refs/heads/" 81 text tdtags "refs/tags/" 82 text tdns "refs/namespaces/" 83 text tdsrh "/refs/heads/" 84 text tdsrt "/refs/tags/" 85 text tdrh0 "refs/heads" 86 text tdrt0 "refs/tags" 87 text tdsrh0 "/refs/heads" 88 text tdsrt0 "/refs/tags" 89 text tdzip ".zip" 90 text tdtgz ".tar.gz" 91 text tdezip "zip" 92 text tdetgz "tar.gz" 93 text tdeblob "blob" 94 text tdrel "/releases" 95 text tdrel2 "/releases/" 96 text tdlat "/releases/latest" 97 text tdrtag "/releases/tag/" 98 text tdrdl "/releases/download/" 99 text tdrevp "rev-parse" 100 text tdverif "--verify" 101 text tdquiet "--quiet" 102 text tdcomm "^{commit}" 103 text tdarcw "archive" 104 text tdfzip "--format=zip" 105 text tdftgz "--format=tar.gz" 106 text tdpref "--prefix=" 107 text tdfer "for-each-ref" 108 text tdcnt1 "--count=1" 109 text tdcont "--contains" 110 text tdpts "--points-at" 111 text tdfmtr "--format=%(refname)" 112 text tdfmtx "--format=x" 113 text tdsortd "--sort=-creatordate" 114 text tdtfmt "--format=%(refname)%1f%(objecttype)%1f%(objectname)%1f%(*objecttype)%1f%(*objectname)%1f%(creatordate:short)%1f%(creatordate:unix)%1e" 115 text tdmfmt "--format=%(contents:subject)%1f%(contents:body)%1e" 116 text tdcatf "cat-file" 117 text tdlstr "ls-tree" 118 text tdlopt "-l" 119 text tdzopt "-z" 120 text tddd "--" 121 text tdradir "release-assets/" 122 text tdmain "main" 123 text tdcommit "commit" 124 text tdtag "tag" 125 text tdnull "/dev/null" 126 text tdadir "archives" 127 text tdtmp ".tmp-" 128 text tdsum ".sha256" 129 text tdctz "application/zip" 130 text tdctg "application/gzip" 131 text tdcto "application/octet-stream" 132 text tdatt "attachment; filename=" 133 text tdcc "public, max-age=300" 134 text tdpage "page" 135 text tdrc "-rc" 136 text tdalpha "-alpha" 137 text tdbeta "-beta" 138 text tdprer "-pre" 139 text tddev "-dev" 140 text tdtrel "Releases: " 141 text tdtrel1 "Release " 142 text tdsec1 "

Releases

\n" 143 text tdsecx "
\n" 144 text tdnorel "

No releases yet. Every tag pushed to this repository is listed here as a release, with its source archives.

\n" 145 text tdart1 "

" 147 text tdax "" 148 text tdlpre " pre-release" 149 text tdllat " latest" 150 text tdmeta "

\n

" 151 text tdcmt1 " · commit " 154 text tdcodex "" 155 text tdcmtx "

\n" 156 text tdsubj "

" 157 text tdpx "

\n" 158 text tdnotes "
"

159 text tdprex "
\n" 160 text tdtbl "\n" 161 text tdtblx "
DownloadBytesSHA-256
\n" 162 text tdtr1 "" 164 text tdtdc "" 165 text tdtrx "\n" 166 text tdnb "-checksum computed on first download\n" 167 text tdask1 "" 168 text tdask2 " more entries in release-assets/ are not offered for download: a name over 120 bytes, a byte other than A-Z a-z 0-9 . _ - +, a leading dot, or not a plain file. They are in the repository: read them with git or rad.\n" 169 text tdsrc " source" 170 text tdarht "/archive/refs/tags/" 171 text tdarhh "/archive/refs/heads/" 172 text tdpg1 "\n" 177 note ---- byte classes and hex 178 fn dlhx v uchar to uchar 179 if lt v 10 180 ret add v 48 181 end 182 ret add v 87 183 end 184 fn dlishex c uchar to bool 185 if and ge c 48 le c 57 186 ret true 187 end 188 ret and ge c 97 le c 102 189 end 190 fn dldig c uchar to bool 191 ret and ge c 48 le c 57 192 end 193 note dlrch: a byte allowed in a ref name in a URL: A-Z a-z 0-9 . _ - / + 194 fn dlrch c uchar to bool 195 if and ge c 97 le c 122 196 ret true 197 end 198 if and ge c 65 le c 90 199 ret true 200 end 201 if dldig c 202 ret true 203 end 204 ret or or or eq c 46 eq c 95 or eq c 45 eq c 47 eq c 43 205 end 206 note dlrefok: gdref[0, gdrefl) is 1..200 allowed bytes, no leading - / ., no trailing / ., no .. // /. 207 fn dlrefok to bool 208 n = get gdrefl 0 209 if or eq n 0 gt n 200 210 ret false 211 end 212 c0 = get gdref 0 213 if or or eq c0 45 eq c0 47 eq c0 46 214 ret false 215 end 216 cl = get gdref sub n 1 217 if or eq cl 47 eq cl 46 218 ret false 219 end 220 p = get gdref 0 221 for i ulong n 222 c = get gdref i 223 if not dlrch c 224 ret false 225 end 226 if gt i 0 227 if and eq c 46 or eq p 46 eq p 47 228 ret false 229 end 230 if and eq c 47 eq p 47 231 ret false 232 end 233 end 234 p = c 235 end 236 ret true 237 end 238 note dlasok: gdasn[0, gdasnl) is one file name: 1..120 bytes of A-Z a-z 0-9 . _ - +, not starting with . 239 fn dlasok to bool 240 n = get gdasnl 0 241 if or eq n 0 gt n 120 242 ret false 243 end 244 if eq get gdasn 0 46 245 ret false 246 end 247 for i ulong n 248 c = get gdasn i 249 if or eq c 47 not dlrch c 250 ret false 251 end 252 end 253 ret true 254 end 255 note ---- frest matching (the path after //) 256 fn dlrat o ulong t view uchar * to bool 257 n = get frestl 0 258 if gt add o len t n 259 ret false 260 end 261 for i ulong len t 262 if ne get frest add o i get t i 263 ret false 264 end 265 end 266 ret true 267 end 268 fn dlrst t view uchar * to bool 269 ret dlrat 0 t 270 end 271 fn dlreq t view uchar * to bool 272 if ne len t get frestl 0 273 ret false 274 end 275 ret dlrat 0 t 276 end 277 fn dlrend t view uchar * to bool 278 n = get frestl 0 279 if lt n len t 280 ret false 281 end 282 ret dlrat sub n len t t 283 end 284 note dlrcopy: frest[a, e) into gdref; false when longer than 200 285 fn dlrcopy a ulong e ulong to bool 286 put gdrefl 0 0 287 if or ge a e gt sub e a 200 288 ret false 289 end 290 for i ulong sub e a 291 put gdref i get frest add a i 292 end 293 put gdrefl 0 sub e a 294 ret true 295 end 296 note ---- path builder gdp (and the final path gdf) 297 fn dlpb to void 298 put gdpl 0 0 299 end 300 fn dlpc c uchar to void 301 n = get gdpl 0 302 if lt n 4095 303 put gdp n c 304 put gdpl 0 add n 1 305 end 306 end 307 fn dlpt t view uchar * to void 308 for i ulong len t 309 dlpc get t i 310 end 311 end 312 fn dlpd v ulong to void 313 d = new uchar 20 0 314 i = ulong 20 315 x = v 316 for it ulong 20 317 i = sub i 1 318 put d i uchar add rem x 10 48 319 x = div x 10 320 if eq x 0 321 break 322 end 323 end 324 for k ulong sub 20 i 325 dlpc get d add i k 326 end 327 end 328 fn dlpf to void 329 for i ulong get gdfl 0 330 dlpc get gdf i 331 end 332 end 333 fn dlp2f to void 334 n = get gdpl 0 335 for i ulong n 336 put gdf i get gdp i 337 end 338 put gdfl 0 n 339 end 340 note dlparc: archives 341 fn dlparc to void 342 dlpb 343 dlpt tfdata 344 dlpt tdadir 345 end 346 note dlpdir: archives/ 347 fn dlpdir to void 348 dlparc 349 dlpc 47 350 for i ulong get fridl 0 351 dlpc get frid i 352 end 353 end 354 fn dlmkdir to bool 355 dlpb 356 dlpt tfdata 357 r = makedir gdp 0 get gdpl 0 448 358 dlparc 359 r = makedir gdp 0 get gdpl 0 448 360 dlpdir 361 r = makedir gdp 0 get gdpl 0 448 362 ret or eq r 0 eq r -17 363 end 364 note dlfinal: gdf = /-. 365 fn dlfinal ext view uchar * to void 366 dlpdir 367 dlpc 47 368 for i ulong 40 369 dlpc get gdsha i 370 end 371 dlpc 45 372 for i ulong 16 373 dlpc get gdh16 i 374 end 375 dlpc 46 376 dlpt ext 377 dlp2f 378 end 379 note dlfblob: gdf = /.blob 380 fn dlfblob to void 381 dlpdir 382 dlpc 47 383 for i ulong 40 384 dlpc get gdsha i 385 end 386 dlpc 46 387 dlpt tdeblob 388 dlp2f 389 end 390 note ---- stat helpers (Linux arm64 stat: mode +16, size +48, ctime +104 s, +112 ns) 391 fn dlst64 o ulong to ulong 392 v = ulong 0 393 for i ulong 8 394 b = ulong get gdst add o i 395 v = or v shl b mul i 8 396 end 397 ret v 398 end 399 fn dlst32 o ulong to ulong 400 v = ulong 0 401 for i ulong 4 402 b = ulong get gdst add o i 403 v = or v shl b mul i 8 404 end 405 ret v 406 end 407 note dlexists: gdf is a nonempty regular file; its size in gdsize 408 fn dlexists to bool 409 r = stat gdf 0 get gdfl 0 gdst 0 128 410 if lt r 0 411 ret false 412 end 413 if ne and dlst32 16 61440 32768 414 ret false 415 end 416 put gdsize 0 dlst64 48 417 ret gt get gdsize 0 0 418 end 419 note ---- argv helpers on the contract's fpk builder 420 fn dlkt t view uchar * to void 421 for i ulong len t 422 fkc get t i 423 end 424 end 425 fn dlksha to void 426 fkopen 427 for i ulong 40 428 fkc get gdsha i 429 end 430 end 431 note dlkns: start an arg "refs/namespaces/" + t 432 fn dlkns t view uchar * to void 433 fkopen 434 dlkt tdns 435 dlkt tfnid 436 dlkt t 437 end 438 note ---- running git with stdout into an open file (archives can pass fxo's 16 MiB) 439 fn dlchild ofd int to void 440 nul = fopen tdnull 0 len tdnull 2 0 441 if lt nul 0 442 exit 126 443 end 444 x = dupfd int nul 0 0 445 x = dupfd ofd 1 0 446 x = dupfd int nul 2 0 447 x = execprog fpk 0 get fpkl 0 448 exit 127 449 end 450 note dlrunf: run argv fpk, stdout into ofd, 120 s deadline, file cap 512 MiB. Exit status 0..255, 451 note -1 killed (deadline or cap), -2 cannot start, -3 signalled, -4 wait failure 452 fn dlrunf ofd int to long 453 pid = fork 454 if lt pid 0 455 ret -2 456 end 457 if eq pid 0 458 dlchild ofd 459 exit 127 460 end 461 dl = add monons `120000000000` 462 for it ulong 200000 463 w = waitpid int pid gdws 0 4 1 464 if eq w pid 465 s = or ulong get gdws 0 shl ulong get gdws 1 8 466 if eq and s 127 0 467 ret long and shr s 8 255 468 end 469 ret -3 470 end 471 if and lt w 0 ne w -4 472 ret -4 473 end 474 r = fstat ofd gdst 0 128 475 toob = false 476 if ge r 0 477 toob = gt dlst64 48 `536870912` 478 end 479 if or toob gt monons dl 480 x = killpid int pid 9 481 w = waitpid int pid gdws 0 4 0 482 ret -1 483 end 484 x = sleepns `2000000` 485 end 486 ret -4 487 end 488 note dlgenx: run the argv already in fpk into /.tmp-., then rename it to gdf 489 fn dlgenx to long 490 dlpdir 491 dlpc 47 492 dlpt tdtmp 493 dlpd ulong getpid 494 fd = fopen gdp 0 get gdpl 0 524865 384 495 if lt fd 0 496 ret -2 497 end 498 r = dlrunf int fd 499 x = fclose int fd 500 if ne r 0 501 x = unlink gdp 0 get gdpl 0 502 ret -1 503 end 504 fkb 505 fkopen 506 for i ulong get gdpl 0 507 fkc get gdp i 508 end 509 fkopen 510 for i ulong get gdfl 0 511 fkc get gdf i 512 end 513 r = renames fpk 0 get fpkl 0 0 514 if ne r 0 515 x = unlink gdp 0 get gdpl 0 516 ret r 517 end 518 ret 0 519 end 520 note dlkarch: argv git archive --format=zip|tar.gz --prefix=/ 521 fn dlkarch to void 522 fksource 523 fka tdarcw 524 if eq get gdfmt 0 1 525 fka tdfzip 526 else 527 fka tdftgz 528 end 529 fkopen 530 dlkt tdpref 531 for i ulong get gdprel 0 532 fkc get gdpre i 533 end 534 fkc 47 535 dlksha 536 end 537 note dlkblob: argv git cat-file blob 538 fn dlkblob to void 539 fksource 540 fka tdcatf 541 fka tdeblob 542 dlksha 543 end 544 note dlensure: gdf exists (a hit touches its ctime) or is generated now (what 1 archive, 2 blob); 545 note either way its .sha256 sidecar is written once; -7 = the site-wide cold-build cap is full 546 fn dlensure what ulong to long 547 if dlexists 548 x = chmod gdf 0 get gdfl 0 384 549 hs = dlsum 550 ret 0 551 end 552 if not dlmkdir 553 ret -2 554 end 555 if not dlcold 556 ret -7 557 end 558 if eq what 1 559 dlkarch 560 else 561 dlkblob 562 end 563 r = dlgenx 564 if lt r 0 565 ret r 566 end 567 gs = dlsum 568 dlevict 569 if not dlexists 570 ret -5 571 end 572 ret 0 573 end 574 note dlcold: take a cold-build slot; at most 2 builds start in any 60 s, site-wide (gdcold: start times) 575 fn dlcold to bool 576 t = ulong monons 577 for i ulong 2 578 s = get gdcold i 579 if or eq s 0 ge sub t s `60000000000` 580 put gdcold i t 581 ret true 582 end 583 end 584 ret false 585 end 586 note dlretry: whole seconds until the older slot frees, at least 1 587 fn dlretry to ulong 588 t = ulong monons 589 a = get gdcold 0 590 b = get gdcold 1 591 if lt b a 592 a = b 593 end 594 e = sub t a 595 if ge e `60000000000` 596 ret 1 597 end 598 ret add div sub `60000000000` e `1000000000` 1 599 end 600 note dlbusy: 503 with Retry-After (the server's error page; fretry is the contract's header field) 601 fn dlbusy to long 602 put fretry 0 dlretry 603 ret 503 604 end 605 note ---- LRU eviction over archives/*/* 606 fn dlevict to void 607 for round ulong 64 608 dlscan 609 if le get gdtot 0 `5368709120` 610 ret 611 end 612 if eq get gdoldl 0 0 613 ret 614 end 615 x = unlink gdold 0 get gdoldl 0 616 n = get gdoldl 0 617 if lt add n 8 4096 618 for i ulong len tdsum 619 put gdold add n i get tdsum i 620 end 621 x = unlink gdold 0 add n len tdsum 622 end 623 end 624 end 625 fn dlscan to void 626 put gdtot 0 0 627 put gdoldl 0 0 628 dlparc 629 fd = fopen gdp 0 get gdpl 0 540672 0 630 if lt fd 0 631 ret 632 end 633 for it ulong 4096 634 n = getdnts int fd gdent 0 16384 635 if le n 0 636 break 637 end 638 dlscan1 ulong n 639 end 640 x = fclose int fd 641 end 642 fn dlscan1 n ulong to void 643 p = ulong 0 644 for it ulong 16384 645 if ge add p 19 n 646 break 647 end 648 rl = or ulong get gdent add p 16 shl ulong get gdent add p 17 8 649 if eq rl 0 650 break 651 end 652 if and eq get gdent add p 18 4 ne get gdent add p 19 46 653 put gdsubl 0 0 654 for i ulong 255 655 c = get gdent add add p 19 i 656 if eq c 0 657 break 658 end 659 put gdsub i c 660 put gdsubl 0 add i 1 661 end 662 dlscand 663 end 664 p = add p rl 665 end 666 end 667 fn dlpsub to void 668 dlparc 669 dlpc 47 670 for i ulong get gdsubl 0 671 dlpc get gdsub i 672 end 673 end 674 fn dlscand to void 675 dlpsub 676 fd = fopen gdp 0 get gdpl 0 540672 0 677 if lt fd 0 678 ret 679 end 680 for it ulong 4096 681 n = getdnts int fd gdent2 0 16384 682 if le n 0 683 break 684 end 685 dlscanf ulong n 686 end 687 x = fclose int fd 688 end 689 fn dlscanf n ulong to void 690 p = ulong 0 691 for it ulong 16384 692 if ge add p 19 n 693 break 694 end 695 rl = or ulong get gdent2 add p 16 shl ulong get gdent2 add p 17 8 696 if eq rl 0 697 break 698 end 699 if eq get gdent2 add p 18 8 700 dlpsub 701 dlpc 47 702 for i ulong 255 703 c = get gdent2 add add p 19 i 704 if eq c 0 705 break 706 end 707 dlpc c 708 end 709 dlscanf1 710 end 711 p = add p rl 712 end 713 end 714 note dlscanf1: count the file in gdp, keep it as the eviction candidate when its ctime is oldest 715 fn dlscanf1 to void 716 r = stat gdp 0 get gdpl 0 gdst 0 128 717 if lt r 0 718 ret 719 end 720 put gdtot 0 add get gdtot 0 dlst64 48 721 ct = add mul dlst64 104 `1000000000` dlst64 112 722 if and ne get gdoldl 0 0 ge ct get gdoldc 0 723 ret 724 end 725 n = get gdpl 0 726 for i ulong n 727 put gdold i get gdp i 728 end 729 put gdoldl 0 n 730 put gdoldc 0 ct 731 end 732 note ---- SHA-256 of the file gdf into gdhex, cached in the sidecar .sha256 733 fn dlsha256f to bool 734 c = new ulong 40 0 735 b = new uchar 65536 0 736 o = new uchar 32 0 737 fd = fopen gdf 0 get gdfl 0 524288 0 738 if lt fd 0 739 ret false 740 end 741 sha256_init c 742 for it ulong 16384 743 r = read int fd b 0 65536 744 if lt r 0 745 x = fclose int fd 746 ret false 747 end 748 if eq r 0 749 break 750 end 751 sha256_update c view part b 0 ulong r 752 end 753 x = fclose int fd 754 sha256_final c o 755 for i ulong 32 756 v = get o i 757 put gdhex mul i 2 dlhx shr v 4 758 put gdhex add mul i 2 1 dlhx and v 15 759 end 760 ret true 761 end 762 fn dlhex64 to bool 763 for i ulong 64 764 if not dlishex get gdhex i 765 ret false 766 end 767 end 768 ret true 769 end 770 note dlsumrd: the SHA-256 of gdf from its .sha256 sidecar into gdhex, never computed (gdp = sidecar) 771 fn dlsumrd to bool 772 dlpb 773 dlpf 774 dlpt tdsum 775 fd = fopen gdp 0 get gdpl 0 524288 0 776 if lt fd 0 777 ret false 778 end 779 r = read int fd gdhex 0 64 780 x = fclose int fd 781 if ne r 64 782 ret false 783 end 784 ret dlhex64 785 end 786 note dlsum: the sidecar's SHA-256, or compute it over gdf in Omega and write the sidecar 787 fn dlsum to bool 788 if dlsumrd 789 ret true 790 end 791 if not dlsha256f 792 ret false 793 end 794 fd = fopen gdp 0 get gdpl 0 524865 384 795 if ge fd 0 796 w = write int fd gdhex 0 64 797 x = fclose int fd 798 end 799 ret true 800 end 801 note ---- ref resolution 802 note dlsha40: fxo starts with 40 lowercase hex; copied into gdsha 803 fn dlsha40 to bool 804 if lt get fxol 0 40 805 ret false 806 end 807 for i ulong 40 808 c = get fxo i 809 if not dlishex c 810 ret false 811 end 812 put gdsha i c 813 end 814 ret true 815 end 816 note dlrevp: rev-parse one candidate for gdref: 0 as given, 1 refs/heads/, 2 delegate heads, 817 note 3 refs/tags/, 4 delegate tags; the commit sha into gdsha 818 fn dlrevp mode ulong to bool 819 fksource 820 fka tdrevp 821 fka tdverif 822 fka tdquiet 823 if eq mode 0 824 fkopen 825 end 826 if eq mode 1 827 fkopen 828 dlkt tdheads 829 end 830 if eq mode 2 831 dlkns tdsrh 832 end 833 if eq mode 3 834 fkopen 835 dlkt tdtags 836 end 837 if eq mode 4 838 dlkns tdsrt 839 end 840 for i ulong get gdrefl 0 841 fkc get gdref i 842 end 843 dlkt tdcomm 844 r = fexec `10000000000` 845 if ne r 0 846 ret false 847 end 848 ret dlsha40 849 end 850 note dlrch0 / dlrch1: reachability from a canonical head or tag (root or delegate namespace): 851 note dlrch0 starts the for-each-ref --contains argv, the caller adds one commit id, dlrch1 adds the 852 note ref patterns and runs it; shared with browse (brreach) 853 fn dlrch0 to void 854 fksource 855 fka tdfer 856 fka tdcnt1 857 fka tdfmtx 858 fka tdcont 859 end 860 fn dlrch1 to bool 861 fka tdrh0 862 fka tdrt0 863 dlkns tdsrh0 864 dlkns tdsrt0 865 r = fexec `20000000000` 866 ret and eq r 0 gt get fxol 0 0 867 end 868 fn dlallhex to bool 869 n = get gdrefl 0 870 if or lt n 7 gt n 40 871 ret false 872 end 873 for i ulong n 874 if not dlishex get gdref i 875 ret false 876 end 877 end 878 ret true 879 end 880 note dlresolve: gdref of kind gdkind (1 head, 2 tag, 3 any head or tag name) to a commit in gdsha 881 fn dlresolve to bool 882 k = get gdkind 0 883 if eq k 1 884 if dlrevp 1 885 ret true 886 end 887 ret dlrevp 2 888 end 889 if eq k 2 890 if dlrevp 3 891 ret true 892 end 893 ret dlrevp 4 894 end 895 if dlrevp 1 896 ret true 897 end 898 if dlrevp 2 899 ret true 900 end 901 if dlrevp 3 902 ret true 903 end 904 ret dlrevp 4 905 end 906 note ---- archive names 907 note dlprefix: gdpre = - with / as -, a tag's leading v before a digit dropped; gdh16 908 fn dlprefix to void 909 put gdprel 0 0 910 for i ulong get frepol 0 911 dlprc get frepo i 912 end 913 dlprc 45 914 s = ulong 0 915 if and eq get gdkind 0 2 gt get gdrefl 0 1 916 if and eq get gdref 0 118 dldig get gdref 1 917 s = 1 918 end 919 end 920 for i ulong sub get gdrefl 0 s 921 c = get gdref add i s 922 if eq c 47 923 c = 45 924 end 925 dlprc c 926 end 927 dlh16 928 end 929 fn dlprc c uchar to void 930 n = get gdprel 0 931 if lt n 511 932 put gdpre n c 933 put gdprel 0 add n 1 934 end 935 end 936 fn dlh16 to void 937 b = new uchar 512 0 938 o = new uchar 32 0 939 n = get gdprel 0 940 for i ulong n 941 put b i get gdpre i 942 end 943 k = sha2_digest 256 view part b 0 n o 944 for i ulong 8 945 v = get o i 946 put gdh16 mul i 2 dlhx shr v 4 947 put gdh16 add mul i 2 1 dlhx and v 15 948 end 949 end 950 note ---- response fields 951 fn dlsetetag to void 952 put fetag 0 34 953 for i ulong 40 954 put fetag add i 1 get gdsha i 955 end 956 put fetag 41 34 957 put fetagl 0 42 958 end 959 fn dlsetcc to void 960 for i ulong len tdcc 961 put fcc i get tdcc i 962 end 963 put fccl 0 len tdcc 964 end 965 fn dlsetfile to void 966 n = get gdfl 0 967 for i ulong n 968 put ffile i get gdf i 969 end 970 put ffilel 0 n 971 end 972 note dlinm: If-None-Match holds "" 973 fn dlinm to bool 974 n = get finml 0 975 if lt n 42 976 ret false 977 end 978 for s ulong add sub n 42 1 979 if eq get finm s 34 980 if dlinm1 s 981 ret true 982 end 983 end 984 end 985 ret false 986 end 987 fn dlinm1 s ulong to bool 988 for i ulong 40 989 j = add add s 1 i 990 if ne get finm j get gdsha i 991 ret false 992 end 993 end 994 ret eq get finm add s 41 34 995 end 996 note ---- /archive/... 997 note dlparse: frest = /archive/[refs/heads/|refs/tags/].zip|.tar.gz into gdkind gdref gdfmt; 998 note 0 ok, 404 not an archive name, 400 a refused ref 999 fn dlparse to ulong 1000 n = get frestl 0 1001 e = n 1002 fmt = ulong 0 1003 if dlrend tdtgz 1004 fmt = 2 1005 e = sub n len tdtgz 1006 end 1007 if and eq fmt 0 dlrend tdzip 1008 fmt = 1 1009 e = sub n len tdzip 1010 end 1011 if eq fmt 0 1012 ret 404 1013 end 1014 put gdfmt 0 fmt 1015 a = len tdarch 1016 k = ulong 3 1017 if dlrat a tdheads 1018 k = 1 1019 a = add a len tdheads 1020 end 1021 if and eq k 3 dlrat a tdtags 1022 k = 2 1023 a = add a len tdtags 1024 end 1025 put gdkind 0 k 1026 if le e a 1027 ret 404 1028 end 1029 if not dlrcopy a e 1030 ret 400 1031 end 1032 if not dlrefok 1033 ret 400 1034 end 1035 ret 0 1036 end 1037 fn dlarch to long 1038 c = dlparse 1039 if ne c 0 1040 ret long c 1041 end 1042 if eq get gdkind 0 3 1043 if dlallhex 1044 ret dlarsha 1045 end 1046 end 1047 if not dlresolve 1048 ret 404 1049 end 1050 if eq get gdfmt 0 1 1051 ret dlarch2 tdezip tdctz 1052 end 1053 ret dlarch2 tdetgz tdctg 1054 end 1055 note dlarsha: /archive/<7..40 hex>: 302 to the archive of a head or tag at exactly that commit, else 1056 note 404 (no archive is built for any other commit) 1057 fn dlarsha to long 1058 if not dlrevp 0 1059 ret 404 1060 end 1061 if not dlpts 1062 ret 404 1063 end 1064 put fkind 0 2 1065 flocb 1066 for i ulong get fownl 0 1067 flocc get fown i 1068 end 1069 flocc 47 1070 for i ulong get frepol 0 1071 flocc get frepo i 1072 end 1073 if eq get gdkind 0 1 1074 floct tdarhh 1075 else 1076 floct tdarht 1077 end 1078 for i ulong get gdrefl 0 1079 flocc get gdref i 1080 end 1081 if eq get gdfmt 0 1 1082 floct tdzip 1083 else 1084 floct tdtgz 1085 end 1086 ret 302 1087 end 1088 note dlpts: the first canonical head (else tag) that points at gdsha, peeled, into gdkind / gdref 1089 note (refname order puts refs/heads and refs/namespaces//refs/heads before any tag) 1090 fn dlpts to bool 1091 fksource 1092 fka tdfer 1093 fka tdcnt1 1094 fka tdfmtr 1095 fka tdpts 1096 dlksha 1097 fka tdrh0 1098 fka tdrt0 1099 dlkns tdsrh0 1100 dlkns tdsrt0 1101 r = fexec `20000000000` 1102 if ne r 0 1103 ret false 1104 end 1105 a = ulong 0 1106 if dlxat 0 tdns 1107 if not dlxat len tdns tfnid 1108 ret false 1109 end 1110 a = add len tdns len tfnid 1111 put gdkind 0 1 1112 if dlxat a tdsrh 1113 ret dlptsn add a len tdsrh 1114 end 1115 put gdkind 0 2 1116 if dlxat a tdsrt 1117 ret dlptsn add a len tdsrt 1118 end 1119 ret false 1120 end 1121 put gdkind 0 1 1122 if dlxat 0 tdheads 1123 ret dlptsn len tdheads 1124 end 1125 put gdkind 0 2 1126 if dlxat 0 tdtags 1127 ret dlptsn len tdtags 1128 end 1129 ret false 1130 end 1131 note dlptsn: the ref name in fxo from a to the newline into gdref, checked by dlrefok 1132 fn dlptsn a ulong to bool 1133 n = get fxol 0 1134 e = a 1135 for i ulong sub n a bound `16777216` 1136 if eq get fxo add a i 10 1137 break 1138 end 1139 e = add e 1 1140 end 1141 if or le e a gt sub e a 200 1142 ret false 1143 end 1144 for i ulong sub e a 1145 put gdref i get fxo add a i 1146 end 1147 put gdrefl 0 sub e a 1148 ret dlrefok 1149 end 1150 fn dlarch2 ext view uchar * ct view uchar * to long 1151 dlprefix 1152 dlfinal ext 1153 dlsetetag 1154 dlsetcc 1155 if dlinm 1156 put fkind 0 1 1157 ret 304 1158 end 1159 r = dlensure 1 1160 if eq r -7 1161 ret dlbusy 1162 end 1163 if lt r 0 1164 ret 500 1165 end 1166 put fkind 0 3 1167 fsetct ct 1168 fsetcd tdatt 1169 for i ulong get gdprel 0 1170 fcdc get gdpre i 1171 end 1172 fcdc 46 1173 for i ulong len ext 1174 fcdc get ext i 1175 end 1176 dlsetfile 1177 ret 200 1178 end 1179 note ---- tags (releases) 1180 note dltags: the whole tag list (no --count: an older tag is a release like the newest) into gdtl, 1181 note records split, short names, dedup and validity into gdkeep 1182 fn dltags to bool 1183 fksource 1184 fka tdfer 1185 fka tdsortd 1186 fka tdtfmt 1187 fka tdrt0 1188 dlkns tdsrt0 1189 r = fexec `20000000000` 1190 if ne r 0 1191 ret false 1192 end 1193 note a list longer than gdtl (or than fxo) is not parsed: its cut copy would be taken for the whole list 1194 note (no releases, or only the newest ones, with status 200). Every caller answers the whole 500 of fincut. 1195 if or gt get fxol 0 len gdtl ne get fxotr 0 0 1196 fincut 1197 ret false 1198 end 1199 note the loops over gdtl carry its size as their bound: a `for` with a smaller bound stops the server 1200 note (trap 4, exit 104) when the list is longer, and the tag list can be 16,777,216 bytes 1201 n = hmin get fxol 0 len gdtl 1202 for i ulong n bound `16777216` 1203 put gdtl i get fxo i 1204 end 1205 put gdtll 0 n 1206 if not dlsplit 1207 fincut 1208 ret false 1209 end 1210 put gdkn 0 0 1211 put gdlat 0 DLNONE 1212 for i ulong len gdht 1213 put gdht i 0 1214 end 1215 for r2 ulong get gdrn 0 bound 262144 1216 dlkeep1 r2 1217 end 1218 ret true 1219 end 1220 note dlsplit: records of gdtl into gdrec / gdrend; false when there are more than the tables hold 1221 fn dlsplit to bool 1222 put gdrn 0 0 1223 s = ulong 0 1224 n = get gdtll 0 1225 for i ulong n bound `16777216` 1226 if eq get gdtl i 30 1227 k = get gdrn 0 1228 if ge k len gdrec 1229 ret false 1230 end 1231 put gdrec k s 1232 put gdrend k i 1233 put gdrn 0 add k 1 1234 s = add i 1 1235 if lt s n 1236 if eq get gdtl s 10 1237 s = add s 1 1238 end 1239 end 1240 end 1241 end 1242 ret true 1243 end 1244 note dlfld: field k of record r into gdfa / gdfn (fields split by 0x1f) 1245 fn dlfld r ulong k ulong to void 1246 a = get gdrec r 1247 e = get gdrend r 1248 f = ulong 0 1249 s = a 1250 for i ulong sub e a bound `16777216` 1251 j = add a i 1252 if eq get gdtl j 31 1253 if eq f k 1254 put gdfa 0 s 1255 put gdfn 0 sub j s 1256 ret 1257 end 1258 f = add f 1 1259 s = add j 1 1260 end 1261 end 1262 if eq f k 1263 put gdfa 0 s 1264 put gdfn 0 sub e s 1265 ret 1266 end 1267 put gdfa 0 e 1268 put gdfn 0 0 1269 end 1270 note dlgat: gdtl[a, a + n) starts at o with t 1271 fn dlgat o ulong e ulong t view uchar * to bool 1272 if gt add o len t e 1273 ret false 1274 end 1275 for i ulong len t 1276 if ne get gdtl add o i get t i 1277 ret false 1278 end 1279 end 1280 ret true 1281 end 1282 fn dlfeq t view uchar * to bool 1283 if ne get gdfn 0 len t 1284 ret false 1285 end 1286 a = get gdfa 0 1287 ret dlgat a add a len t t 1288 end 1289 note dlshort: the short tag name of record r (after refs/tags/ or the delegate prefix); false if neither 1290 fn dlshort r ulong to bool 1291 dlfld r 0 1292 a = get gdfa 0 1293 e = add a get gdfn 0 1294 if dlgat a e tdtags 1295 put gdso r add a len tdtags 1296 put gdsl r sub e add a len tdtags 1297 ret true 1298 end 1299 if not dlgat a e tdns 1300 ret false 1301 end 1302 o = add a len tdns 1303 if not dlgat o e tfnid 1304 ret false 1305 end 1306 o = add o len tfnid 1307 if not dlgat o e tdsrt 1308 ret false 1309 end 1310 o = add o len tdsrt 1311 put gdso r o 1312 put gdsl r sub e o 1313 ret true 1314 end 1315 fn dlsn2ref r ulong to void 1316 n = hmin get gdsl r 255 1317 a = get gdso r 1318 for i ulong n 1319 put gdref i get gdtl add a i 1320 end 1321 put gdrefl 0 n 1322 put gdkind 0 2 1323 end 1324 fn dlsneq r ulong q ulong to bool 1325 n = get gdsl r 1326 if ne n get gdsl q 1327 ret false 1328 end 1329 a = get gdso r 1330 b = get gdso q 1331 for i ulong n bound `16777216` 1332 if ne get gdtl add a i get gdtl add b i 1333 ret false 1334 end 1335 end 1336 ret true 1337 end 1338 note dlcommit: the peeled commit of record r (offset into gdtl in gdco); false for non-commits 1339 fn dlcmof r ulong to bool 1340 dlfld r 1 1341 if dlfeq tdcommit 1342 dlfld r 2 1343 put gdco r get gdfa 0 1344 ret eq get gdfn 0 40 1345 end 1346 dlfld r 3 1347 if dlfeq tdcommit 1348 dlfld r 4 1349 put gdco r get gdfa 0 1350 ret eq get gdfn 0 40 1351 end 1352 ret false 1353 end 1354 fn dlkeep1 r ulong to void 1355 if not dlshort r 1356 ret 1357 end 1358 dlsn2ref r 1359 if not dlrefok 1360 ret 1361 end 1362 if not dlcmof r 1363 ret 1364 end 1365 if dldup r 1366 ret 1367 end 1368 note gdkn stays below len gdkeep: it counts kept records, at most gdrn, at most len gdrec 1369 k = get gdkn 0 1370 put gdkeep k r 1371 put gdkn 0 add k 1 1372 if eq get gdlat 0 DLNONE 1373 if not dlpre 1374 put gdlat 0 r 1375 end 1376 end 1377 end 1378 note dldup r: a kept record has the short name of record r (true), else r joins the set (gdht) 1379 fn dldup r ulong to bool 1380 m = sub len gdht 1 1381 j = and dlhash r m 1382 for it ulong len gdht 1383 v = get gdht j 1384 if eq v 0 1385 put gdht j add r 1 1386 ret false 1387 end 1388 if dlsneq r sub v 1 1389 ret true 1390 end 1391 j = and add j 1 m 1392 end 1393 ret true 1394 end 1395 note dlhash r: FNV-1a 64 of the short name of record r 1396 fn dlhash r ulong to ulong 1397 h = ulong `14695981039346656037` 1398 a = get gdso r 1399 for i ulong get gdsl r bound `16777216` 1400 c = ulong get gdtl add a i 1401 h = mul xor h c `1099511628211` 1402 end 1403 ret h 1404 end 1405 note dlpre: gdref looks like a pre-release (-rc -alpha -beta -pre -dev) 1406 fn dlpre to bool 1407 if dlrhas tdrc 1408 ret true 1409 end 1410 if dlrhas tdalpha 1411 ret true 1412 end 1413 if dlrhas tdbeta 1414 ret true 1415 end 1416 if dlrhas tdprer 1417 ret true 1418 end 1419 ret dlrhas tddev 1420 end 1421 fn dlrhas t view uchar * to bool 1422 n = get gdrefl 0 1423 if lt n len t 1424 ret false 1425 end 1426 for s ulong add sub n len t 1 1427 if dlrhas1 s t 1428 ret true 1429 end 1430 end 1431 ret false 1432 end 1433 fn dlrhas1 s ulong t view uchar * to bool 1434 for i ulong len t 1435 if ne get gdref add s i get t i 1436 ret false 1437 end 1438 end 1439 ret true 1440 end 1441 fn dlsetsha r ulong to void 1442 a = get gdco r 1443 for i ulong 40 1444 put gdsha i get gdtl add a i 1445 end 1446 end 1447 note ---- HTML pieces 1448 fn dlescref to void 1449 for i ulong get gdrefl 0 1450 fescc get gdref i 1451 end 1452 end 1453 fn dlescf to void 1454 a = get gdfa 0 1455 for i ulong get gdfn 0 bound `16777216` 1456 fescc get gdtl add a i 1457 end 1458 end 1459 fn dlrepol to void 1460 fputb 1461 fputrepo 1462 end 1463 note dlrel1: one release article for kept record r; full adds the release-assets/ files 1464 fn dlrel1 r ulong full bool to void 1465 dlsn2ref r 1466 dlsetsha r 1467 fput tdart1 1468 dlrepol 1469 fput tdrtag 1470 dlescref 1471 fput tdq2 1472 dlescref 1473 fput tdax 1474 if dlpre 1475 fput tdlpre 1476 end 1477 if eq get gdlat 0 r 1478 fput tdllat 1479 end 1480 fput tdmeta 1481 dlfld r 5 1482 dlescf 1483 fput tdcmt1 1484 dlrepol 1485 fput tdcommp 1486 for i ulong 40 1487 fputc get gdsha i 1488 end 1489 fput tdq2 1490 fput tdcode 1491 for i ulong 7 1492 fputc get gdsha i 1493 end 1494 fput tdcmtx 1495 dlnotes r 1496 fput tdtbl 1497 dlarow 1 1498 dlarow 2 1499 if full 1500 dlassets 1501 end 1502 fput tdtblx 1503 end 1504 fn dlnotes r ulong to void 1505 dlfld r 1 1506 if not dlfeq tdtag 1507 ret 1508 end 1509 if not dlmsg r 1510 ret 1511 end 1512 if gt get gdmsn 0 0 1513 fput tdsubj 1514 fxesc get gdmsa 0 get gdmsn 0 1515 fput tdpx 1516 end 1517 if gt get gdmbn 0 0 1518 fput tdnotes 1519 fxesc get gdmba 0 get gdmbn 0 1520 fput tdprex 1521 end 1522 end 1523 note dlmsg r: the subject and notes of the tag of record r, read on their own into fxo (gdmsa / gdmsn, 1524 note gdmba / gdmbn) and shown before the next git call. false when git fails (the whole 500 of fovfl) 1525 note or the message is longer than fxo (the whole 500 of fincut): a message is never shown cut. 1526 fn dlmsg r ulong to bool 1527 put gdmsn 0 0 1528 put gdmbn 0 0 1529 dlfld r 0 1530 fksource 1531 fka tdfer 1532 fka tdcnt1 1533 fka tdmfmt 1534 fkopen 1535 a = get gdfa 0 1536 for i ulong get gdfn 0 bound 8192 1537 fkc get gdtl add a i 1538 end 1539 x = fexec `20000000000` 1540 if ne get fxotr 0 0 1541 fincut 1542 ret false 1543 end 1544 if ne x 0 1545 put fobtr 0 1 1546 ret false 1547 end 1548 n = get fxol 0 1549 e = n 1550 k = n 1551 while gt k 0 bound `16777216` 1552 k = sub k 1 1553 if eq get fxo k 30 1554 e = k 1555 break 1556 end 1557 end 1558 s = ulong 0 1559 while lt s e bound `16777216` 1560 if eq get fxo s 31 1561 break 1562 end 1563 s = add s 1 1564 end 1565 put gdmsa 0 0 1566 put gdmsn 0 s 1567 if lt s e 1568 put gdmba 0 add s 1 1569 put gdmbn 0 sub e add s 1 1570 end 1571 ret true 1572 end 1573 note dlarow: the source archive row (fmt 1 zip, 2 tar.gz) of the release in gdref / gdsha 1574 fn dlarow fmt ulong to void 1575 put gdfmt 0 fmt 1576 dlprefix 1577 if eq fmt 1 1578 dlfinal tdezip 1579 else 1580 dlfinal tdetgz 1581 end 1582 fput tdtr1 1583 dlrepol 1584 fput tdarht 1585 dlescref 1586 if eq fmt 1 1587 fput tdzip 1588 else 1589 fput tdtgz 1590 end 1591 fput tdq2 1592 for i ulong get gdprel 0 1593 fescc get gdpre i 1594 end 1595 if eq fmt 1 1596 fput tdzip 1597 else 1598 fput tdtgz 1599 end 1600 fput tdsrc 1601 fput tdax 1602 dlsumcells 1603 end 1604 note dlsumcells: the size and SHA-256 cells of gdf (archive or blob) only when it is already built 1605 note with its sidecar; rendering a page never builds or hashes anything 1606 fn dlsumcells to void 1607 if dlexists 1608 if dlsumrd 1609 fput tdtd 1610 fnum get gdsize 0 1611 fput tdtdc 1612 for i ulong 64 1613 fputc get gdhex i 1614 end 1615 fput tdtrx 1616 ret 1617 end 1618 end 1619 fput tdnb 1620 end 1621 note ---- release-assets/ of a tag (the commit in gdsha) 1622 note dllsa: git ls-tree -l -z -- release-assets/ into fxo, one row per asset in gdabo / gdano / 1623 note gdanl / gdasz (offsets into fxo: the rows are shown, or the download found, before the next git 1624 note call), and the count of entries not offered in gdaskip 1625 fn dllsa to void 1626 put gdan 0 0 1627 put gdaskip 0 0 1628 fksource 1629 fka tdlstr 1630 fka tdlopt 1631 fka tdzopt 1632 dlksha 1633 fka tddd 1634 fka tdradir 1635 r = fexec `20000000000` 1636 if ne r 0 1637 ret 1638 end 1639 if ne get fxotr 0 0 1640 fincut 1641 ret 1642 end 1643 n = get fxol 0 1644 note the listing can be longer than 1,000,000 bytes (many assets): the bound is the size of fxo 1645 s = ulong 0 1646 for i ulong n bound `16777216` 1647 if eq get fxo i 0 1648 dllsa1 s i 1649 s = add i 1 1650 end 1651 end 1652 end 1653 note dllsa1: one entry fxo[s, e) " blob \t" 1654 fn dllsa1 s ulong e ulong to void 1655 note the table holds 131,072 assets: more rows than one page can carry (the response is at most 8 MiB 1656 note and a row is over 100 bytes). One more entry is not dropped in silence: the whole 500 of fincut. 1657 k = get gdan 0 1658 if ge k len gdabo 1659 fincut 1660 ret 1661 end 1662 t = s 1663 for i ulong sub e s bound `16777216` 1664 if eq get fxo add s i 9 1665 t = add s i 1666 break 1667 end 1668 end 1669 if or le t s lt sub t s 53 1670 dlaskip 1671 ret 1672 end 1673 p = s 1674 for i ulong 8 1675 if eq get fxo add s i 32 1676 p = add add s i 1 1677 break 1678 end 1679 end 1680 if ne get fxo p 98 1681 dlaskip 1682 ret 1683 end 1684 q = add p 4 1685 if ne get fxo q 32 1686 dlaskip 1687 ret 1688 end 1689 q = add p 45 1690 if ne get fxo q 32 1691 dlaskip 1692 ret 1693 end 1694 dllsa2 k add p 5 add p 46 t e 1695 end 1696 note dlaskip: one entry of release-assets/ that is not offered (the page and the JSON say how many) 1697 fn dlaskip to void 1698 put gdaskip 0 add get gdaskip 0 1 1699 end 1700 fn dllsa2 k ulong h ulong z ulong t ulong e ulong to void 1701 a = add t 1 1702 if not dlxat a tdradir 1703 ret 1704 end 1705 a = add a len tdradir 1706 nl = sub e a 1707 if or eq nl 0 gt nl 120 1708 dlaskip 1709 ret 1710 end 1711 for i ulong nl 1712 put gdasn i get fxo add a i 1713 end 1714 put gdasnl 0 nl 1715 if not dlasok 1716 dlaskip 1717 ret 1718 end 1719 dllsa3 k h a nl dlszp z t 1720 end 1721 fn dlszp z ulong t ulong to ulong 1722 sz = ulong 0 1723 for i ulong sub t z bound `16777216` 1724 c = get fxo add z i 1725 if dldig c 1726 sz = add mul sz 10 ulong sub c 48 1727 end 1728 end 1729 ret sz 1730 end 1731 fn dllsa3 k ulong h ulong a ulong nl ulong sz ulong to void 1732 put gdabo k h 1733 put gdano k a 1734 put gdanl k nl 1735 put gdasz k sz 1736 put gdan 0 add k 1 1737 end 1738 fn dlxat o ulong t view uchar * to bool 1739 if gt add o len t get fxol 0 1740 ret false 1741 end 1742 for i ulong len t 1743 if ne get fxo add o i get t i 1744 ret false 1745 end 1746 end 1747 ret true 1748 end 1749 fn dlassets to void 1750 dllsa 1751 c = new uchar 40 0 1752 for i ulong 40 1753 put c i get gdsha i 1754 end 1755 for k ulong get gdan 0 bound 131072 1756 dlasrow k 1757 end 1758 if gt get gdaskip 0 0 1759 fput tdask1 1760 fnum get gdaskip 0 1761 fput tdask2 1762 end 1763 for i ulong 40 1764 put gdsha i get c i 1765 end 1766 end 1767 fn dlabsha k ulong to void 1768 b = get gdabo k 1769 for i ulong 40 1770 put gdsha i get fxo add b i 1771 end 1772 end 1773 fn dlasrow k ulong to void 1774 fput tdtr1 1775 dlrepol 1776 fput tdrdl 1777 dlescref 1778 fputc 47 1779 n = get gdanl k 1780 b = get gdano k 1781 fxesc b n 1782 fput tdq2 1783 fxesc b n 1784 fput tdax 1785 dlabsha k 1786 dlfblob 1787 dlsumcells 1788 end 1789 note dlblobf: (browse /raw/ over 8 MiB) blob id s[0,40) into the blob cache and ffile; 0 ok, -1 not a 1790 note lowercase hex id, else dlensure's code (-7 = cold-build cap full: answer with dlbusy) 1791 fn dlblobf s view uchar * to long 1792 if lt len s 40 1793 ret -1 1794 end 1795 for i ulong 40 1796 c = get s i 1797 if not dlishex c 1798 ret -1 1799 end 1800 put gdsha i c 1801 end 1802 dlfblob 1803 r = dlensure 2 1804 if lt r 0 1805 ret r 1806 end 1807 dlsetfile 1808 ret 0 1809 end 1810 note ---- /releases pages 1811 fn dlrtitle t view uchar * to void 1812 fsetti t 1813 for i ulong get frepol 0 1814 ftic get frepo i 1815 end 1816 end 1817 note dlpageq: ?page=N of /releases, /branches and /tags; 1 when absent or not a decimal number. No 1818 note digit cap: 150,000 tags are 15,000 pages of 10, and with a 4-digit cap page 10000 and later 1819 note were page 1 again (a 200 of the wrong rows; the older link of page 9999 led back to page 1). A 1820 note number over DLPGMAX is DLPGMAX, which is past the end of every list: the 404 of a page past the 1821 note last row. 1822 const DLPGMAX ulong `1000000000` 1823 fn dlpageq to ulong 1824 n = fqget tdpage 1825 if le n 0 1826 ret 1 1827 end 1828 v = ulong 0 1829 for i ulong ulong n bound 4096 1830 c = get fval i 1831 if not dldig c 1832 ret 1 1833 end 1834 v = add mul v 10 ulong sub c 48 1835 if gt v DLPGMAX 1836 v = DLPGMAX 1837 end 1838 end 1839 if eq v 0 1840 ret 1 1841 end 1842 ret v 1843 end 1844 fn dlrels to long 1845 if not dltags 1846 ret 500 1847 end 1848 p = dlpageq 1849 s = mul sub p 1 10 1850 kn = get gdkn 0 1851 if and gt p 1 ge s kn 1852 ret 404 1853 end 1854 dlrtitle tdtrel 1855 frepohd 4 1856 fput tdsec1 1857 if eq kn 0 1858 fput tdnorel 1859 fput tdsecx 1860 ret 200 1861 end 1862 for i ulong 10 1863 k = add s i 1864 if ge k kn 1865 break 1866 end 1867 dlrel1 get gdkeep k false 1868 end 1869 dlpager p kn 1870 fput tdsecx 1871 ret 200 1872 end 1873 fn dlpager p ulong kn ulong to void 1874 more = lt mul p 10 kn 1875 if and eq p 1 not more 1876 ret 1877 end 1878 fput tdpg1 1879 if gt p 1 1880 fput tdpgn 1881 fnum sub p 1 1882 fput tdpgnew 1883 end 1884 if more 1885 fput tdpgn 1886 fnum add p 1 1887 fput tdpgold 1888 end 1889 fput tdnavx 1890 end 1891 fn dlrlat to long 1892 if not dltags 1893 ret 500 1894 end 1895 r = get gdlat 0 1896 if eq r DLNONE 1897 ret 404 1898 end 1899 dlsn2ref r 1900 put fkind 0 2 1901 flocb 1902 for i ulong get fownl 0 1903 flocc get fown i 1904 end 1905 flocc 47 1906 for i ulong get frepol 0 1907 flocc get frepo i 1908 end 1909 floct tdrtag 1910 for i ulong get gdrefl 0 1911 flocc get gdref i 1912 end 1913 ret 302 1914 end 1915 note dlrfind: the kept record whose short name is gdref, or DLNONE 1916 fn dlrfind to ulong 1917 n = get gdrefl 0 1918 for i ulong get gdkn 0 bound 262144 1919 r = get gdkeep i 1920 if eq get gdsl r n 1921 if dlrfind1 r 1922 ret r 1923 end 1924 end 1925 end 1926 ret DLNONE 1927 end 1928 fn dlrfind1 r ulong to bool 1929 a = get gdso r 1930 for i ulong get gdrefl 0 1931 if ne get gdtl add a i get gdref i 1932 ret false 1933 end 1934 end 1935 ret true 1936 end 1937 note dltags reuses gdref per record, so the requested tag is copied in only after it 1938 fn dlrtag to long 1939 if not dltags 1940 ret 500 1941 end 1942 if not dlrcopy len tdrtag get frestl 0 1943 ret 404 1944 end 1945 if not dlrefok 1946 ret 400 1947 end 1948 r = dlrfind 1949 if eq r DLNONE 1950 ret 404 1951 end 1952 dlrtitle tdtrel1 1953 frepohd 4 1954 fput tdsec1 1955 dlrel1 r true 1956 fput tdsecx 1957 ret 200 1958 end 1959 note dlrdl: /releases/download//, the asset from release-assets/ of the tag's commit 1960 fn dlrdl to long 1961 a = len tdrdl 1962 e = get frestl 0 1963 m = e 1964 for i ulong sub e a 1965 j = sub sub e 1 i 1966 if eq get frest j 47 1967 m = j 1968 break 1969 end 1970 end 1971 if or ge m e le m a 1972 ret 404 1973 end 1974 put gdasnl 0 0 1975 if gt sub e add m 1 120 1976 ret 400 1977 end 1978 for i ulong sub e add m 1 1979 put gdasn i get frest add add m 1 i 1980 end 1981 put gdasnl 0 sub e add m 1 1982 if not dlasok 1983 ret 400 1984 end 1985 for i ulong get gdasnl 0 1986 put gdwant i get gdasn i 1987 end 1988 put gdwantl 0 get gdasnl 0 1989 if not dlrcopy a m 1990 ret 400 1991 end 1992 if not dlrefok 1993 ret 400 1994 end 1995 put gdkind 0 2 1996 if not dlresolve 1997 ret 404 1998 end 1999 ret dlrdl2 2000 end 2001 fn dlrdl2 to long 2002 dllsa 2003 k = dlasfind 2004 if eq k DLNONE 2005 ret 404 2006 end 2007 dlabsha k 2008 dlfblob 2009 dlsetetag 2010 dlsetcc 2011 if dlinm 2012 put fkind 0 1 2013 ret 304 2014 end 2015 r = dlensure 2 2016 if eq r -7 2017 ret dlbusy 2018 end 2019 if lt r 0 2020 ret 500 2021 end 2022 put fkind 0 3 2023 fsetct tdcto 2024 fsetcd tdatt 2025 for i ulong get gdwantl 0 2026 fcdc get gdwant i 2027 end 2028 dlsetfile 2029 ret 200 2030 end 2031 note dlasfind: the listed asset named gdwant (dllsa reuses gdasn while it scans), or DLNONE 2032 fn dlasfind to ulong 2033 n = get gdwantl 0 2034 for k ulong get gdan 0 bound 131072 2035 if eq get gdanl k n 2036 if dlasfind1 k n 2037 ret k 2038 end 2039 end 2040 end 2041 ret DLNONE 2042 end 2043 fn dlasfind1 k ulong n ulong to bool 2044 b = get gdano k 2045 for i ulong n 2046 if ne get fxo add b i get gdwant i 2047 ret false 2048 end 2049 end 2050 ret true 2051 end 2052 fn dlrelr to long 2053 if or dlreq tdrel dlreq tdrel2 2054 if fjwant 2055 ret dljrels 2056 end 2057 fyalt 2058 ret dlrels 2059 end 2060 if dlreq tdlat 2061 ret dlrlat 2062 end 2063 if dlrst tdrtag 2064 if fjwant 2065 ret dljrtag 2066 end 2067 fyalt 2068 ret dlrtag 2069 end 2070 if dlrst tdrdl 2071 ret dlrdl 2072 end 2073 ret 404 2074 end 2075 note dlanytag: the current repo has at least one tag where the releases page looks for them (the 2076 note storage root, then the delegate namespace), so /releases lists a release. One for-each-ref with 2077 note --count=1: the project page's "Get it" button (server/pages.om fpjget) reads only this, never the 2078 note whole tag list (a list too long for gdtl is the whole 500 of dltags; the button must not be). 2079 fn dlanytag to bool 2080 fksource 2081 fka tdfer 2082 fka tdcnt1 2083 fka tdfmtx 2084 fka tdrt0 2085 dlkns tdsrt0 2086 r = fexec `5000000000` 2087 if ne r 0 2088 ret false 2089 end 2090 ret gt get fxol 0 0 2091 end 2092 note ---- clone panel for the repo header (current repo: frid, frepo); default branch from nodes/head.om 2093 fn dldefbr to void 2094 if nshead 2095 put gdrefl 0 0 2096 for i ulong get nshbl 0 bound 256 2097 put gdref i get nshb i 2098 end 2099 put gdrefl 0 get nshbl 0 2100 if dlrefok 2101 ret 2102 end 2103 end 2104 for i ulong len tdmain 2105 put gdref i get tdmain i 2106 end 2107 put gdrefl 0 len tdmain 2108 end 2109 note ---- dispatch 2110 fn dlroute to long 2111 if ge get fridx 0 get fan 0 2112 ret 0 2113 end 2114 arch = dlrst tdarch 2115 rel = or dlreq tdrel dlrst tdrel2 2116 if and not arch not rel 2117 ret 0 2118 end 2119 m = get fmeth 0 2120 if and ne m 1 ne m 2 2121 ret 405 2122 end 2123 if arch 2124 ret dlarch 2125 end 2126 ret dlrelr 2127 end