]> git.lizzy.rs Git - plan9front.git/blob - sys/src/ape/lib/ap/plan9/isatty.c
merge
[plan9front.git] / sys / src / ape / lib / ap / plan9 / isatty.c
1 #include "lib.h"
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include "sys9.h"
6 #include "dir.h"
7
8 int
9 _isatty(int fd)
10 {
11         int t;
12         char buf[64];
13
14         if(_FD2PATH(fd, buf, sizeof buf) < 0)
15                 return 0;
16
17         /* might be /mnt/term/dev/cons */
18         return strlen(buf) >= 9 && strcmp(buf+strlen(buf)-9, "/dev/cons") == 0;
19 }
20
21 /* The FD_ISTTY flag is set via _isatty in _fdsetup or open */
22 int
23 isatty(fd)
24 {
25         if(_fdinfo[fd].flags&FD_ISTTY)
26                 return 1;
27         else
28                 return 0;
29 }