Add functions which allow to remove strings in gadget
and configuration.
Signed-off-by: Krzysztof Opasiak <[email protected]>
---
include/usbg/usbg.h | 16 ++++++++++++++++
src/usbg.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h
index aa8ebc9..6c14cbc 100644
--- a/include/usbg/usbg.h
+++ b/include/usbg/usbg.h
@@ -277,6 +277,22 @@ extern usbg_config *usbg_get_config(usbg_gadget *g, const
char *name);
*/
extern int usbg_remove_binding(usbg_binding *b);
+/**
+ * @brief Remove configuration strings for given language
+ * @param c Pointer to configuration
+ * @param lang Language of strings which should be deleted
+ * @return 0 on success, usbg_error if error occurred
+ */
+extern int usbg_remove_config_strs(usbg_config *c, int lang);
+
+/**
+ * @brief Remove gadget strings for given language
+ * @param g Pointer to gadget
+ * @param lang Language of strings which should be deleted
+ * @return 0 on success, usbg_error if error occurred
+ */
+extern int usbg_remove_gadget_strs(usbg_gadget *g, int lang);
+
/* USB gadget allocation and configuration */
/**
diff --git a/src/usbg.c b/src/usbg.c
index e82658c..8f18047 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -467,6 +467,22 @@ static int usbg_remove_file(char *path, char *name)
return ret;
}
+static int usbg_remove_dir(char *path, char *name)
+{
+ int ret;
+ char buf[USBG_MAX_PATH_LENGTH];
+
+ sprintf(buf, "%s/%s", path, name);
+
+ ret = rmdir(buf);
+ if (ret != 0)
+ ret = usbg_translate_error(errno);
+ else
+ ret = USBG_SUCCESS;
+
+ return ret;
+}
+
static int usbg_parse_function_net_attrs(usbg_function *f,
usbg_function_attrs *f_attrs)
{
@@ -993,6 +1009,37 @@ int usbg_remove_binding(usbg_binding *b)
return ret;
}
+int usbg_remove_config_strs(usbg_config *c, int lang)
+{
+ int ret = USBG_SUCCESS;
+ char path[USBG_MAX_PATH_LENGTH];
+
+ if (!c)
+ return USBG_ERROR_INVALID_PARAM;
+
+ sprintf(path, "%s/%s/%s/0x%x", c->path, c->name, STRINGS_DIR, lang);
+
+ ret = usbg_remove_dir(path, "");
+
+ return ret;
+}
+
+int usbg_remove_gadget_strs(usbg_gadget *g, int lang)
+{
+ int ret = USBG_SUCCESS;
+ char path[USBG_MAX_PATH_LENGTH];
+
+ if (!g)
+ return USBG_ERROR_INVALID_PARAM;
+
+ sprintf(path, "%s/%s/%s/0x%x", g->path, g->name, STRINGS_DIR, lang);
+
+ ret = usbg_remove_dir(path, "");
+
+ return ret;
+}
+
+
static int usbg_create_empty_gadget(usbg_state *s, char *name, usbg_gadget **g)
{
char gpath[USBG_MAX_PATH_LENGTH];
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html