libusbgx: Add functions to get import error text and line
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Mon, 7 Jul 2014 17:26:24 +0000 (19:26 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 22 Dec 2015 19:45:02 +0000 (20:45 +0100)
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
include/usbg/usbg.h
src/usbg.c

index 1a33554..89749e3 100644 (file)
@@ -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);
+
 /**
  * @}
  */
index 756af98..2cc372d 100644 (file)
@@ -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);
+}
+