#ifndef UC_READ_FILE_H_ #define UC_READ_FILE_H_ #include #ifdef __cplusplus extern "C" { #endif /** Read the content of a file. * The returned char* is malloced memory and must be freed by the caller. * The content is terminated by a nul byte, regardless of whether the content * is binary or text. The returned length does not include this nul byte. * * @param file_name name of the file * @param length Returned length of the content read * @param max Fail if the read content length is greater than max. * @return The content read from the file, or NULL if something failed * (inspect errno to see why it failed) */ char * uc_read_file(const char *file_name, size_t *length, size_t max); /** Read the content of a file descriptor as a stream. * @see uc_read_file * This is similar but reads from a file descriptor, * of any type as long as it supports the read() call. * * uc_read_fd close() the fd in all cases before it returns */ char * uc_read_fd(int fd, size_t *length, size_t max); #ifdef __cplusplus } #endif #endif