File: const_io.c

package info (click to toggle)
ngetty 1.1-3.1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 392 kB
  • sloc: ansic: 1,588; makefile: 206; sh: 193; asm: 100
file content (16 lines) | stat: -rw-r--r-- 311 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <unistd.h>
#include <errno.h>

int const_io(int (*op)(), int fd, void *buf, int len) /*EXTRACT_INCL*/{
  char *x = buf;
  while (len > 0) {
    int ret = op(fd, x, len);
    if (ret <= 0) {
      if (ret && errno == EINTR) continue;
      break;
    }
    x += ret;
    len -= ret;
  }
  return len;
}