[Galago-commits] r2639 - in trunk/galago-daemon: . src
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Wed Mar 29 22:14:36 PST 2006
Author: chipx86
Date: 2006-03-29 22:14:28 -0800 (Wed, 29 Mar 2006)
New Revision: 2639
Modified:
trunk/galago-daemon/ChangeLog
trunk/galago-daemon/src/account.c
trunk/galago-daemon/src/person.c
trunk/galago-daemon/src/service.c
trunk/galago-daemon/src/utils.c
trunk/galago-daemon/src/utils.h
Log:
Move galago_dbus_normalize_name() from libgalago to here, and rename to galagod_dbus_normalize_name().
Modified: trunk/galago-daemon/ChangeLog
===================================================================
--- trunk/galago-daemon/ChangeLog 2006-03-29 10:04:01 UTC (rev 2638)
+++ trunk/galago-daemon/ChangeLog 2006-03-30 06:14:28 UTC (rev 2639)
@@ -1,3 +1,13 @@
+Wed Mar 29 22:13:53 PST 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/account.c:
+ * src/person.c:
+ * src/service.c:
+ * src/utils.c:
+ * src/utils.h:
+ - Move galago_dbus_normalize_name() from libgalago to here, and
+ rename to galagod_dbus_normalize_name().
+
Mon Mar 13 23:23:11 PST 2006 Christian Hammond <chipx86 at chipx86.com>
* tests/Makefile.am:
Modified: trunk/galago-daemon/src/account.c
===================================================================
--- trunk/galago-daemon/src/account.c 2006-03-29 10:04:01 UTC (rev 2638)
+++ trunk/galago-daemon/src/account.c 2006-03-30 06:14:28 UTC (rev 2639)
@@ -585,7 +585,7 @@
return g_strdup_printf("%s/%s",
galago_object_get_dbus_path(
GALAGO_OBJECT(galago_account_get_service(account))),
- galago_dbus_normalize_name(galago_account_get_username(account)));
+ galagod_dbus_normalize_name(galago_account_get_username(account)));
}
void
Modified: trunk/galago-daemon/src/person.c
===================================================================
--- trunk/galago-daemon/src/person.c 2006-03-29 10:04:01 UTC (rev 2638)
+++ trunk/galago-daemon/src/person.c 2006-03-30 06:14:28 UTC (rev 2639)
@@ -329,7 +329,7 @@
(coco == NULL
? galago_context_get_obj_path_prefix()
: galago_object_get_dbus_path(GALAGO_OBJECT(coco))),
- galago_dbus_normalize_name(galagod_get_uid()));
+ galagod_dbus_normalize_name(galagod_get_uid()));
}
void
Modified: trunk/galago-daemon/src/service.c
===================================================================
--- trunk/galago-daemon/src/service.c 2006-03-29 10:04:01 UTC (rev 2638)
+++ trunk/galago-daemon/src/service.c 2006-03-30 06:14:28 UTC (rev 2639)
@@ -214,7 +214,7 @@
(coco == NULL
? galago_context_get_obj_path_prefix()
: galago_object_get_dbus_path(GALAGO_OBJECT(coco))),
- galago_dbus_normalize_name(galago_service_get_id(service)));
+ galagod_dbus_normalize_name(galago_service_get_id(service)));
}
void
Modified: trunk/galago-daemon/src/utils.c
===================================================================
--- trunk/galago-daemon/src/utils.c 2006-03-29 10:04:01 UTC (rev 2638)
+++ trunk/galago-daemon/src/utils.c 2006-03-30 06:14:28 UTC (rev 2639)
@@ -43,6 +43,41 @@
dbus_message_unref(reply);
}
+#define IS_VALID_DBUS_NAME_CHAR(c) \
+ (((c) >= '0' && (c) <= '9') || \
+ ((c) >= 'A' && (c) <= 'Z') || \
+ ((c) >= 'a' && (c) <= 'z'))
+
+const char *
+galagod_dbus_normalize_name(const char *name)
+{
+ static char buffer[BUFSIZ];
+ const char *c;
+ char *d;
+
+ g_return_val_if_fail(name != NULL, NULL);
+
+ for (c = name, d = buffer; *c != '\0'; c++)
+ {
+ if (!IS_VALID_DBUS_NAME_CHAR(*c))
+ {
+ char escaped_c[9];
+ g_snprintf(escaped_c, sizeof(escaped_c), "_0x%x_", *c);
+
+ strncpy(d, escaped_c, BUFSIZ - (d - buffer));
+ d += strlen(escaped_c);
+ }
+ else
+ {
+ *d++ = *c;
+ }
+ }
+
+ *d = '\0';
+
+ return buffer;
+}
+
DBusMessage *
galagod_object_not_found_error_new(DBusMessage *message,
const char *str, ...)
Modified: trunk/galago-daemon/src/utils.h
===================================================================
--- trunk/galago-daemon/src/utils.h 2006-03-29 10:04:01 UTC (rev 2638)
+++ trunk/galago-daemon/src/utils.h 2006-03-30 06:14:28 UTC (rev 2639)
@@ -28,6 +28,17 @@
void galagod_dbus_send_empty_reply(DBusConnection *dbus_conn,
DBusMessage *message);
+/**
+ * Normalizes the passed name for purposes of using it in D-BUS paths
+ * and commands.
+ *
+ * @param name The name to normalize.
+ *
+ * @return A pointer to a static buffer containing the normalized name.
+ */
+const char *galagod_dbus_normalize_name(const char *name);
+
+
DBusMessage *galagod_object_not_found_error_new(DBusMessage *message,
const char *str, ...);
More information about the galago-commits
mailing list