summaryrefslogtreecommitdiff
path: root/com32/lib/fwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/lib/fwrite.c')
-rw-r--r--com32/lib/fwrite.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/com32/lib/fwrite.c b/com32/lib/fwrite.c
new file mode 100644
index 00000000..0a73188c
--- /dev/null
+++ b/com32/lib/fwrite.c
@@ -0,0 +1,35 @@
+/*
+ * fwrite.c
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+
+size_t _fwrite(const void *buf, size_t count, FILE *f)
+{
+ size_t bytes = 0;
+ ssize_t rv;
+ const char *p = buf;
+
+ while ( count ) {
+ rv = write(fileno(f), p, count);
+ if ( rv == -1 ) {
+ if ( errno == EINTR )
+ continue;
+ else
+ break;
+ } else if ( rv == 0 ) {
+ break;
+ }
+
+ p += rv;
+ bytes += rv;
+ count -= rv;
+ }
+
+ return bytes;
+}
+
+
+