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/core.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 / core.om` 197 lines ยท 3223 bytes Raw Blame History 1 note Linux adapter for Hop's unchanged Omega matching helper. 2 note Requests use the existing Omega/README.md kind1 protocol, not a second matcher. 3 note An anonymous local socket carries stdio so send uses MSG_NOSIGNAL if the helper dies. 4 text hp_link "/proc/self/exe" 5 text hp_tail "/hopcore" 6 text hp_fail "Hop could not use its search helper. Rebuild Hop before launching it.\n" 7 global hp_fd int 3 8 9 fn hp_le a view uchar * p ulong n ulong to ulong 10 v = ulong 0 11 for i ulong n 12 v = or v shl ulong get a add p i mul i 8 13 end 14 ret v 15 end 16 17 fn hp_put a edit uchar * p ulong v ulong n ulong to void 18 for i ulong n 19 put a add p i uchar and shr v mul i 8 255 20 end 21 end 22 23 fn hp_bad to void 24 k = write 2 hp_fail 0 len hp_fail 25 end 26 27 fn hp_start to int 28 hp_path = new uchar 4096 0 29 hp_exec = new uchar 4104 0 30 hp_addr = new uchar 19 0 31 put hp_fd 0 -1 32 put hp_fd 1 -1 33 put hp_fd 2 -1 34 n = readlnk hp_link 0 len hp_link hp_path 0 len hp_path 35 if le n 0 36 hp_bad 37 ret 1 38 end 39 if eq n long len hp_path 40 hp_bad 41 ret 1 42 end 43 p = ulong n 44 while gt p 0 bound 4096 45 if eq get hp_path sub p 1 47 46 break 47 end 48 p = sub p 1 49 end 50 if or eq p 0 gt add p len hp_tail len hp_path 51 hp_bad 52 ret 1 53 end 54 p = sub p 1 55 for i ulong len hp_tail 56 put hp_path add p i get hp_tail i 57 end 58 p = add p len hp_tail 59 hp_put hp_exec 0 1 2 60 hp_put hp_exec 2 p 2 61 for i ulong p 62 put hp_exec add i 4 get hp_path i 63 end 64 server = socknew 1 1 0 65 if lt server 0 66 hp_bad 67 ret 1 68 end 69 put hp_addr 0 1 70 k = random hp_addr 3 16 0 71 if ne k 16 72 k = fclose int server 73 hp_bad 74 ret 1 75 end 76 k = bind int server hp_addr 0 len hp_addr 77 if ne k 0 78 k = fclose int server 79 hp_bad 80 ret 1 81 end 82 k = listen int server 1 83 if ne k 0 84 k = fclose int server 85 hp_bad 86 ret 1 87 end 88 pid = fork 89 if eq pid 0 90 sock = socknew 1 1 0 91 if lt sock 0 92 exit 126 93 end 94 k = connect int sock hp_addr 0 len hp_addr 95 if ne k 0 96 exit 126 97 end 98 k = dupfd int sock 0 0 99 if lt k 0 100 exit 126 101 end 102 k = dupfd int sock 1 0 103 if lt k 0 104 exit 126 105 end 106 k = execprog hp_exec 0 add p 4 107 exit 127 108 end 109 if lt pid 0 110 k = fclose int server 111 hp_bad 112 ret 1 113 end 114 put hp_fd 2 int pid 115 ready = waitio int server 1 `2000000000` 116 if le ready 0 117 k = fclose int server 118 hp_stop 119 hp_bad 120 ret 1 121 end 122 sock = accept int server 0 123 k = fclose int server 124 if lt sock 0 125 hp_stop 126 hp_bad 127 ret 1 128 end 129 put hp_fd 0 int sock 130 put hp_fd 1 int sock 131 ret 0 132 end 133 134 fn hp_fuzz inp view ulong 256 to ulong 135 hp_req = new uchar 2056 0 136 hp_rep = new uchar 11 0 137 if lt get hp_fd 0 0 138 ret 0 139 end 140 hp_put hp_req 0 1 4 141 hp_put hp_req 4 2048 4 142 for i ulong 256 143 hp_put hp_req add 8 mul i 8 get inp i 8 144 end 145 p = ulong 0 146 while lt p len hp_req bound 2056 147 k = send get hp_fd 0 hp_req p sub len hp_req p 0 148 if le k 0 149 hp_bad 150 ret 0 151 end 152 p = add p ulong k 153 end 154 p = ulong 0 155 while lt p 11 bound 11 156 ready = waitio get hp_fd 1 1 `2000000000` 157 if le ready 0 158 hp_bad 159 ret 0 160 end 161 k = read get hp_fd 1 hp_rep p sub 11 p 162 if le k 0 163 hp_bad 164 ret 0 165 end 166 p = add p ulong k 167 end 168 if ne hp_le hp_rep 0 4 0 169 hp_bad 170 ret 0 171 end 172 if ne hp_le hp_rep 4 4 3 173 hp_bad 174 ret 0 175 end 176 if ne get hp_rep 8 1 177 ret 0 178 end 179 ret hp_le hp_rep 9 2 180 end 181 182 fn hp_stop to void 183 hp_state = new uchar 4 0 184 if ge get hp_fd 0 0 185 k = fclose get hp_fd 0 186 end 187 if and ge get hp_fd 1 0 ne get hp_fd 1 get hp_fd 0 188 k = fclose get hp_fd 1 189 end 190 put hp_fd 0 -1 191 put hp_fd 1 -1 192 if gt get hp_fd 2 0 193 k = killpid get hp_fd 2 15 194 k = waitpid get hp_fd 2 hp_state 0 4 0 195 put hp_fd 2 -1 196 end 197 end