This source file includes following definitions.
- fpurge
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19
20 #include <stdio.h>
21
22 #if HAVE___FPURGE
23 # if HAVE_STDIO_EXT_H
24 # include <stdio_ext.h>
25 # endif
26 #endif
27 #include <stdlib.h>
28
29 #include "stdio-impl.h"
30
31 int
32 fpurge (FILE *fp)
33 {
34 #if HAVE___FPURGE
35
36 __fpurge (fp);
37
38 return 0;
39
40 #elif HAVE_FPURGE
41
42
43 # undef fpurge
44 # if !HAVE_DECL_FPURGE
45 extern int fpurge (FILE *);
46 # endif
47 int result = fpurge (fp);
48 # if defined __sferror || defined __DragonFly__ || defined __ANDROID__
49
50 if (result == 0)
51
52
53
54
55
56
57 if ((fp_->_flags & __SRD) != 0)
58 fp_->_w = 0;
59 # endif
60 return result;
61
62 #else
63
64
65
66
67 # if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
68
69 fp->_IO_read_end = fp->_IO_read_ptr;
70 fp->_IO_write_ptr = fp->_IO_write_base;
71
72 if (fp->_IO_save_base != NULL)
73 {
74 free (fp->_IO_save_base);
75 fp->_IO_save_base = NULL;
76 }
77 return 0;
78 # elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
79
80 fp_->_p = fp_->_bf._base;
81 fp_->_r = 0;
82 fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0
83 ? fp_->_bf._size
84 : 0);
85
86 if (fp_ub._base != NULL)
87 {
88 if (fp_ub._base != fp_->_ubuf)
89 free (fp_ub._base);
90 fp_ub._base = NULL;
91 }
92 return 0;
93 # elif defined __EMX__
94 fp->_ptr = fp->_buffer;
95 fp->_rcount = 0;
96 fp->_wcount = 0;
97 fp->_ungetc_count = 0;
98 return 0;
99 # elif defined __minix
100 fp->_ptr = fp->_buf;
101 if (fp->_ptr != NULL)
102 fp->_count = 0;
103 return 0;
104 # elif defined _IOERR
105 fp_->_ptr = fp_->_base;
106 if (fp_->_ptr != NULL)
107 fp_->_cnt = 0;
108 return 0;
109 # elif defined __UCLIBC__
110 # ifdef __STDIO_BUFFERS
111 if (fp->__modeflags & __FLAG_WRITING)
112 fp->__bufpos = fp->__bufstart;
113 else if (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING))
114 fp->__bufpos = fp->__bufread;
115 # endif
116 return 0;
117 # elif defined __QNX__
118 fp->_Rback = fp->_Back + sizeof (fp->_Back);
119 fp->_Rsave = NULL;
120 if (fp->_Mode & 0x2000 )
121
122 fp->_Next = fp->_Buf;
123 else
124
125 fp->_Rend = fp->_Next;
126 return 0;
127 # elif defined __MINT__
128 if (fp->__pushed_back)
129 {
130 fp->__bufp = fp->__pushback_bufp;
131 fp->__pushed_back = 0;
132 }
133
134 if (fp->__target != -1)
135 fp->__target += fp->__bufp - fp->__buffer;
136 fp->__bufp = fp->__buffer;
137
138 fp->__get_limit = fp->__bufp;
139
140 fp->__put_limit = fp->__buffer;
141 return 0;
142 # elif defined EPLAN9
143 fp->rp = fp->wp = fp->lp = fp->buf;
144 return 0;
145 # else
146 # error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
147 # endif
148
149 #endif
150 }