1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-print-message.h Utility function to print out a message
4 * Copyright (C) 2003 Philip Blundell <philb@gnu.org>
5 * Copyright (C) 2003 Red Hat, Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "dbus-print-message.h"
25 print_message (DBusMessage *message)
30 sender = dbus_message_get_sender (message);
32 printf ("message name=%s; sender=%s\n",
33 dbus_message_get_name (message),
34 sender ? sender : "(no sender)");
36 dbus_message_iter_init (message, &iter);
40 int type = dbus_message_iter_get_arg_type (&iter);
47 if (type == DBUS_TYPE_INVALID)
52 case DBUS_TYPE_STRING:
53 str = dbus_message_iter_get_string (&iter);
54 printf ("string:%s\n", str);
58 int32 = dbus_message_iter_get_int32 (&iter);
59 printf ("int32:%d\n", int32);
62 case DBUS_TYPE_UINT32:
63 uint32 = dbus_message_iter_get_uint32 (&iter);
64 printf ("int32:%u\n", uint32);
67 case DBUS_TYPE_DOUBLE:
68 d = dbus_message_iter_get_double (&iter);
69 printf ("double:%f\n", d);
73 byte = dbus_message_iter_get_byte (&iter);
74 printf ("byte:%d\n", byte);
78 printf ("(unknown arg type %d)\n", type);
81 } while (dbus_message_iter_next (&iter));