summaryrefslogtreecommitdiff
path: root/include/usbg
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2014-03-07 11:44:42 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2014-03-10 09:15:13 +0100
commit4071efa817e055c38fedd6605ecf502af19b4cf7 (patch)
treec0379b3090360363444d8006e1c616be5fc07568 /include/usbg
parent22838e8385eb6509010ce4f6b1c0a05557e6306b (diff)
downloadlibusbg-4071efa817e055c38fedd6605ecf502af19b4cf7.tar.gz
libusbg-4071efa817e055c38fedd6605ecf502af19b4cf7.tar.bz2
libusbg-4071efa817e055c38fedd6605ecf502af19b4cf7.zip
libusbg: Add error handling to usbg_init() and related functions.
Assumption that all malloc() and read()/write() finish correctly is too bold. Errors should be handled and propagated to upper layers of library and returned to user. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'include/usbg')
-rw-r--r--include/usbg/usbg.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h
index 562fdc5..ffef084 100644
--- a/include/usbg/usbg.h
+++ b/include/usbg/usbg.h
@@ -175,14 +175,29 @@ typedef union {
usbg_f_phonet_attrs phonet;
} usbg_function_attrs;
+/**
+ * @typedef usbg_error
+ * @brief Errors which could be returned by library functions
+ */
+typedef enum {
+ USBG_SUCCESS = 0,
+ USBG_ERROR_NO_MEM = -1,
+ USBG_ERROR_NO_ACCESS = -2,
+ USBG_ERROR_INVALID_PARAM = -3,
+ USBG_ERROR_NOT_FOUND = -4,
+ USBG_ERROR_IO = -5,
+ USBG_ERROR_OTHER_ERROR = -99
+} usbg_error;
+
/* Library init and cleanup */
/**
* @brief Initialize the libusbg library state
* @param configfs_path Path to the mounted configfs filesystem
- * @return Pointer to a state structure
+ * @param Pointer to be filled with pointer to usbg_state
+ * @return 0 on success, usbg_error on error
*/
-extern usbg_state *usbg_init(char *configfs_path);
+extern int usbg_init(char *configfs_path, usbg_state **state);
/**
* @brief Clean up the libusbg library state