From c6ecf79fba84a09feecd7314a150f07f374f530c Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Wed, 6 Apr 2022 15:58:55 +0900 Subject: [PATCH] Add description for the declaration of the file utils Change-Id: Ia8367863a59fd3f31738fa62db1d0618c4e8ba5a Signed-off-by: SangYoun Kwak --- src/libcommon/file.h | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/libcommon/file.h b/src/libcommon/file.h index 31df8fa..7154494 100644 --- a/src/libcommon/file.h +++ b/src/libcommon/file.h @@ -20,12 +20,76 @@ #include +/** + * @brief Open file, read and close + * + * @param[in] file File name + * @param[in] len Length of buffer + * @param[out] buf Buffer that stores read data + * + * @return read length if read was successful else negative error value + */ int sys_read_buf(char *file, char *buf, int len); + +/** + * @brief Open file, write and close + * + * @param[in] file File name + * @param[out] buf Buffer that stores data to write + * + * @return zero on success otherwise negative error value + */ int sys_write_buf(char *file, char *buf); + +/** + * @brief Read integer from file + * + * @param[in] fname File name + * @param[out] val integer value that read from file + * + * @return read length if reading integer was successful else negative error value + */ int sys_get_int(char *fname, int *val); + +/** + * @brief Read string from file + * + * @param[in] fname File name + * @param[in] len String length + * @param[out] str Buffer + * + * @return zero on success otherwise negative error value + */ int sys_get_str(char *fname, char *str, int len); + +/** + * @brief Write integer to file + * + * @param[in] fname File name + * @param[in] val Integer value to write + * + * @return zero on success otherwise negative error value + */ int sys_set_int(char *fname, int val); + +/** + * @brief Write string to file + * + * @param[in] fname File name + * @param[out] val String to write + * + * @return zero on success otherwise negative error value + */ int sys_set_str(char *fname, char *val); + +/** + * @brief Parse format from /proc/cmdline + * + * @param[in] format Format string + * @param[out] ... Variable argument + * + * @return zero if cannot read else the number of matched and assigned items + */ int libsys_parse_cmdline_scanf(const char *format, ...); #endif /* __LIBCOMMON_FILE_H__ */ -- 2.34.1