aboutsummaryrefslogtreecommitdiff
path: root/src/npassd/util.c
blob: 9b1fdac9299fff15ed46bbd760273b6370e5ed35 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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;
}