entering char from keyboard
Assalamu 'alaikum..... everybody
I want to build code to enter some char from keyboard what syscall i need...?
Re!
* On 29 April, 2002 11:28:55 AM
Quoted 1 line · * "ssams" ([email protected]) wrote:
Assalamu 'alaikum..... everybody
Assalamu,
Quoted 2 lines
I want to build code to enter some char from keyboard what syscall i need...?
#define __NR_read 3,
for reading, and maybe also __NR_write for writing it at stdout ...
look also at
$ man 2 read
Your file d. should be stdin
myst@xor:/dev$ ls -al stdin lrwxrwxrwx 1 root root 4 24. Nov 17:38 stdin -> fd/0
bye
--
Leonardo Di Lella
[0x01] http://www.comfire.de
[0x02] http://www.netline-is.de
Hello, (its more neutral I guess)
Any program in unix while running has open the file descriptor (handle) for STDIN STDOUT and STDERR (0,1,2).
If you want to read from keyboard you just read(stdin)
via a syscall. But may happen that the syscall returns after pressing ENTER. If you want just read one ahar without (ENTER) confirming it, you should change terminal IOCTL.
look in sh.asm in asmutils
mov edx,termattrs
sys_ioctl STDIN,TCGETS
mov eax,[termattrs.c_lflag]
push eax
and eax,~(ICANON|ECHO) ; this turns OFF echo also
mov [termattrs.c_lflag],eax
sys_ioctl STDIN, TCSETS
this should work under linux, this under *NIX (maybe)
sys_fcntl STDIN,F_GETFL
and eax,~(O_NONBLOCK)
sys_fcntl STDIN,F_SETFL,eax
and the rest is smth like read 1 byte from STDIN
Regards
Rudolf