From da21dd57634aebffe0f5833b598e1128fafc0def Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 27 Apr 2024 12:31:12 +0530 Subject: npassd/collection: init --- src/npassd/util.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/npassd/util.c (limited to 'src/npassd/util.c') diff --git a/src/npassd/util.c b/src/npassd/util.c new file mode 100644 index 0000000..9b1fdac --- /dev/null +++ b/src/npassd/util.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int dbus_objpath_alnumify(char *path) +{ + for (size_t i = 0; path[i]; i++) { + if (!isalnum(path[i]) && path[i] != '/') + path[i] = '_'; + else if (i > 0 && path[i] == '/' && path[i - 1] == '/') + return -EINVAL; + } + + return 0; +} -- cgit v1.2.3