1 #ifndef SENDFILE_UTIL_H
2 #define SENDFILE_UTIL_H
3 
4 /* Wrapper for various sendfile()-like calls. Read a maximum of count bytes
5    from the given offset in in_fd and write them to out_fd. The offset is
6    updated after the call. Note the call assert-crashes if count is 0.
7 
8    Returns:
9    >0 number of bytes successfully written (maybe less than count)
10    0 if offset points to the input's EOF or past it
11    -1, errno=EINVAL if it isn't supported for some reason (out_fd isn't a
12        socket or there simply is no sendfile()).
13    -1, errno=EAGAIN if non-blocking write couldn't send anything */
14 ssize_t safe_sendfile(int out_fd, int in_fd, uoff_t *offset, size_t count);
15 
16 #endif
17