aboutgitcodelistschat:MatrixIRC
path: root/cooker/parse.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-06-04 09:51:15 +0200
committerStefano Brivio <sbrivio@redhat.com>2023-06-04 09:51:15 +0200
commitc021082abcc9d94c2e94679f6729265fe65529a3 (patch)
treee0c8d7160d9a725911edafc80ab0bceeec35e159 /cooker/parse.c
parent15c01cbd4b1fabe929cb93226f6295e88b0c04c4 (diff)
downloadseitan-c021082abcc9d94c2e94679f6729265fe65529a3.tar
seitan-c021082abcc9d94c2e94679f6729265fe65529a3.tar.gz
seitan-c021082abcc9d94c2e94679f6729265fe65529a3.tar.bz2
seitan-c021082abcc9d94c2e94679f6729265fe65529a3.tar.lz
seitan-c021082abcc9d94c2e94679f6729265fe65529a3.tar.xz
seitan-c021082abcc9d94c2e94679f6729265fe65529a3.tar.zst
seitan-c021082abcc9d94c2e94679f6729265fe65529a3.zip
cooker: Generic attributes and ATTR_SIZE
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'cooker/parse.c')
-rw-r--r--cooker/parse.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/cooker/parse.c b/cooker/parse.c
index 5a474f8..ab77e6b 100644
--- a/cooker/parse.c
+++ b/cooker/parse.c
@@ -57,7 +57,7 @@ static void handle_fd(struct gluten_ctx *g, JSON_Value *value)
}
if (json_object_get_value(obj, "return"))
- desc.do_return = json_object_get_boolean(obj, "return")
+ desc.do_return = json_object_get_boolean(obj, "return");
if (json_object_get_value(obj, "close_on_exec"))
desc.cloexec = json_object_get_boolean(obj, "close_on_exec");
@@ -139,6 +139,14 @@ long long value_get_num(struct num *desc, JSON_Value *value)
return n;
}
+ssize_t value_get_size(struct gluten_ctx *g, intptr_t id)
+{
+ if (!g)
+ return -1;
+
+ return gluten_get_attr(g, ATTR_SIZE, id).v_num;
+}
+
/**
* value_get() - Get generic value from description matching JSON input
* @desc: Description of possible values from model
@@ -170,6 +178,12 @@ struct field *select_field(struct gluten_ctx *g, int pos,
for (d_num = s->desc.d_num; d_num->target.f.type; d_num++) {
if (d_num->value == v.v_num) {
+ if (g && d_num->sel_size != -1) {
+ v.v_num = d_num->sel_size;
+ gluten_add_attr(g, ATTR_SIZE,
+ (intptr_t)s, v);
+ }
+
if (d_num->target.pos == pos)
return &d_num->target.f;