/
githubmirror
/
fstrm
Обзор
Документация
Войти
/
githubmirror
/
fstrm
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
libmy/read_bytes.h
26 строк
500 B
Robert Edmonds
Merge branch 'master' of ../libmy
25 апр 2014, 19:49
25 апр 2014, 19:49
aed23ef
Код
Авторство
О чём код?
#ifndef MY_READ_BYTES_H #define MY_READ_BYTES_H #include <errno.h> #include <stdbool.h> #include <stdint.h> #include <unistd.h> static inline bool read_bytes(int fd, uint8_t *buf, size_t bytes_needed) { while (bytes_needed > 0) { ssize_t bytes_read; bytes_read = read(fd, buf, bytes_needed); if (bytes_read == -1 && errno == EINTR) continue; else if (bytes_read <= 0) return false; bytes_needed -= bytes_read; buf += bytes_read; } return true; } #endif /* MY_READ_BYTES_H */