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/omega-mv/blob/main/apps/interplane-forge/browse/c1_page.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / apps / interplane-forge / browse / c1_page.om` 1234 lines ยท 20583 bytes Raw Blame History 1 note browse/c1_page.om: shared page pieces, the repo home, /tree, /blob and /raw (ForgeBrowse). 2 note Every handler validates first and writes nothing before it decides; a failure returns the 3 note status with fob empty, so the server renders its own error page. 4 global gbf ulong 16 5 global gbfn ulong 1 6 global gbrm uchar 256 7 global gbrml ulong 1 8 global gbrmk ulong 1 9 global gbx uchar 16 10 global gbxl ulong 1 11 global gbpg ulong 1 12 global gbboid uchar 40 13 global gbbsz ulong 1 14 note gbbig: the blob is larger than fxo (16 MiB); fxo then holds cat-file -s, not the file 15 global gbbig ulong 1 16 const BRMAXE ulong 5000 17 const BRSHOW ulong `2097152` 18 note BRRAWMX: the largest blob /raw/ serves (the contract's kind-3 file cap, 512 MiB) 19 const BRRAWMX ulong `536870912` 20 text tbsz "-s" 21 text tblstr "ls-tree" 22 text tbz "-z" 23 text tbll "-l" 24 text tbcatf "cat-file" 25 text tbt "-t" 26 text tbblob "blob" 27 text tbtree "tree" 28 text tbraw "raw" 29 text tbblame "blame" 30 text tbcmts "commits" 31 text tbcmt "commit" 32 text tblog "log" 33 text tbn1 "-n" 34 text tbone "1" 35 text tbdd "--" 36 text tbfmtc "--format=%H%x1f%an%x1f%at%x1f%s" 37 text tbskip "--skip=" 38 text tbplain "plain" 39 text tbpage "page" 40 text tbcr1 "

" 43 text tbbe "" 44 text tbpe "

\n" 45 text tbbar1 "
" 46 text tbkbr "branch" 47 text tbktag "tag" 48 text tbkcmt "commit" 49 text tbcode " " 50 text tbcodee " " 51 text tbbrs "/branches\">Branches " 52 text tbtgs "/tags\">Tags " 53 text tbhist "\">History " 54 text tbdive "
\n" 55 text tblat1 "
" 57 text tblat3 " " 58 text tblat4 " committed " 59 text tblat5 "
\n" 60 text tbtab1 "\n" 61 text tbtab2 "
\n" 62 text tbtr1 "
\n" 65 text tbtrf "" 66 text tbtre "\n" 67 text tbtrsm "" 68 text tbtrsm2 " @ " 69 text tbtrsm3 "\n" 70 text tbup "..\n" 72 text tbmany "

Listing cut at 5000 entries.

\n" 73 text tbempty "

This directory is empty.

\n" 74 text tbrd1 "

" 75 text tbrd2 "

\n
\n" 76 text tbrd3 "
\n" 77 text tbrd4 "

\n
"

78 text tbrd5 "
\n" 79 text tbreadme "readme" 80 text tbxmd "md" 81 text tbxmkd "markdown" 82 text tbxtxt "txt" 83 text tbinfo1 "
" 84 text tbinfo2 " lines · " 85 text tbinfo3 " bytes " 86 text tbinfo4 "\">Raw " 87 text tbinfo5 "\">Blame " 88 text tbinfo6 "?plain=1\">Source " 89 text tbinfo7 "\">Rendered " 90 text tbimg1 "

\""

\n" 93 text tbbin1 "

Binary file not shown. Download

\n" 95 text tbbig1 "

This file is too large to show here. View it raw.

\n" 97 text tbcd1 "\n" 98 text tbcd2 "\n" 102 text tbart1 "
\n" 103 text tbart2 "
\n" 104 text tbctxt "text/plain; charset=utf-8" 105 text tbcoct "application/octet-stream" 106 text tbcpng "image/png" 107 text tbcjpg "image/jpeg" 108 text tbcgif "image/gif" 109 text tbcwebp "image/webp" 110 text tbcsvg "image/svg+xml" 111 text tbcico "image/x-icon" 112 text tbcbmp "image/bmp" 113 text tbcpdf "application/pdf" 114 text tbxpng "png" 115 text tbxjpg "jpg" 116 text tbxjpeg "jpeg" 117 text tbxgif "gif" 118 text tbxwebp "webp" 119 text tbxsvg "svg" 120 text tbxico "ico" 121 text tbxbmp "bmp" 122 text tbxpdf "pdf" 123 text tbatt "attachment; filename=\"" 124 text tbbig3 "

This file is too large to show here.

\n" 125 text tbh2 "

" 126 text tbh2e "

\n" 127 text tbtfil "Files" 128 text tbtblob "File" 129 text tbtsep " - " 130 note ---- small shared helpers 131 note brerr: drop any output and answer st (the server renders the error page) 132 fn brerr st ulong to long 133 put fobl 0 0 134 put fkind 0 0 135 ret long st 136 end 137 note brknum: append the decimal v to the open argv argument 138 fn brknum v ulong to void 139 w = v 140 p = ulong 1 141 while le mul p 10 w bound 20 142 p = mul p 10 143 end 144 while gt p 0 bound 21 145 fkc uchar add div w p 48 146 w = rem w p 147 p = div p 10 148 end 149 end 150 note brsplit: split fxo[a, e) at byte c into gbf (start, end pairs, at most 8); returns the count 151 fn brsplit a ulong e ulong c uchar to ulong 152 k = ulong 0 153 s = a 154 i = a 155 while lt i e bound BRBIG 156 if eq get fxo i c 157 if lt k 7 158 put gbf mul k 2 s 159 put gbf add mul k 2 1 i 160 k = add k 1 161 s = add i 1 162 end 163 end 164 i = add i 1 165 end 166 put gbf mul k 2 s 167 put gbf add mul k 2 1 e 168 k = add k 1 169 put gbfn 0 k 170 ret k 171 end 172 fn brfa k ulong to ulong 173 ret get gbf mul k 2 174 end 175 fn brfl k ulong to ulong 176 if ge k get gbfn 0 177 ret 0 178 end 179 ret sub get gbf add mul k 2 1 get gbf mul k 2 180 end 181 note brfne: fields j and k hold different bytes (a committer named differently from the author) 182 fn brfne j ulong k ulong to bool 183 n = brfl j 184 if ne n brfl k 185 ret true 186 end 187 a = brfa j 188 b = brfa k 189 for i ulong n bound BRBIG 190 if ne get fxo add a i get fxo add b i 191 ret true 192 end 193 end 194 ret false 195 end 196 note brfesc: html-escape field k; brfurl: url-encode field k 197 fn brfesc k ulong to void 198 fxesc brfa k brfl k 199 end 200 fn brfurl k ulong to void 201 bruxo brfa k brfl k 202 end 203 note brti: page title "[: ] - owner/repo"; the path is cut at 120 bytes. The loop count 204 note must be capped here: a count past the bound is trap 4, which ends the server. 205 fn brti t view uchar * to void 206 fsetti t 207 n = get gbpl 0 208 if gt n 0 209 ftic 58 210 ftic 32 211 for i ulong hmin n 120 bound 120 212 ftic get gbp i 213 end 214 end 215 for i ulong len tbtsep 216 ftic get tbtsep i 217 end 218 ftirepo 219 end 220 note brucmt: /commit/ 221 fn brucmt a ulong n ulong to void 222 brurepo 223 fputc 47 224 fput tbcmt 225 fputc 47 226 bruxo a n 227 end 228 note brfrat: gbfr[o..] starts with t 229 fn brfrat o ulong t view uchar * to bool 230 n = get gbfrl 0 231 k = len t 232 if gt add o k n 233 ret false 234 end 235 for i ulong k 236 if ne get gbfr add o i get t i 237 ret false 238 end 239 end 240 ret true 241 end 242 fn brrkind to ulong 243 if or brfrat 0 tbrts brfrat 65 tbrts 244 ret 2 245 end 246 if brfrat 0 tbrhs 247 ret 1 248 end 249 if brfrat 65 tbrhs 250 ret 1 251 end 252 ret 3 253 end 254 note brrefbar: the ref, branch and tag links, the history link for the current path 255 fn brrefbar to void 256 fput tbbar1 257 k = brrkind 258 if eq k 1 259 fput tbkbr 260 end 261 if eq k 2 262 fput tbktag 263 end 264 if eq k 3 265 fput tbkcmt 266 end 267 fput tbcode 268 brrefesc 269 fput tbcodee 270 fput tbah 271 brurepo 272 fput tbbrs 273 fput tbah 274 brurepo 275 fput tbtgs 276 fput tbah 277 bruactp tbcmts get gbpl 0 278 fput tbhist 279 fput tbdive 280 end 281 note brcrumb: repo / dir / dir / name, each but the last a tree link 282 fn brcrumb to void 283 fput tbcr1 284 bruact tbtree 285 fput tbaq 286 fputrnm 287 fput tbae 288 n = get gbpl 0 289 s = ulong 0 290 i = ulong 0 291 while le i n bound BRBIG 292 lastb = eq i n 293 if not lastb 294 lastb = eq get gbp i 47 295 end 296 if lastb 297 if gt i s 298 fput tbsl 299 brcrumb1 s i 300 end 301 s = add i 1 302 end 303 i = add i 1 304 end 305 fput tbpe 306 end 307 fn brcrumb1 s ulong i ulong to void 308 if eq i get gbpl 0 309 fput tbb 310 brgesc s sub i s 311 fput tbbe 312 ret 313 end 314 fput tbah 315 bruactp tbtree i 316 fput tbaq 317 brgesc s sub i s 318 fput tbae 319 end 320 note brlast: the newest commit touching gbp at gbsha, in a box 321 fn brlast to void 322 fksource 323 fka tblog 324 fka tbn1 325 fka tbone 326 fka tbfmtc 327 fkopen 328 brksha 329 if gt get gbpl 0 0 330 fka tbdd 331 fkopen 332 brkp 333 end 334 st = fexec BRTMO 335 n = get fxol 0 336 if or ne st 0 eq n 0 337 ret 338 end 339 e = brxfind 0 n 10 340 k = brsplit 0 e 31 341 if lt k 4 342 ret 343 end 344 fput tblat1 345 brucmt brfa 0 brfl 0 346 fput tbaq 347 fxput brfa 0 7 348 fput tblat2 349 brfesc 3 350 fput tblat3 351 brfesc 1 352 fput tblat4 353 brdate brxdec brfa 2 add brfa 2 brfl 2 354 fput tblat5 355 end 356 note brotype: object type of :: 1 tree, 2 blob, 0 missing 357 fn brotype to ulong 358 if eq get gbpl 0 0 359 ret 1 360 end 361 fksource 362 fka tbcatf 363 fka tbt 364 brkshp 365 st = fexec BRTMO 366 if ne st 0 367 ret 0 368 end 369 n = get fxol 0 370 if brxat 0 n tbtree 371 ret 1 372 end 373 if brxat 0 n tbblob 374 ret 2 375 end 376 ret 0 377 end 378 note ---- tree listing 379 fn brlsx to bool 380 fksource 381 fka tblstr 382 fka tbz 383 fka tbll 384 if gt get gbpl 0 0 385 brkshp 386 else 387 fkopen 388 brksha 389 end 390 st = fexec BRTMO 391 note a listing longer than fxo is not shown as the directory: entries past the cut would be missing 392 note (the trees pass and the files pass both read it) and the last name could be cut. The whole 500 of 393 note fincut, as for the other lists; the 5000-entry display cap below stays marked on the page. 394 if ne get fxotr 0 0 395 fincut 396 ret false 397 end 398 ret eq st 0 399 end 400 note brtent: one ls-tree -z -l entry fxo[s, e): " \t"; pass 1 trees, pass 2 rest 401 fn brtent s ulong e ulong pass ulong to bool 402 t = add s 7 403 if ge t e 404 ret false 405 end 406 tab = brxfind s e 9 407 if ge tab e 408 ret false 409 end 410 c = get fxo t 411 istree = eq c 116 412 want = eq pass 1 413 if and istree not want 414 ret false 415 end 416 if and not istree want 417 ret false 418 end 419 na = add tab 1 420 nl = sub e na 421 if istree 422 brtdir na nl 423 ret true 424 end 425 if eq c 99 426 brtsub na nl add t 7 427 ret true 428 end 429 brreadme na nl 430 brtfile na nl add t 46 tab 431 ret true 432 end 433 fn brtpre to void 434 n = get gbpl 0 435 bruactp tbtree n 436 end 437 fn brtdir na ulong nl ulong to void 438 fput tbtr1 439 brtpre 440 fputc 47 441 bruxo na nl 442 fput tbaq 443 fxesc na nl 444 fput tbtrs 445 end 446 fn brtsub na ulong nl ulong sa ulong to void 447 fput tbtrsm 448 fxesc na nl 449 fput tbtrsm2 450 fxesc sa 7 451 fput tbtrsm3 452 end 453 fn brtfile na ulong nl ulong sa ulong tab ulong to void 454 fput tbtr1f 455 bruactp tbblob get gbpl 0 456 fputc 47 457 bruxo na nl 458 fput tbaq 459 fxesc na nl 460 fput tbtrf 461 s = sa 462 while lt s tab bound 64 463 if ne get fxo s 32 464 break 465 end 466 s = add s 1 467 end 468 fxput s sub tab s 469 fput tbtre 470 end 471 note brreadme: remember the best README name seen (markdown 1 beats plain 2) 472 fn brreadme na ulong nl ulong to void 473 if or lt nl 6 gt nl 200 474 ret 475 end 476 for i ulong 6 477 if ne brlow get fxo add na i get tbreadme i 478 ret 479 end 480 end 481 k = ulong 2 482 if gt nl 6 483 if ne get fxo add na 6 46 484 ret 485 end 486 if or brxlext add na 7 add na nl tbxmd brxlext add na 7 add na nl tbxmkd 487 k = 1 488 end 489 end 490 m = get gbrmk 0 491 if and ne m 0 le m k 492 ret 493 end 494 for i ulong nl 495 put gbrm i get fxo add na i 496 end 497 put gbrml 0 nl 498 put gbrmk 0 k 499 end 500 note brxlext: fxo[a, e) equals the lower-case t, ignoring case 501 fn brxlext a ulong e ulong t view uchar * to bool 502 if ne sub e a len t 503 ret false 504 end 505 for i ulong len t 506 if ne brlow get fxo add a i get t i 507 ret false 508 end 509 end 510 ret true 511 end 512 note brlist: the directory listing of :; false when ls-tree failed 513 fn brlist to bool 514 put gbrml 0 0 515 put gbrmk 0 0 516 if not brlsx 517 ret false 518 end 519 n = get fxol 0 520 fput tbtab1 521 if gt get gbpl 0 0 522 fput tbup 523 brtup 524 fput tbup2 525 end 526 c = ulong 0 527 for q ulong 2 528 pass = add q 1 529 s = ulong 0 530 while lt s n bound BRBIG 531 e = brxfind s n 0 532 if brtent s e pass 533 c = add c 1 534 end 535 if ge c BRMAXE 536 break 537 end 538 s = add e 1 539 end 540 end 541 fput tbtab2 542 if ge c BRMAXE 543 fput tbmany 544 end 545 if eq c 0 546 fput tbempty 547 end 548 ret true 549 end 550 note brtup: link to the parent directory 551 fn brtup to void 552 n = get gbpl 0 553 k = n 554 while gt k 0 bound BRBIG 555 k = sub k 1 556 if eq get gbp k 47 557 break 558 end 559 end 560 bruactp tbtree k 561 end 562 note brrdshow: fetch and render the README found by brlist (in directory gbp) 563 fn brrdshow to void 564 n = get gbrml 0 565 if eq n 0 566 ret 567 end 568 fksource 569 fka tbcatf 570 fka tbblob 571 fkopen 572 brksha 573 fkc 58 574 if gt get gbpl 0 0 575 brkp 576 fkc 47 577 end 578 for i ulong n 579 fkc get gbrm i 580 end 581 st = fexec BRTMO 582 if ne st 0 583 ret 584 end 585 m = get fxol 0 586 if gt m BRSHOW 587 m = BRSHOW 588 end 589 fput tbrd1 590 for i ulong n 591 fescc get gbrm i 592 end 593 if eq get gbrmk 0 1 594 fput tbrd2 595 brmdir 596 brmd 0 m 597 fput tbrd3 598 ret 599 end 600 fput tbrd4 601 fxesc 0 m 602 fput tbrd5 603 end 604 note brmdir: gbmd = gbp (the Markdown link base directory) 605 fn brmdir to void 606 n = get gbpl 0 607 for i ulong n 608 put gbmd i get gbp i 609 end 610 put gbmdl 0 n 611 end 612 note brmdfile: gbmd = directory of gbp (a file path) 613 fn brmdfile to void 614 n = get gbpl 0 615 k = n 616 while gt k 0 bound BRBIG 617 k = sub k 1 618 if eq get gbp k 47 619 break 620 end 621 end 622 for i ulong k 623 put gbmd i get gbp i 624 end 625 put gbmdl 0 k 626 end 627 note ---- pages 628 note brrdfind: find the README of : the way brlist does (brreadme on every file entry), 629 note without writing the listing; false when ls-tree failed 630 fn brrdfind to bool 631 put gbrml 0 0 632 put gbrmk 0 0 633 if not brlsx 634 ret false 635 end 636 n = get fxol 0 637 s = ulong 0 638 while lt s n bound BRBIG 639 e = brxfind s n 0 640 brrdent s e 641 s = add e 1 642 end 643 ret true 644 end 645 fn brrdent s ulong e ulong to void 646 t = add s 7 647 if ge t e 648 ret 649 end 650 tab = brxfind s e 9 651 if ge tab e 652 ret 653 end 654 c = get fxo t 655 if or eq c 116 eq c 99 656 ret 657 end 658 na = add tab 1 659 brreadme na sub e na 660 end 661 text tbnord "

This project has no README yet. A README is the page where a project says what it is and how to use it. Here are its files:

\n" 662 note brhome: repo home at the default branch; 0 hands an empty repo back to the server's home. 663 note README first: the friendly header (frepohd), the README (or a plain note and the file list when 664 note there is none), then the "For developers: proof and records" section (server/pages.om fpjdev1, 665 note fpjdev2) with everything the page held before: the counts, the branch bar, the clone panel, the 666 note newest commit and the file list. 667 fn brhome to long 668 brdefref 669 if not brres 670 ret 0 671 end 672 put ftil 0 0 673 ftirepo 674 frepohd 0 675 lsok = brrdfind 676 rd = and lsok gt get gbrml 0 0 677 if rd 678 brrdshow 679 else 680 if lsok 681 fput tbnord 682 end 683 if not brlist 684 fput tbempty 685 end 686 end 687 fpjdev1 688 brrefbar 689 brlast 690 if rd 691 if not brlist 692 fput tbempty 693 end 694 end 695 fpjdev2 696 ret 200 697 end 698 note brtreepg: /tree/[/] 699 fn brtreepg to long 700 if not brres 701 ret brerr 404 702 end 703 k = brotype 704 if eq k 0 705 ret brerr 404 706 end 707 if eq k 2 708 brloc tbblob 709 ret 302 710 end 711 brti tbtfil 712 frepohd 0 713 brrefbar 714 brcrumb 715 brlast 716 if not brlist 717 fput tbempty 718 end 719 brrdshow 720 ret 200 721 end 722 note brloc: redirect to /// 723 fn brloc t view uchar * to void 724 put fkind 0 2 725 put fobl 0 0 726 flocb 727 for i ulong get fownl 0 bound 64 728 brlc get fown i 729 end 730 flocc 47 731 for i ulong get frepol 0 bound 128 732 brlc get frepo i 733 end 734 flocc 47 735 floct t 736 flocc 47 737 for i ulong get gbrefl 0 738 brlc get gbref i 739 end 740 n = get gbpl 0 741 if gt n 0 742 flocc 47 743 end 744 for i ulong n bound BRBIG 745 brlc get gbp i 746 end 747 end 748 fn brlc c uchar to void 749 ok = bralnum c 750 if or eq c 45 eq c 46 751 ok = true 752 end 753 if or eq c 95 eq c 126 754 ok = true 755 end 756 if eq c 47 757 ok = true 758 end 759 if ok 760 flocc c 761 ret 762 end 763 flocc 37 764 flocc get tbhex shr c 4 765 flocc get tbhex and c 15 766 end 767 note brext: lower-case extension of gbp's last segment into gbx (empty when none or > 15) 768 fn brext to void 769 put gbxl 0 0 770 n = get gbpl 0 771 k = n 772 while gt k 0 bound BRBIG 773 k = sub k 1 774 c = get gbp k 775 if eq c 47 776 ret 777 end 778 if eq c 46 779 if gt sub n add k 1 15 780 ret 781 end 782 for i ulong sub n add k 1 783 put gbx i brlow get gbp add add k 1 i 784 end 785 put gbxl 0 sub n add k 1 786 ret 787 end 788 end 789 end 790 fn brisx t view uchar * to bool 791 n = get gbxl 0 792 if ne n len t 793 ret false 794 end 795 for i ulong n 796 if ne get gbx i get t i 797 ret false 798 end 799 end 800 ret true 801 end 802 note brimgct: the content type of an image or pdf extension; 0 when not one 803 fn brimgk to ulong 804 if brisx tbxpng 805 ret 1 806 end 807 if or brisx tbxjpg brisx tbxjpeg 808 ret 2 809 end 810 if brisx tbxgif 811 ret 3 812 end 813 if brisx tbxwebp 814 ret 4 815 end 816 if brisx tbxsvg 817 ret 5 818 end 819 if brisx tbxico 820 ret 6 821 end 822 if brisx tbxbmp 823 ret 7 824 end 825 if brisx tbxpdf 826 ret 8 827 end 828 ret 0 829 end 830 note brbin: a NUL in the first 8000 bytes of fxo 831 fn brbin to bool 832 n = get fxol 0 833 if gt n 8000 834 n = 8000 835 end 836 for i ulong n 837 if eq get fxo i 0 838 ret true 839 end 840 end 841 ret false 842 end 843 fn brcatb to bool 844 fksource 845 fka tbcatf 846 fka tbblob 847 brkshp 848 st = fexec BRTMO 849 ret eq st 0 850 end 851 note brblobpg: /blob// 852 fn brblobpg to long 853 if not brres 854 ret brerr 404 855 end 856 if eq get gbpl 0 0 857 ret brerr 404 858 end 859 k = brotype 860 if eq k 0 861 ret brerr 404 862 end 863 if eq k 1 864 brloc tbtree 865 ret 302 866 end 867 if not brcatb 868 ret brerr 404 869 end 870 put gbbsz 0 get fxol 0 871 put gbbig 0 0 872 if ne get fxotr 0 0 873 put gbbig 0 1 874 if brbin 875 put gbbig 0 2 876 end 877 if not brbsz 878 ret brerr 404 879 end 880 end 881 brti tbtblob 882 frepohd 0 883 brrefbar 884 brcrumb 885 brbinfo 886 brbbody 887 ret 200 888 end 889 note brlines: number of lines in fxo 890 fn brlines to ulong 891 n = get fxol 0 892 c = ulong 0 893 for i ulong n bound `16777216` 894 if eq get fxo i 10 895 c = add c 1 896 end 897 end 898 if gt n 0 899 if ne get fxo sub n 1 10 900 c = add c 1 901 end 902 end 903 ret c 904 end 905 fn brismd to bool 906 brext 907 ret or brisx tbxmd brisx tbxmkd 908 end 909 note brbinfo: lines, size and the raw / blame / history / source links (no raw link past BRRAWMX) 910 fn brbinfo to void 911 fput tbinfo1 912 if eq get gbbig 0 0 913 fnum brlines 914 fput tbinfo2 915 end 916 fnum get gbbsz 0 917 fput tbinfo3 918 if le get gbbsz 0 BRRAWMX 919 fput tbah 920 bruactp tbraw get gbpl 0 921 fput tbinfo4 922 end 923 fput tbah 924 bruactp tbblame get gbpl 0 925 fput tbinfo5 926 fput tbah 927 bruactp tbcmts get gbpl 0 928 fput tbhist 929 if brismd 930 fput tbah 931 bruactp tbblob get gbpl 0 932 if brplain 933 fput tbinfo7 934 else 935 fput tbinfo6 936 end 937 end 938 fput tbdive 939 end 940 fn brplain to bool 941 r = fqget tbplain 942 if lt r 1 943 ret false 944 end 945 ret ne get fval 0 48 946 end 947 fn brbbody to void 948 if gt get gbbsz 0 BRRAWMX 949 fput tbbig3 950 ret 951 end 952 brext 953 k = brimgk 954 if and gt k 0 lt k 8 955 fput tbimg1 956 bruactp tbraw get gbpl 0 957 fput tbimg2 958 brbase 959 fput tbimg3 960 ret 961 end 962 n = get fxol 0 963 bn = false 964 if eq get gbbig 0 0 965 bn = brbin 966 else 967 bn = eq get gbbig 0 2 968 end 969 if or bn ne k 0 970 fput tbbin1 971 bruactp tbraw get gbpl 0 972 fput tbbin2 973 ret 974 end 975 if ne get gbbig 0 0 976 fput tbbig1 977 bruactp tbraw get gbpl 0 978 fput tbbig2 979 ret 980 end 981 if or gt n BRSHOW ne get fxotr 0 0 982 fput tbbig1 983 bruactp tbraw get gbpl 0 984 fput tbbig2 985 ret 986 end 987 if and brismd not brplain 988 fput tbart1 989 brmdfile 990 brmd 0 n 991 fput tbart2 992 ret 993 end 994 brcode 0 n 995 end 996 note brbase: html-escaped last segment of gbp 997 fn brbase to void 998 n = get gbpl 0 999 k = n 1000 while gt k 0 bound BRBIG 1001 if eq get gbp sub k 1 47 1002 break 1003 end 1004 k = sub k 1 1005 end 1006 brgesc k sub n k 1007 end 1008 note brcode: fxo[a, e) as a numbered line table with L anchors 1009 fn brcode a ulong e ulong to void 1010 fput tbcd1 1011 s = a 1012 ln = ulong 1 1013 while lt s e bound BRBIG 1014 x = brxfind s e 10 1015 fput tbcd2 1016 fnum ln 1017 fput tbcd3 1018 fnum ln 1019 fput tbaq 1020 fnum ln 1021 fput tbcd4 1022 fxesc s sub x s 1023 fput tbcd5 1024 ln = add ln 1 1025 s = add x 1 1026 end 1027 fput tbtab2 1028 end 1029 note brrawpg: /raw//: text/plain is shown; every other type (images, svg, pdf, other 1030 note binaries) is sent with Content-Disposition: attachment. Up to len fob from memory; above, 1031 note from dl's blob cache as a kind-3 file (brrawbig); above BRRAWMX, 404 1032 text tbcache "public, max-age=60" 1033 fn brrawpg to long 1034 if not brres 1035 ret brerr 404 1036 end 1037 if eq get gbpl 0 0 1038 ret brerr 404 1039 end 1040 k = brotype 1041 if ne k 2 1042 ret brerr 404 1043 end 1044 if not brbsz 1045 ret brerr 404 1046 end 1047 sz = get gbbsz 0 1048 if gt sz BRRAWMX 1049 ret brerr 404 1050 end 1051 if gt sz len fob 1052 ret brrawbig 1053 end 1054 if not brcatb 1055 ret brerr 404 1056 end 1057 n = get fxol 0 1058 if or gt n len fob ne get fxotr 0 0 1059 ret brerr 404 1060 end 1061 brext 1062 put fobl 0 0 1063 put fkind 0 1 1064 fsetsbx 1065 brrawct 1066 fxput 0 n 1067 fsetcc tbcache 1068 ret 200 1069 end 1070 note brrawbig: the blob (gbboid) through dl's blob cache (dlblobf: cat-file into 1071 note /archives//.blob, LRU and cold-build caps shared with downloads) 1072 fn brrawbig to long 1073 if not brboid 1074 ret brerr 404 1075 end 1076 b = new uchar 64 0 1077 for i ulong 40 1078 put b i get gbboid i 1079 end 1080 r = dlblobf view part b 0 40 1081 if eq r -7 1082 ret dlbusy 1083 end 1084 if lt r 0 1085 ret brerr 500 1086 end 1087 if not brrdhd 1088 ret brerr 500 1089 end 1090 brext 1091 put fobl 0 0 1092 put fkind 0 3 1093 fsetsbx 1094 brrawct 1095 fsetcc tbcache 1096 ret 200 1097 end 1098 note brrdhd: fxo = the first 8000 bytes of ffile (the cached blob), so brrawct's brbin sees 1099 note the blob's own bytes; false when it cannot be read 1100 fn brrdhd to bool 1101 put fxol 0 0 1102 fd = fopen ffile 0 get ffilel 0 524288 0 1103 if lt fd 0 1104 ret false 1105 end 1106 ch = new uchar 8192 0 1107 n = read int fd ch 0 8000 1108 x = fclose int fd 1109 if le n 0 1110 ret false 1111 end 1112 m = ulong n 1113 for i ulong m 1114 put fxo i get ch i 1115 end 1116 put fxol 0 m 1117 ret true 1118 end 1119 note brbsz: gbbsz = the size of the blob : (git cat-file -s) 1120 fn brbsz to bool 1121 put gbbsz 0 0 1122 fksource 1123 fka tbcatf 1124 fka tbsz 1125 brkshp 1126 st = fexec BRTMO 1127 if ne st 0 1128 ret false 1129 end 1130 v = ulong 0 1131 d = ulong 0 1132 for i ulong get fxol 0 bound 24 1133 c = get fxo i 1134 if or lt c 48 gt c 57 1135 break 1136 end 1137 v = add mul v 10 sub ulong c 48 1138 d = add d 1 1139 end 1140 if eq d 0 1141 ret false 1142 end 1143 put gbbsz 0 v 1144 ret true 1145 end 1146 note brboid: gbboid = the blob id of : (rev-parse, 40 lowercase hex checked) 1147 fn brboid to bool 1148 fksource 1149 fka tbrevp 1150 fka tbverif 1151 fka tbq 1152 fka tbeoo 1153 brkshp 1154 st = fexec BRTMO 1155 if ne st 0 1156 ret false 1157 end 1158 if lt get fxol 0 40 1159 ret false 1160 end 1161 for i ulong 40 1162 c = get fxo i 1163 if not brlhex c 1164 ret false 1165 end 1166 put gbboid i c 1167 end 1168 ret true 1169 end 1170 fn brrawct to void 1171 k = brimgk 1172 if eq k 1 1173 fsetct tbcpng 1174 end 1175 if eq k 2 1176 fsetct tbcjpg 1177 end 1178 if eq k 3 1179 fsetct tbcgif 1180 end 1181 if eq k 4 1182 fsetct tbcwebp 1183 end 1184 if eq k 5 1185 fsetct tbcsvg 1186 end 1187 if eq k 6 1188 fsetct tbcico 1189 end 1190 if eq k 7 1191 fsetct tbcbmp 1192 end 1193 if eq k 8 1194 fsetct tbcpdf 1195 end 1196 if ne k 0 1197 brattach 1198 ret 1199 end 1200 if not brbin 1201 fsetct tbctxt 1202 ret 1203 end 1204 fsetct tbcoct 1205 brattach 1206 end 1207 note brattach: Content-Disposition attachment with the base name, bytes outside [A-Za-z0-9._-] as _ 1208 fn brattach to void 1209 fsetcd tbatt 1210 n = get gbpl 0 1211 k = n 1212 while gt k 0 bound BRBIG 1213 if eq get gbp sub k 1 47 1214 break 1215 end 1216 k = sub k 1 1217 end 1218 m = sub n k 1219 if gt m 100 1220 m = 100 1221 end 1222 for i ulong m 1223 c = get gbp add k i 1224 ok = bralnum c 1225 if or eq c 46 or eq c 45 eq c 95 1226 ok = true 1227 end 1228 if not ok 1229 c = 95 1230 end 1231 fcdc c 1232 end 1233 fcdc 34 1234 end
" 101 text tbcd5 "