chiark / gitweb /
[PATCH] klibc: version 1.0.3
[elogind.git] / klibc / klibc / fwrite.c
1 /*
2  * fwrite.c
3  */
4
5 #include <errno.h>
6 #include <unistd.h>
7 #include <stdio.h>
8
9 size_t _fwrite(const void *buf, size_t count, FILE *f)
10 {
11   size_t bytes = 0;
12   ssize_t rv;
13   const char *p = buf;
14
15   while ( count ) {
16     rv = write(fileno(f), p, count);
17     if ( rv == -1 ) {
18       if ( errno == EINTR ) {
19         errno = 0;
20         continue; 
21       } else
22         break;
23     } else if ( rv == 0 ) {
24       break;
25     }
26
27     p += rv;
28     bytes += rv;
29     count -= rv;
30   }
31
32   return bytes;
33 }
34
35     
36