diff options
Diffstat (limited to 'src/geometry/geometry.c')
-rw-r--r-- | src/geometry/geometry.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c index 322ada0..fd42735 100644 --- a/src/geometry/geometry.c +++ b/src/geometry/geometry.c @@ -13,11 +13,25 @@ int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src) return -1; } - char *count_str = kai_tag_get_attr(src, "count"); - if (count_str == NULL) { - /* missing required count attribute! */ + int flag; + dest->count = kai_tag_attr_to_long(src, "count", 0, &flag); + if (flag != 0) { + /* count not present */ return -1; } + char *id = kai_tag_get_attr(src, "id"); + if (id != NULL) + dest->id = strdup(id); + else + dest->id = NULL; + + dest->digits = kai_tag_attr_to_long(src, "digits", 6, NULL); + dest->magnitude = kai_tag_attr_to_long(src, "magnitude", 38, NULL); + + /* allocate & fill buffer */ + dest->buf = malloc(dest->count * sizeof(ka_real_t)); + kai_text_to_reals(dest->buf, src->content, dest->count); + return 0; } |