+#define DEFAULT_SIZE 100
+
+static void
+print_ay (DBusMessageIter *iter, int depth)
+{
+ /* Not using DBusString because it's not public API. It's 2009, and I'm
+ * manually growing a string chunk by chunk.
+ */
+ unsigned char *bytes = malloc (DEFAULT_SIZE + 1);
+ unsigned int len = 0;
+ unsigned int max = DEFAULT_SIZE;
+ dbus_bool_t all_ascii = TRUE;
+ int current_type;
+
+ while ((current_type = dbus_message_iter_get_arg_type (iter))
+ != DBUS_TYPE_INVALID)
+ {
+ unsigned char val;
+
+ dbus_message_iter_get_basic (iter, &val);
+ bytes[len] = val;
+ len++;
+
+ if (val < 32 || val > 126)
+ all_ascii = FALSE;
+
+ if (len == max)
+ {
+ max *= 2;
+ bytes = realloc (bytes, max + 1);
+ }
+
+ dbus_message_iter_next (iter);
+ }
+
+ if (all_ascii)
+ {
+ bytes[len] = '\0';
+ printf ("array of bytes \"%s\"\n", bytes);
+ }
+ else
+ {
+ print_hex (bytes, len, depth);
+ }
+
+ free (bytes);
+}
+