[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH v2 2/3] libc: lio_compat_eof()



* libc: Den von FILE unabhängigen Teil von feof() in eine eigene
  Funktion lio_compat_eof() herausgesplittet

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/include/lostio.h         |    3 +++
 src/modules/lib/lostio/client/file.c |    7 +++++++
 src/modules/lib/stdlibc/file.c       |    8 ++------
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/modules/include/lostio.h b/src/modules/include/lostio.h
index e5b90f2..f67e7ab 100644
--- a/src/modules/include/lostio.h
+++ b/src/modules/include/lostio.h
@@ -203,6 +203,9 @@ size_t lio_compat_read(void* dest, size_t blocksize, size_t blockcount,
 size_t lio_compat_write(const void* src, size_t blocksize, size_t blockcount,
     io_resource_t* io_res);
 
+/// Prueft, ob das Ende des Streams erreicht ist
+int lio_compat_eof(io_resource_t* io_res);
+
 /// Stream-Position setzen
 bool lio_seek(io_resource_t* io_res, uint64_t offset, int origin);
 
diff --git a/src/modules/lib/lostio/client/file.c b/src/modules/lib/lostio/client/file.c
index 6140f6a..3b789b4 100644
--- a/src/modules/lib/lostio/client/file.c
+++ b/src/modules/lib/lostio/client/file.c
@@ -187,4 +187,11 @@ size_t lio_compat_write(const void* src, size_t blocksize, size_t blockcount,
     return resp;
 }
 
+int lio_compat_eof(io_resource_t* io_res)
+{
+    io_eof_request_t eof_request;
+    eof_request.id = io_res->id;
 
+    return rpc_get_dword(io_res->pid, "IO_EOF  ", sizeof(io_eof_request_t),
+        (char*) &eof_request);
+}
diff --git a/src/modules/lib/stdlibc/file.c b/src/modules/lib/stdlibc/file.c
index 1a99417..8a50f0f 100644
--- a/src/modules/lib/stdlibc/file.c
+++ b/src/modules/lib/stdlibc/file.c
@@ -544,15 +544,11 @@ int feof(FILE* io_res)
     if (io_res->ungetc_count != 0) {
         return 0;
     }
-    
-    io_eof_request_t eof_request;
-    eof_request.id = io_res->res->id;
-    
+
     //Auch hier könnte mit Daten im Buffer ein falsches Ergebnis rauskommen
     fflush(io_res);
 
-    return rpc_get_dword(io_res->res->pid, "IO_EOF  ", sizeof(io_eof_request_t),
-        (char*) &eof_request);
+    return lio_compat_eof(io_res->res);
 }
 
 
-- 
1.6.0.2