Input/Output Helpers

ssize_t writeallfd(int fd, const void *buf, size_t count)

Write exactly count bytes to file descriptor

Parameters

int fd

file descriptor

const void *buf

buffer to write

size_t count

number of bytes to write

Description

Write exactly count bytes or error out if not possible.

Return

count on success, otherwise, -1 and set errno.

ssize_t writeall(const char *path, const void *buf, size_t count)

Write exactly count bytes to file

Parameters

const char *path

name of file to write to

const void *buf

buffer to write

size_t count

number of bytes to write

Description

Write exactly count bytes or error out if not possible.

Return

count on success, otherwise -1 and set errno.

ssize_t readmaxfd(int fd, void *buf, size_t count)

Read up to count number of bytes

Parameters

int fd

file descriptor

void *buf

buffer to read into

size_t count

number of bytes to read

Description

Read up to count number of bytes.

Return

number of bytes read or -1 and set errno.

ssize_t readmax(const char *path, void *buf, size_t count)

Read up to count number of bytes

Parameters

const char *path

name of file to read from

void *buf

buffer to read into

size_t count

number of bytes to read

Description

Read up to count number of bytes.

Return

number of bytes read or -1 and set errno.