diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-02-02 17:27:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-02 17:27:50 +0100 |
commit | d58f31793a622c5c5db73aabbb5fd0657eca74d0 (patch) | |
tree | 6b4cd5361198bf7a9cb9f6456b1d147909d9a140 /src/libsystemd | |
parent | ddb10d8ccd6a51c304bb61e4991531ed304d6e00 (diff) | |
parent | f770b7e084d6c2d1ac04d9e723cd793ec52187d9 (diff) | |
download | systemd-d58f31793a622c5c5db73aabbb5fd0657eca74d0.tar.gz |
Merge pull request #14645 from keszybz/sd-bus-message-dump
sd_bus_message_dump
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/libsystemd.sym | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-dump.c | 18 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-dump.h | 7 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-chat.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-gvariant.c | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-marshal.c | 10 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-objects.c | 16 |
7 files changed, 27 insertions, 33 deletions
diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym index 17a39e1d0f..ccc23e1257 100644 --- a/src/libsystemd/libsystemd.sym +++ b/src/libsystemd/libsystemd.sym @@ -685,6 +685,7 @@ global: LIBSYSTEMD_245 { global: + sd_bus_message_dump; sd_bus_message_sensitive; sd_event_add_child_pidfd; sd_event_source_get_child_pidfd; diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c index 9a6a81d7aa..caab5e5ebe 100644 --- a/src/libsystemd/sd-bus/bus-dump.c +++ b/src/libsystemd/sd-bus/bus-dump.c @@ -18,23 +18,23 @@ #include "terminal-util.h" #include "util.h" -static char *indent(unsigned level, unsigned flags) { +static char *indent(unsigned level, uint64_t flags) { char *p; unsigned n, i = 0; n = 0; - if (flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY && level > 0) + if (flags & SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY && level > 0) level -= 1; - if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) + if (flags & SD_BUS_MESSAGE_DUMP_WITH_HEADER) n += 2; p = new(char, n + level*8 + 1); if (!p) return NULL; - if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) { + if (flags & SD_BUS_MESSAGE_DUMP_WITH_HEADER) { p[i++] = ' '; p[i++] = ' '; } @@ -45,7 +45,7 @@ static char *indent(unsigned level, unsigned flags) { return p; } -int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { +_public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) { unsigned level = 1; int r; @@ -54,7 +54,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { if (!f) f = stdout; - if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) { + if (flags & SD_BUS_MESSAGE_DUMP_WITH_HEADER) { fprintf(f, "%s%s%s Type=%s%s%s Endian=%c Flags=%u Version=%u Priority=%"PRIi64, m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() : @@ -118,11 +118,11 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { bus_creds_dump(&m->creds, f, true); } - r = sd_bus_message_rewind(m, !(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)); + r = sd_bus_message_rewind(m, !(flags & SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY)); if (r < 0) return log_error_errno(r, "Failed to rewind: %m"); - if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) { + if (!(flags & SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY)) { _cleanup_free_ char *prefix = NULL; prefix = indent(0, flags); @@ -259,7 +259,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { } } - if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) { + if (!(flags & SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY)) { _cleanup_free_ char *prefix = NULL; prefix = indent(0, flags); diff --git a/src/libsystemd/sd-bus/bus-dump.h b/src/libsystemd/sd-bus/bus-dump.h index a1b67c6b14..f138791c04 100644 --- a/src/libsystemd/sd-bus/bus-dump.h +++ b/src/libsystemd/sd-bus/bus-dump.h @@ -6,13 +6,6 @@ #include "sd-bus.h" -enum { - BUS_MESSAGE_DUMP_WITH_HEADER = 1 << 0, - BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1 << 1, -}; - -int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags); - int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse); int bus_pcap_header(size_t snaplen, FILE *f); diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index d9716ae745..05127f0e0c 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -145,7 +145,7 @@ static int server(sd_bus *bus) { strna(sd_bus_message_get_member(m)), pid, strna(label)); - /* bus_message_dump(m); */ + /* sd_bus_message_dump(m); */ /* sd_bus_message_rewind(m, true); */ if (sd_bus_message_is_method_call(m, "org.freedesktop.systemd.test", "LowerCase")) { diff --git a/src/libsystemd/sd-bus/test-bus-gvariant.c b/src/libsystemd/sd-bus/test-bus-gvariant.c index 1a9a35d56b..d248bd4da1 100644 --- a/src/libsystemd/sd-bus/test-bus-gvariant.c +++ b/src/libsystemd/sd-bus/test-bus-gvariant.c @@ -175,7 +175,7 @@ static int test_marshal(void) { } #endif - assert_se(bus_message_dump(m, NULL, BUS_MESSAGE_DUMP_WITH_HEADER) >= 0); + assert_se(sd_bus_message_dump(m, NULL, SD_BUS_MESSAGE_DUMP_WITH_HEADER) >= 0); assert_se(bus_message_get_blob(m, &blob, &sz) >= 0); @@ -196,7 +196,7 @@ static int test_marshal(void) { assert_se(bus_message_from_malloc(bus, blob, sz, NULL, 0, NULL, &n) >= 0); blob = NULL; - assert_se(bus_message_dump(n, NULL, BUS_MESSAGE_DUMP_WITH_HEADER) >= 0); + assert_se(sd_bus_message_dump(n, NULL, SD_BUS_MESSAGE_DUMP_WITH_HEADER) >= 0); m = sd_bus_message_unref(m); @@ -205,7 +205,7 @@ static int test_marshal(void) { assert_se(sd_bus_message_append(m, "as", 0) >= 0); assert_se(sd_bus_message_seal(m, 4712, 0) >= 0); - assert_se(bus_message_dump(m, NULL, BUS_MESSAGE_DUMP_WITH_HEADER) >= 0); + assert_se(sd_bus_message_dump(m, NULL, SD_BUS_MESSAGE_DUMP_WITH_HEADER) >= 0); return EXIT_SUCCESS; } diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c index d7d51ba950..107eea390e 100644 --- a/src/libsystemd/sd-bus/test-bus-marshal.c +++ b/src/libsystemd/sd-bus/test-bus-marshal.c @@ -188,10 +188,10 @@ int main(int argc, char *argv[]) { r = sd_bus_message_seal(m, 4711, 0); assert_se(r >= 0); - bus_message_dump(m, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(m, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); ms = open_memstream_unlocked(&first, &first_size); - bus_message_dump(m, ms, 0); + sd_bus_message_dump(m, ms, 0); fflush(ms); assert_se(!ferror(ms)); @@ -244,11 +244,11 @@ int main(int argc, char *argv[]) { r = bus_message_from_malloc(bus, buffer, sz, NULL, 0, NULL, &m); assert_se(r >= 0); - bus_message_dump(m, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(m, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); fclose(ms); ms = open_memstream_unlocked(&second, &second_size); - bus_message_dump(m, ms, 0); + sd_bus_message_dump(m, ms, 0); fflush(ms); assert_se(!ferror(ms)); assert_se(first_size == second_size); @@ -354,7 +354,7 @@ int main(int argc, char *argv[]) { fclose(ms); ms = open_memstream_unlocked(&third, &third_size); - bus_message_dump(copy, ms, 0); + sd_bus_message_dump(copy, ms, 0); fflush(ms); assert_se(!ferror(ms)); diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c index 3c5bb88f4e..41cf8c1670 100644 --- a/src/libsystemd/sd-bus/test-bus-objects.c +++ b/src/libsystemd/sd-bus/test-bus-objects.c @@ -399,7 +399,7 @@ static int client(struct context *c) { r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.DBus.Properties", "GetAll", &error, &reply, "s", ""); assert_se(r >= 0); - bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); sd_bus_message_unref(reply); reply = NULL; @@ -417,7 +417,7 @@ static int client(struct context *c) { r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects", &error, &reply, ""); assert_se(r >= 0); - bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); sd_bus_message_unref(reply); reply = NULL; @@ -429,7 +429,7 @@ static int client(struct context *c) { assert_se(r > 0); assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.Properties", "PropertiesChanged")); - bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); sd_bus_message_unref(reply); reply = NULL; @@ -441,7 +441,7 @@ static int client(struct context *c) { assert_se(r > 0); assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.Properties", "PropertiesChanged")); - bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); sd_bus_message_unref(reply); reply = NULL; @@ -453,7 +453,7 @@ static int client(struct context *c) { assert_se(r > 0); assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesAdded")); - bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); sd_bus_message_unref(reply); reply = NULL; @@ -465,7 +465,7 @@ static int client(struct context *c) { assert_se(r > 0); assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved")); - bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); sd_bus_message_unref(reply); reply = NULL; @@ -477,7 +477,7 @@ static int client(struct context *c) { assert_se(r > 0); assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesAdded")); - bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); sd_bus_message_unref(reply); reply = NULL; @@ -489,7 +489,7 @@ static int client(struct context *c) { assert_se(r > 0); assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved")); - bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_WITH_HEADER); + sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER); sd_bus_message_unref(reply); reply = NULL; |