static int property_get_what( sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { Mount *m = userdata; const char *d; assert(bus); assert(reply); assert(m); if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.what) d = m->parameters_proc_self_mountinfo.what; else if (m->from_fragment && m->parameters_fragment.what) d = m->parameters_fragment.what; else d = ""; return sd_bus_message_append(reply, "s", d); }
static int transient_kill_set_properties(sd_bus_message *m) { assert(m); if (arg_send_sighup) return sd_bus_message_append(m, "(sv)", "SendSIGHUP", "b", arg_send_sighup); else return 0; }
static int get_group_property(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { struct dmmp_path_group *group = userdata; if (strcmp(property, GROUP_ID) == 0) return sd_bus_message_append(reply, "u", dmmp_path_group_id_get(group)); if (strcmp(property, GROUP_PRIORITY) == 0) return sd_bus_message_append(reply, "u", dmmp_path_group_priority_get(group)); if (strcmp(property, GROUP_STATUS) == 0) return sd_bus_message_append(reply, "s", dmmp_path_group_status_str( dmmp_path_group_status_get(group))); // TODO deal with error return -1; }
static void client_chart(const char *address) { _cleanup_bus_message_unref_ sd_bus_message *x = NULL; size_t csize; sd_bus *b; int r; r = sd_bus_new(&b); assert_se(r >= 0); r = sd_bus_set_address(b, address); assert_se(r >= 0); r = sd_bus_start(b); assert_se(r >= 0); assert_se(sd_bus_call_method(b, ":1.1", "/", "benchmark.server", "Ping", NULL, NULL, NULL) >= 0); printf("SIZE\tCOPY\tMEMFD\n"); for (csize = 1; csize <= MAX_SIZE; csize *= 2) { usec_t t; unsigned n_copying, n_memfd; printf("%zu\t", csize); b->use_memfd = 0; t = now(CLOCK_MONOTONIC); for (n_copying = 0;; n_copying++) { transaction(b, csize); if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec) break; } printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec)); b->use_memfd = -1; t = now(CLOCK_MONOTONIC); for (n_memfd = 0;; n_memfd++) { transaction(b, csize); if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec) break; } printf("%u\n", (unsigned) ((n_memfd * USEC_PER_SEC) / arg_loop_usec)); } b->use_memfd = 1; assert_se(sd_bus_message_new_method_call(b, ":1.1", "/", "benchmark.server", "Exit", &x) >= 0); assert_se(sd_bus_message_append(x, "t", csize) >= 0); assert_se(sd_bus_send(b, x, NULL) >= 0); sd_bus_unref(b); }
static int get_handler(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { struct context *c = userdata; int r; log_info("property get for %s called, returning \"%s\".", property, c->something); r = sd_bus_message_append(reply, "s", c->something); assert_se(r >= 0); return 1; }
static struct ipmi_rs *ipmi_dbus_sendrecv(struct ipmi_intf *intf, struct ipmi_rq *req) { sd_bus_message *msg; int rc; (void)intf; rsp.ccode = 0xff; rc = sd_bus_message_new_signal(bus, &msg, object_path, interface, "ReceivedMessage"); if (rc < 0) { lprintf(LOG_ERR, "%s: failed to create message: %s\n", __func__, strerror(-rc)); goto out; } rc = sd_bus_message_append(msg, "yyyy", ++seq, req->msg.netfn, req->msg.lun, req->msg.cmd); if (rc < 0) { lprintf(LOG_ERR, "%s: failed to init bytes\n", __func__); goto out_free; } rc = sd_bus_message_append_array(msg, 'y', req->msg.data, req->msg.data_len); if (rc < 0) { lprintf(LOG_ERR, "%s: failed to init body\n", __func__); goto out_free; } rc = sd_bus_send(bus, msg, NULL); if (rc < 0) { lprintf(LOG_ERR, "%s: failed to send dbus message\n", __func__); goto out_free; } for (reply_received = false; !reply_received;) { rc = sd_bus_wait(bus, -1); sd_bus_process(bus, NULL); } out_free: sd_bus_message_unref(msg); out: return &rsp; }
static int transient_unit_set_properties(sd_bus_message *m, char **properties) { char **i; int r; r = sd_bus_message_append(m, "(sv)", "Description", "s", arg_description); if (r < 0) return r; STRV_FOREACH(i, properties) { r = bus_append_unit_property_assignment(m, *i); if (r < 0) return r; }
int bus_property_get_tristate( sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { int *tristate = userdata; return sd_bus_message_append(reply, "b", *tristate > 0); }
static int transient_unit_set_properties(sd_bus_message *m, char **properties) { int r; r = sd_bus_message_append(m, "(sv)", "Description", "s", arg_description); if (r < 0) return r; r = bus_append_unit_property_assignment_many(m, properties); if (r < 0) return r; return 0; }
_public_ int sd_bus_set_property( sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *error, const char *type, ...) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; va_list ap; int r; bus_assert_return(bus, -EINVAL, error); bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error); bus_assert_return(member_name_is_valid(member), -EINVAL, error); bus_assert_return(signature_is_single(type, false), -EINVAL, error); bus_assert_return(!bus_pid_changed(bus), -ECHILD, error); if (!BUS_IS_OPEN(bus->state)) { r = -ENOTCONN; goto fail; } r = sd_bus_message_new_method_call(bus, &m, destination, path, "org.freedesktop.DBus.Properties", "Set"); if (r < 0) goto fail; r = sd_bus_message_append(m, "ss", strempty(interface), member); if (r < 0) goto fail; r = sd_bus_message_open_container(m, 'v', type); if (r < 0) goto fail; va_start(ap, type); r = sd_bus_message_appendv(m, type, ap); va_end(ap); if (r < 0) goto fail; r = sd_bus_message_close_container(m); if (r < 0) goto fail; return sd_bus_call(bus, m, 0, error, NULL); fail: return sd_bus_error_set_errno(error, r); }
static int transient_timer_set_properties(sd_bus_message *m) { int r; assert(m); r = transient_unit_set_properties(m, arg_timer_property); if (r < 0) return r; /* Automatically clean up our transient timers */ r = sd_bus_message_append(m, "(sv)", "RemainAfterElapse", "b", false); if (r < 0) return r; if (arg_on_active) { r = sd_bus_message_append(m, "(sv)", "OnActiveSec", "t", arg_on_active); if (r < 0) return r; } if (arg_on_boot) { r = sd_bus_message_append(m, "(sv)", "OnBootSec", "t", arg_on_boot); if (r < 0) return r; } if (arg_on_startup) { r = sd_bus_message_append(m, "(sv)", "OnStartupSec", "t", arg_on_startup); if (r < 0) return r; } if (arg_on_unit_active) { r = sd_bus_message_append(m, "(sv)", "OnUnitActiveSec", "t", arg_on_unit_active); if (r < 0) return r; } if (arg_on_unit_inactive) { r = sd_bus_message_append(m, "(sv)", "OnUnitInactiveSec", "t", arg_on_unit_inactive); if (r < 0) return r; } if (arg_on_calendar) { r = sd_bus_message_append(m, "(sv)", "OnCalendar", "s", arg_on_calendar); if (r < 0) return r; } return 0; }
static int value_handler(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { _cleanup_free_ char *s = NULL; const char *x; int r; assert_se(asprintf(&s, "object %p, path %s", userdata, path) >= 0); r = sd_bus_message_append(reply, "s", s); assert_se(r >= 0); assert_se(x = startswith(path, "/value/")); assert_se(PTR_TO_UINT(userdata) == 30); return 1; }
int cc_Calculator_split_async( struct cc_client_Calculator *instance, double value, cc_Calculator_split_reply_t callback) { int result = 0; struct cc_instance *i; sd_bus_message *message = NULL; CC_LOG_DEBUG("invoked cc_Calculator_split_async()\n"); assert(instance); assert(callback); i = instance->instance; assert(i && i->backend && i->backend->bus); assert(i->service && i->path && i->interface); if (instance->split_reply_slot) { CC_LOG_ERROR("unable to call method with already pending reply\n"); return -EBUSY; } assert(!instance->split_reply_callback); result = sd_bus_message_new_method_call( i->backend->bus, &message, i->service, i->path, i->interface, "split"); if (result < 0) { CC_LOG_ERROR("unable to create message: %s\n", strerror(-result)); goto fail; } result = sd_bus_message_append(message, "d", value); if (result < 0) { CC_LOG_ERROR("unable to append message method arguments: %s\n", strerror(-result)); goto fail; } result = sd_bus_call_async( i->backend->bus, &instance->split_reply_slot, message, &cc_Calculator_split_reply_thunk, instance, CC_DBUS_ASYNC_CALL_TIMEOUT_USEC); if (result < 0) { CC_LOG_ERROR("unable to issue method call: %s\n", strerror(-result)); goto fail; } instance->split_reply_callback = callback; fail: message = sd_bus_message_unref(message); return result; }
static int append_controller_property(sd_bus *bus, sd_bus_message *m) { const char *unique; int r; assert(bus); assert(m); r = sd_bus_get_unique_name(bus, &unique); if (r < 0) return log_error_errno(r, "Failed to get unique name: %m"); r = sd_bus_message_append(m, "(sv)", "Controller", "s", unique); if (r < 0) return bus_log_create_error(r); return 0; }
int main(int argc, char *argv[]) { struct bus_match_node root = { .type = BUS_MATCH_ROOT, }; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; enum bus_match_node_type i; sd_bus_slot slots[19]; int r; r = sd_bus_open_system(&bus); if (r < 0) return EXIT_TEST_SKIP; assert_se(match_add(slots, &root, "arg2='wal\\'do',sender='foo',type='signal',interface='bar.x',", 1) >= 0); assert_se(match_add(slots, &root, "arg2='wal\\'do2',sender='foo',type='signal',interface='bar.x',", 2) >= 0); assert_se(match_add(slots, &root, "arg3='test',sender='foo',type='signal',interface='bar.x',", 3) >= 0); assert_se(match_add(slots, &root, "arg3='test',sender='foo',type='method_call',interface='bar.x',", 4) >= 0); assert_se(match_add(slots, &root, "", 5) >= 0); assert_se(match_add(slots, &root, "interface='quux.x'", 6) >= 0); assert_se(match_add(slots, &root, "interface='bar.x'", 7) >= 0); assert_se(match_add(slots, &root, "member='waldo',path='/foo/bar'", 8) >= 0); assert_se(match_add(slots, &root, "path='/foo/bar'", 9) >= 0); assert_se(match_add(slots, &root, "path_namespace='/foo'", 10) >= 0); assert_se(match_add(slots, &root, "path_namespace='/foo/quux'", 11) >= 0); assert_se(match_add(slots, &root, "arg1='two'", 12) >= 0); assert_se(match_add(slots, &root, "member='waldo',arg2path='/prefix/'", 13) >= 0); assert_se(match_add(slots, &root, "member=waldo,path='/foo/bar',arg3namespace='prefix'", 14) >= 0); assert_se(match_add(slots, &root, "arg4has='pi'", 15) >= 0); assert_se(match_add(slots, &root, "arg4has='pa'", 16) >= 0); assert_se(match_add(slots, &root, "arg4has='po'", 17) >= 0); assert_se(match_add(slots, &root, "arg4='pi'", 18) >= 0); bus_match_dump(&root, 0); assert_se(sd_bus_message_new_signal(bus, &m, "/foo/bar", "bar.x", "waldo") >= 0); assert_se(sd_bus_message_append(m, "ssssas", "one", "two", "/prefix/three", "prefix.four", 3, "pi", "pa", "po") >= 0); assert_se(bus_message_seal(m, 1, 0) >= 0); zero(mask); assert_se(bus_match_run(NULL, &root, m) == 0); assert_se(mask_contains((unsigned[]) { 9, 8, 7, 5, 10, 12, 13, 14, 15, 16, 17 }, 11));
int bus_property_get_tristate( sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, sd_bus_error *error, void *userdata) { int *tristate = userdata; int r; r = sd_bus_message_append(reply, "b", *tristate > 0); if (r < 0) return r; return 1; }
static int transient_cgroup_set_properties(sd_bus_message *m) { int r; assert(m); if (!isempty(arg_slice)) { _cleanup_free_ char *slice; r = unit_name_mangle_with_suffix(arg_slice, UNIT_NAME_NOGLOB, ".slice", &slice); if (r < 0) return r; r = sd_bus_message_append(m, "(sv)", "Slice", "s", slice); if (r < 0) return r; } return 0; }
static int property_get_chassis( sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { Context *c = userdata; const char *name; if (isempty(c->data[PROP_CHASSIS])) name = fallback_chassis(); else name = c->data[PROP_CHASSIS]; return sd_bus_message_append(reply, "s", name); }
static sd_bus_message * create_property_set(sd_bus *bus, const char *service, const char *path, const char *interface, const char *member) { sd_bus_message *m; int r; r = sd_bus_message_new_method_call(bus, &m, service, path, "org.freedesktop.DBus.Properties", "Set"); SOL_INT_CHECK(r, < 0, NULL); r = sd_bus_message_append(m, "ss", interface, member); SOL_INT_CHECK_GOTO(r, < 0, error_append); return m; error_append: sd_bus_message_unref(m); return NULL; }
static int property_get_options( sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { Swap *s = SWAP(userdata); const char *options = NULL; assert(bus); assert(reply); assert(s); if (s->from_fragment) options = s->parameters_fragment.options; return sd_bus_message_append(reply, "s", options); }
static int message_start_transient_unit_new(sd_bus *bus, const char *name, sd_bus_message **ret) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL; char **i; int r; assert(bus); assert(name); assert(ret); r = sd_bus_message_new_method_call( bus, &m, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartTransientUnit"); if (r < 0) return r; r = sd_bus_message_append(m, "ss", name, "fail"); if (r < 0) return r; r = sd_bus_message_open_container(m, 'a', "(sv)"); if (r < 0) return r; STRV_FOREACH(i, arg_property) { r = sd_bus_message_open_container(m, 'r', "sv"); if (r < 0) return r; r = bus_append_unit_property_assignment(m, *i); if (r < 0) return r; r = sd_bus_message_close_container(m); if (r < 0) return r; }
int sysview_seat_switch_to(sysview_seat *seat, uint32_t nr) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL; int r; assert_return(seat, -EINVAL); assert_return(seat->context->sysbus, -EINVAL); r = sd_bus_message_new_method_call(seat->context->sysbus, &m, "org.freedesktop.login1", seat->path, "org.freedesktop.login1.Seat", "SwitchTo"); if (r < 0) return r; r = sd_bus_message_append(m, "u", nr); if (r < 0) return r; return sd_bus_send(seat->context->sysbus, m, NULL); }
static int property_get_unit( sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { _cleanup_free_ char *p = NULL; Job *j = userdata; assert(bus); assert(reply); assert(j); p = unit_dbus_path(j->unit); if (!p) return -ENOMEM; return sd_bus_message_append(reply, "(so)", j->unit->id, p); }
static int property_get_icon_name( sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { _cleanup_free_ char *n = NULL; Context *c = userdata; const char *name; if (isempty(c->data[PROP_ICON_NAME])) name = n = context_fallback_icon_name(c); else name = c->data[PROP_ICON_NAME]; if (!name) return -ENOMEM; return sd_bus_message_append(reply, "s", name); }
static int transient_scope_set_properties(sd_bus_message *m) { int r; assert(m); r = transient_unit_set_properties(m, arg_property); if (r < 0) return r; r = transient_kill_set_properties(m); if (r < 0) return r; r = transient_cgroup_set_properties(m); if (r < 0) return r; r = sd_bus_message_append(m, "(sv)", "PIDs", "au", 1, (uint32_t) getpid()); if (r < 0) return r; return 0; }
static int property_get_type( sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { const char *fstype = NULL; Mount *m = userdata; assert(bus); assert(reply); assert(m); if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.fstype) fstype = m->parameters_proc_self_mountinfo.fstype; else if (m->from_fragment && m->parameters_fragment.fstype) fstype = m->parameters_fragment.fstype; return sd_bus_message_append(reply, "s", fstype); }
static void test_hostname_lookup(sd_bus *bus, const char *name, int family, const char *result) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL, *reply = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_free_ char *m = NULL; const char *af; int r; af = family == AF_UNSPEC ? "AF_UNSPEC" : af_to_name(family); /* If the name starts with a dot, we prefix one to three random labels */ if (startswith(name, ".")) { prefix_random(name + 1, &m); name = m; } assert_se(sd_bus_message_new_method_call( bus, &req, "org.freedesktop.resolve1", "/org/freedesktop/resolve1", "org.freedesktop.resolve1.Manager", "ResolveHostname") >= 0); assert_se(sd_bus_message_append(req, "isit", 0, name, family, UINT64_C(0)) >= 0); r = sd_bus_call(bus, req, SD_RESOLVED_QUERY_TIMEOUT_USEC, &error, &reply); if (r < 0) { assert_se(result); assert_se(sd_bus_error_has_name(&error, result)); log_info("[OK] %s/%s resulted in <%s>.", name, af, error.name); } else { assert_se(!result); log_info("[OK] %s/%s succeeded.", name, af); } }
static int remove_image(int argc, char *argv[], void *userdata) { _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; int r, i; r = acquire_bus(&bus); if (r < 0) return r; (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password); for (i = 1; i < argc; i++) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; r = sd_bus_message_new_method_call( bus, &m, "org.freedesktop.portable1", "/org/freedesktop/portable1", "org.freedesktop.portable1.Manager", "RemoveImage"); if (r < 0) return bus_log_create_error(r); r = sd_bus_message_append(m, "s", argv[i]); if (r < 0) return bus_log_create_error(r); /* This is a slow operation, hence turn off any method call timeouts */ r = sd_bus_call(bus, m, USEC_INFINITY, &error, NULL); if (r < 0) return log_error_errno(r, "Could not remove image: %s", bus_error_message(&error, r)); } return 0; }
static int resolve_host(sd_bus *bus, const char *name) { _cleanup_bus_message_unref_ sd_bus_message *req = NULL, *reply = NULL; _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; const char *canonical = NULL; char ifname[IF_NAMESIZE] = ""; unsigned c = 0; int r; uint64_t flags; usec_t ts; assert(name); if (arg_ifindex > 0 && !if_indextoname(arg_ifindex, ifname)) return log_error_errno(errno, "Failed to resolve interface name for index %i: %m", arg_ifindex); log_debug("Resolving %s (family %s, interface %s).", name, af_to_name(arg_family) ?: "*", isempty(ifname) ? "*" : ifname); r = sd_bus_message_new_method_call( bus, &req, "org.freedesktop.resolve1", "/org/freedesktop/resolve1", "org.freedesktop.resolve1.Manager", "ResolveHostname"); if (r < 0) return bus_log_create_error(r); r = sd_bus_message_append(req, "isit", arg_ifindex, name, arg_family, arg_flags); if (r < 0) return bus_log_create_error(r); ts = now(CLOCK_MONOTONIC); r = sd_bus_call(bus, req, DNS_CALL_TIMEOUT_USEC, &error, &reply); if (r < 0) { log_error("%s: resolve call failed: %s", name, bus_error_message(&error, r)); return r; } ts = now(CLOCK_MONOTONIC) - ts; r = sd_bus_message_enter_container(reply, 'a', "(iiay)"); if (r < 0) return bus_log_parse_error(r); while ((r = sd_bus_message_enter_container(reply, 'r', "iiay")) > 0) { const void *a; size_t sz; _cleanup_free_ char *pretty = NULL; int ifindex, family; assert_cc(sizeof(int) == sizeof(int32_t)); r = sd_bus_message_read(reply, "ii", &ifindex, &family); if (r < 0) return bus_log_parse_error(r); r = sd_bus_message_read_array(reply, 'y', &a, &sz); if (r < 0) return bus_log_parse_error(r); r = sd_bus_message_exit_container(reply); if (r < 0) return bus_log_parse_error(r); if (!IN_SET(family, AF_INET, AF_INET6)) { log_debug("%s: skipping entry with family %d (%s)", name, family, af_to_name(family) ?: "unknown"); continue; } if (sz != FAMILY_ADDRESS_SIZE(family)) { log_error("%s: systemd-resolved returned address of invalid size %zu for family %s", name, sz, af_to_name(family) ?: "unknown"); continue; }
static void test_marshal(void) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *n = NULL; _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL; _cleanup_free_ void *blob; size_t sz; int r; r = sd_bus_open_system(&bus); if (r < 0) exit(EXIT_TEST_SKIP); bus->message_version = 2; /* dirty hack to enable gvariant */ assert_se(sd_bus_message_new_method_call(bus, &m, "a.service.name", "/an/object/path/which/is/really/really/long/so/that/we/hit/the/eight/bit/boundary/by/quite/some/margin/to/test/this/stuff/that/it/really/works", "an.interface.name", "AMethodName") >= 0); assert_cc(sizeof(struct bus_header) == 16); assert_se(sd_bus_message_append(m, "a(usv)", 3, 4711, "first-string-parameter", "(st)", "X", (uint64_t) 1111, 4712, "second-string-parameter", "(a(si))", 2, "Y", 5, "Z", 6, 4713, "third-string-parameter", "(uu)", 1, 2) >= 0); assert_se(bus_message_seal(m, 4711, 0) >= 0); #ifdef HAVE_GLIB { GVariant *v; char *t; #if !defined(GLIB_VERSION_2_36) g_type_init(); #endif v = g_variant_new_from_data(G_VARIANT_TYPE("(yyyyuta{tv})"), m->header, sizeof(struct bus_header) + m->fields_size, false, NULL, NULL); assert_se(g_variant_is_normal_form(v)); t = g_variant_print(v, TRUE); printf("%s\n", t); g_free(t); g_variant_unref(v); v = g_variant_new_from_data(G_VARIANT_TYPE("(a(usv))"), m->body.data, m->user_body_size, false, NULL, NULL); assert_se(g_variant_is_normal_form(v)); t = g_variant_print(v, TRUE); printf("%s\n", t); g_free(t); g_variant_unref(v); } #endif assert_se(bus_message_dump(m, NULL, BUS_MESSAGE_DUMP_WITH_HEADER) >= 0); assert_se(bus_message_get_blob(m, &blob, &sz) >= 0); #ifdef HAVE_GLIB { GVariant *v; char *t; v = g_variant_new_from_data(G_VARIANT_TYPE("(yyyyuta{tv}v)"), blob, sz, false, NULL, NULL); assert_se(g_variant_is_normal_form(v)); t = g_variant_print(v, TRUE); printf("%s\n", t); g_free(t); g_variant_unref(v); } #endif 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); m = sd_bus_message_unref(m); assert_se(sd_bus_message_new_method_call(bus, &m, "a.x", "/a/x", "a.x", "Ax") >= 0); assert_se(sd_bus_message_append(m, "as", 0) >= 0); assert_se(bus_message_seal(m, 4712, 0) >= 0); assert_se(bus_message_dump(m, NULL, BUS_MESSAGE_DUMP_WITH_HEADER) >= 0); }