-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
11 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
#include <stdio.h> | ||
#include <errno.h> | ||
#include "lib.h" | ||
|
||
int fileno(FILE *stream) | ||
int (fileno)(FILE *stream) | ||
{ | ||
if (stream != NULL) | ||
return FILE_GET_HANDLE(stream); | ||
else | ||
{ | ||
// errno = EBADF; | ||
return -1; | ||
} | ||
|
||
} | ||
__set_errno(EBADF); | ||
return -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,11 @@ | ||
#include <mint/mintbind.h> | ||
#include <mint/errno.h> | ||
#include <unistd.h> | ||
|
||
#ifndef TIOCGPGRP | ||
#define TIOCGPGRP (('T'<< 8) | 6) | ||
#endif | ||
int isatty (int handle) { | ||
long r, pos; | ||
|
||
int isatty (int fd) { | ||
long dummy, retval; | ||
int rc; | ||
|
||
retval = Fcntl (fd, &dummy, TIOCGPGRP); | ||
if (retval == -ENOSYS) { | ||
long oldloc; | ||
|
||
/* save current location */ | ||
oldloc = Fseek (0L, fd, SEEK_CUR); | ||
|
||
/* try to seek ahead one byte */ | ||
if (Fseek (1L, fd, SEEK_CUR) != 0) { | ||
/* got either a file position or an error (usually | ||
* EBADARG indicating a range error from trying to | ||
* seek past EOF), so it is not a tty | ||
*/ | ||
rc = 0; | ||
|
||
/* seek back to original location */ | ||
(void) Fseek (oldloc, fd, SEEK_SET); | ||
} | ||
else { | ||
rc = 1; /* yes, tty */ | ||
} | ||
} | ||
else { | ||
rc = (retval == 0); | ||
} | ||
return rc; | ||
pos = Fseek(0, handle, SEEK_CUR); | ||
r = Fseek(1, handle, SEEK_SET); | ||
Fseek(pos, handle, SEEK_SET); | ||
return r == 0; | ||
} |