Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | #include |
||
8 | #include |
||
9 | |||
10 | int fflush(FILE *f) |
||
11 | { |
||
12 | char *base; |
||
13 | int n, rn; |
||
14 | if(!f) return 0; |
||
15 | if(f->std_ops && STM_OP(f,flush)) |
||
16 | return STM_OP(f,flush)(f); |
||
17 | if ((f->_flag&(_IONBF|_IOWRT))==_IOWRT |
||
18 | && (base = f->_base) != NULL |
||
19 | && (rn = n = f->_ptr - base) > 0) |
||
20 | { |
||
21 | f->_ptr = base; |
||
22 | f->_cnt = (f->_flag&(_IOLBF|_IONBF)) ? 0 : f->_bufsiz; |
||
23 | do { |
||
24 | n = write(fileno(f), base, rn); |
||
25 | if (n <= 0) { |
||
26 | f->_flag |= _IOERR; |
||
27 | return EOF; |
||
28 | } |
||
29 | rn -= n; |
||
30 | base += n; |
||
31 | } while (rn > 0); |
||
32 | _dosemu_flush(fileno(f)); |
||
33 | } |
||
34 | if (f->_flag & _IORW) |
||
35 | { |
||
36 | f->_cnt = 0; |
||
37 | f->_flag &= ~(_IOWRT|_IOREAD); |
||
38 | f->_ptr = f->_base; |
||
39 | } |
||
40 | return 0; |
||
41 | }=> |