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/hop/blob/main/Linux/apps.om # hop Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key. Brought by drakestapleton Sign in to star 1 stars 1 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `hop / Linux / apps.om` 949 lines ยท 18424 bytes Raw Blame History 1 note Linux application discovery and launch. SPDX-License-Identifier: Apache-2.0 2 note Platform contracts: freedesktop Desktop Entry 1.5 and XDG Base Directory 0.8. 3 note gio owns Desktop Entry Exec field codes, Terminal and D-Bus activation; build records its exact version. 4 note env preserves the desktop session environment without shell evaluation; build records its exact version. 5 note Omega successor: native Desktop Entry Exec expansion and D-Bus activation; neither is claimed here. 6 note PATH_MAX buffer is Linux pathname syscall boundary. getdents64 record length is a u16 wire field. 7 note Tables and input lines grow with input. Executable packed-list boundaries are compiler contracts, 8 note checked before exec: 65536 bytes and 1024 records. No environment is silently discarded. 9 global ha_path uchar 4096 10 global ha_read uchar 4096 11 global ha_dent uchar 65536 12 global ha_env uchar 131072 13 global ha_exec uchar 65536 14 global ha_wait uchar 4 15 global ha_stat uchar 128 16 global ha_line uchar * 17 global ha_text uchar * 18 global ha_meta ulong * 19 global ha_dirs uchar * 20 global ha_dmeta ulong * 21 global ha_hits ulong * 22 global ha_scores ulong * 23 global ha_n ulong 1 24 global ha_tn ulong 1 25 global ha_dn ulong 1 26 global ha_db ulong 1 27 global ha_ln ulong 1 28 global ha_pn ulong 1 29 global ha_state ulong 8 30 global ha_hn ulong 1 31 text ha_home "HOME=" 32 text ha_data "XDG_DATA_HOME=" 33 text ha_xdirs "XDG_DATA_DIRS=" 34 text ha_local "/.local/share" 35 text ha_apps "/applications" 36 text ha_def "/usr/local/share:/usr/share" 37 text ha_ext ".desktop" 38 text ha_group "[Desktop Entry]" 39 text ha_name "Name" 40 text ha_type "Type" 41 text ha_hidden "Hidden" 42 text ha_nodisp "NoDisplay" 43 text ha_cmd "Exec" 44 text ha_dbus "DBusActivatable" 45 text ha_true "true" 46 text ha_app "Application" 47 text ha_only "OnlyShowIn" 48 text ha_not "NotShowIn" 49 text ha_try "TryExec" 50 text ha_session "XDG_CURRENT_DESKTOP=" 51 text ha_pathenv "PATH=" 52 text ha_defpath "/usr/local/bin:/usr/bin:/bin" 53 text ha_envbin "/usr/bin/env" 54 text ha_options "--" 55 text ha_gio "/usr/bin/gio" 56 text ha_launch "launch" 57 text ha_open "open" 58 text ha_errmem "Hop: Linux application list could not grow.\n" 59 text ha_errpath "Hop: application pathname exceeds the Linux pathname boundary.\n" 60 text ha_errexec "Hop: application launch exceeds the compiler argument packet boundary.\n" 61 text ha_errlaunch "Hop: the desktop could not launch that application.\n" 62 text ha_errenv "Hop: an environment entry could not be read in full.\n" 63 64 fn ha_die textv view uchar * to void 65 x = write 2 textv 0 len textv 66 exit 1 67 end 68 69 fn ha_reserve need ulong which ulong to void 70 r = long 0 71 if eq which 0 72 if gt need len ha_text 73 r = enlarge ha_text add need add len ha_text 4096 74 end 75 end 76 if eq which 1 77 if gt need len ha_meta 78 r = enlarge ha_meta add need add len ha_meta 64 79 end 80 end 81 if eq which 2 82 if gt need len ha_dirs 83 r = enlarge ha_dirs add need add len ha_dirs 4096 84 end 85 end 86 if eq which 3 87 if gt need len ha_dmeta 88 r = enlarge ha_dmeta add need add len ha_dmeta 64 89 end 90 end 91 if eq which 4 92 if gt need len ha_line 93 r = enlarge ha_line add need add len ha_line 256 94 end 95 end 96 if eq which 5 97 if gt need len ha_hits 98 r = enlarge ha_hits add need add len ha_hits 64 99 if ge r 0 100 r = enlarge ha_scores len ha_hits 101 end 102 end 103 end 104 if lt r 0 105 ha_die ha_errmem 106 end 107 end 108 109 fn ha_envkey key view uchar * to bool 110 for j ulong len key bound `9223372036854775807` 111 if ne get ha_env j get key j 112 ret false 113 end 114 end 115 ret true 116 end 117 118 fn ha_envget key view uchar * to long 119 for i ulong ulong envcnt bound `9223372036854775807` 120 n = envread i ha_env 0 len ha_env 121 if lt n 0 122 ha_die ha_errenv 123 end 124 if ge ulong n len key 125 if ha_envkey key 126 amount = sub ulong n len key 127 ha_envshift len key amount 128 ret long amount 129 end 130 end 131 end 132 ret -1 133 end 134 135 fn ha_envshift start ulong size ulong to void 136 for j ulong size bound `9223372036854775807` 137 c = get ha_env add j start 138 put ha_env j c 139 end 140 end 141 142 fn ha_setpath src view uchar * to void 143 if ge len src len ha_path 144 ha_die ha_errpath 145 end 146 for i ulong len src bound `9223372036854775807` 147 put ha_path i get src i 148 end 149 put ha_pn 0 len src 150 end 151 152 fn ha_pathadd src view uchar * to void 153 p = get ha_pn 0 154 if ge add p len src len ha_path 155 ha_die ha_errpath 156 end 157 for i ulong len src bound `9223372036854775807` 158 put ha_path add p i get src i 159 end 160 put ha_pn 0 add p len src 161 end 162 163 fn ha_envpath n ulong to void 164 if ge n len ha_path 165 ha_die ha_errpath 166 end 167 for i ulong n bound `9223372036854775807` 168 put ha_path i get ha_env i 169 end 170 put ha_pn 0 n 171 end 172 173 fn ha_queue root ulong to void 174 n = get ha_pn 0 175 p = get ha_db 0 176 k = get ha_dn 0 177 ha_reserve add p n 2 178 ha_reserve mul add k 1 3 3 179 for i ulong n bound `9223372036854775807` 180 put ha_dirs add p i get ha_path i 181 end 182 put ha_dmeta mul k 3 p 183 put ha_dmeta add mul k 3 1 n 184 put ha_dmeta add mul k 3 2 root 185 put ha_dn 0 add k 1 186 put ha_db 0 add p n 187 end 188 189 fn ha_lower c uchar to uchar 190 if and ge c 65 le c 90 191 ret add c 32 192 end 193 ret c 194 end 195 196 fn ha_lineeq start ulong size ulong value view uchar * to bool 197 if ne size len value 198 ret false 199 end 200 for i ulong size bound `9223372036854775807` 201 if ne get ha_line add start i get value i 202 ret false 203 end 204 end 205 ret true 206 end 207 208 fn ha_recordline to void 209 n = get ha_ln 0 210 if eq n 0 211 ret 212 end 213 if eq get ha_line sub n 1 13 214 n = sub n 1 215 end 216 if eq n 0 217 ret 218 end 219 if eq get ha_line 0 91 220 active = ha_lineeq 0 n ha_group 221 put ha_state 0 0 222 if active 223 put ha_state 0 1 224 end 225 ret 226 end 227 if eq get ha_state 0 0 228 ret 229 end 230 k = ulong 0 231 while lt k n bound `9223372036854775807` 232 if eq get ha_line k 61 233 break 234 end 235 k = add k 1 236 end 237 if eq k n 238 ret 239 end 240 v = add k 1 241 vn = sub n v 242 if ha_lineeq 0 k ha_name 243 p = get ha_tn 0 244 ha_reserve add p vn 0 245 j = ulong 0 246 while lt j vn bound `9223372036854775807` 247 c = get ha_line add v j 248 if and eq c 92 lt add j 1 vn 249 j = add j 1 250 c = get ha_line add v j 251 if or or eq c 115 eq c 110 or eq c 114 eq c 116 252 c = 32 253 end 254 end 255 if or lt c 32 eq c 127 256 c = 32 257 end 258 put ha_text p c 259 p = add p 1 260 j = add j 1 261 end 262 put ha_state 1 get ha_tn 0 263 put ha_state 2 sub p get ha_tn 0 264 put ha_tn 0 p 265 end 266 if ha_lineeq 0 k ha_type 267 put ha_state 3 0 268 if ha_lineeq v vn ha_app 269 put ha_state 3 1 270 end 271 end 272 if or ha_lineeq 0 k ha_hidden ha_lineeq 0 k ha_nodisp 273 if ha_lineeq v vn ha_true 274 put ha_state 4 1 275 end 276 end 277 if ha_lineeq 0 k ha_cmd 278 if gt vn 0 279 put ha_state 5 1 280 end 281 end 282 if ha_lineeq 0 k ha_dbus 283 if ha_lineeq v vn ha_true 284 put ha_state 5 1 285 end 286 end 287 if ha_lineeq 0 k ha_only 288 if not ha_insession v vn 289 put ha_state 6 1 290 end 291 end 292 if ha_lineeq 0 k ha_not 293 if ha_insession v vn 294 put ha_state 6 1 295 end 296 end 297 if ha_lineeq 0 k ha_try 298 if not ha_tryexec v vn 299 put ha_state 7 1 300 end 301 end 302 end 303 304 fn ha_insession start ulong size ulong to bool 305 n = ha_envget ha_session 306 if le n 0 307 ret false 308 end 309 lo = ulong 0 310 for i ulong add size 1 bound `9223372036854775807` 311 sep = eq i size 312 if not sep 313 sep = eq get ha_line add start i 59 314 end 315 if sep 316 if ha_sessionhas add start lo sub i lo ulong n 317 ret true 318 end 319 lo = add i 1 320 end 321 end 322 ret false 323 end 324 325 fn ha_sessionhas start ulong size ulong envsize ulong to bool 326 if eq size 0 327 ret false 328 end 329 lo = ulong 0 330 for i ulong add envsize 1 bound `9223372036854775807` 331 sep = eq i envsize 332 if not sep 333 sep = eq get ha_env i 58 334 end 335 if sep 336 if eq sub i lo size 337 if ha_sessioneq start lo size 338 ret true 339 end 340 end 341 lo = add i 1 342 end 343 end 344 ret false 345 end 346 347 fn ha_sessioneq start ulong envstart ulong size ulong to bool 348 for j ulong size bound `9223372036854775807` 349 c = get ha_line add start j 350 if ne c get ha_env add envstart j 351 ret false 352 end 353 end 354 ret true 355 end 356 357 fn ha_tryexec start ulong size ulong to bool 358 if eq size 0 359 ret false 360 end 361 slash = false 362 for i ulong size bound `9223372036854775807` 363 if eq get ha_line add start i 47 364 slash = true 365 end 366 end 367 if slash 368 ha_trypath 0 0 start size 369 ret ha_executable 370 end 371 n = ha_envget ha_pathenv 372 if le n 0 373 for i ulong len ha_defpath 374 put ha_env i get ha_defpath i 375 end 376 n = long len ha_defpath 377 end 378 lo = ulong 0 379 for i ulong add ulong n 1 bound `9223372036854775807` 380 sep = eq i ulong n 381 if not sep 382 sep = eq get ha_env i 58 383 end 384 if sep 385 ha_trypath lo sub i lo start size 386 if ha_executable 387 ret true 388 end 389 lo = add i 1 390 end 391 end 392 ret false 393 end 394 395 fn ha_trypath envstart ulong envsize ulong start ulong size ulong to void 396 extra = ulong 0 397 if gt envsize 0 398 extra = 1 399 end 400 total = add add envsize extra size 401 if ge total len ha_path 402 ha_die ha_errpath 403 end 404 for i ulong envsize bound `9223372036854775807` 405 c = get ha_env add envstart i 406 put ha_path i c 407 end 408 if gt extra 0 409 put ha_path envsize 47 410 end 411 for i ulong size bound `9223372036854775807` 412 c = get ha_line add start i 413 put ha_path add add envsize extra i c 414 end 415 put ha_pn 0 total 416 end 417 418 fn ha_regular to bool 419 r = stat ha_path 0 get ha_pn 0 ha_stat 0 len ha_stat 420 if lt r 0 421 ret false 422 end 423 note asm-generic/stat.h st_mode offset16, bits/stat.h S_IFMT=`0170000` and S_IFREG=`0100000`. 424 note Decimal conversions: calc:`48b0ef104b499352fffecc0c0f52c5a98d33fcc80282357db3f03dd3c6d51c3d` 425 note and calc:`ee2ba7a0bf702c139c1496ff5510397b56b897779b6783b8158f5f5c15a2511f`. 426 mode = add ulong get ha_stat 16 shl ulong get ha_stat 17 8 427 ret eq and mode 61440 32768 428 end 429 430 fn ha_executable to bool 431 if not ha_regular 432 ret false 433 end 434 ret eq faccess ha_path 0 get ha_pn 0 1 0 435 end 436 437 fn ha_readentry index ulong to void 438 for i ulong 8 439 put ha_state i 0 440 end 441 if not ha_regular 442 ret 443 end 444 fd = int fopen ha_path 0 get ha_pn 0 0 0 445 if lt fd 0 446 ret 447 end 448 put ha_ln 0 0 449 done = false 450 while not done bound `9223372036854775807` 451 n = read fd ha_read 0 len ha_read 452 if lt n 0 453 x = fclose fd 454 ret 455 end 456 if eq n 0 457 done = true 458 ha_recordline 459 else 460 for i ulong ulong n bound `9223372036854775807` 461 c = get ha_read i 462 if eq c 10 463 ha_recordline 464 put ha_ln 0 0 465 else 466 j = get ha_ln 0 467 ha_reserve add j 1 4 468 put ha_line j c 469 put ha_ln 0 add j 1 470 end 471 end 472 end 473 end 474 x = fclose fd 475 if and eq get ha_state 3 1 eq get ha_state 4 0 476 if eq get ha_state 5 1 477 if and eq get ha_state 6 0 eq get ha_state 7 0 478 put ha_meta add mul index 6 4 get ha_state 1 479 put ha_meta add mul index 6 5 get ha_state 2 480 end 481 end 482 end 483 end 484 485 fn ha_addentry root ulong to void 486 n = get ha_pn 0 487 start = add root 1 488 if le n start 489 ret 490 end 491 idn = sub n start 492 for i ulong get ha_n 0 bound `9223372036854775807` 493 m = mul i 6 494 if eq get ha_meta add m 1 idn 495 if ha_sameid start idn get ha_meta m 496 ret 497 end 498 end 499 end 500 k = get ha_n 0 501 ha_reserve mul add k 1 6 1 502 p = get ha_tn 0 503 ha_reserve add add p idn n 0 504 put ha_meta mul k 6 p 505 put ha_meta add mul k 6 1 idn 506 for i ulong idn bound `9223372036854775807` 507 c = get ha_path add start i 508 if eq c 47 509 c = 45 510 end 511 put ha_text add p i c 512 end 513 p = add p idn 514 put ha_meta add mul k 6 2 p 515 put ha_meta add mul k 6 3 n 516 put ha_meta add mul k 6 4 0 517 put ha_meta add mul k 6 5 0 518 for i ulong n bound `9223372036854775807` 519 put ha_text add p i get ha_path i 520 end 521 put ha_tn 0 add p n 522 put ha_n 0 add k 1 523 ha_readentry k 524 end 525 526 fn ha_sameid start ulong size ulong offset ulong to bool 527 for j ulong size bound `9223372036854775807` 528 c = get ha_path add start j 529 if eq c 47 530 c = 45 531 end 532 if ne c get ha_text add offset j 533 ret false 534 end 535 end 536 ret true 537 end 538 539 fn ha_direntry pos ulong root ulong base ulong to void 540 sz = ulong 0 541 while ne get ha_dent add add pos 19 sz 0 bound 65536 542 sz = add sz 1 543 end 544 if eq sz 0 545 ret 546 end 547 if eq get ha_dent add pos 19 46 548 if eq sz 1 549 ret 550 end 551 if eq sz 2 552 if eq get ha_dent add pos 20 46 553 ret 554 end 555 end 556 end 557 if ge add add base 1 sz len ha_path 558 ha_die ha_errpath 559 end 560 put ha_path base 47 561 for i ulong sz bound `9223372036854775807` 562 put ha_path add add base 1 i get ha_dent add add pos 19 i 563 end 564 put ha_pn 0 add add base 1 sz 565 typ = get ha_dent add pos 18 566 if eq typ 4 567 ha_queue root 568 ret 569 end 570 if lt sz len ha_ext 571 ret 572 end 573 for i ulong len ha_ext 574 if ne get ha_dent add add pos 19 add sub sz len ha_ext i get ha_ext i 575 ret 576 end 577 end 578 ha_addentry root 579 end 580 581 fn ha_scanroot to void 582 if eq get ha_pn 0 0 583 ret 584 end 585 if ne get ha_path 0 47 586 ret 587 end 588 ha_pathadd ha_apps 589 put ha_dn 0 0 590 put ha_db 0 0 591 ha_queue get ha_pn 0 592 di = ulong 0 593 while lt di get ha_dn 0 bound `9223372036854775807` 594 m = mul di 3 595 base = get ha_dmeta add m 1 596 root = get ha_dmeta add m 2 597 off = get ha_dmeta m 598 ha_dirpath off base 599 put ha_pn 0 base 600 fd = int fopen ha_path 0 base 0 0 601 if ge fd 0 602 done = false 603 while not done bound `9223372036854775807` 604 n = getdnts fd ha_dent 0 len ha_dent 605 if le n 0 606 done = true 607 else 608 ha_parseents ulong n root base off 609 end 610 end 611 x = fclose fd 612 end 613 di = add di 1 614 end 615 end 616 617 fn ha_parseents size ulong root ulong base ulong offset ulong to void 618 pos = ulong 0 619 while lt pos size bound 65536 620 low = ulong get ha_dent add pos 16 621 high = ulong get ha_dent add pos 17 622 rec = add low shl high 8 623 if or lt rec 20 gt add pos rec size 624 ret 625 end 626 ha_dirpath offset base 627 ha_direntry pos root base 628 pos = add pos rec 629 end 630 end 631 632 fn ha_dirpath offset ulong size ulong to void 633 for j ulong size bound `9223372036854775807` 634 c = get ha_dirs add offset j 635 put ha_path j c 636 end 637 end 638 639 fn ha_init to int 640 put ha_n 0 0 641 put ha_tn 0 0 642 n = ha_envget ha_data 643 valid = false 644 if gt n 0 645 valid = eq get ha_env 0 47 646 end 647 if valid 648 ha_envpath ulong n 649 else 650 n = ha_envget ha_home 651 if gt n 0 652 ha_envpath ulong n 653 ha_pathadd ha_local 654 else 655 put ha_pn 0 0 656 end 657 end 658 ha_scanroot 659 n = ha_envget ha_xdirs 660 if le n 0 661 for i ulong len ha_def 662 put ha_env i get ha_def i 663 end 664 n = long len ha_def 665 end 666 note Preserve the directory list while each scan reads environment-independent files. 667 list = new uchar 131072 0 668 for i ulong ulong n bound `9223372036854775807` 669 put list i get ha_env i 670 end 671 lo = ulong 0 672 for i ulong add ulong n 1 bound `9223372036854775807` 673 sep = eq i ulong n 674 if not sep 675 sep = eq get list i 58 676 end 677 if sep 678 size = sub i lo 679 if gt size 0 680 ha_scanpart list lo size 681 end 682 lo = add i 1 683 end 684 end 685 ret 0 686 end 687 688 fn ha_scanpart list view uchar * start ulong size ulong to void 689 if ge size len ha_path 690 ha_die ha_errpath 691 end 692 for j ulong size bound `9223372036854775807` 693 c = get list add start j 694 put ha_path j c 695 end 696 put ha_pn 0 size 697 ha_scanroot 698 end 699 700 fn ha_literal nameoff ulong namesize ulong to bool 701 qn = get lx_qn 0 702 if eq qn 0 703 ret true 704 end 705 if gt qn namesize 706 ret false 707 end 708 for i ulong add sub namesize qn 1 bound `9223372036854775807` 709 same = true 710 for j ulong qn bound `9223372036854775807` 711 if ne ha_lower get lx_query j ha_lower get ha_text add add nameoff i j 712 same = false 713 break 714 end 715 end 716 if same 717 ret true 718 end 719 end 720 ret false 721 end 722 723 fn ha_word c uchar to ulong 724 v = ulong ha_lower c 725 alpha = or and ge c 65 le c 90 and ge c 97 le c 122 726 if or alpha and ge c 48 le c 57 727 v = or v `4294967296` 728 end 729 if or eq c 32 and ge c 9 le c 13 730 v = or v `8589934592` 731 end 732 ret v 733 end 734 735 fn ha_ascii nameoff ulong namesize ulong to bool 736 for j ulong get lx_qn 0 bound `9223372036854775807` 737 if ge get lx_query j 128 738 ret false 739 end 740 end 741 for j ulong namesize bound `9223372036854775807` 742 if ge get ha_text add nameoff j 128 743 ret false 744 end 745 end 746 ret true 747 end 748 749 fn ha_score nameoff ulong namesize ulong to ulong 750 qn = get lx_qn 0 751 if eq qn 0 752 ret 1 753 end 754 note Hop's existing helper wire format permits64 query words and184 name words. 755 note Longer input and non-ASCII names use full literal matching, never a cut-short fuzzy request. 756 if or gt qn 64 gt namesize 184 757 if ha_literal nameoff namesize 758 ret 1 759 end 760 ret 0 761 end 762 if not ha_ascii nameoff namesize 763 if ha_literal nameoff namesize 764 ret 1 765 end 766 ret 0 767 end 768 packet = new ulong 256 0 769 put packet 0 `1212568922` 770 put packet 1 1 771 put packet 2 qn 772 put packet 3 namesize 773 for j ulong qn bound 64 774 put packet add 8 j ha_word get lx_query j 775 end 776 for j ulong namesize bound 184 777 put packet add 72 j ha_word get ha_text add nameoff j 778 end 779 ret hp_fuzz packet 780 end 781 782 fn ha_inserthit index ulong score ulong to void 783 k = get ha_hn 0 784 ha_reserve add k 1 5 785 while gt k 0 bound `9223372036854775807` 786 prev = get ha_scores sub k 1 787 if ge prev score 788 break 789 end 790 old = get ha_hits sub k 1 791 put ha_hits k old 792 put ha_scores k prev 793 k = sub k 1 794 end 795 put ha_hits k index 796 put ha_scores k score 797 put ha_hn 0 add get ha_hn 0 1 798 end 799 800 fn ha_query to void 801 put lx_rn 0 0 802 put ha_hn 0 0 803 for i ulong get ha_n 0 bound `9223372036854775807` 804 m = mul i 6 805 n = get ha_meta add m 5 806 if gt n 0 807 p = get ha_meta add m 4 808 score = ha_score p n 809 if gt score 0 810 ha_inserthit i score 811 end 812 end 813 end 814 for j ulong get ha_hn 0 bound `9223372036854775807` 815 ha_addrow get ha_hits j 816 end 817 end 818 819 fn ha_addrow index ulong to void 820 m = mul index 6 821 n = get ha_meta add m 5 822 p = get ha_meta add m 4 823 pos = get lx_rn 0 824 r = enlarge lx_rows add add pos n 1 825 if lt r 0 826 ha_die ha_errmem 827 end 828 ha_rowcopy pos p n 829 put lx_rows add pos n 10 830 put lx_rn 0 add add pos n 1 831 end 832 833 fn ha_rowcopy dest ulong source ulong size ulong to void 834 for j ulong size bound `9223372036854775807` 835 c = get ha_text add source j 836 put lx_rows add dest j c 837 end 838 end 839 840 fn ha_packetrec pos ulong value view uchar * to ulong 841 if or gt len value 65535 gt add add pos 2 len value len ha_exec 842 ha_die ha_errexec 843 end 844 put ha_exec pos uchar and len value 255 845 put ha_exec add pos 1 uchar shr len value 8 846 for j ulong len value bound `9223372036854775807` 847 put ha_exec add add pos 2 j get value j 848 end 849 ret add add pos 2 len value 850 end 851 852 fn ha_activate to int 853 k = get lx_pick 0 854 if ge k get ha_hn 0 855 ret 0 856 end 857 index = get ha_hits k 858 p = get ha_meta add mul index 6 2 859 n = get ha_meta add mul index 6 3 860 if ge n len ha_path 861 ha_die ha_errpath 862 end 863 for i ulong n bound `9223372036854775807` 864 put ha_path i get ha_text add p i 865 end 866 put ha_pn 0 n 867 ret ha_runpath ha_launch 868 end 869 870 fn ha_openfile path view uchar * to int 871 ha_setpath path 872 ret ha_runpath ha_open 873 end 874 875 fn ha_privateenv entry view uchar * to bool 876 note Hop's private settings belong to Hop and its configured model, never a desktop program. 877 if lt len entry 4 878 ret false 879 end 880 if ne get entry 0 72 881 ret false 882 end 883 if ne get entry 1 79 884 ret false 885 end 886 if ne get entry 2 80 887 ret false 888 end 889 ret eq get entry 3 95 890 end 891 892 fn ha_runpath action view uchar * to int 893 note env is an external platform wrapper: no shell parses the environment or pathname. 894 pos = ha_packetrec 2 ha_envbin 895 pos = ha_packetrec pos ha_options 896 nc = ulong 5 897 envbuf = new uchar 131072 0 898 for i ulong ulong envcnt bound `9223372036854775807` 899 n = envread i envbuf 0 len envbuf 900 if lt n 0 901 ha_die ha_errenv 902 end 903 if not ha_privateenv part envbuf 0 ulong n 904 nc = add nc 1 905 if gt nc 1024 906 ha_die ha_errexec 907 end 908 pos = ha_packetrec pos part envbuf 0 ulong n 909 end 910 end 911 pos = ha_packetrec pos ha_gio 912 pos = ha_packetrec pos action 913 pos = ha_packetpath pos get ha_pn 0 914 put ha_exec 0 uchar and nc 255 915 put ha_exec 1 uchar shr nc 8 916 pid = int fork 917 if eq pid 0 918 x = execprog ha_exec 0 pos 919 x = write 2 ha_errlaunch 0 len ha_errlaunch 920 exit 1 921 end 922 if lt pid 0 923 x = write 2 ha_errlaunch 0 len ha_errlaunch 924 ret 0 925 end 926 status = waitpid pid ha_wait 0 4 0 927 if lt status 0 928 x = write 2 ha_errlaunch 0 len ha_errlaunch 929 ret 0 930 end 931 if ne or get ha_wait 0 get ha_wait 1 0 932 x = write 2 ha_errlaunch 0 len ha_errlaunch 933 ret 0 934 end 935 ret 1 936 end 937 938 fn ha_packetpath pos ulong size ulong to ulong 939 if or gt size 65535 gt add add pos 2 size len ha_exec 940 ha_die ha_errexec 941 end 942 put ha_exec pos uchar and size 255 943 put ha_exec add pos 1 uchar shr size 8 944 for i ulong size bound `9223372036854775807` 945 c = get ha_path i 946 put ha_exec add add pos 2 i c 947 end 948 ret add add pos 2 size 949 end