diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2023-06-04 09:51:15 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-06-04 09:51:15 +0200 |
commit | c021082abcc9d94c2e94679f6729265fe65529a3 (patch) | |
tree | e0c8d7160d9a725911edafc80ab0bceeec35e159 /cooker/gluten.c | |
parent | 15c01cbd4b1fabe929cb93226f6295e88b0c04c4 (diff) | |
download | seitan-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/gluten.c')
-rw-r--r-- | cooker/gluten.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cooker/gluten.c b/cooker/gluten.c index a488dfd..01c2369 100644 --- a/cooker/gluten.c +++ b/cooker/gluten.c @@ -123,6 +123,36 @@ struct gluten_offset gluten_get_tag(struct gluten_ctx *g, const char *name) return g->tags[0].offset; /* Pro forma, not actually happening */ } +void gluten_add_attr(struct gluten_ctx *g, enum attr_type type, intptr_t id, + union value v) +{ + int i; + + for (i = 0; i < ATTRS_MAX && g->attrs[i].id; i++); + if (i == ATTRS_MAX) + die("Too many attributes"); + + g->attrs[i].type = type; + g->attrs[i].id = id; + g->attrs[i].v = v; + + debug(" attribute '%p' set", id); +} + +union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type, + intptr_t id) +{ + int i; + + for (i = 0; i < ATTRS_MAX && g->attrs[i].type; i++) { + if (g->attrs[i].type == type && g->attrs[i].id == id) + return g->attrs[i].v; + } + + die(" attribute '%p' not found", id); + return g->attrs[0].v; /* Pro forma, not actually happening */ +} + /** * gluten_init() - Initialise gluten structures and layout * @g: gluten context |