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