From: Krzysztof Opasiak Date: Mon, 7 Jul 2014 17:26:24 +0000 (+0200) Subject: libusbgx: Add functions to get import error text and line X-Git-Tag: libusbgx-v0.1.0~168 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8cadbec5ceaddcbc2a80878c9e2548ed806d02c7;p=platform%2Fupstream%2Flibusbg.git libusbgx: Add functions to get import error text and line Signed-off-by: Krzysztof Opasiak [Port from libusbg and update description] Signed-off-by: Krzysztof Opasiak --- diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index 1a33554..89749e3 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -962,6 +962,49 @@ extern int usbg_import_config(usbg_gadget *g, FILE *stream, int id, */ extern int usbg_import_gadget(usbg_state *s, FILE *stream, const char *name, usbg_gadget **g); + +/** + * @brief Get text of error which occurred during last function import + * @param g gadget where function import error occurred + * @return Text of error or NULL if no error data + */ +extern const char *usbg_get_func_import_error_text(usbg_gadget *g); + +/** + * @brief Get line number where function import error occurred + * @param g gadget where function import error occurred + * @return line number or value below 0 if no error data + */ +extern int usbg_get_func_import_error_line(usbg_gadget *g); + +/** + * @brief Get text of error which occurred during last config import + * @param g gadget where config import error occurred + * @return Text of error or NULL if no error data + */ +extern const char *usbg_get_config_import_error_text(usbg_gadget *g); + +/** + * @brief Get line number where config import error occurred + * @param g gadget where config import error occurred + * @return line number or value below 0 if no error data + */ +extern int usbg_get_config_import_error_line(usbg_gadget *g); + +/** + * @brief Get text of error which occurred during last gadget import + * @param s where gadget import error occurred + * @return Text of error or NULL if no error data + */ +extern const char *usbg_get_gadget_import_error_text(usbg_state *s); + +/** + * @brief Get line number where gadget import error occurred + * @param s where gadget import error occurred + * @return line number or value below 0 if no error data + */ +extern int usbg_get_gadget_import_error_line(usbg_state *s); + /** * @} */ diff --git a/src/usbg.c b/src/usbg.c index 756af98..2cc372d 100644 --- a/src/usbg.c +++ b/src/usbg.c @@ -4205,3 +4205,51 @@ out: return ret; } +const char *usbg_get_func_import_error_text(usbg_gadget *g) +{ + if (!g || !g->last_failed_import) + return NULL; + + return config_error_text(g->last_failed_import); +} + +const char *usbg_get_func_import_error_line(usbg_gadget *g) +{ + if (!g || !g->last_failed_import) + return -1; + + return config_error_line(g->last_failed_import); +} + +const char *usbg_get_config_import_error_text(usbg_gadget *g) +{ + if (!g || !g->last_failed_import) + return NULL; + + return config_error_text(g->last_failed_import); +} + +const char *usbg_get_config_import_error_line(usbg_gadget *g) +{ + if (!g || !g->last_failed_import) + return -1; + + return config_error_line(g->last_failed_import); +} + +const char *usbg_get_gadget_import_error_text(usbg_state *s) +{ + if (!s || !s->last_failed_import) + return NULL; + + return config_error_text(s->last_failed_import); +} + +const char *usbg_get_gadget_import_error_line(usbg_state *s) +{ + if (!s || !s->last_failed_import) + return -1; + + return config_error_line(s->last_failed_import); +} +