mirror of
https://github.com/systemd/systemd.git
synced 2024-11-26 19:53:45 +08:00
json: introduce json_dispatch_int8() and json_dispatch_uint8()
This commit is contained in:
parent
d30d44883f
commit
6b67cf808a
@ -4812,6 +4812,42 @@ int json_dispatch_uint16(const char *name, JsonVariant *variant, JsonDispatchFla
|
||||
return 0;
|
||||
}
|
||||
|
||||
int json_dispatch_int8(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
|
||||
int8_t *i = ASSERT_PTR(userdata);
|
||||
int64_t i64;
|
||||
int r;
|
||||
|
||||
assert(variant);
|
||||
|
||||
r = json_dispatch_int64(name, variant, flags, &i64);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (i64 < INT8_MIN || i64 > INT8_MAX)
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(ERANGE), "JSON field '%s' out of bounds.", strna(name));
|
||||
|
||||
*i = (int8_t) i64;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int json_dispatch_uint8(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
|
||||
uint8_t *u = ASSERT_PTR(userdata);
|
||||
uint64_t u64;
|
||||
int r;
|
||||
|
||||
assert(variant);
|
||||
|
||||
r = json_dispatch_uint64(name, variant, flags, &u64);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u64 > UINT8_MAX)
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(ERANGE), "JSON field '%s' out of bounds.", strna(name));
|
||||
|
||||
*u = (uint8_t) u64;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int json_dispatch_string(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
|
||||
char **s = ASSERT_PTR(userdata);
|
||||
int r;
|
||||
|
@ -421,6 +421,8 @@ int json_dispatch_uint32(const char *name, JsonVariant *variant, JsonDispatchFla
|
||||
int json_dispatch_int32(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
|
||||
int json_dispatch_uint16(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
|
||||
int json_dispatch_int16(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
|
||||
int json_dispatch_int8(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
|
||||
int json_dispatch_uint8(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
|
||||
int json_dispatch_uid_gid(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
|
||||
int json_dispatch_user_group_name(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
|
||||
int json_dispatch_id128(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata);
|
||||
|
Loading…
Reference in New Issue
Block a user