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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#include <string.h>
#include <mxml.h>
#include "types.h"
#include "xml.h"
char xmlbuff[4096];
char * /* O - Buffer */
get_value(mxml_node_t *node, /* I - Node to get */
void *buffer, /* I - Buffer */
int buflen) /* I - Size of buffer */
{
char *ptr, /* Pointer into buffer */
*end; /* End of buffer */
int len; /* Length of node */
mxml_node_t *current; /* Current node */
ptr = (char*)buffer;
end = (char*)buffer + buflen - 1;
char tempbuf[4092];
current = node->child;
for (current = node->child; current && ptr < end; current = current->next)
{
if (current->type == MXML_TEXT)
{
if (current->value.text.whitespace)
*ptr++ = ' ';
len = (int)strlen(current->value.text.string);
if (len > (int)(end - ptr))
len = (int)(end - ptr);
memcpy(ptr, current->value.text.string, len);
ptr += len;
}
else if (current->type == MXML_OPAQUE)
{
len = (int)strlen(current->value.opaque);
if (len > (int)(end - ptr))
len = (int)(end - ptr);
memcpy(ptr, current->value.opaque, len);
ptr += len;
}
else if (current->type == MXML_INTEGER)
{
sprintf(tempbuf, "%d", current->value.integer);
len = (int)strlen(tempbuf);
if (len > (int)(end - ptr))
len = (int)(end - ptr);
memcpy(ptr, tempbuf, len);
ptr += len;
}
else if (current->type == MXML_REAL)
{
sprintf(tempbuf, "%f", current->value.real);
len = (int)strlen(tempbuf);
if (len > (int)(end - ptr))
len = (int)(end - ptr);
memcpy(ptr, tempbuf, len);
ptr += len;
}
}
*ptr = 0;
return buffer;
}
const char *whitespace_cb(mxml_node_t *node, int where)
{
/* code by Matt_P */
const char *name = node->value.element.name;
mxml_node_t * temp = node;
int depth = 0;
while(temp){
depth++;
temp = temp->parent;
}
if (where == 3 || where == 1){
sprintf(xmlbuff, "");
}else if((node->prev && where == 0 || node->parent) && !(where == 2 && strncmp(name, "ua", 2) && strcmp(name, "flip") && strcmp(name, "zoom") && strcmp(name, "coords") && strcmp(name, "entries") && strcmp(name, "xmlyt") && strcmp(name, "xmlan") && strcmp(name, "entries") && strcmp(name, "triplet") && strcmp(name, "pair") && strcmp(name, "entry") && strcmp(name, "pane") && (strcmp(name, "tag") && strcmp(name, "size") && strcmp(name, "material") && strcmp(name, "colors") && strcmp(name, "font"))) ){
sprintf(xmlbuff, "\n%*s", (depth-1)*4, "");
}else{
sprintf(xmlbuff, "");
}
return (xmlbuff);
}
|