#include #include #include "util/util.h" #include "xml/xml.h" #include "geometry.h" int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src) { if (strcmp(src->type, "float_array") != 0) { /* incorrect tag type */ return -1; } long count = kai_tag_attr_to_long(src, "count", -1); if (count == -1) { /* count not present */ return -1; } dest->count = count; dest->id = kai_tag_attr_to_dup(src, "id"); dest->digits = kai_tag_attr_to_long(src, "digits", 6); dest->magnitude = kai_tag_attr_to_long(src, "magnitude", 38); /* allocate & fill buffer */ dest->buf = malloc(dest->count * sizeof(ka_real_t)); kai_text_to_reals(dest->buf, src->content, dest->count); return 0; }