r = sd_json_buildo(&status,
SD_JSON_BUILD_PAIR_STRING("state", home_state_to_string(state)),
SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Home")),
- SD_JSON_BUILD_PAIR("useFallback", SD_JSON_BUILD_BOOLEAN(!HOME_STATE_IS_ACTIVE(state))),
+ SD_JSON_BUILD_PAIR_BOOLEAN("useFallback", !HOME_STATE_IS_ACTIVE(state)),
SD_JSON_BUILD_PAIR("fallbackShell", JSON_BUILD_CONST_STRING(BINDIR "/systemd-home-fallback-shell")),
SD_JSON_BUILD_PAIR("fallbackHomeDirectory", JSON_BUILD_CONST_STRING("/")),
SD_JSON_BUILD_PAIR_CONDITION(disk_size != UINT64_MAX, "diskSize", SD_JSON_BUILD_UNSIGNED(disk_size)),
SD_JSON_BUILD_PAIR_STRING("description", description),
SD_JSON_BUILD_PAIR("binding", SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(user_record_gid(h))))))),
+ SD_JSON_BUILD_PAIR_UNSIGNED("gid", user_record_gid(h)))))),
SD_JSON_BUILD_PAIR_CONDITION(h->disposition >= 0, "disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(user_record_disposition(h)))),
SD_JSON_BUILD_PAIR("status", SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
_cleanup_(sd_json_variant_unrefp) sd_json_variant *j = NULL;
r = sd_json_buildo(
&j,
- SD_JSON_BUILD_PAIR("remote", SD_JSON_BUILD_STRING(remote)),
- SD_JSON_BUILD_PAIR("local", SD_JSON_BUILD_STRING(local)),
+ SD_JSON_BUILD_PAIR_STRING("remote", remote),
+ SD_JSON_BUILD_PAIR_STRING("local", local),
SD_JSON_BUILD_PAIR("class", JSON_BUILD_STRING_UNDERSCORIFY(image_class_to_string(class))),
SD_JSON_BUILD_PAIR("type", JSON_BUILD_STRING_UNDERSCORIFY(import_type_to_string(type))),
- SD_JSON_BUILD_PAIR("readOnly", SD_JSON_BUILD_BOOLEAN(ro)),
+ SD_JSON_BUILD_PAIR_BOOLEAN("readOnly", ro),
SD_JSON_BUILD_PAIR("verify", JSON_BUILD_STRING_UNDERSCORIFY(import_verify_to_string(verify))),
- SD_JSON_BUILD_PAIR("imageRoot", SD_JSON_BUILD_STRING(image_root)));
+ SD_JSON_BUILD_PAIR_STRING("imageRoot", image_root));
if (r < 0)
return log_error_errno(r, "Failed to build import JSON object: %m");
return sd_json_buildo(
ret,
- SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(contents)),
- SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(value)));
+ SD_JSON_BUILD_PAIR_STRING("type", contents),
+ SD_JSON_BUILD_PAIR_VARIANT("data", value));
}
static int json_transform_dict_array(sd_bus_message *m, sd_json_variant **ret) {
return sd_json_buildo(
ret,
- SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(type)),
- SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(v)));
+ SD_JSON_BUILD_PAIR_STRING("type", type),
+ SD_JSON_BUILD_PAIR_VARIANT("data", v));
}
_public_ int sd_bus_message_dump_json(sd_bus_message *m, uint64_t flags, sd_json_variant **ret) {
return sd_json_buildo(
ret,
- SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(bus_message_type_to_string(m->header->type))),
- SD_JSON_BUILD_PAIR("endian", SD_JSON_BUILD_STRING(CHAR_TO_STR(m->header->endian))),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(m->header->flags)),
- SD_JSON_BUILD_PAIR("version", SD_JSON_BUILD_INTEGER(m->header->version)),
- SD_JSON_BUILD_PAIR("cookie", SD_JSON_BUILD_INTEGER(BUS_MESSAGE_COOKIE(m))),
+ SD_JSON_BUILD_PAIR_STRING("type", bus_message_type_to_string(m->header->type)),
+ SD_JSON_BUILD_PAIR_STRING("endian", CHAR_TO_STR(m->header->endian)),
+ SD_JSON_BUILD_PAIR_INTEGER("flags", m->header->flags),
+ SD_JSON_BUILD_PAIR_INTEGER("version", m->header->version),
+ SD_JSON_BUILD_PAIR_INTEGER("cookie", BUS_MESSAGE_COOKIE(m)),
SD_JSON_BUILD_PAIR_CONDITION(m->reply_cookie != 0, "reply_cookie", SD_JSON_BUILD_INTEGER(m->reply_cookie)),
- SD_JSON_BUILD_PAIR("timestamp-realtime", SD_JSON_BUILD_UNSIGNED(ts)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("timestamp-realtime", ts),
SD_JSON_BUILD_PAIR_CONDITION(!!m->sender, "sender", SD_JSON_BUILD_STRING(m->sender)),
SD_JSON_BUILD_PAIR_CONDITION(!!m->destination, "destination", SD_JSON_BUILD_STRING(m->destination)),
SD_JSON_BUILD_PAIR_CONDITION(!!m->path, "path", SD_JSON_BUILD_STRING(m->path)),
SD_JSON_BUILD_PAIR_CONDITION(m->realtime != 0, "realtime", SD_JSON_BUILD_INTEGER(m->realtime)),
SD_JSON_BUILD_PAIR_CONDITION(m->seqnum != 0, "seqnum", SD_JSON_BUILD_INTEGER(m->seqnum)),
SD_JSON_BUILD_PAIR_CONDITION(!!m->error.name, "error_name", SD_JSON_BUILD_STRING(m->error.name)),
- SD_JSON_BUILD_PAIR("payload", SD_JSON_BUILD_VARIANT(v)));
+ SD_JSON_BUILD_PAIR_VARIANT("payload", v));
}
if (ratelimit_configured(rl)) {
r = sd_json_buildo(
&add,
- SD_JSON_BUILD_PAIR("intervalUSec", SD_JSON_BUILD_UNSIGNED(rl->interval)),
- SD_JSON_BUILD_PAIR("burst", SD_JSON_BUILD_UNSIGNED(rl->burst)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("intervalUSec", rl->interval),
+ SD_JSON_BUILD_PAIR_UNSIGNED("burst", rl->burst));
if (r < 0)
goto finish;
} else
goto finish;
r = sd_json_buildo(&add_more,
- SD_JSON_BUILD_PAIR("realtime", SD_JSON_BUILD_UNSIGNED(ts->realtime)),
- SD_JSON_BUILD_PAIR("monotonic", SD_JSON_BUILD_UNSIGNED(ts->monotonic)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("realtime", ts->realtime),
+ SD_JSON_BUILD_PAIR_UNSIGNED("monotonic", ts->monotonic));
if (r < 0)
goto finish;
}
goto finish;
r = sd_json_buildo(&add_more,
- SD_JSON_BUILD_PAIR("intervalUSec", SD_JSON_BUILD_UNSIGNED(rl->interval)),
- SD_JSON_BUILD_PAIR("burst", SD_JSON_BUILD_UNSIGNED(rl->burst)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("intervalUSec", rl->interval),
+ SD_JSON_BUILD_PAIR_UNSIGNED("burst", rl->burst));
if (r < 0)
goto finish;
}
r = sd_json_buildo(
&v,
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(m->name)),
+ SD_JSON_BUILD_PAIR_STRING("name", m->name),
SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(m->id), "id", SD_JSON_BUILD_ID128(m->id)),
- SD_JSON_BUILD_PAIR("class", SD_JSON_BUILD_STRING(machine_class_to_string(m->class))),
+ SD_JSON_BUILD_PAIR_STRING("class", machine_class_to_string(m->class)),
JSON_BUILD_PAIR_STRING_NON_EMPTY("service", m->service),
JSON_BUILD_PAIR_STRING_NON_EMPTY("rootDirectory", m->root_directory),
JSON_BUILD_PAIR_STRING_NON_EMPTY("unit", m->unit),
r = sd_json_variant_append_arraybo(
&digests,
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_usize)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
}
r = sd_json_buildo(ret_record,
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(pcr)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("pcr", pcr),
+ SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to build record object: %m");
r = sd_json_variant_append_arraybo(
&digests,
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_usize)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
r = sd_json_buildo(
&record,
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(i)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("pcr", i),
+ SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to build record object: %m");
r = sd_json_buildo(
&v,
- SD_JSON_BUILD_PAIR("records", SD_JSON_BUILD_VARIANT(array)));
+ SD_JSON_BUILD_PAIR_VARIANT("records", array));
if (r < 0)
return log_error_errno(r, "Failed to build JSON object: %m");
LIST_FOREACH(banks, bank, rec->banks) {
r = sd_json_variant_append_arraybo(
&digests,
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(bank->algorithm))),
+ SD_JSON_BUILD_PAIR_STRING("hashAlg", tpm2_hash_alg_to_string(bank->algorithm)),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(bank->hash.buffer, bank->hash.size)));
if (r < 0)
return log_error_errno(r, "Failed to build digests array: %m");
r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(rec->pcr)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("pcr", rec->pcr),
+ SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to build record array: %m");
}
LIST_FOREACH(banks, bank, rec->banks) {
r = sd_json_variant_append_arraybo(
&digests,
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(bank->algorithm))),
+ SD_JSON_BUILD_PAIR_STRING("hashAlg", tpm2_hash_alg_to_string(bank->algorithm)),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(bank->hash.buffer, bank->hash.size)));
if (r < 0)
return log_error_errno(r, "Failed to build digests array: %m");
r = sd_json_variant_append_arraybo(
FLAGS_SET(separator_seen_mask, bit) ? &array_late : &array_early,
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(rec->pcr)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("pcr", rec->pcr),
+ SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to build record array: %m");
}
r = sd_json_variant_append_arraybo(
&digests,
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_size)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(i)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("pcr", i),
+ SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to append record object: %m");
}
r = sd_json_variant_append_arraybo(
&pe_digests,
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(peh, hash_sizes[i])));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(TPM2_PCR_BOOT_LOADER_CODE)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(pe_digests)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("pcr", TPM2_PCR_BOOT_LOADER_CODE),
+ SD_JSON_BUILD_PAIR_VARIANT("digests", pe_digests));
if (r < 0)
return log_error_errno(r, "Failed to append record object: %m");
r = sd_json_variant_append_arraybo(
§ion_digests,
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_sizes[i])));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
/* And then append a record for the section contents digests as well */
r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(TPM2_PCR_KERNEL_BOOT /* =11 */)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(section_digests)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("pcr", TPM2_PCR_KERNEL_BOOT),
+ SD_JSON_BUILD_PAIR_VARIANT("digests", section_digests));
if (r < 0)
return log_error_errno(r, "Failed to append record object: %m");
}
return sd_varlink_replybo(context->link,
SD_JSON_BUILD_PAIR_STRING("name", context->metric_family->name),
JSON_BUILD_PAIR_STRING_NON_EMPTY("object", object),
- SD_JSON_BUILD_PAIR("value", SD_JSON_BUILD_VARIANT(value)),
+ SD_JSON_BUILD_PAIR_VARIANT("value", value),
JSON_BUILD_PAIR_VARIANT_NON_NULL("fields", fields));
}
SD_JSON_BUILD_ARRAY(
SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("foo_bar", JSON_BUILD_CONST_STRING("v1")),
- SD_JSON_BUILD_PAIR("quux", SD_JSON_BUILD_UNSIGNED(4711)),
- SD_JSON_BUILD_PAIR("zzz", SD_JSON_BUILD_BOOLEAN(true)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("quux", 4711),
+ SD_JSON_BUILD_PAIR_BOOLEAN("zzz", true),
SD_JSON_BUILD_PAIR("asdf-custom", SD_JSON_BUILD_NULL)),
SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("foo_bar", SD_JSON_BUILD_STRV(STRV_MAKE("a", "b", "c"))),
SD_JSON_BUILD_PAIR("quux", SD_JSON_BUILD_NULL),
- SD_JSON_BUILD_PAIR("zzz", SD_JSON_BUILD_UNSIGNED(0755)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("zzz", 0755),
SD_JSON_BUILD_PAIR("asdf-custom", SD_JSON_BUILD_NULL)))));
ASSERT_TRUE(sd_json_variant_equal(v, w));
ASSERT_OK(sd_json_build(&b,
SD_JSON_BUILD_ARRAY(
SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("int", SD_JSON_BUILD_INTEGER(-1)),
- SD_JSON_BUILD_PAIR("int8", SD_JSON_BUILD_INTEGER(-1)),
- SD_JSON_BUILD_PAIR("int16", SD_JSON_BUILD_INTEGER(-1)),
- SD_JSON_BUILD_PAIR("int32", SD_JSON_BUILD_INTEGER(-1)),
- SD_JSON_BUILD_PAIR("int64", SD_JSON_BUILD_INTEGER(-1))),
+ SD_JSON_BUILD_PAIR_INTEGER("int", -1),
+ SD_JSON_BUILD_PAIR_INTEGER("int8", -1),
+ SD_JSON_BUILD_PAIR_INTEGER("int16", -1),
+ SD_JSON_BUILD_PAIR_INTEGER("int32", -1),
+ SD_JSON_BUILD_PAIR_INTEGER("int64", -1)),
SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("int", SD_JSON_BUILD_INTEGER(INT_MAX)),
- SD_JSON_BUILD_PAIR("int8", SD_JSON_BUILD_INTEGER(INT8_MAX)),
- SD_JSON_BUILD_PAIR("int16", SD_JSON_BUILD_INTEGER(INT16_MAX)),
- SD_JSON_BUILD_PAIR("int32", SD_JSON_BUILD_INTEGER(INT32_MAX)),
- SD_JSON_BUILD_PAIR("int64", SD_JSON_BUILD_INTEGER(INT64_MAX))),
+ SD_JSON_BUILD_PAIR_INTEGER("int", INT_MAX),
+ SD_JSON_BUILD_PAIR_INTEGER("int8", INT8_MAX),
+ SD_JSON_BUILD_PAIR_INTEGER("int16", INT16_MAX),
+ SD_JSON_BUILD_PAIR_INTEGER("int32", INT32_MAX),
+ SD_JSON_BUILD_PAIR_INTEGER("int64", INT64_MAX)),
SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("int", SD_JSON_BUILD_INTEGER(INT_MIN)),
- SD_JSON_BUILD_PAIR("int8", SD_JSON_BUILD_INTEGER(INT8_MIN)),
- SD_JSON_BUILD_PAIR("int16", SD_JSON_BUILD_INTEGER(INT16_MIN)),
- SD_JSON_BUILD_PAIR("int32", SD_JSON_BUILD_INTEGER(INT32_MIN)),
- SD_JSON_BUILD_PAIR("int64", SD_JSON_BUILD_INTEGER(INT64_MIN))))));
+ SD_JSON_BUILD_PAIR_INTEGER("int", INT_MIN),
+ SD_JSON_BUILD_PAIR_INTEGER("int8", INT8_MIN),
+ SD_JSON_BUILD_PAIR_INTEGER("int16", INT16_MIN),
+ SD_JSON_BUILD_PAIR_INTEGER("int32", INT32_MIN),
+ SD_JSON_BUILD_PAIR_INTEGER("int64", INT64_MIN)))));
sd_json_variant_dump(b, SD_JSON_FORMAT_NEWLINE, stdout, NULL);
ASSERT_TRUE(sd_json_variant_equal(a, b));
ASSERT_OK(sd_json_build(&b,
SD_JSON_BUILD_ARRAY(
SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("uint", SD_JSON_BUILD_UNSIGNED(0)),
- SD_JSON_BUILD_PAIR("uint8", SD_JSON_BUILD_UNSIGNED(0)),
- SD_JSON_BUILD_PAIR("uint16", SD_JSON_BUILD_UNSIGNED(0)),
- SD_JSON_BUILD_PAIR("uint32", SD_JSON_BUILD_UNSIGNED(0)),
- SD_JSON_BUILD_PAIR("uhex32", SD_JSON_BUILD_UNSIGNED(0)),
- SD_JSON_BUILD_PAIR("uint64", SD_JSON_BUILD_UNSIGNED(0)),
- SD_JSON_BUILD_PAIR("uhex64", SD_JSON_BUILD_UNSIGNED(0))),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint", 0),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint8", 0),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint16", 0),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint32", 0),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uhex32", 0),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint64", 0),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uhex64", 0)),
SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("uint", SD_JSON_BUILD_UNSIGNED(UINT_MAX)),
- SD_JSON_BUILD_PAIR("uint8", SD_JSON_BUILD_UNSIGNED(UINT8_MAX)),
- SD_JSON_BUILD_PAIR("uint16", SD_JSON_BUILD_UNSIGNED(UINT16_MAX)),
- SD_JSON_BUILD_PAIR("uint32", SD_JSON_BUILD_UNSIGNED(UINT32_MAX)),
- SD_JSON_BUILD_PAIR("uhex32", SD_JSON_BUILD_UNSIGNED(UINT32_MAX)),
- SD_JSON_BUILD_PAIR("uint64", SD_JSON_BUILD_UNSIGNED(UINT64_MAX)),
- SD_JSON_BUILD_PAIR("uhex64", SD_JSON_BUILD_UNSIGNED(UINT64_MAX))))));
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint", UINT_MAX),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint8", UINT8_MAX),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint16", UINT16_MAX),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint32", UINT32_MAX),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uhex32", UINT32_MAX),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uint64", UINT64_MAX),
+ SD_JSON_BUILD_PAIR_UNSIGNED("uhex64", UINT64_MAX)))));
sd_json_variant_dump(b, SD_JSON_FORMAT_NEWLINE, stdout, NULL);
ASSERT_TRUE(sd_json_variant_equal(a, b));
ASSERT_OK(table_to_json(t, &a));
ASSERT_OK(sd_json_build(&b, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pfft_aa", SD_JSON_BUILD_STRING("foo")),
- SD_JSON_BUILD_PAIR("dimpfelmoser", SD_JSON_BUILD_UNSIGNED(1024)),
- SD_JSON_BUILD_PAIR("custom-quux", SD_JSON_BUILD_STRING("asdf")),
- SD_JSON_BUILD_PAIR("lllllllllllo", SD_JSON_BUILD_STRING("jjjjjjjjjjjjjjjjj")))));
+ SD_JSON_BUILD_PAIR_STRING("pfft_aa", "foo"),
+ SD_JSON_BUILD_PAIR_UNSIGNED("dimpfelmoser", 1024),
+ SD_JSON_BUILD_PAIR_STRING("custom-quux", "asdf"),
+ SD_JSON_BUILD_PAIR_STRING("lllllllllllo", "jjjjjjjjjjjjjjjjj"))));
ASSERT_TRUE(sd_json_variant_equal(a, b));
}
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
assert_se(sd_json_build(&v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("a", SD_JSON_BUILD_STRING("x")),
- SD_JSON_BUILD_PAIR("b", SD_JSON_BUILD_UNSIGNED(44)),
+ SD_JSON_BUILD_PAIR_STRING("a", "x"),
+ SD_JSON_BUILD_PAIR_UNSIGNED("b", 44),
SD_JSON_BUILD_PAIR("d", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_UNSIGNED(5), SD_JSON_BUILD_UNSIGNED(7), SD_JSON_BUILD_UNSIGNED(107))),
SD_JSON_BUILD_PAIR("g", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("f", SD_JSON_BUILD_REAL(0.5f)))))) >= 0);
y = sd_json_variant_integer(b);
- r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("sum", SD_JSON_BUILD_INTEGER(x + y))));
+ r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("sum", x + y)));
if (r < 0)
return r;
for (int i = 0; i < 5; i++) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *w = NULL;
- r = sd_json_build(&w, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("sum", SD_JSON_BUILD_INTEGER(s.x + (s.y * i)))));
+ r = sd_json_build(&w, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("sum", s.x + (s.y * i))));
if (r < 0)
return r;
return r;
}
- r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("sum", SD_JSON_BUILD_INTEGER(s.x + (s.y * 5)))));
+ r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("sum", s.x + (s.y * 5))));
if (r < 0)
return r;
ASSERT_OK(vv = memfd_new_and_seal_string("data", "miau"));
ASSERT_OK(ww = memfd_new_and_seal_string("data", "wuff"));
- r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("yo", SD_JSON_BUILD_INTEGER(88))));
+ r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("yo", 88)));
if (r < 0)
return r;
ASSERT_OK(asprintf(&t, "flood-%zu", k));
ASSERT_OK(sd_varlink_set_description(connections[k], t));
ASSERT_OK(sd_varlink_attach_event(connections[k], e, k));
- ASSERT_OK(sd_varlink_sendb(connections[k], "io.test.Rubbish", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("id", SD_JSON_BUILD_INTEGER(k)))));
+ ASSERT_OK(sd_varlink_sendb(connections[k], "io.test.Rubbish", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("id", k))));
}
/* Then, create one more, which should fail */
const char *error_id, *e;
int x = 0;
- ASSERT_OK(sd_json_build(&i, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("a", SD_JSON_BUILD_INTEGER(88)),
- SD_JSON_BUILD_PAIR("b", SD_JSON_BUILD_INTEGER(99)))));
+ ASSERT_OK(sd_json_build(&i, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("a", 88),
+ SD_JSON_BUILD_PAIR_INTEGER("b", 99))));
ASSERT_OK(sd_varlink_connect_address(&c, arg));
ASSERT_OK(sd_varlink_set_description(c, "thread-client"));
ASSERT_OK(sd_varlink_set_allow_fd_passing_output(c, true));
/* Test that client is able to perform two sequential sd_varlink_collect calls if first resulted in an error */
- ASSERT_OK(sd_json_build(&wrong, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("a", SD_JSON_BUILD_INTEGER(88)),
- SD_JSON_BUILD_PAIR("c", SD_JSON_BUILD_INTEGER(99)))));
+ ASSERT_OK(sd_json_build(&wrong, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("a", 88),
+ SD_JSON_BUILD_PAIR_INTEGER("c", 99))));
ASSERT_OK(sd_varlink_collect(c, "io.test.DoSomethingMore", wrong, &j, &error_id));
ASSERT_STREQ(error_id, "org.varlink.service.InvalidParameter");
ASSERT_OK_EQ(sd_varlink_push_fd(c, fd2), 1);
ASSERT_OK_EQ(sd_varlink_push_fd(c, fd3), 2);
- ASSERT_OK(sd_varlink_callb(c, "io.test.PassFD", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("fd", SD_JSON_BUILD_STRING("whoop")))));
+ ASSERT_OK(sd_varlink_callb(c, "io.test.PassFD", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_STRING("fd", "whoop"))));
ASSERT_NULL(e);
int fd4, fd5;
test_fd(fd4, "miau", 4);
test_fd(fd5, "wuff", 4);
- ASSERT_OK(sd_varlink_callb(c, "io.test.PassFD", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("fdx", SD_JSON_BUILD_STRING("whoopx")))));
+ ASSERT_OK(sd_varlink_callb(c, "io.test.PassFD", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_STRING("fdx", "whoopx"))));
ASSERT_TRUE(sd_varlink_error_is_invalid_parameter(e, o, "fd"));
ASSERT_OK(sd_varlink_callb(c, "io.test.IDontExist", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("x", SD_JSON_BUILD_REAL(5.5)))));
ASSERT_OK(sd_varlink_server_attach_event(s, e, 0));
ASSERT_OK(sd_varlink_server_set_connections_max(s, OVERLOAD_CONNECTIONS));
- ASSERT_OK(sd_json_build(&v, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("a", SD_JSON_BUILD_INTEGER(7)),
- SD_JSON_BUILD_PAIR("b", SD_JSON_BUILD_INTEGER(22)))));
+ ASSERT_OK(sd_json_build(&v, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("a", 7),
+ SD_JSON_BUILD_PAIR_INTEGER("b", 22))));
ASSERT_OK(sd_varlink_connect_address(&c, sp));
ASSERT_OK(sd_varlink_set_description(c, "main-client"));