• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "stdio_impl.h"
2 
__towrite(FILE * f)3 int __towrite(FILE *f)
4 {
5 	f->mode |= f->mode-1;
6 	if (f->flags & F_NOWR) {
7 		f->flags |= F_ERR;
8 		return EOF;
9 	}
10 	/* Clear read buffer (easier than summoning nasal demons) */
11 	f->rpos = f->rend = 0;
12 
13 	/* Alloc file buffer if needed */
14 	if (__falloc_buf(f) < 0) {
15 		f->flags |= F_ERR;
16 		return EOF;
17 	}
18 
19 	/* Activate write through the buffer. */
20 	f->wpos = f->wbase = f->buf;
21 	f->wend = f->buf + f->buf_size;
22 	return 0;
23 }
24 
__towrite_needs_stdio_exit()25 hidden void __towrite_needs_stdio_exit()
26 {
27 	__stdio_exit_needed();
28 }
29