Implemented __freading(), __fpurge(), and fpurge().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28397 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
#ifndef _STDIO_H_
|
||||
@@ -96,6 +96,7 @@ extern void perror(const char *errorPrefix);
|
||||
/* file I/O */
|
||||
extern int fflush(FILE *stream);
|
||||
extern int fflush_unlocked(FILE *stream);
|
||||
extern int fpurge(FILE *stream);
|
||||
|
||||
extern int fgetpos(FILE *stream, fpos_t *position);
|
||||
extern int fsetpos(FILE *stream, const fpos_t *position);
|
||||
|
||||
@@ -17,12 +17,12 @@ extern "C" {
|
||||
|
||||
/* The following stdio extensions are not implemented yet */
|
||||
/* extern size_t __fufsize(FILE* stream); */
|
||||
/* extern int __freading(FILE* stream); */
|
||||
extern int __freading(FILE* stream);
|
||||
/* extern int __fwriting(FILE* stream); */
|
||||
/* extern int __freadable(FILE* stream); */
|
||||
/* extern int __fwritable(FILE* stream); */
|
||||
/* extern int __flbf(FILE* stream); */
|
||||
/* extern void __fpurge(FILE* stream); */
|
||||
extern void __fpurge(FILE* stream);
|
||||
/* extern size_t __fpending(FILE* stream); */
|
||||
|
||||
extern void _flushlbf(void);
|
||||
|
||||
@@ -3,7 +3,9 @@ SubDir HAIKU_TOP src system libroot posix stdio ;
|
||||
UsePrivateSystemHeaders ;
|
||||
|
||||
MergeObject posix_stdio.o :
|
||||
__freading.cpp
|
||||
_fseek.c
|
||||
fpurge.cpp
|
||||
remove.c
|
||||
rename.c
|
||||
# The other files are superseded by the glibc libio/stdio stuff
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2008, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <libio.h>
|
||||
#include <stdio_ext.h>
|
||||
|
||||
|
||||
int
|
||||
__freading(FILE* stream)
|
||||
{
|
||||
// Return true, if writing is not allowed or the last operation was a read.
|
||||
return (stream->_flags & _IO_NO_WRITES) != 0
|
||||
|| ((stream->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
|
||||
&& stream->_IO_read_base != NULL);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2008, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <libio.h>
|
||||
#include <stdio_ext.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int
|
||||
fpurge(FILE* stream)
|
||||
{
|
||||
// purge read and write buffers
|
||||
stream->_IO_read_end = stream->_IO_read_ptr;
|
||||
stream->_IO_write_ptr = stream->_IO_write_base;
|
||||
|
||||
// free ungetc buffer
|
||||
if (stream->_IO_save_base != NULL) {
|
||||
free(stream->_IO_save_base);
|
||||
stream->_IO_save_base = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__fpurge(FILE* stream)
|
||||
{
|
||||
fpurge(stream);
|
||||
}
|
||||
Reference in New Issue
Block a user