libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit 9f9b5e0657a0901f086f15841ce6396f1e91f57f
parent cef5e48c072967a37b1ec685d7176edcc2a374c4
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon,  6 Mar 2017 19:34:30 +0100

Fix(Comment style): config.{c,h}

Diffstat:
Minc/config.h | 21++++++++++++++++++++-
Msrc/config.c | 32+++++++++-----------------------
2 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/inc/config.h b/inc/config.h @@ -87,9 +87,28 @@ typedef struct config_s { char *err; } config_t; +/*! + * \brief Initialize a new config_t structure and read a config file + * \param path Path of the config file. If null, the default PATH is used + * \param ret Return code of the parse function + * + * This function will open a file, read a configuration in it. + * If anything is wrong, the ret variable will be set to the proper error value. + * + * \return A freshly allocated structure + */ config_t *parse_config(const char *path, u8_t *ret); + +/*! + * \brief Free a config_t pointer + * \param ptr Pointer to free + */ void config_free(config_t **ptr); -void config_error_cb(cfg_t *ptr, const char *fmt, va_list ap); + +/*! + * \brief Get the parsing error string + * \paran[in] ptr Config context + */ void config_get_error_string(config_t *ptr); #endif /* CONFIG_H */ diff --git a/src/config.c b/src/config.c @@ -18,16 +18,15 @@ static char g_error[ERROR_MAX_LEN] = ""; -/*! - * \brief Initialize a new config_t structure and read a config file - * \param path Path of the config file. If null, the default PATH is used - * \param ret Return code of the parse function - * - * This function will open a file, read a configuration in it. - * If anything is wrong, the ret variable will be set to the proper error value. - * - * \return A freshly allocated structure - */ +static void config_error_cb(cfg_t *ptr, const char *fmt, va_list ap) { + char err[250]; + + (void)ptr; + vsnprintf(err, 250, fmt, ap); + if (strlen(err) < 250) + strcpy(g_error, err); +} + config_t *parse_config(const char *path, u8_t *ret) { config_t *config = NULL; @@ -111,10 +110,6 @@ config_t *parse_config(const char *path, u8_t *ret) { return config; } -/*! - * \brief Free a config_t pointer - * \param ptr Pointer to free - */ void config_free(config_t **ptr) { if (ptr != NULL && *ptr != NULL) { @@ -126,15 +121,6 @@ void config_free(config_t **ptr) { } } -void config_error_cb(cfg_t *ptr, const char *fmt, va_list ap) { - char err[250]; - - (void)ptr; - vsnprintf(err, 250, fmt, ap); - if (strlen(err) < 250) - strcpy(g_error, err); -} - void config_get_error_string(config_t *ptr) { if (strlen(g_error) == 0) return ;