summaryrefslogtreecommitdiff
path: root/src/dbus.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-12-14 09:34:25 +0100
committerMarcel Holtmann <marcel@holtmann.org>2009-12-14 09:34:25 +0100
commit627d936df1945e8476a37dc82f460e245469a335 (patch)
treedeb21608f23d2a751cbe852e929d1a7a56d0de2b /src/dbus.c
parentc3a422ac4842e0c1309f2f2437cae387b9b30c61 (diff)
downloadconnman-627d936df1945e8476a37dc82f460e245469a335.tar.gz
connman-627d936df1945e8476a37dc82f460e245469a335.tar.bz2
connman-627d936df1945e8476a37dc82f460e245469a335.zip
Add public function to validate D-Bus identifiers
Diffstat (limited to 'src/dbus.c')
-rw-r--r--src/dbus.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/dbus.c b/src/dbus.c
index daa2239c..9cb13dd4 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -24,9 +24,30 @@
#endif
#include <string.h>
+#include <dbus/dbus.h>
#include "connman.h"
+dbus_bool_t connman_dbus_validate_ident(const char *ident)
+{
+ unsigned int i;
+
+ if (ident == NULL)
+ return FALSE;
+
+ for (i = 0; i < strlen(ident); i++) {
+ if (ident[i] >= '0' && ident[i] <= '9')
+ continue;
+ if (ident[i] >= 'a' && ident[i] <= 'z')
+ continue;
+ if (ident[i] >= 'A' && ident[i] <= 'Z')
+ continue;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
char *connman_dbus_encode_string(const char *value)
{
GString *str;