File: buffer_stubborn.c

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (16 lines) | stat: -rw-r--r-- 366 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <errno.h>
#include "buffer.h"

ssize_t buffer_stubborn(ssize_t (*op)(int fd,const char* buf,size_t len,void* cookie),int fd,const char* buf, size_t len,void* cookie) {
  ssize_t w;
  errno=0;
  while (len) {
    if ((w=op(fd,buf,len,cookie))<=0) {
      if (errno == EINTR) continue;
      return -1;
    }
    buf+=w;
    len-=(size_t)w;
  }
  return 0;
}