source: trunk/libs/newlib/src/newlib/libc/stdio/stdio_ext.c @ 543

Last change on this file since 543 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.0 KB
Line 
1/*
2FUNCTION
3<<stdio_ext>>,<<__fbufsize>>,<<__fpending>>,<<__flbf>>,<<__freadable>>,<<__fwritable>>,<<__freading>>,<<__fwriting>>---access internals of FILE structure
4
5INDEX
6        __fbufsize
7INDEX
8        __fpending
9INDEX
10        __flbf
11INDEX
12        __freadable
13INDEX
14        __fwritable
15INDEX
16        __freading
17INDEX
18        __fwriting
19
20SYNOPSIS
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
31DESCRIPTION
32These functions provides access to the internals of the FILE structure <[fp]>.
33
34RETURNS
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
46it 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
49it was a write, or if it write-only, and <<0>> if not.
50
51PORTABILITY
52These functions originate from Solaris and are also provided by GNU libc.
53
54No 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
64size_t
65__fbufsize (FILE * fp)
66{
67  return (size_t) fp->_bf._size;
68}
69
70size_t
71__fpending (FILE * fp)
72{
73  return fp->_p - fp->_bf._base;
74}
75
76int
77__flbf (FILE * fp)
78{
79  return (fp->_flags & __SLBF) != 0;
80}
81
82int
83__freadable (FILE * fp)
84{
85  return (fp->_flags & (__SRD | __SRW)) != 0;
86}
87
88int
89__fwritable (FILE * fp)
90{
91  return (fp->_flags & (__SWR | __SRW)) != 0;
92}
93
94int
95__freading (FILE * fp)
96{
97  return (fp->_flags & __SRD) != 0;
98}
99
100int
101__fwriting (FILE * fp)
102{
103  return (fp->_flags & __SWR) != 0;
104}
105
106#endif /* __rtems__ */
Note: See TracBrowser for help on using the repository browser.