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/social/10base.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 / social / 10base.om` 115 lines ยท 2372 bytes Raw Blame History 1 note social/10base.om: ForgeSocial (INTERPLANE Forge web) shared state, path builder, hex, time. 2 note Prefixes (docs/CONTRACT.md): functions so*, globals gs*, texts ts*. Composed after server/util.om. 3 note gsdd: data dir (ends in /). soload sets it from env FORGE_SOCIAL_DIR when present, else tfdata. 4 note ---- path builder: gspth = data dir + parts (host words take the global directly) 5 fn sopclr to void 6 put gspthl 0 0 7 end 8 fn sopc c uchar to void 9 n = get gspthl 0 10 if lt n sub len gspth 1 11 put gspth n c 12 put gspthl 0 add n 1 13 end 14 end 15 fn sopt t view uchar * to void 16 for i ulong len t bound 1024 17 sopc get t i 18 end 19 end 20 fn sopdd to void 21 sopclr 22 for i ulong get gsddl 0 bound 512 23 sopc get gsdd i 24 end 25 end 26 note sodirset: gsdd from FORGE_SOCIAL_DIR (absolute, ends in /, no "..") else tfdata 27 fn sodirset to void 28 put gsddl 0 0 29 for i ulong len tfdata 30 put gsdd i get tfdata i 31 end 32 put gsddl 0 len tfdata 33 nenv = envcnt 34 if lt nenv 1 35 ret 36 end 37 for e ulong ulong nenv bound 4096 38 r = envread e gsenv 0 len gsenv 39 if gt r long len tsenvdd 40 if sodirenv ulong r 41 ret 42 end 43 end 44 end 45 end 46 fn sodirenv n ulong to bool 47 for i ulong len tsenvdd 48 if ne get gsenv i get tsenvdd i 49 ret false 50 end 51 end 52 k = sub n len tsenvdd 53 if or lt k 2 gt k 500 54 ret false 55 end 56 if ne get gsenv len tsenvdd 47 57 ret false 58 end 59 if ne get gsenv sub n 1 47 60 ret false 61 end 62 note refuse NUL and any segment starting with "." ("/." and "/.."); copy only once valid 63 p = uchar 47 64 for i ulong k 65 c = get gsenv add len tsenvdd i 66 if or eq c 0 and eq c 46 eq p 47 67 ret false 68 end 69 p = c 70 end 71 for i ulong k 72 put gsdd i get gsenv add len tsenvdd i 73 end 74 put gsddl 0 k 75 ret true 76 end 77 note ---- hex and decimal 78 fn sohexc v ulong to uchar 79 if lt v 10 80 ret uchar add v 48 81 end 82 ret uchar add v 87 83 end 84 fn sohexv c uchar to long 85 if and ge c 48 le c 57 86 ret long sub c 48 87 end 88 if and ge c 97 le c 102 89 ret long sub c 87 90 end 91 ret -1 92 end 93 note sohex: 2*len s lowercase hex chars of s into o (o at least that long) 94 fn sohex s view uchar * o edit uchar * to void 95 for i ulong len s bound 4096 96 b = ulong get s i 97 put o mul i 2 sohexc shr b 4 98 put o add mul i 2 1 sohexc and b 15 99 end 100 end 101 fn sonowset to void 102 t = realns 103 put gsnow 0 div ulong t `1000000000` 104 end 105 note soeqct: constant-time equality of two equal-length views 106 fn soeqct a view uchar * b view uchar * to bool 107 if ne len a len b 108 ret false 109 end 110 d = uchar 0 111 for i ulong len a bound 4096 112 d = or d xor get a i get b i 113 end 114 ret eq d 0 115 end