/* _flushall calls fflush which calls _flushall */
int CDECL fflush(FILE* file);
-/*********************************************************************
- * _flushall (MSVCRT.@)
- */
-int CDECL _flushall(void)
+/* INTERNAL: Flush all stream buffer */
+static int flush_all_buffers(int mask)
{
int i, num_flushed = 0;
FILE *file;
if (file->_flag)
{
- if(file->_flag & _IOWRT) {
- fflush(file);
+ if(file->_flag & mask) {
+ fflush(file);
num_flushed++;
}
}
return num_flushed;
}
+/*********************************************************************
+ * _flushall (MSVCRT.@)
+ */
+int CDECL _flushall(void)
+{
+ return flush_all_buffers(_IOWRT | _IOREAD);
+}
+
/*********************************************************************
* fflush (MSVCRT.@)
*/
int CDECL fflush(FILE* file)
{
if(!file) {
- _flushall();
+ flush_all_buffers(_IOWRT);
} else if(file->_flag & _IOWRT) {
int res;
_lock_file(file);
res = flush_buffer(file);
+ /* FIXME
+ if(!res && (file->_flag & _IOCOMMIT))
+ res = _commit(file->_file) ? EOF : 0;
+ */
_unlock_file(file);
return res;
- }
+ } else if(file->_flag & _IOREAD) {
+ _lock_file(file);
+ file->_cnt = 0;
+ file->_ptr = file->_base;
+ _unlock_file(file);
+
+ return 0;
+ }
return 0;
}
*open_flags |= _O_BINARY;
*open_flags &= ~_O_TEXT;
break;
- case 'T': case 't':
+ case 't':
*open_flags |= _O_TEXT;
*open_flags &= ~_O_BINARY;
break;