From: <gu...@us...> - 2007-04-18 16:33:52
|
Hello, I need to program a function in sbcl unix to read a password, but I don't know how to make the keyboard echo disabled and enable (echo off and on). At news groups I found a Fred Gilham code to do this with CMUCL: http://groups.google.com/group/comp.lang.lisp/msg/af274400a851d58a I think using sb-posix package may be usefull to do that. Any help? Regards, P. Garcia |
From: Richard M K. <kr...@pr...> - 2007-04-19 01:11:33
|
"P. García" <gu...@us...> writes: > Hello, > > I need to program a function in sbcl unix to read a password, but I > don't know how to make the keyboard echo disabled and enable (echo > off and on). > > > At news groups I found a Fred Gilham code to do this with CMUCL: > http://groups.google.com/group/comp.lang.lisp/msg/af274400a851d58a > > > I think using sb-posix package may be usefull to do that. Any help? I've used something like the following in the past. Dunno if it's the recommended way to do things, but it seems to work. (require :sb-posix) (defun echo-off () (let ((tm (sb-posix:tcgetattr sb-sys:*tty*))) (setf (sb-posix:termios-lflag tm) (logandc2 (sb-posix:termios-lflag tm) sb-posix:echo)) (sb-posix:tcsetattr sb-sys:*tty* sb-posix:tcsanow tm))) (defun echo-on () (let ((tm (sb-posix:tcgetattr sb-sys:*tty*))) (setf (sb-posix:termios-lflag tm) (logior (sb-posix:termios-lflag tm) sb-posix:echo)) (sb-posix:tcsetattr sb-sys:*tty* sb-posix:tcsanow tm))) -- RmK |
From: <gu...@us...> - 2007-04-19 11:19:14
|
Richard M Kreuter wrote: > The following message is a courtesy copy of an article > that has been posted to gmane.lisp.steel-bank.general as well. > > "P. García" <gu...@us...> writes: > >> Hello, >> >> I need to program a function in sbcl unix to read a password, but I >> don't know how to make the keyboard echo disabled and enable (echo >> off and on). >> >> >> At news groups I found a Fred Gilham code to do this with CMUCL: >> http://groups.google.com/group/comp.lang.lisp/msg/af274400a851d58a >> >> >> I think using sb-posix package may be usefull to do that. Any help? > > I've used something like the following in the past. Dunno if it's the > recommended way to do things, but it seems to work. > > (require :sb-posix) > > (defun echo-off () > (let ((tm (sb-posix:tcgetattr sb-sys:*tty*))) > (setf (sb-posix:termios-lflag tm) > (logandc2 (sb-posix:termios-lflag tm) sb-posix:echo)) > (sb-posix:tcsetattr sb-sys:*tty* sb-posix:tcsanow tm))) > > (defun echo-on () > (let ((tm (sb-posix:tcgetattr sb-sys:*tty*))) > (setf (sb-posix:termios-lflag tm) > (logior (sb-posix:termios-lflag tm) sb-posix:echo)) > (sb-posix:tcsetattr sb-sys:*tty* sb-posix:tcsanow tm))) > Thanks!, it works, but when I define echo-off and echo-on function there are several notes about the "unable to optimize". Any idea to fix it? : ; in: LAMBDA NIL ; (SB-POSIX:TCGETATTR SB-SYS:*TTY*) ; --> BLOCK SB-POSIX::WITH-ALIEN-TERMIOS WITH-ALIEN SYMBOL-MACROLET ; --> SYMBOL-MACROLET LET MULTIPLE-VALUE-PROG1 SYMBOL-MACROLET UNWIND-PROTECT ; --> FLET BLOCK MULTIPLE-VALUE-BIND MULTIPLE-VALUE-CALL BLOCK ; --> SB-C::%WITHIN-CLEANUP RETURN-FROM PROGN LET SETF SETQ THE ; --> SB-POSIX::ALIEN-TO-TERMIOS SB-POSIX::A-TERMIOS ; --> SB-ALIEN-INTERNALS:LOCAL-ALIEN SB-ALIEN-INTERNALS:NATURALIZE ; ==> ; (SB-ALIEN-INTERNALS:%SAP-ALIEN ALIEN ; '#<SB-ALIEN-INTERNALS:ALIEN-POINTER-TYPE (* ; (STRUCT ; SB-POSIX::ALIEN-TERMIOS ; (SB-POSIX::IFLAG ; #) ; (SB-POSIX::OFLAG ; #) ; (SB-POSIX::CFLAG ; #) ; (SB-POSIX::LFLAG ; #) ; (SB-POSIX::CC ; #) ; (SB-POSIX::PADDING17 ; #)))>) ; ; note: unable to ; optimize ; because: ; could not optimize away %SAP-ALIEN: forced to do runtime ; allocation of alien-value structure ; --> BLOCK SB-POSIX::WITH-ALIEN-TERMIOS WITH-ALIEN SYMBOL-MACROLET ; --> SYMBOL-MACROLET LET MULTIPLE-VALUE-PROG1 SYMBOL-MACROLET UNWIND-PROTECT ; --> FLET BLOCK FUNCALL SB-C::%FUNCALL ; --> #<SB-C::GLOBAL-VAR :%SOURCE-NAME SB-POSIX::FREE-ALIEN-TERMIOS :TYPE #<SB-KERNEL:BUILT-IN-CLASSOID FUNCTION (read-only)> :WHERE-FROM :DEFINED :KIND :GLOBAL-FUNCTION {49A81081}> ; --> SB-POSIX::A-TERMIOS SB-ALIEN-INTERNALS:LOCAL-ALIEN ; --> SB-ALIEN-INTERNALS:NATURALIZE ; ==> ; (SB-ALIEN-INTERNALS:%SAP-ALIEN ALIEN ; '#<SB-ALIEN-INTERNALS:ALIEN-POINTER-TYPE (* ; (STRUCT ; SB-POSIX::ALIEN-TERMIOS ; (SB-POSIX::IFLAG ; #) ; (SB-POSIX::OFLAG ; #) ; (SB-POSIX::CFLAG ; #) ; (SB-POSIX::LFLAG ; #) ; (SB-POSIX::CC ; #) ; (SB-POSIX::PADDING17 ; #)))>) ; ; note: unable to ; optimize ; because: ; could not optimize away %SAP-ALIEN: forced to do runtime ; allocation of alien-value structure ; (SB-POSIX:TCSETATTR SB-SYS:*TTY* SB-POSIX:TCSANOW TM) ; --> BLOCK SB-POSIX::WITH-ALIEN-TERMIOS WITH-ALIEN SYMBOL-MACROLET ; --> SYMBOL-MACROLET LET MULTIPLE-VALUE-PROG1 SYMBOL-MACROLET UNWIND-PROTECT ; --> FLET BLOCK MULTIPLE-VALUE-BIND MULTIPLE-VALUE-CALL BLOCK ; --> SB-C::%WITHIN-CLEANUP RETURN-FROM PROGN SB-POSIX::TERMIOS-TO-ALIEN ; --> SB-POSIX::A-TERMIOS SB-ALIEN-INTERNALS:LOCAL-ALIEN ; --> SB-ALIEN-INTERNALS:NATURALIZE ; ==> ; (SB-ALIEN-INTERNALS:%SAP-ALIEN ALIEN ; '#<SB-ALIEN-INTERNALS:ALIEN-POINTER-TYPE (* ; (STRUCT ; SB-POSIX::ALIEN-TERMIOS ; (SB-POSIX::IFLAG ; #) ; (SB-POSIX::OFLAG ; #) ; (SB-POSIX::CFLAG ; #) ; (SB-POSIX::LFLAG ; #) ; (SB-POSIX::CC ; #) ; (SB-POSIX::PADDING17 ; #)))>) ; ; note: unable to ; optimize ; because: ; could not optimize away %SAP-ALIEN: forced to do runtime ; allocation of alien-value structure ; --> BLOCK SB-POSIX::WITH-ALIEN-TERMIOS WITH-ALIEN SYMBOL-MACROLET ; --> SYMBOL-MACROLET LET MULTIPLE-VALUE-PROG1 SYMBOL-MACROLET UNWIND-PROTECT ; --> FLET BLOCK FUNCALL SB-C::%FUNCALL ; --> #<SB-C::GLOBAL-VAR :%SOURCE-NAME SB-POSIX::FREE-ALIEN-TERMIOS :TYPE #<SB-KERNEL:BUILT-IN-CLASSOID FUNCTION (read-only)> :WHERE-FROM :DEFINED :KIND :GLOBAL-FUNCTION {49A62E31}> ; --> SB-POSIX::A-TERMIOS SB-ALIEN-INTERNALS:LOCAL-ALIEN ; --> SB-ALIEN-INTERNALS:NATURALIZE ; ==> ; (SB-ALIEN-INTERNALS:%SAP-ALIEN ALIEN ; '#<SB-ALIEN-INTERNALS:ALIEN-POINTER-TYPE (* ; (STRUCT ; SB-POSIX::ALIEN-TERMIOS ; (SB-POSIX::IFLAG ; #) ; (SB-POSIX::OFLAG ; #) ; (SB-POSIX::CFLAG ; #) ; (SB-POSIX::LFLAG ; #) ; (SB-POSIX::CC ; #) ; (SB-POSIX::PADDING17 ; #)))>) ; ; note: unable to ; optimize ; because: ; could not optimize away %SAP-ALIEN: forced to do runtime ; allocation of alien-value structure ; ; compilation unit finished ; printed 4 notes ECHO-OFF |