This source file includes following definitions.
- freadptr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19
20 #include "freadptr.h"
21
22 #include <stdlib.h>
23
24 #include "stdio-impl.h"
25
26
27
28
29 const char *
30 freadptr (FILE *fp, size_t *sizep)
31 {
32 size_t size;
33
34
35 #if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
36
37 if (fp->_IO_write_ptr > fp->_IO_write_base)
38 return NULL;
39 size = fp->_IO_read_end - fp->_IO_read_ptr;
40 if (size == 0)
41 return NULL;
42 *sizep = size;
43 return (const char *) fp->_IO_read_ptr;
44 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
45
46 if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
47 return NULL;
48 size = fp_->_r;
49 if (size == 0)
50 return NULL;
51 *sizep = size;
52 return (const char *) fp_->_p;
53 #elif defined __EMX__
54 if ((fp->_flags & _IOWRT) != 0)
55 return NULL;
56
57
58 if (fp->_rcount <= 0)
59 return NULL;
60 if (!(fp->_ungetc_count == 0))
61 abort ();
62 *sizep = fp->_rcount;
63 return fp->_ptr;
64 #elif defined __minix
65 if ((fp_->_flags & _IOWRITING) != 0)
66 return NULL;
67 size = fp_->_count;
68 if (size == 0)
69 return NULL;
70 *sizep = size;
71 return (const char *) fp_->_ptr;
72 #elif defined _IOERR
73 if ((fp_->_flag & _IOWRT) != 0)
74 return NULL;
75 size = fp_->_cnt;
76 if (size == 0)
77 return NULL;
78 *sizep = size;
79 return (const char *) fp_->_ptr;
80 #elif defined __UCLIBC__
81 # ifdef __STDIO_BUFFERS
82 if (fp->__modeflags & __FLAG_WRITING)
83 return NULL;
84 if (fp->__modeflags & __FLAG_UNGOT)
85 return NULL;
86 size = fp->__bufread - fp->__bufpos;
87 if (size == 0)
88 return NULL;
89 *sizep = size;
90 return (const char *) fp->__bufpos;
91 # else
92 return NULL;
93 # endif
94 #elif defined __QNX__
95 if ((fp->_Mode & 0x2000 ) != 0)
96 return NULL;
97
98 size = fp->_Rend - fp->_Next;
99 if (size == 0)
100 return NULL;
101 *sizep = size;
102 return (const char *) fp->_Next;
103 #elif defined __MINT__
104 if (!fp->__mode.__read)
105 return NULL;
106 size = fp->__get_limit - fp->__bufp;
107 if (size == 0)
108 return NULL;
109 *sizep = size;
110 return fp->__bufp;
111 #elif defined EPLAN9
112 if (fp->state == 4 )
113 return NULL;
114 if (fp->rp >= fp->wp)
115 return NULL;
116 *sizep = fp->wp - fp->rp;
117 return fp->rp;
118 #elif defined SLOW_BUT_NO_HACKS
119
120
121 return NULL;
122 #else
123 #error "Please port gnulib freadptr.c to your platform! Look at the definition of fflush, fread, getc, getc_unlocked on your system, then report this to bug-gnulib."
124 #endif
125 }