Add usbg_get_configfs_path_len() and usbg_get_configfs_path() to avoid direct access to state structure. Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx> --- include/usbg/usbg.h | 16 ++++++++++++++++ src/usbg.c | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index 2577382..e90a3b6 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -233,6 +233,22 @@ extern struct state *usbg_init(char *configfs_path); */ extern void usbg_cleanup(struct state *s); +/** + * @brief Get ConfigFS path length + * @param s Pointer to state + * @return Length of path or -1 if error occurred. + */ +extern size_t usbg_get_configfs_path_len(struct state *s); + +/** + * @brieg Get ConfigFS path + * @param s Pointer to state + * @param buf Buffer where path should be copied + * @param len Length of given buffer + * @return Pointer to destination or NULL if error occurred. + */ +extern char *usbg_get_configfs_path(struct state *s, char *buf, size_t len); + /* USB gadget queries */ /** diff --git a/src/usbg.c b/src/usbg.c index 6e27358..6b48d68 100644 --- a/src/usbg.c +++ b/src/usbg.c @@ -470,6 +470,16 @@ void usbg_cleanup(struct state *s) free(s); } +size_t usbg_get_configfs_path_len(struct state *s) +{ + return s ? strlen(s->path) : -1; +} + +char *usbg_get_configfs_path(struct state *s, char *buf, size_t len) +{ + return s ? strncpy(buf, s->path, len) : NULL; +} + struct gadget *usbg_get_gadget(struct state *s, const char *name) { struct gadget *g; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html