mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-20 14:03:39 +03:00
sd-bus: make dump flags public
This commit is contained in:
parent
c7d26acce6
commit
27cf4c18c7
@ -1158,7 +1158,7 @@ static int introspect(int argc, char **argv, void *userdata) {
|
||||
}
|
||||
|
||||
static int message_dump(sd_bus_message *m, FILE *f) {
|
||||
return bus_message_dump(m, f, BUS_MESSAGE_DUMP_WITH_HEADER);
|
||||
return bus_message_dump(m, f, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
|
||||
}
|
||||
|
||||
static int message_pcap(sd_bus_message *m, FILE *f) {
|
||||
@ -2158,7 +2158,7 @@ static int get_property(int argc, char **argv, void *userdata) {
|
||||
} else if (arg_verbose) {
|
||||
(void) pager_open(arg_pager_flags);
|
||||
|
||||
r = bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_SUBTREE_ONLY);
|
||||
r = bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
if (getenv_bool("SYSTEMD_FUZZ_OUTPUT") <= 0)
|
||||
assert_se(g = open_memstream_unlocked(&out, &out_size));
|
||||
|
||||
bus_message_dump(m, g ?: stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
|
||||
bus_message_dump(m, g ?: stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
|
||||
|
||||
r = sd_bus_message_rewind(m, true);
|
||||
assert_se(r >= 0);
|
||||
|
@ -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) {
|
||||
int 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);
|
||||
|
@ -6,12 +6,7 @@
|
||||
|
||||
#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_message_dump(sd_bus_message *m, FILE *f, uint64_t flags);
|
||||
|
||||
int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse);
|
||||
|
||||
|
@ -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(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(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(bus_message_dump(m, NULL, SD_BUS_MESSAGE_DUMP_WITH_HEADER) >= 0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ 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);
|
||||
bus_message_dump(m, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
|
||||
|
||||
ms = open_memstream_unlocked(&first, &first_size);
|
||||
bus_message_dump(m, ms, 0);
|
||||
@ -244,7 +244,7 @@ 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);
|
||||
bus_message_dump(m, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
|
||||
|
||||
fclose(ms);
|
||||
ms = open_memstream_unlocked(&second, &second_size);
|
||||
|
@ -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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_WITH_HEADER);
|
||||
|
||||
sd_bus_message_unref(reply);
|
||||
reply = NULL;
|
||||
|
@ -105,6 +105,11 @@ enum {
|
||||
SD_BUS_NAME_QUEUE = 1ULL << 2
|
||||
};
|
||||
|
||||
enum {
|
||||
SD_BUS_MESSAGE_DUMP_WITH_HEADER = 1ULL << 0,
|
||||
SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1ULL << 1,
|
||||
};
|
||||
|
||||
/* Callbacks */
|
||||
|
||||
typedef int (*sd_bus_message_handler_t)(sd_bus_message *m, void *userdata, sd_bus_error *ret_error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user