aboutsummaryrefslogtreecommitdiff
path: root/src/npassd/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/npassd/util.c')
-rw-r--r--src/npassd/util.c15
1 files changed, 15 insertions, 0 deletions
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 <ctype.h>
+#include <errno.h>
+#include <sys/types.h>
+
+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;
+}