Finita la conversione dei listati in file separati. Passato anche alla nuova
[gapil.git] / listati / FullRead.c
1 #include <unistd.h>
2
3 ssize_t FullRead(int fd, void *buf, size_t count) 
4 {
5     size_t nleft;
6     ssize_t nread;
7  
8     nleft = count;
9     while (nleft > 0) {             /* repeat until no left */
10         if ( (nread = read(fd, buf, nleft)) < 0) {
11             if (errno == EINTR) {   /* if interrupted by system call */
12                 continue;           /* repeat the loop */
13             } else {
14                 return(nread);      /* otherwise exit */
15             }
16         } else if (nread == 0) {    /* EOF */
17             break;                  /* break loop here */ 
18         }
19         nleft -= nread;             /* set left to read */
20         buf +=nread;                /* set pointer */
21     }
22     return (count - nleft);
23 }