Artifact Content
Not logged in

Artifact ee5819d64c8cf2005451a2a8427a049b6d47ff2d:


\ init wurstkessel to be actually useful

: random-init ( -- )
    s" /dev/random" r/o open-file throw >r
    wurst-salt state# r@ read-file throw drop
    r> close-file throw ;

: read-wurstrng ( fd -- flag )  { fd }
    0. fd reposition-file throw
    wurst-salt state# fd read-file throw state# = >r
    state-init state# fd read-file throw state# = r> and
    fd close-file throw ;

: write-wurstrng ( -- )
    s" ~/.wurstrng" r/w create-file throw >r
    rng-buffer cell+ state# 2* r@ write-file throw
    r> close-file throw ;

: salt-init ( -- )
    s" ~/.wurstrng" r/o open-file IF  drop random-init
    ELSE  read-wurstrng  0= IF  random-init  THEN  THEN
    rng-step write-wurstrng rng-step ;

wurst-init
wurst-task-init
salt-init