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/quiet/qn1dig.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 / quiet / qn1dig.om` 428 lines ยท 6821 bytes Raw Blame History 1 note quiet/qn1dig.om: one digest file per subscriber, rewritten when an event is appended. 2 note A page read does not call qnregen. Caps: the newest 64 KiB of events, 32 lines, no clock. 3 text tqev "quiet/events" 4 text tqsb "quiet/subs" 5 text tqod "quiet/out/" 6 text tqdir "quiet" 7 text tqoutdir "quiet/out" 8 text tqdv1 "QUIET-DIGEST v1\n" 9 text tqsk "subscriber=" 10 text tqak "agent=" 11 text tqrk "repo=" 12 text tqck "count=" 13 text tqkind "patch" 14 text tqnl "\n" 15 global qndd uchar 512 16 global qnddl ulong 1 17 global qnev uchar 65536 18 global qnevl ulong 1 19 global qnsub uchar 8192 20 global qnsl ulong 1 21 global qnline uchar 256 22 global qnlinel ulong 1 23 global qnhold uchar 256 24 global qnholn ulong 1 25 global qnout uchar 8192 26 global qnol ulong 1 27 global qnovf ulong 1 28 global qnt0 ulong 1 29 global qnt1 ulong 1 30 global qnfa ulong 1 31 global qnfn ulong 1 32 global qnra ulong 1 33 global qnrn ulong 1 34 fn qnsetd p view uchar * n ulong to void 35 put qnddl 0 0 36 if or eq n 0 gt n 512 37 ret 38 end 39 for i ulong n bound 512 40 put qndd i get p i 41 end 42 put qnddl 0 n 43 end 44 fn qnsetg to void 45 qnsetd tfdata len tfdata 46 end 47 fn qnpfx t view uchar * to void 48 fpb 49 for i ulong get qnddl 0 bound 512 50 fpc get qndd i 51 end 52 fpt t 53 end 54 fn qnmk to void 55 qnpfx tqdir 56 x = makedir fpth 0 get fpthl 0 448 57 qnpfx tqoutdir 58 x = makedir fpth 0 get fpthl 0 448 59 end 60 fn qnread to bool 61 r = frdall 62 if lt r 0 63 put fxol 0 0 64 ret false 65 end 66 ret true 67 end 68 fn qnapp to bool 69 qnmk 70 qnpfx tqev 71 fd = fopen fpth 0 get fpthl 0 525377 384 72 if lt fd 0 73 ret false 74 end 75 left = get qnlinel 0 76 off = ulong 0 77 ok = true 78 while gt left 0 bound 256 79 k = write int fd qnline off left 80 if le k 0 81 ok = false 82 left = ulong 0 83 end 84 if gt k 0 85 off = add off ulong k 86 left = sub left ulong k 87 end 88 end 89 x = fsync int fd 90 x = fclose int fd 91 ret ok 92 end 93 fn qncc c uchar to void 94 n = get qnol 0 95 if lt n 8191 96 put qnout n c 97 put qnol 0 add n 1 98 end 99 if ge n 8191 100 put qnovf 0 1 101 end 102 end 103 fn qnct t view uchar * to void 104 for i ulong len t bound 64 105 qncc get t i 106 end 107 end 108 fn qnhcs a ulong n ulong to void 109 for i ulong n bound 64 110 qncc get qnhold add a i 111 end 112 end 113 fn qntok k ulong to bool 114 p = ulong 0 115 seen = ulong 0 116 while lt p get qnlinel 0 bound 256 117 while and lt p get qnlinel 0 eq get qnline p 32 bound 256 118 p = add p 1 119 end 120 q = p 121 while and lt q get qnlinel 0 ne get qnline q 32 bound 256 122 q = add q 1 123 end 124 if gt q p 125 if eq seen k 126 put qnt0 0 p 127 put qnt1 0 q 128 ret true 129 end 130 seen = add seen 1 131 end 132 p = q 133 end 134 ret false 135 end 136 fn qneq a ulong n ulong t view uchar * to bool 137 if ne n len t 138 ret false 139 end 140 for i ulong n bound 64 141 if ne get qnline add a i get t i 142 ret false 143 end 144 end 145 ret true 146 end 147 fn qnstar a ulong n ulong to bool 148 if ne n 1 149 ret false 150 end 151 ret eq get qnhold a 42 152 end 153 fn qnholdline to void 154 n = get qnlinel 0 155 if gt n 256 156 n = ulong 256 157 end 158 for i ulong n bound 256 159 put qnhold i get qnline i 160 end 161 put qnholn 0 n 162 end 163 fn qncopyline s ulong e ulong to void 164 n = sub e s 165 if gt n 255 166 n = ulong 255 167 end 168 for i ulong n bound 256 169 put qnline i get qnev add s i 170 end 171 put qnlinel 0 n 172 end 173 fn qnsame a ulong n ulong b ulong m ulong to bool 174 if ne n m 175 ret false 176 end 177 for i ulong n bound 64 178 if ne get qnline add a i get qnhold add b i 179 ret false 180 end 181 end 182 ret true 183 end 184 fn qnmatch to bool 185 if not qntok 0 186 ret false 187 end 188 if not qneq get qnt0 0 sub get qnt1 0 get qnt0 0 tqkind 189 ret false 190 end 191 if not qntok 1 192 ret false 193 end 194 er = get qnt0 0 195 en = sub get qnt1 0 er 196 if not qntok 2 197 ret false 198 end 199 ea = get qnt0 0 200 eal = sub get qnt1 0 ea 201 if not qnstar get qnra 0 get qnrn 0 202 if not qnsame er en get qnra 0 get qnrn 0 203 ret false 204 end 205 end 206 if not qnstar get qnfa 0 get qnfn 0 207 if not qnsame ea eal get qnfa 0 get qnfn 0 208 ret false 209 end 210 end 211 ret true 212 end 213 fn qnuserok a ulong n ulong to bool 214 if or eq n 0 gt n 39 215 ret false 216 end 217 for i ulong n bound 39 218 c = get qnhold add a i 219 ok = false 220 if and ge c 48 le c 57 221 ok = true 222 end 223 if and ge c 97 le c 122 224 ok = true 225 end 226 if eq c 45 227 ok = true 228 end 229 if not ok 230 ret false 231 end 232 end 233 ret true 234 end 235 fn qnwriteu a ulong n ulong to bool 236 qnpfx tqod 237 for i ulong n bound 39 238 fpc get qnhold add a i 239 end 240 fd = fopen fpth 0 get fpthl 0 524865 384 241 if lt fd 0 242 ret false 243 end 244 left = get qnol 0 245 off = ulong 0 246 ok = true 247 while gt left 0 bound 8192 248 k = write int fd qnout off left 249 if le k 0 250 ok = false 251 left = ulong 0 252 end 253 if gt k 0 254 off = add off ulong k 255 left = sub left ulong k 256 end 257 end 258 x = fsync int fd 259 x = fclose int fd 260 ret ok 261 end 262 fn qnnum v ulong to void 263 if ge v 10 264 qnnum div v 10 265 end 266 qncc add 48 uchar rem v 10 267 end 268 note qnscan: walk the event lines; count the matching ones, and when emit is true append the 269 note matching lines numbered from skip on (the newest 32 when there are more) 270 fn qnscan emit bool skip ulong to ulong 271 cnt = ulong 0 272 p = ulong 0 273 while lt p get qnevl 0 bound 65536 274 e = p 275 while lt e get qnevl 0 bound 65536 276 if eq get qnev e 10 277 break 278 end 279 e = add e 1 280 end 281 qncopyline p e 282 if qnmatch 283 if and emit ge cnt skip 284 qnnum cnt 285 qncc 32 286 for i ulong get qnlinel 0 bound 256 287 qncc get qnline i 288 end 289 qncc 10 290 end 291 cnt = add cnt 1 292 end 293 if lt e get qnevl 0 294 p = add e 1 295 end 296 if ge e get qnevl 0 297 p = e 298 end 299 end 300 ret cnt 301 end 302 fn qnfinish ua ulong un ulong to bool 303 put qnol 0 0 304 put qnovf 0 0 305 total = qnscan false 0 306 put qnol 0 0 307 qnct tqdv1 308 qnct tqsk 309 qnhcs ua un 310 qnct tqnl 311 qnct tqak 312 qnhcs get qnfa 0 get qnfn 0 313 qnct tqnl 314 qnct tqrk 315 qnhcs get qnra 0 get qnrn 0 316 qnct tqnl 317 qnct tqck 318 qnnum total 319 qncc 10 320 skip = ulong 0 321 if gt total 32 322 skip = sub total 32 323 end 324 k = qnscan true skip 325 if eq get qnovf 0 1 326 ret false 327 end 328 ret qnwriteu ua un 329 end 330 fn qnone to bool 331 qnholdline 332 if not qntok 0 333 ret false 334 end 335 ua = get qnt0 0 336 un = sub get qnt1 0 ua 337 if not qnuserok ua un 338 ret false 339 end 340 if not qntok 1 341 ret false 342 end 343 put qnfa 0 get qnt0 0 344 put qnfn 0 sub get qnt1 0 get qnt0 0 345 if not qntok 2 346 ret false 347 end 348 put qnra 0 get qnt0 0 349 put qnrn 0 sub get qnt1 0 get qnt0 0 350 note a filter word is at most 39 bytes when forged wrote the line (qnokg). A longer one, from a 351 note hand-edited file, is refused here: qnhcs and qnsame loop over it under bound 64. 352 if or gt get qnfn 0 39 gt get qnrn 0 39 353 ret false 354 end 355 ret qnfinish ua un 356 end 357 note qntail: start of the newest 64 KiB of fxo (n bytes), at a line start 358 fn qntail n ulong to ulong 359 if le n 65536 360 ret 0 361 end 362 s = sub n 65536 363 if eq get fxo sub s 1 10 364 ret s 365 end 366 while lt s n bound 65536 367 if eq get fxo s 10 368 ret add s 1 369 end 370 s = add s 1 371 end 372 ret n 373 end 374 fn qnregen to bool 375 qnmk 376 put qnevl 0 0 377 qnpfx tqev 378 if qnread 379 n = get fxol 0 380 s = qntail n 381 m = sub n s 382 for i ulong m bound 65536 383 put qnev i get fxo add s i 384 end 385 put qnevl 0 m 386 end 387 qnpfx tqsb 388 if not qnread 389 put qnsl 0 0 390 ret true 391 end 392 n = get fxol 0 393 if gt n 8192 394 n = ulong 8192 395 end 396 for i ulong n bound 8192 397 put qnsub i get fxo i 398 end 399 put qnsl 0 n 400 p = ulong 0 401 ok = true 402 while lt p get qnsl 0 bound 8192 403 e = p 404 while lt e get qnsl 0 bound 8192 405 if eq get qnsub e 10 406 break 407 end 408 e = add e 1 409 end 410 m = sub e p 411 if and gt m 0 le m 255 412 for i ulong m bound 256 413 put qnline i get qnsub add p i 414 end 415 put qnlinel 0 m 416 if not qnone 417 ok = false 418 end 419 end 420 if lt e get qnsl 0 421 p = add e 1 422 end 423 if ge e get qnsl 0 424 p = e 425 end 426 end 427 ret ok 428 end