Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2. FUNCTION
  3. <<stdio_ext>>,<<__fbufsize>>,<<__fpending>>,<<__flbf>>,<<__freadable>>,<<__fwritable>>,<<__freading>>,<<__fwriting>>---access internals of FILE structure
  4.  
  5. INDEX
  6.         __fbufsize
  7. INDEX
  8.         __fpending
  9. INDEX
  10.         __flbf
  11. INDEX
  12.         __freadable
  13. INDEX
  14.         __fwritable
  15. INDEX
  16.         __freading
  17. INDEX
  18.         __fwriting
  19.  
  20. ANSI_SYNOPSIS
  21.         #include <stdio.h>
  22.         #include <stdio_ext.h>
  23.         size_t __fbufsize(FILE *<[fp]>);
  24.         size_t __fpending(FILE *<[fp]>);
  25.         int __flbf(FILE *<[fp]>);
  26.         int __freadable(FILE *<[fp]>);
  27.         int __fwritable(FILE *<[fp]>);
  28.         int __freading(FILE *<[fp]>);
  29.         int __fwriting(FILE *<[fp]>);
  30.  
  31. DESCRIPTION
  32. These functions provides access to the internals of the FILE structure <[fp]>.
  33.  
  34. RETURNS
  35. <<__fbufsize>> returns the number of bytes in the buffer of stream <[fp]>.
  36.  
  37. <<__fpending>> returns the number of bytes in the output buffer of stream <[fp]>.
  38.  
  39. <<__flbf>> returns nonzero if stream <[fp]> is line-buffered, and <<0>> if not.
  40.  
  41. <<__freadable>> returns nonzero if stream <[fp]> may be read, and <<0>> if not.
  42.  
  43. <<__fwritable>> returns nonzero if stream <[fp]> may be written, and <<0>> if not.
  44.  
  45. <<__freading>> returns nonzero if stream <[fp]> if the last operation on
  46. it was a read, or if it read-only, and <<0>> if not.
  47.  
  48. <<__fwriting>> returns nonzero if stream <[fp]> if the last operation on
  49. it was a write, or if it write-only, and <<0>> if not.
  50.  
  51. PORTABILITY
  52. These functions originate from Solaris and are also provided by GNU libc.
  53.  
  54. No supporting OS subroutines are required.
  55. */
  56.  
  57. #ifndef __rtems__
  58.  
  59. #include <_ansi.h>
  60. #include <stdio.h>
  61.  
  62. /* Subroutine versions of the inline or macro functions. */
  63.  
  64. size_t
  65. _DEFUN(__fbufsize, (fp),
  66.        FILE * fp)
  67. {
  68.   return (size_t) fp->_bf._size;
  69. }
  70.  
  71. size_t
  72. _DEFUN(__fpending, (fp),
  73.        FILE * fp)
  74. {
  75.   return fp->_p - fp->_bf._base;
  76. }
  77.  
  78. int
  79. _DEFUN(__flbf, (fp),
  80.        FILE * fp)
  81. {
  82.   return (fp->_flags & __SLBF) != 0;
  83. }
  84.  
  85. int
  86. _DEFUN(__freadable, (fp),
  87.        FILE * fp)
  88. {
  89.   return (fp->_flags & (__SRD | __SRW)) != 0;
  90. }
  91.  
  92. int
  93. _DEFUN(__fwritable, (fp),
  94.        FILE * fp)
  95. {
  96.   return (fp->_flags & (__SWR | __SRW)) != 0;
  97. }
  98.  
  99. int
  100. _DEFUN(__freading, (fp),
  101.        FILE * fp)
  102. {
  103.   return (fp->_flags & __SRD) != 0;
  104. }
  105.  
  106. int
  107. _DEFUN(__fwriting, (fp),
  108.        FILE * fp)
  109. {
  110.   return (fp->_flags & __SWR) != 0;
  111. }
  112.  
  113. #endif /* __rtems__ */
  114.