]> pd.if.org Git - pdclib/blobdiff - functions/stdio/_PDCLIB_fillbuffer.c
PDCLIB-8: First phase of intergation of new I/O backend system (with minimal
[pdclib] / functions / stdio / _PDCLIB_fillbuffer.c
similarity index 62%
rename from platform/win32/functions/_PDCLIB/_PDCLIB_fillbuffer.c
rename to functions/stdio/_PDCLIB_fillbuffer.c
index c6a2b6b520f436a6f5a1433d1f5483e3eec1ebeb..dfdfe262510d858043e23bfb3a30505271bbb2f0 100644 (file)
@@ -1,54 +1,45 @@
-/* $Id$ */
-
-/* _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )
-
-   This file is part of the Public Domain C Library (PDCLib).
-   Permission is granted to use, modify, and / or redistribute at will.
-*/
-
-/* This is a stub version of _PDCLIB_fillbuffer
-*/
-
-#include <stdio.h>
-
-#ifndef REGTEST
-#include <_PDCLIB_glue.h>
-#include <errno.h>
-#include <windows.h>
-
-void _PDCLIB_w32errno(void);
-int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )
-{
-    DWORD nBytesRead;
-    BOOL ok = ReadFile( stream->handle, stream->buffer, stream->bufsize,
-                        &nBytesRead, NULL );
-
-    if( ok ) {
-        if( nBytesRead == 0 ) {
-            stream->status |= _PDCLIB_EOFFLAG;
-            return EOF;
-        }
-        stream->pos.offset += nBytesRead;
-        stream->bufend = nBytesRead;
-        stream->bufidx = 0;
-        return 0;
-    } else {
-        _PDCLIB_w32errno();
-        stream->status |= _PDCLIB_ERRORFLAG;
-        return EOF;
-    }
-}
-
-#endif
-
-#ifdef TEST
-#include <_PDCLIB_test.h>
-
-int main( void )
-{
-    /* Testing covered by ftell.c */
-    return TEST_RESULTS;
-}
-
-#endif
-
+/* _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )\r
+\r
+   This file is part of the Public Domain C Library (PDCLib).\r
+   Permission is granted to use, modify, and / or redistribute at will.\r
+*/\r
+\r
+#include <stdio.h>\r
+\r
+#ifndef REGTEST\r
+#include <_PDCLIB_glue.h>\r
+\r
+int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )\r
+{\r
+    size_t bytesRead;\r
+    bool ok = stream->ops->read( stream->handle, stream->buffer, stream->bufsize,\r
+                        &bytesRead);\r
+\r
+    if( ok ) {\r
+        if( bytesRead == 0 ) {\r
+            stream->status |= _PDCLIB_EOFFLAG;\r
+            return EOF;\r
+        }\r
+        stream->pos.offset += bytesRead;\r
+        stream->bufend = bytesRead;\r
+        stream->bufidx = 0;\r
+        return 0;\r
+    } else {\r
+        stream->status |= _PDCLIB_ERRORFLAG;\r
+        return EOF;\r
+    }\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    /* Testing covered by ftell.c */\r
+    return TEST_RESULTS;\r
+}\r
+\r
+#endif\r
+\r