Subversion Repositories Kolibri OS

Rev

Rev 4921 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /* Reentrant versions of isatty system call.  */
  2.  
  3. #include <reent.h>
  4. #include <unistd.h>
  5. #include <_syslist.h>
  6.  
  7. /* Some targets provides their own versions of these functions.  Those
  8.    targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
  9.  
  10. #ifdef _REENT_ONLY
  11. #ifndef REENTRANT_SYSCALLS_PROVIDED
  12. #define REENTRANT_SYSCALLS_PROVIDED
  13. #endif
  14. #endif
  15.  
  16. #ifdef REENTRANT_SYSCALLS_PROVIDED
  17.  
  18. int _dummy_isatty_syscalls = 1;
  19.  
  20. #else
  21.  
  22. /* We use the errno variable used by the system dependent layer.  */
  23. #undef errno
  24. extern int errno;
  25.  
  26. /*
  27. FUNCTION
  28.         <<_isatty_r>>---Reentrant version of isatty
  29.        
  30. INDEX
  31.         _isatty_r
  32.  
  33. ANSI_SYNOPSIS
  34.         #include <reent.h>
  35.         int _isatty_r(struct _reent *<[ptr]>,
  36.                      int <[fd]>);
  37.  
  38. TRAD_SYNOPSIS
  39.         #include <reent.h>
  40.         int _isatty_r(<[ptr]>, <[fd]>)
  41.         struct _reent *<[ptr]>;
  42.         int <[fd]>;
  43.  
  44. DESCRIPTION
  45.         This is a reentrant version of <<isatty>>.  It
  46.         takes a pointer to the global data block, which holds
  47.         <<errno>>.
  48. */
  49.  
  50. int
  51. _isatty_r (ptr, fd)
  52.      struct _reent *ptr;
  53.      int fd;
  54. {
  55.   int ret;
  56.  
  57.   errno = 0;
  58.   if ((ret = _isatty (fd)) == -1 && errno != 0)
  59.     ptr->_errno = errno;
  60.   return ret;
  61. }
  62.  
  63. #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
  64.