Mercurial > trustbridge
changeset 769:44257ecdae6d
Make Read File public
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 10 Jul 2014 19:11:09 +0200 |
parents | 3f290ea49d45 |
children | 7861950f7637 |
files | common/listutil.c common/listutil.h |
diffstat | 2 files changed, 16 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/common/listutil.c Thu Jul 10 19:10:23 2014 +0200 +++ b/common/listutil.c Thu Jul 10 19:11:09 2014 +0200 @@ -34,24 +34,13 @@ #define MAX_FILESIZE (MAX_LINE_LENGTH * MAX_LINES) -/** - * @brief Read a file into memory. - * - * The caller needs to free data - * - * @param[in] fileName Name of the file. - * @param[out] data the file content - * @param[out] size size in bytes of the file content. - * @param[in] max_size the maximum amount of bytes to read. - * - * @return 0 on success an error code otherwise. - */ #define READ_FILE_UNREADABLE -1 #define READ_FILE_TOO_LARGE -2 #define READ_FILE_NO_MEMORY -3 #define READ_FILE_READ_FAILED -4 #define READ_FILE_INVALID_CALL -5 -static int read_file(const char *file_name, char **data, size_t *size, +int +read_file(const char *file_name, char **data, size_t *size, const size_t max_size) { FILE *f;
--- a/common/listutil.h Thu Jul 10 19:10:23 2014 +0200 +++ b/common/listutil.h Thu Jul 10 19:11:09 2014 +0200 @@ -81,6 +81,20 @@ * */ char **get_certs_from_list (char *data, const size_t size); +/** + * @brief Read a file into memory. + * + * The caller needs to free data + * + * @param[in] fileName Name of the file. + * @param[out] data the file content + * @param[out] size size in bytes of the file content. + * @param[in] max_size the maximum amount of bytes to read. + * + * @return 0 on success an error code otherwise. + */ +int read_file(const char *file_name, char **data, size_t *size, + const size_t max_size); #ifdef __cplusplus } #endif