1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <string.h>
#include <kalmia.h>
#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;
}
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;
}
|