Artifact 27f13abbb9f037c17951e609418d6726774f9295:
- File wurstkessel-init.fs — part of check-in [1aef9561ba] at 2012-10-23 00:19:55 on branch trunk — Fixed stack underflow in salt-init (user: bernd size: 682)
0000: 5c 20 69 6e 69 74 20 77 75 72 73 74 6b 65 73 73 \ init wurstkess 0010: 65 6c 20 74 6f 20 62 65 20 61 63 74 75 61 6c 6c el to be actuall 0020: 79 20 75 73 65 66 75 6c 0a 0a 3a 20 72 61 6e 64 y useful..: rand 0030: 6f 6d 2d 69 6e 69 74 20 28 20 2d 2d 20 29 0a 20 om-init ( -- ). 0040: 20 20 20 73 22 20 2f 64 65 76 2f 72 61 6e 64 6f s" /dev/rando 0050: 6d 22 20 72 2f 6f 20 6f 70 65 6e 2d 66 69 6c 65 m" r/o open-file 0060: 20 74 68 72 6f 77 20 3e 72 0a 20 20 20 20 77 75 throw >r. wu 0070: 72 73 74 2d 73 61 6c 74 20 73 74 61 74 65 23 20 rst-salt state# 0080: 72 40 20 72 65 61 64 2d 66 69 6c 65 20 74 68 72 r@ read-file thr 0090: 6f 77 20 64 72 6f 70 0a 20 20 20 20 72 3e 20 63 ow drop. r> c 00a0: 6c 6f 73 65 2d 66 69 6c 65 20 74 68 72 6f 77 20 lose-file throw 00b0: 3b 0a 0a 3a 20 72 65 61 64 2d 77 75 72 73 74 72 ;..: read-wurstr 00c0: 6e 67 20 28 20 66 64 20 2d 2d 20 29 20 20 3e 72 ng ( fd -- ) >r 00d0: 0a 20 20 20 20 30 2e 20 72 40 20 72 65 70 6f 73 . 0. r@ repos 00e0: 69 74 69 6f 6e 2d 66 69 6c 65 20 74 68 72 6f 77 ition-file throw 00f0: 0a 20 20 20 20 77 75 72 73 74 2d 73 61 6c 74 20 . wurst-salt 0100: 73 74 61 74 65 23 20 72 40 20 72 65 61 64 2d 66 state# r@ read-f 0110: 69 6c 65 20 74 68 72 6f 77 20 64 72 6f 70 0a 20 ile throw drop. 0120: 20 20 20 73 74 61 74 65 2d 69 6e 69 74 20 73 74 state-init st 0130: 61 74 65 23 20 72 40 20 72 65 61 64 2d 66 69 6c ate# r@ read-fil 0140: 65 20 74 68 72 6f 77 20 64 72 6f 70 0a 20 20 20 e throw drop. 0150: 20 72 3e 20 63 6c 6f 73 65 2d 66 69 6c 65 20 74 r> close-file t 0160: 68 72 6f 77 20 3b 0a 0a 3a 20 77 72 69 74 65 2d hrow ;..: write- 0170: 77 75 72 73 74 72 6e 67 20 28 20 2d 2d 20 29 0a wurstrng ( -- ). 0180: 20 20 20 20 73 22 20 7e 2f 2e 77 75 72 73 74 72 s" ~/.wurstr 0190: 6e 67 22 20 72 2f 77 20 63 72 65 61 74 65 2d 66 ng" r/w create-f 01a0: 69 6c 65 20 74 68 72 6f 77 20 3e 72 0a 20 20 20 ile throw >r. 01b0: 20 77 75 72 73 74 2d 73 61 6c 74 20 73 74 61 74 wurst-salt stat 01c0: 65 23 20 72 40 20 77 72 69 74 65 2d 66 69 6c 65 e# r@ write-file 01d0: 20 74 68 72 6f 77 0a 20 20 20 20 73 74 61 74 65 throw. state 01e0: 2d 69 6e 69 74 20 73 74 61 74 65 23 20 72 40 20 -init state# r@ 01f0: 77 72 69 74 65 2d 66 69 6c 65 20 74 68 72 6f 77 write-file throw 0200: 0a 20 20 20 20 72 3e 20 63 6c 6f 73 65 2d 66 69 . r> close-fi 0210: 6c 65 20 74 68 72 6f 77 20 3b 0a 0a 3a 20 73 61 le throw ;..: sa 0220: 6c 74 2d 69 6e 69 74 20 28 20 2d 2d 20 29 0a 20 lt-init ( -- ). 0230: 20 20 20 73 22 20 7e 2f 2e 77 75 72 73 74 72 6e s" ~/.wurstrn 0240: 67 22 20 72 2f 6f 20 6f 70 65 6e 2d 66 69 6c 65 g" r/o open-file 0250: 20 49 46 20 20 64 72 6f 70 20 72 61 6e 64 6f 6d IF drop random 0260: 2d 69 6e 69 74 0a 20 20 20 20 45 4c 53 45 20 20 -init. ELSE 0270: 72 65 61 64 2d 77 75 72 73 74 72 6e 67 20 20 54 read-wurstrng T 0280: 48 45 4e 20 20 72 6e 67 2d 73 74 65 70 20 77 72 HEN rng-step wr 0290: 69 74 65 2d 77 75 72 73 74 72 6e 67 20 3b 0a 0a ite-wurstrng ;.. 02a0: 73 61 6c 74 2d 69 6e 69 74 0a salt-init.