xref: /haiku/src/system/libroot/posix/stdio/__freading.cpp (revision 508f54795f39c3e7552d87c95aae9dd8ec6f505b)
1 /*
2  * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include <libio.h>
7 #include <stdio_ext.h>
8 
9 
10 int
11 __freading(FILE* stream)
12 {
13 	// Return true, if writing is not allowed or the last operation was a read.
14 	return (stream->_flags & _IO_NO_WRITES) != 0
15 		|| ((stream->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
16 			&& stream->_IO_read_base != NULL);
17 }
18