2022-08-07 20:10:08 +00:00
|
|
|
#
|
|
|
|
! $Source$
|
|
|
|
! $State$
|
|
|
|
! $Revision$
|
|
|
|
|
|
|
|
! Declare segments (the order is important).
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
.sect .rom
|
|
|
|
.sect .data
|
|
|
|
.sect .bss
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
|
|
|
|
! Say whether a given file descriptor number refers to a terminal.
|
|
|
|
|
|
|
|
.define _isatty
|
|
|
|
_isatty:
|
2022-08-18 22:08:57 +00:00
|
|
|
mov ebx, esp
|
2022-08-17 20:34:06 +00:00
|
|
|
mov ebx, 4(ebx)
|
|
|
|
o16 mov ax, 0x4400
|
2022-08-07 20:10:08 +00:00
|
|
|
int 0x21
|
|
|
|
jc error
|
|
|
|
testb dl, dl
|
|
|
|
jz not_tty
|
2022-08-17 20:34:06 +00:00
|
|
|
mov eax, 1
|
2022-08-07 20:10:08 +00:00
|
|
|
ret
|
|
|
|
not_tty:
|
|
|
|
mov (_errno), 25 ! ENOTTY
|
|
|
|
not_tty_2:
|
2022-08-17 20:34:06 +00:00
|
|
|
xor eax, eax
|
2022-08-07 20:10:08 +00:00
|
|
|
ret
|
|
|
|
error:
|
2022-08-17 20:34:06 +00:00
|
|
|
push eax
|
2022-08-07 20:10:08 +00:00
|
|
|
call __sys_seterrno
|
2022-08-17 20:34:06 +00:00
|
|
|
pop ecx
|
2022-08-07 20:10:08 +00:00
|
|
|
jmp not_tty_2
|