Artifact
ee5819d64c8cf2005451a2a8427a049b6d47ff2d :
File
wurstkessel-init.fs
— part of check-in
[e10de49724]
at
2013-03-12 23:51:59
on branch trunk
— client loop as thread
(user:
bernd
size: 741)
File
wurstkessel/wurstkessel-init.fs
— part of check-in
[2788abc2d4]
at
2014-01-28 18:48:59
on branch trunk
— Moved Wurstkessel into subfolder
(user:
bernd
size: 741)
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 66 6c 61 67 20 ng ( fd -- flag
00d0: 29 20 20 7b 20 66 64 20 7d 0a 20 20 20 20 30 2e ) { fd }. 0.
00e0: 20 66 64 20 72 65 70 6f 73 69 74 69 6f 6e 2d 66 fd reposition-f
00f0: 69 6c 65 20 74 68 72 6f 77 0a 20 20 20 20 77 75 ile throw. wu
0100: 72 73 74 2d 73 61 6c 74 20 73 74 61 74 65 23 20 rst-salt state#
0110: 66 64 20 72 65 61 64 2d 66 69 6c 65 20 74 68 72 fd read-file thr
0120: 6f 77 20 73 74 61 74 65 23 20 3d 20 3e 72 0a 20 ow state# = >r.
0130: 20 20 20 73 74 61 74 65 2d 69 6e 69 74 20 73 74 state-init st
0140: 61 74 65 23 20 66 64 20 72 65 61 64 2d 66 69 6c ate# fd read-fil
0150: 65 20 74 68 72 6f 77 20 73 74 61 74 65 23 20 3d e throw state# =
0160: 20 72 3e 20 61 6e 64 0a 20 20 20 20 66 64 20 63 r> and. fd c
0170: 6c 6f 73 65 2d 66 69 6c 65 20 74 68 72 6f 77 20 lose-file throw
0180: 3b 0a 0a 3a 20 77 72 69 74 65 2d 77 75 72 73 74 ;..: write-wurst
0190: 72 6e 67 20 28 20 2d 2d 20 29 0a 20 20 20 20 73 rng ( -- ). s
01a0: 22 20 7e 2f 2e 77 75 72 73 74 72 6e 67 22 20 72 " ~/.wurstrng" r
01b0: 2f 77 20 63 72 65 61 74 65 2d 66 69 6c 65 20 74 /w create-file t
01c0: 68 72 6f 77 20 3e 72 0a 20 20 20 20 72 6e 67 2d hrow >r. rng-
01d0: 62 75 66 66 65 72 20 63 65 6c 6c 2b 20 73 74 61 buffer cell+ sta
01e0: 74 65 23 20 32 2a 20 72 40 20 77 72 69 74 65 2d te# 2* r@ write-
01f0: 66 69 6c 65 20 74 68 72 6f 77 0a 20 20 20 20 72 file throw. r
0200: 3e 20 63 6c 6f 73 65 2d 66 69 6c 65 20 74 68 72 > close-file thr
0210: 6f 77 20 3b 0a 0a 3a 20 73 61 6c 74 2d 69 6e 69 ow ;..: salt-ini
0220: 74 20 28 20 2d 2d 20 29 0a 20 20 20 20 73 22 20 t ( -- ). s"
0230: 7e 2f 2e 77 75 72 73 74 72 6e 67 22 20 72 2f 6f ~/.wurstrng" r/o
0240: 20 6f 70 65 6e 2d 66 69 6c 65 20 49 46 20 20 64 open-file IF d
0250: 72 6f 70 20 72 61 6e 64 6f 6d 2d 69 6e 69 74 0a rop random-init.
0260: 20 20 20 20 45 4c 53 45 20 20 72 65 61 64 2d 77 ELSE read-w
0270: 75 72 73 74 72 6e 67 20 20 30 3d 20 49 46 20 20 urstrng 0= IF
0280: 72 61 6e 64 6f 6d 2d 69 6e 69 74 20 20 54 48 45 random-init THE
0290: 4e 20 20 54 48 45 4e 0a 20 20 20 20 72 6e 67 2d N THEN. rng-
02a0: 73 74 65 70 20 77 72 69 74 65 2d 77 75 72 73 74 step write-wurst
02b0: 72 6e 67 20 72 6e 67 2d 73 74 65 70 20 3b 0a 0a rng rng-step ;..
02c0: 77 75 72 73 74 2d 69 6e 69 74 0a 77 75 72 73 74 wurst-init.wurst
02d0: 2d 74 61 73 6b 2d 69 6e 69 74 0a 73 61 6c 74 2d -task-init.salt-
02e0: 69 6e 69 74 0a init.