Files
libucore/include/ucore/read_file.h
T
2013-10-13 17:37:28 +02:00

29 lines
754 B
C

#ifndef UC_READ_FILE_H_
#define UC_READ_FILE_H_y
#include <stddef.h>
#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);
#ifdef __cplusplus
}
#endif
#endif