diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-04-27 12:31:12 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-04-28 15:43:50 +0530 |
commit | da21dd57634aebffe0f5833b598e1128fafc0def (patch) | |
tree | 71d8e510eb788e0df695052325a1fe4fec6bf5a7 /src/npassd/util.c | |
parent | 06e3f1885fc112093f867cd5d7a8b163ef28650c (diff) |
npassd/collection: init
Diffstat (limited to 'src/npassd/util.c')
-rw-r--r-- | src/npassd/util.c | 15 |
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; +} |