int
PerlLIOIsatty(struct IPerlLIO* piPerl, int fd)
{
- /* The Microsoft isatty() function returns true for *all*
- * character mode devices, including "nul". Our implementation
- * should only return true if the handle has a console buffer.
- */
- DWORD mode;
- HANDLE fh = (HANDLE)_get_osfhandle(fd);
- if (fh == (HANDLE)-1) {
- /* errno is already set to EBADF */
- return 0;
- }
-
- if (GetConsoleMode(fh, &mode))
- return 1;
-
- errno = ENOTTY;
- return 0;
+ return win32_isatty(fd);
}
int
}
DllExport int
+win32_isatty(int fd)
+{
+ /* The Microsoft isatty() function returns true for *all*
+ * character mode devices, including "nul". Our implementation
+ * should only return true if the handle has a console buffer.
+ */
+ DWORD mode;
+ HANDLE fh = (HANDLE)_get_osfhandle(fd);
+ if (fh == (HANDLE)-1) {
+ /* errno is already set to EBADF */
+ return 0;
+ }
+
+ if (GetConsoleMode(fh, &mode))
+ return 1;
+
+ errno = ENOTTY;
+ return 0;
+}
+
+DllExport int
win32_dup(int fd)
{
return dup(fd);
DllExport int win32_open(const char *path, int oflag,...);
DllExport int win32_close(int fd);
DllExport int win32_eof(int fd);
+DllExport int win32_isatty(int fd);
DllExport int win32_read(int fd, void *buf, unsigned int cnt);
DllExport int win32_write(int fd, const void *buf, unsigned int cnt);
DllExport int win32_spawnvp(int mode, const char *cmdname,
#define open win32_open
#define close(fd) win32_close(fd)
#define eof(fd) win32_eof(fd)
+#define isatty(fd) win32_isatty(fd)
#define read(fd,b,s) win32_read(fd,b,s)
#define write(fd,b,s) win32_write(fd,b,s)
#define _open_osfhandle win32_open_osfhandle