3 int read_in_full(int fd
, void *buf
, size_t count
)
10 loaded
= xread(fd
, p
, count
);
25 void read_or_die(int fd
, void *buf
, size_t count
)
31 loaded
= read_in_full(fd
, buf
, count
);
33 die("unexpected end of file");
35 die("read error (%s)", strerror(errno
));
38 int write_in_full(int fd
, const void *buf
, size_t count
)
44 size_t written
= xwrite(fd
, p
, count
);
59 void write_or_die(int fd
, const void *buf
, size_t count
)
61 if (write_in_full(fd
, buf
, count
) < 0) {
64 die("write error (%s)", strerror(errno
));
68 int write_or_whine_pipe(int fd
, const void *buf
, size_t count
, const char *msg
)
70 if (write_in_full(fd
, buf
, count
) < 0) {
73 fprintf(stderr
, "%s: write error (%s)\n",
74 msg
, strerror(errno
));
81 int write_or_whine(int fd
, const void *buf
, size_t count
, const char *msg
)
83 if (write_in_full(fd
, buf
, count
) < 0) {
84 fprintf(stderr
, "%s: write error (%s)\n",
85 msg
, strerror(errno
));