Remove priority details from network structure
[connman] / src / dbus.c
index 6960a40..daa2239 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
 #include <config.h>
 #endif
 
-#include <connman/dbus.h>
+#include <string.h>
+
+#include "connman.h"
+
+char *connman_dbus_encode_string(const char *value)
+{
+       GString *str;
+       unsigned int i, size;
+
+       if (value == NULL)
+               return NULL;
+
+       size = strlen(value);
+
+       str = g_string_new(NULL);
+       if (str == NULL)
+               return NULL;
+
+       for (i = 0; i < size; i++) {
+               const char tmp = value[i];
+               if ((tmp < '0' || tmp > '9') && (tmp < 'A' || tmp > 'Z') &&
+                                               (tmp < 'a' || tmp > 'z'))
+                       g_string_append_printf(str, "_%02x", tmp);
+               else
+                       str = g_string_append_c(str, tmp);
+       }
+
+       return g_string_free(str, FALSE);
+}
 
 void connman_dbus_property_append_variant(DBusMessageIter *iter,
                                        const char *key, int type, void *val)