1 /* Copyright (c) 2011 Yaakov Selkowitz <yselkowi@redhat.com> */
2 /*
3  * stdio_ext.h
4  *
5  * Definitions for I/O internal operations, originally from Solaris.
6  */
7 
8 #ifndef _STDIO_EXT_H_
9 #define _STDIO_EXT_H_
10 
11 #include <stdio.h>
12 
13 #define	FSETLOCKING_QUERY	0
14 #define	FSETLOCKING_INTERNAL	1
15 #define	FSETLOCKING_BYCALLER	2
16 
17 _BEGIN_STD_C
18 
19 void	 __fpurge (FILE *);
20 int	 __fsetlocking (FILE *, int);
21 
22 /* TODO:
23 
24    void _flushlbf (void);
25 */
26 
27 #ifdef __declare_extern_inline
28 
29 __declare_extern_inline(size_t)
__fbufsize(FILE * __fp)30 __fbufsize (FILE *__fp) { return (size_t) __fp->_bf._size; }
31 
32 __declare_extern_inline(int)
__freading(FILE * __fp)33 __freading (FILE *__fp) { return (__fp->_flags & __SRD) != 0; }
34 
35 __declare_extern_inline(int)
__fwriting(FILE * __fp)36 __fwriting (FILE *__fp) { return (__fp->_flags & __SWR) != 0; }
37 
38 __declare_extern_inline(int)
__freadable(FILE * __fp)39 __freadable (FILE *__fp) { return (__fp->_flags & (__SRD | __SRW)) != 0; }
40 
41 __declare_extern_inline(int)
__fwritable(FILE * __fp)42 __fwritable (FILE *__fp) { return (__fp->_flags & (__SWR | __SRW)) != 0; }
43 
44 __declare_extern_inline(int)
__flbf(FILE * __fp)45 __flbf (FILE *__fp) { return (__fp->_flags & __SLBF) != 0; }
46 
47 __declare_extern_inline(size_t)
__fpending(FILE * __fp)48 __fpending (FILE *__fp) { return __fp->_p - __fp->_bf._base; }
49 
50 #endif
51 
52 size_t	 __fbufsize (FILE *);
53 int	 __freading (FILE *);
54 int	 __fwriting (FILE *);
55 int	 __freadable (FILE *);
56 int	 __fwritable (FILE *);
57 int	 __flbf (FILE *);
58 size_t	 __fpending (FILE *);
59 
60 _END_STD_C
61 
62 #endif /* _STDIO_EXT_H_ */
63