summaryrefslogtreecommitdiff
path: root/tools/dbus-print-message.c
Commit message (Collapse)AuthorAgeFilesLines
* tools: Mark GPL-only files with SPDX license identifierSimon McVittie2022-11-291-0/+1
| | | | | | | | These files are licensed under the GPL only, without the AFL dual-license of most of the dbus codebase. Signed-off-by: Simon McVittie <smcv@collabora.com> Co-authored-by: Ralf Habacker <ralf.habacker@freenet.de>
* build: Define DBUS_INT64_MODIFIER, analogous to G_GINT64_MODIFIERSimon McVittie2022-04-191-11/+2
| | | | | | | | | | | | | | | | | | | Using PRId64, etc. to print dbus_int64_t or dbus_uint64_t is not 100% portable. On platforms where both long and long long are 64-bit (such as Linux and macOS), we will prefer to define dbus_int64_t as long. If the operating system has chosen to define int64_t as long long, which is apparently the case on macOS, then the compiler can warn that we are passing a long argument to PRId64, which is "lld" and therefore expects a long long argument (even though that ends up with the same bit-pattern being used). We can't necessarily just use int64_t and uint64_t directly, even if all our supported platforms have them available now, because swapping dbus_int64_t between long and long long might change C++ name mangling, causing ABI breaks in third-party libraries if they define C++ functions that take a dbus_int64_t argument. Signed-off-by: Simon McVittie <smcv@collabora.com>
* Normalize C source files to end with exactly one newlineSimon McVittie2020-06-101-1/+0
| | | | | | | | | | | | | | | | | | | Some editors automatically remove trailing blank lines, or automatically add a trailing newline to avoid having a trailing non-blank line that is not terminated by a newline. To avoid unrelated whitespace changes when users of such editors contribute to dbus, let's pre-emptively normalize all files. Unlike more intrusive whitespace normalization like removing trailing whitespace from each line, this seems unlikely to cause significant issues with cherry-picking changes to stable branches. Implemented by: find . -name '*.[ch]' -print0 | \ xargs -0 perl -0777 -p -i -e 's/\n+\z//g; s/\z/\n/g' Signed-off-by: Simon McVittie <smcv@collabora.com>
* Consistently use socklen_t for getsockname, getsockopt etc.Simon McVittie2016-02-111-2/+6
| | | | | | | | | | | | | | This fixes signedness mismatch warnings on platforms where socklen_t is unsigned, notably Linux (where it's an unsigned int). We still use int for the fallback case where the platform does not define socklen_t, because that was the traditional (pre-POSIX) type: for details see NOTES in Linux accept(2), <http://manpages.debian.org/cgi-bin/man.cgi?query=accept&sektion=2>. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93069 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
* Use C99 standard PRI*64 for printing 64 bit integersNatanael Copa2015-09-301-10/+15
| | | | | | | | | | | | | Use the standard C99 PRI*64 macros instead of checking for specific GNU libc version. We also specifically check for windows which does not have proper C99 support. This fixes printing of int64 on non-GNU 32 bit systems (like musl libc). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92043 Reviewed-by: Thiago Macieira <thiago@kde.org> Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> [smcv: fix extra % in the Windows fallbacks; include <inttypes.h> where needed]
* Fix assorted compiler warnings on Windows.Simon McVittie2015-03-241-4/+2
| | | | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444 Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> [rh: rebased because a few hunks have already been applied with commit 92c39d1d8a30110c5760bd8d5e695e26a8538d1a]
* dbus-print-message: conditionalize Unix FD handling on DBUS_UNIXSimon McVittie2015-03-051-0/+2
| | | | | | | | | We close() the fd after we have printed it, but close() isn't standard functionality on Windows. Unix FD-passing is never going to work on non-Unix platforms anyway. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89428 Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
* Trivial -Wsign-compare fixes.Ralf Habacker2015-03-041-1/+1
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=17289 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* dbus-monitor: Keep term 'dest' in --monitor output in sync with related ↵Ralf Habacker2015-02-241-2/+2
| | | | | | | | | watch expression. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> [smcv: rebase onto differently indented version of previous commit] Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
* dbus-monitor: Add timestamp to --monitor mode.Ralf Habacker2015-02-241-6/+16
| | | | | | | | | | | Use cross platform function _dbus_get_real_time() for fetching current time. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> [smcv: use %ld to avoid needing casts; reinstate printing the timestamp; libdbus-1 is sufficient now that fd.o#83115 is fixed; print timestamp for non-literal dbus-send replies too] Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
* dbus-monitor: Keep parameter list of method returns in --monitor mode in ↵Ralf Habacker2015-02-241-1/+2
| | | | | | | sync with --profile mode. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* dbus-monitor: convert remaining hard tabs to 8 space.Ralf Habacker2015-02-241-216/+216
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* dbus-send: pretty-print GVariant-style bytestringsSimon McVittie2015-02-161-29/+31
| | | | | | | | | | | | | | dbus-send could already pretty-print bytestrings that do not have \0 termination, but those are awkward to work with (they need copying), so they are now discouraged. Teach it to print bytestrings that do have \0 termination as well. In the process, rewrite this part of the message parser to use dbus_message_iter_get_fixed_array(), which is the Right way to get arrays of numbers out of a message. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89109 Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
* dbus-monitor: more details on file descriptorsAlban Crequy2014-09-151-1/+158
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Print more details when receiving a file descriptor. Before: unix fd 5 After: file descriptor inode: 1030 type: char file descriptor inode: 295664 type: socket address family: unknown (16) file descriptor inode: 295665 type: socket address family: inet name 127.0.0.1 port 47723 peer 127.0.0.1 port 22 file descriptor inode: 295666 type: socket address family: unix name @/tmp/d67s774Sws0pEra file descriptor inode: 295667 type: socket address family: unix name @ peer @ Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80603 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* dbus-monitor: do not leak file descriptors from fd-passingAlban Crequy2014-09-151-0/+7
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80603 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Support printing unix file descriptors in dbus-send/dbus-monitorRobert Ancell2013-11-271-1/+9
| | | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=70592 Reviewed-by: Chengwei Yang <chengwei.yang@intel.com> Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Fixed compiler warnings.Ralf Habacker2010-06-071-1/+1
|
* Merge branch 'dbus-1.2'Colin Walters2010-03-221-2/+11
|\ | | | | | | | | | | | | Conflicts: bus/dispatch.c configure.in test/name-test/test-names.c
| * [64 bit printf] Update to use DBUS_PID_FORMAT, print (omitted)Colin Walters2010-03-221-2/+6
| | | | | | | | | | | | | | There were already defines for formatting pids and uids, so use those. In the case where we don't have a format specifier for 64 bit, print (omitted) in dbus-monitor.
| * Add DBUS_INT64_MODIFIER define, turn on -WformatColin Walters2010-03-221-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | https://bugs.freedesktop.org/show_bug.cgi?id=19195 We were previously using -Wno-format because we didn't have a #define for DBUS_INT64_MODIFIER, which was really lame because it easily hid problems. For now, just define it if we're on glibc; this is obviously not strictly correct but it's safe, because the formatting is only used in DBUS_VERBOSE mode, and in tools/dbus-monitor. Ideally we get the the glib code relicensed.
| * Print all-printable-ASCII byte arrays as stringsWill Thompson2010-01-281-17/+58
| | | | | | | | | | | | | | In practice, ay seems to be used mostly for binary data (in which case, hex output is fine) or for Unix file paths (because they may be non-UTF-8) and similar human-readable strings. So let's print the latter similarly to strings.
| * Print byte arrays as nicely-formatted hex.Will Thompson2010-01-281-1/+58
| |
| * Make array-printing code easier to followWill Thompson2010-01-281-2/+7
| | | | | | | | | | | | | | Previously dbus_message_iter_get_arg_type() was called twice: once in the loop condition to update 'current_type', and once to check if the loop will run again. This patch moves updating current_type to the end of the loop body.
| * Bug 21161 - Update the FSF addressTobias Mueller2009-07-141-1/+1
| | | | | | | | | | | | | | No comment. Signed-off-by: Colin Walters <walters@verbum.org> (cherry picked from commit 5baf2f856a9c6625993234855b07680da1c8916f)
| * Print serial in dbus-monitorMichael Meeks2009-01-061-1/+2
| | | | | | | | | | | | * tools/dbus-print-message.c: Print serial too. Signed-off-by: Colin Walters <walters@verbum.org>
* | Consistently include <config.h> in all C source files and never in header files.Marcus Brinkmann2010-03-191-0/+2
| |
* | Print all-printable-ASCII byte arrays as stringsWill Thompson2009-11-041-17/+58
| | | | | | | | | | | | | | In practice, ay seems to be used mostly for binary data (in which case, hex output is fine) or for Unix file paths (because they may be non-UTF-8) and similar human-readable strings. So let's print the latter similarly to strings.
* | Print byte arrays as nicely-formatted hex.Will Thompson2009-11-041-1/+58
| |
* | Make array-printing code easier to followWill Thompson2009-11-011-2/+7
| | | | | | | | | | | | | | Previously dbus_message_iter_get_arg_type() was called twice: once in the loop condition to update 'current_type', and once to check if the loop will run again. This patch moves updating current_type to the end of the loop body.
* | Bug 21161 - Update the FSF addressTobias Mueller2009-07-101-1/+1
| | | | | | | | | | | | No comment. Signed-off-by: Colin Walters <walters@verbum.org>
* | Print serial in dbus-monitorMichael Meeks2008-08-291-1/+2
|/ | | | | | * tools/dbus-print-message.c: Print serial too. Signed-off-by: Colin Walters <walters@verbum.org>
* 2007-07-13 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-07-141-1/+1
| | | | * Add indent-tabs-mode: nil to all file headers.
* * tools/dbus-print-message.c (print_message): added printing of the reply ↵Ralf Habacker2007-03-101-3/+5
| | | | serial to method returns and errors, so you can actually figure out the message/reply pairs - patch by olli.salli at collabora.co.uk.
* 2006-06-14 Ross Burton <ross@openedhand.com>Ross Burton2006-06-141-1/+2
| | | | | * tools/dbus-print-message.c: Also print the object path when outputting signals or method calls.
* Added support for printing of all remaining data types. Fixed logic for ↵Daniel P. Berrange2006-04-161-56/+134
| | | | indentation of compound data types.
* 2006-03-10 Ross Burton <ross@openedhand.com>Ross Burton2006-03-101-3/+21
| | | | | * tools/dbus-print-message.c: Add support for object paths and signatures.
* 2005-08-26 Colin Walters <walters@verbum.org>Colin Walters2005-08-261-0/+1
| | | | | | * tools/dbus-print-message.c (print_message): Flush stdout after printing a message, so that redirecting to a file, then hitting Ctrl-C works.
* 2005-07-06 Colin Walters <walters@verbum.org>Colin Walters2005-07-061-31/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dbus/dbus-glib.h (DBusGPendingCall, DBusGPendingCallNotify) (DBUS_TYPE_G_PENDING_CALL, dbus_g_pending_call_get_g_type) (dbus_g_pending_call_ref, dbus_g_pending_call_unref): Delete. (dbus_g_pending_call_set_notify, dbus_g_pending_call_cancel): Delete in favor of dbus_g_proxy_begin_call and dbus_g_proxy_cancel_call. (DBusGProxyCall, DBusGProxyCallNotify): New. (dbus_g_proxy_begin_call): Change prototype to take callback, user data, and destroy function. This replaces dbus_g_pending_call_set_notify. (dbus_g_proxy_cancel_call): Prototype. (DBusGAsyncData): Delete, shouldn't be needed anymore. * glib/dbus-gproxy.c (struct _DBusGProxy): Add call_id_counter and pending_calls map. (struct _DBusGProxyManager): Add bus_proxy member, which is an internal proxy for calls to the bus. Remove pending_nameowner_calls, now the internal proxy keeps track. (dbus_g_proxy_manager_unref): Unref bus proxy, remove reference to pending_nameowner_calls. (got_name_owner_cb): Update prototype, and use dbus_g_proxy_end_call. (got_name_owner_cb): Remove reference to pending_nameowner_calls. (dbus_g_proxy_manager_register): Delete directly libdbus code in favor of using internal proxy. (dbus_g_proxy_manager_unregister): Update to use dbus_g_proxy_cancel_call for any pending GetNameOwner call. (dbus_g_proxy_init): Initialize pending calls map. (dbus_g_proxy_constructor): New. (dbus_g_proxy_class_init): Add get/set property functions, constructor, and add NAME, PATH, and INTERFACE properties. (cancel_pending_call): New function. (dbus_g_proxy_dispose): Iterate over any outstanding calls and cancel them. (dbus_g_proxy_set_property, dbus_g_proxy_get_property): New. (GPendingNotifyClosure): New structure. (d_pending_call_notify, d_pending_call_free): Moved here from dbus-glib.c. (DBUS_G_VALUE_ARRAY_COLLECT_ALL): Moved around to satisfy function ordering. (manager_begin_bus_call): New internal function for talking to internal bus proxy. (dbus_g_proxy_new): Construct object using GObjet properties. (dbus_g_proxy_begin_call_internal): Update to take user data, etc. Create closure of same, and insert call into map of pending calls. (dbus_g_proxy_end_call_internal): Take call id instead of pending call. Look up pending call in current set. Remove it when we've completed. (dbus_g_pending_call_end, dbus_g_proxy_end_call_internal): Delete. (dbus_g_proxy_begin_call): Change API to take callback, user data, and destroy function directly. (dbus_g_proxy_end_call): Update to take DBusGProxyCall. (dbus_g_proxy_call): Invoke with NULL callback. (dbus_g_proxy_cancel_call): New function, replaces dbus_g_pending_call_cancel. * glib/dbus-gparser.c (validate_signature): Fix call to dbus_set_g_error. * glib/dbus-gobject.c (dbus_g_object_type_dbus_metadata_quark): New quark for attaching metadata to GType. (info_hash): Delete. (lookup_object_info): Look up using quark. (dbus_g_object_type_install_info): Check that a type is classed, not that it's an object. Also just install type data using quark instead of using global hash. * glib/dbus-glib.c (dbus_g_pending_call_ref) (dbus_g_pending_call_unref, dbus_pending_call_get_g_type) (GPendingNotifyClosure): Delete. (d_pending_call_notify, d_pending_call_free): Move to dbus-gproxy.c. (dbus_g_pending_call_set_notify, dbus_g_pending_call_cancel): Delete. * glib/dbus-binding-tool-glib.c (generate_client_glue): Disable async client method generation until we can fix it... * tools/dbus-viewer.c (load_child_nodes): Use dbus_g_proxy_call. (load_from_service_thread_func): Ditto. * tools/dbus-names-model.c (struct NamesModel): Hold DBusGProxyCall. (have_names_notify): Update prototype, use dbus_g_proxy_cancel_call. (names_model_reload): Update for new dbus_g_proxy_begin_call API. * tools/dbus-monitor.c (filter_func): Update for print_message API change. * test/glib/test-dbus-glib.c: Add more tests for async invocations. Update many begin_call/end_call pairs to just use dbus_g_proxy_call. * tools/dbus-send.c (main): Add --print-reply=literal mode. This allows us to dump print-introspect.c. * tools/dbus-print-message.h (print_message): Add literal argument to print_message which is intended to allow printing arguments without metadata like "string=". * tools/dbus-print-message.c (print_iter): Add literal argument. (print_message): Allow printing string messages literally.
* 2005-06-16 Colin Walters <walters@verbum.org>Colin Walters2005-06-161-0/+13
| | | | | | | | | | * tools/dbus-send.c (append_array): Use strtok. (append_dict): New function. (type_from_name): New function, extracted from main. (main): Handle sending dicts. * tools/dbus-print-message.c (print_iter): Print dict entries.
* 2005-05-11 Colin Walters <walters@verbum.org>Colin Walters2005-05-111-54/+89
| | | | | | | | | * tools/dbus-send.c (append_array): New function. (append_arg): Broken out from main. (main): Add cheesy hack to send arrays and variants. (usage): Update. * tools/dbus-print-message.c (print_iter): Broken out from main.
* 2005-01-30 Havoc Pennington <hp@redhat.com>Havoc Pennington2005-01-301-24/+28
| | | | | | | | | | | | | | | | | | | | * glib/dbus-gobject.c (introspect_properties): fix the XML generated * dbus/dbus-message.c (dbus_message_unref): add an in_cache flag which effectively detects the use of freed messages * glib/dbus-gobject.c (handle_introspect): modify and return the reply message instead of the incoming message * dbus/dbus-object-tree.c (handle_default_introspect_unlocked): gee, maybe it should SEND THE XML instead of just making a string and freeing it again ;-) * tools/dbus-print-message.c (print_message): improve printing of messages * configure.in: add debug-glib.service to the output
* 2005-01-15 Havoc Pennington <hp@redhat.com>Havoc Pennington2005-01-151-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Land the new message args API and type system. This patch is huge, but the public API change is not really large. The set of D-BUS types has changed somewhat, and the arg "getters" are more geared toward language bindings; they don't make a copy, etc. There are also some known issues. See these emails for details on this huge patch: http://lists.freedesktop.org/archives/dbus/2004-December/001836.html http://lists.freedesktop.org/archives/dbus/2005-January/001922.html * dbus/dbus-marshal-*: all the new stuff * dbus/dbus-message.c: basically rewritten * dbus/dbus-memory.c (check_guards): with "guards" enabled, init freed blocks to be all non-nul bytes so using freed memory is less likely to work right * dbus/dbus-internals.c (_dbus_test_oom_handling): add DBUS_FAIL_MALLOC=N environment variable, so you can do DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or DBUS_FAIL_MALLOC=10 to make it really, really, really slow and thorough. * qt/message.cpp: port to the new message args API (operator<<): use str.utf8() rather than str.unicode() (pretty sure this is right from the Qt docs?) * glib/dbus-gvalue.c: port to the new message args API * bus/dispatch.c, bus/driver.c: port to the new message args API * dbus/dbus-string.c (_dbus_string_init_const_len): initialize the "locked" flag to TRUE and align_offset to 0; I guess we never looked at these anyhow, but seems cleaner. * dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING): move allocation padding macro to this header; use it to implement (_DBUS_STRING_STATIC): ability to declare a static string. * dbus/dbus-message.c (_dbus_message_has_type_interface_member): change to return TRUE if the interface is not set. * dbus/dbus-string.[hc]: move the D-BUS specific validation stuff to dbus-marshal-validate.[hc] * dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from dbus-internals.c * dbus/Makefile.am: cut over from dbus-marshal.[hc] to dbus-marshal-*.[hc] * dbus/dbus-object-tree.c (_dbus_decompose_path): move this function here from dbus-marshal.c
* 2003-08-18 Havoc Pennington <hp@redhat.com>Havoc Pennington2003-08-181-6/+31
| | | | | | | | | | | | | | | | | | | | | | | | * dbus/dbus-hash.c (_dbus_hash_table_insert_two_strings): fix * dbus/dbus-message.c (_dbus_message_loader_queue_messages): fix dumb bug created earlier (wrong order of args to decode_header_data()) * tools/dbus-send.c: port * tools/dbus-print-message.c (print_message): port * test/data/*messages: port all messages over * dbus/dbus-message-builder.c: support including message type * bus/driver.c: port over * bus/dispatch.c: port over to new stuff * dbus/dbus-connection.c (_dbus_connection_new_for_transport): rename disconnect signal to "Disconnected"
* 2003-08-10 Havoc Pennington <hp@pobox.com>Havoc Pennington2003-08-111-1/+22
| | | | | | | | | | | | | | | | | | | | | | * tools/dbus-send.c (main): add --type argument, for now supporting only method_call and signal types. * tools/dbus-print-message.c: print message type * dbus/dbus-connection.c (_dbus_connection_new_for_transport): init connection->objects * doc/dbus-specification.sgml: fix sgml * bus/*.c: port over to object-instance API changes * test/test-service.c: ditto * dbus/dbus-message.c (dbus_message_create_header): allow #NULL name, we will have to fix up the rest of the code to also handle this (dbus_message_new): generic message-creation call (set_string_field): allow appending name field
* 2003-06-19 Philip Blundell <philb@gnu.org>Anders Carlsson2003-06-191-0/+6
| | | | | | | | * tools/dbus-print-message.c (print_message): Handle BOOLEAN. * tools/dbus-send.c: Accept both --system and --session. * tools/dbus-monitor.c: Same here.
* 2003-05-16 Havoc Pennington <hp@redhat.com>Havoc Pennington2003-05-161-0/+83
* dbus/dbus-connection.c: disable verbose lock spew * tools/dbus-send.c: add --print-reply command line option * tools/dbus-print-message.h (print_message): new util function shared by dbus-send and dbus-monitor * tools/dbus-monitor.c (handler_func): exit on disconnect * dbus/dbus-transport-unix.c (do_reading): if the transport is disconnected, don't try to use the read_watch * dbus/dbus-watch.c (dbus_watch_get_enabled): assert watch != NULL so we can find this bug more easily