Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 5a3d998cc00060c67a9a8d7f23c2d34c > files > 77

gauche-0.8.14-3.fc11.x86_64.rpm

;; Example of gauche.termios
;;  $Id: noecho.scm,v 1.1 2003-01-08 02:06:27 shirok Exp $

#!no-fold-case

(use gauche.termios)

(define (get-password prompt)
  (let* ((port (current-input-port))
         (attr (sys-tcgetattr port))
         (lflag (slot-ref attr 'lflag)))
    ;; Show prompt
    (display prompt)
    (flush)
    ;; Turn off echo during reading.
    (dynamic-wind
     (lambda ()
       (slot-set! attr 'lflag (logand lflag (lognot ECHO)))
       (sys-tcsetattr port TCSAFLUSH attr))
     (lambda ()
       (read-line port))
     (lambda ()
       (slot-set! attr 'lflag lflag)
       (sys-tcsetattr port TCSANOW attr)))))