mirror of
https://github.com/systemd/systemd.git
synced 2025-01-25 10:04:04 +03:00
resolve: make sd_json_dispatch_field table static
This commit is contained in:
parent
36df48d863
commit
f7923ef318
@ -2145,26 +2145,31 @@ int dns_resource_key_to_json(DnsResourceKey *key, sd_json_variant **ret) {
|
||||
}
|
||||
|
||||
int dns_resource_key_from_json(sd_json_variant *v, DnsResourceKey **ret) {
|
||||
_cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL;
|
||||
uint16_t type = 0, class = 0;
|
||||
const char *name = NULL;
|
||||
int r;
|
||||
struct params {
|
||||
uint16_t type;
|
||||
uint16_t class;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
sd_json_dispatch_field dispatch_table[] = {
|
||||
{ "class", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint16, PTR_TO_SIZE(&class), SD_JSON_MANDATORY },
|
||||
{ "type", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint16, PTR_TO_SIZE(&type), SD_JSON_MANDATORY },
|
||||
{ "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, PTR_TO_SIZE(&name), SD_JSON_MANDATORY },
|
||||
static const sd_json_dispatch_field dispatch_table[] = {
|
||||
{ "class", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint16, offsetof(struct params, class), SD_JSON_MANDATORY },
|
||||
{ "type", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint16, offsetof(struct params, type), SD_JSON_MANDATORY },
|
||||
{ "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(struct params, name), SD_JSON_MANDATORY },
|
||||
{}
|
||||
};
|
||||
|
||||
_cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL;
|
||||
struct params p;
|
||||
int r;
|
||||
|
||||
assert(v);
|
||||
assert(ret);
|
||||
|
||||
r = sd_json_dispatch(v, dispatch_table, 0, NULL);
|
||||
r = sd_json_dispatch(v, dispatch_table, 0, &p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
key = dns_resource_key_new(class, type, name);
|
||||
key = dns_resource_key_new(p.class, p.type, p.name);
|
||||
if (!key)
|
||||
return -ENOMEM;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user