AND readpassword( buffer, size )  =  VALOF
$(
//  Read the user's password from disc (if it is there).  The result is a
//  boolean saying whether the operation succeeded.

    LET oldin   =  input()
    LET stream  =  findinput( "HOME:CS-Password" )
    
    TEST  stream = 0  THEN  RESULTIS  FALSE
    ELSE
    $(
        //  We have opened the stream, so we should read the password from the
        //  file, decoding it as we go.
        
        LET length  =  0
        LET ch      =  0
        
        selectinput( stream )
        
        length  :=  (NOT rdch())  &  #XFF
        
        UNLESS  length > size  DO
        $(
            //  All is OK, so we can fill in the string.
            
            buffer % 0  :=  length

            FOR  i = 1  TO  length  DO  buffer % i  :=  (NOT rdch())  &  #XFF
        $)
        
        endread()
        
        selectinput( oldin )
        
        //  The result now is simply an indication of whether the password was
        //  too big or not.
        
        RESULTIS  NOT (length > size)
    $)
$)


