67 #define ENCODE_UTF16BE 1
68 #define ENCODE_UTF16LE 2
75 #define mxml_bad_char(ch) ((ch) < ' ' && (ch) != '\n' && (ch) != '\r' && (ch) != '\t')
85 typedef struct _mxml_fdbuf_s
88 unsigned char *current,
98 static int mxml_add_char(
int ch,
char **ptr,
char **buffer,
100 static int mxml_fd_getc(
void *p,
int *encoding);
101 static int mxml_fd_putc(
int ch,
void *p);
104 static int mxml_file_getc(
void *p,
int *encoding);
105 static int mxml_file_putc(
int ch,
void *p);
106 static int mxml_get_entity(
mxml_node_t *parent,
void *p,
109 static inline int mxml_isspace(
int ch)
111 return (ch ==
' ' || ch ==
'\t' || ch ==
'\r' ||
118 static int mxml_parse_element(
mxml_node_t *node,
void *p,
121 static int mxml_string_getc(
void *p,
int *encoding);
122 static int mxml_string_putc(
int ch,
void *p);
123 static int mxml_write_name(
const char *s,
void *p,
125 static int mxml_write_node(
mxml_node_t *node,
void *p,
129 static int mxml_write_string(
const char *s,
void *p,
131 static int mxml_write_ws(
mxml_node_t *node,
void *p,
164 buf.current = buf.buffer;
165 buf.end = buf.buffer;
171 return (mxml_load_data(top, &buf, cb, mxml_fd_getc,
MXML_NO_CALLBACK, NULL));
199 return (mxml_load_data(top, fp, cb, mxml_file_getc,
MXML_NO_CALLBACK, NULL));
227 return (mxml_load_data(top, (
void *)&s, cb, mxml_string_getc,
MXML_NO_CALLBACK,
267 if (bytes < (
int)(
sizeof(buffer) - 1))
321 buf.current = buf.buffer;
322 buf.end = buf.buffer +
sizeof(buf.buffer);
328 if ((col = mxml_write_node(node, &buf, cb, 0, mxml_fd_putc, global)) < 0)
332 if (mxml_fd_putc(
'\n', &buf) < 0)
339 return (mxml_fd_write(&buf));
367 if ((col = mxml_write_node(node, fp, cb, 0, mxml_file_putc, global)) < 0)
371 if (putc(
'\n', fp) < 0)
413 ptr[1] = buffer + bufsize;
415 if ((col = mxml_write_node(node, ptr, cb, 0, mxml_string_putc, global)) < 0)
419 mxml_string_putc(
'\n', ptr);
425 if (ptr[0] >= ptr[1])
426 buffer[bufsize - 1] =
'\0';
434 return (
int)(ptr[0] - buffer);
475 buf.current = buf.buffer;
476 buf.end = buf.buffer;
482 return (mxml_load_data(top, &buf, cb, mxml_fd_getc, sax_cb, sax_data));
520 return (mxml_load_data(top, fp, cb, mxml_file_getc, sax_cb, sax_data));
558 return (mxml_load_data(top, (
void *)&s, cb, mxml_string_getc, sax_cb, sax_data));
617 global->
wrap = column;
626 mxml_add_char(
int ch,
634 if (*bufptr >= (*buffer + *bufsize - 4))
649 mxml_error(
"Unable to expand string buffer to %d bytes!", *bufsize);
654 *bufptr = newbuffer + (*bufptr - *buffer);
672 *(*bufptr)++ = 0xc0 | (ch >> 6);
673 *(*bufptr)++ = 0x80 | (ch & 0x3f);
675 else if (ch < 0x10000)
681 *(*bufptr)++ = 0xe0 | (ch >> 12);
682 *(*bufptr)++ = 0x80 | ((ch >> 6) & 0x3f);
683 *(*bufptr)++ = 0x80 | (ch & 0x3f);
691 *(*bufptr)++ = 0xf0 | (ch >> 18);
692 *(*bufptr)++ = 0x80 | ((ch >> 12) & 0x3f);
693 *(*bufptr)++ = 0x80 | ((ch >> 6) & 0x3f);
694 *(*bufptr)++ = 0x80 | (ch & 0x3f);
706 mxml_fd_getc(
void *p,
720 if (buf->current >= buf->end)
721 if (mxml_fd_read(buf) < 0)
724 ch = *(buf->current)++;
736 printf(
"mxml_fd_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
741 mxml_error(
"Bad control character 0x%02x not allowed by XML standard!",
754 if (buf->current >= buf->end)
755 if (mxml_fd_read(buf) < 0)
758 ch = *(buf->current)++;
765 return (mxml_fd_getc(p, encoding));
773 if (buf->current >= buf->end)
774 if (mxml_fd_read(buf) < 0)
777 ch = *(buf->current)++;
784 return (mxml_fd_getc(p, encoding));
786 else if ((ch & 0xe0) == 0xc0)
792 if (buf->current >= buf->end)
793 if (mxml_fd_read(buf) < 0)
796 temp = *(buf->current)++;
798 if ((temp & 0xc0) != 0x80)
801 ch = ((ch & 0x1f) << 6) | (temp & 0x3f);
805 mxml_error(
"Invalid UTF-8 sequence for character 0x%04x!", ch);
809 else if ((ch & 0xf0) == 0xe0)
815 if (buf->current >= buf->end)
816 if (mxml_fd_read(buf) < 0)
819 temp = *(buf->current)++;
821 if ((temp & 0xc0) != 0x80)
824 ch = ((ch & 0x0f) << 6) | (temp & 0x3f);
826 if (buf->current >= buf->end)
827 if (mxml_fd_read(buf) < 0)
830 temp = *(buf->current)++;
832 if ((temp & 0xc0) != 0x80)
835 ch = (ch << 6) | (temp & 0x3f);
839 mxml_error(
"Invalid UTF-8 sequence for character 0x%04x!", ch);
848 return (mxml_fd_getc(p, encoding));
850 else if ((ch & 0xf8) == 0xf0)
856 if (buf->current >= buf->end)
857 if (mxml_fd_read(buf) < 0)
860 temp = *(buf->current)++;
862 if ((temp & 0xc0) != 0x80)
865 ch = ((ch & 0x07) << 6) | (temp & 0x3f);
867 if (buf->current >= buf->end)
868 if (mxml_fd_read(buf) < 0)
871 temp = *(buf->current)++;
873 if ((temp & 0xc0) != 0x80)
876 ch = (ch << 6) | (temp & 0x3f);
878 if (buf->current >= buf->end)
879 if (mxml_fd_read(buf) < 0)
882 temp = *(buf->current)++;
884 if ((temp & 0xc0) != 0x80)
887 ch = (ch << 6) | (temp & 0x3f);
891 mxml_error(
"Invalid UTF-8 sequence for character 0x%04x!", ch);
904 if (buf->current >= buf->end)
905 if (mxml_fd_read(buf) < 0)
908 temp = *(buf->current)++;
910 ch = (ch << 8) | temp;
914 mxml_error(
"Bad control character 0x%02x not allowed by XML standard!",
918 else if (ch >= 0xd800 && ch <= 0xdbff)
926 if (buf->current >= buf->end)
927 if (mxml_fd_read(buf) < 0)
930 lch = *(buf->current)++;
932 if (buf->current >= buf->end)
933 if (mxml_fd_read(buf) < 0)
936 temp = *(buf->current)++;
938 lch = (lch << 8) | temp;
940 if (lch < 0xdc00 || lch >= 0xdfff)
943 ch = (((ch & 0x3ff) << 10) | (lch & 0x3ff)) + 0x10000;
952 if (buf->current >= buf->end)
953 if (mxml_fd_read(buf) < 0)
956 temp = *(buf->current)++;
962 mxml_error(
"Bad control character 0x%02x not allowed by XML standard!",
966 else if (ch >= 0xd800 && ch <= 0xdbff)
974 if (buf->current >= buf->end)
975 if (mxml_fd_read(buf) < 0)
978 lch = *(buf->current)++;
980 if (buf->current >= buf->end)
981 if (mxml_fd_read(buf) < 0)
984 temp = *(buf->current)++;
988 if (lch < 0xdc00 || lch >= 0xdfff)
991 ch = (((ch & 0x3ff) << 10) | (lch & 0x3ff)) + 0x10000;
997 printf(
"mxml_fd_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
1009 mxml_fd_putc(
int ch,
1021 if (buf->current >= buf->end)
1022 if (mxml_fd_write(buf) < 0)
1025 *(buf->current)++ = ch;
1048 if (!
NT_SUCCESS(
NtReadFile(buf->fd, NULL, NULL, NULL, &isb, buf->buffer,
sizeof(buf->buffer), NULL, NULL)))
1054 buf->current = buf->buffer;
1074 if (buf->current == buf->buffer)
1077 if (!
NT_SUCCESS(
NtWriteFile(buf->fd, NULL, NULL, NULL, &isb, buf->buffer, (ULONG)(buf->current - buf->buffer), NULL, NULL)))
1080 buf->current = buf->buffer;
1091 mxml_file_getc(
void *p,
1120 mxml_error(
"Bad control character 0x%02x not allowed by XML standard!",
1126 printf(
"mxml_file_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
1131 else if (ch == 0xfe)
1143 return (mxml_file_getc(p, encoding));
1145 else if (ch == 0xff)
1157 return (mxml_file_getc(p, encoding));
1159 else if ((ch & 0xe0) == 0xc0)
1165 if ((temp = getc(fp)) == EOF || (temp & 0xc0) != 0x80)
1168 ch = ((ch & 0x1f) << 6) | (temp & 0x3f);
1172 mxml_error(
"Invalid UTF-8 sequence for character 0x%04x!", ch);
1176 else if ((ch & 0xf0) == 0xe0)
1182 if ((temp = getc(fp)) == EOF || (temp & 0xc0) != 0x80)
1185 ch = ((ch & 0x0f) << 6) | (temp & 0x3f);
1187 if ((temp = getc(fp)) == EOF || (temp & 0xc0) != 0x80)
1190 ch = (ch << 6) | (temp & 0x3f);
1194 mxml_error(
"Invalid UTF-8 sequence for character 0x%04x!", ch);
1203 return (mxml_file_getc(p, encoding));
1205 else if ((ch & 0xf8) == 0xf0)
1211 if ((temp = getc(fp)) == EOF || (temp & 0xc0) != 0x80)
1214 ch = ((ch & 0x07) << 6) | (temp & 0x3f);
1216 if ((temp = getc(fp)) == EOF || (temp & 0xc0) != 0x80)
1219 ch = (ch << 6) | (temp & 0x3f);
1221 if ((temp = getc(fp)) == EOF || (temp & 0xc0) != 0x80)
1224 ch = (ch << 6) | (temp & 0x3f);
1228 mxml_error(
"Invalid UTF-8 sequence for character 0x%04x!", ch);
1241 ch = (ch << 8) | getc(fp);
1245 mxml_error(
"Bad control character 0x%02x not allowed by XML standard!",
1249 else if (ch >= 0xd800 && ch <= 0xdbff)
1255 int lch = (getc(fp) << 8) | getc(fp);
1257 if (lch < 0xdc00 || lch >= 0xdfff)
1260 ch = (((ch & 0x3ff) << 10) | (lch & 0x3ff)) + 0x10000;
1269 ch |= (getc(fp) << 8);
1273 mxml_error(
"Bad control character 0x%02x not allowed by XML standard!",
1277 else if (ch >= 0xd800 && ch <= 0xdbff)
1283 int lch = getc(fp) | (getc(fp) << 8);
1285 if (lch < 0xdc00 || lch >= 0xdfff)
1288 ch = (((ch & 0x3ff) << 10) | (lch & 0x3ff)) + 0x10000;
1294 printf(
"mxml_file_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
1306 mxml_file_putc(
int ch,
1309 return (putc(ch, (FILE *)p) == EOF ? -1 : 0);
1321 int (*getc_cb)(
void *,
int *))
1331 while ((ch = (*getc_cb)(p, encoding)) != EOF)
1332 if (ch > 126 || (!isalnum(ch) && ch !=
'#'))
1334 else if (entptr < (entity +
sizeof(entity) - 1))
1338 mxml_error(
"Entity name too long under parent <%s>!",
1347 mxml_error(
"Character entity \"%s\" not terminated under parent <%s>!",
1352 if (entity[0] ==
'#')
1354 if (entity[1] ==
'x')
1355 ch = strtol(entity + 2, NULL, 16);
1357 ch = strtol(entity + 1, NULL, 10);
1360 mxml_error(
"Entity name \"%s;\" not supported under parent <%s>!",
1365 mxml_error(
"Bad control character 0x%02x under parent <%s> not allowed by XML standard!",
1399 static const char *
const types[] =
1416 mxml_error(
"Unable to allocate string buffer!");
1428 type = (*cb)(parent);
1432 while ((ch = (*getc_cb)(p, &encoding)) != EOF)
1455 node =
mxmlNewReal(parent, strtod(buffer, &bufptr));
1473 mxml_error(
"Bad custom value '%s' in parent <%s>!",
1492 mxml_error(
"Bad %s value '%s' in parent <%s>!",
1499 whitespace = mxml_isspace(ch) && type ==
MXML_TEXT;
1507 mxml_error(
"Unable to add value node of type %s to parent <%s>!",
1523 else if (mxml_isspace(ch) && type ==
MXML_TEXT)
1531 if (ch ==
'<' && whitespace && type ==
MXML_TEXT)
1557 while ((ch = (*getc_cb)(p, &encoding)) != EOF)
1558 if (mxml_isspace(ch) || ch ==
'>' || (ch ==
'/' && bufptr > buffer))
1567 if ((ch = mxml_get_entity(parent, p, &encoding, getc_cb)) == EOF)
1570 if (mxml_add_char(ch, &bufptr, &buffer, &bufsize))
1573 else if (mxml_add_char(ch, &bufptr, &buffer, &bufsize))
1575 else if (((bufptr - buffer) == 1 && buffer[0] ==
'?') ||
1576 ((bufptr - buffer) == 3 && !strncmp(buffer,
"!--", 3)) ||
1577 ((bufptr - buffer) == 8 && !strncmp(buffer,
"![CDATA[", 8)))
1582 if (!strcmp(buffer,
"!--"))
1588 while ((ch = (*getc_cb)(p, &encoding)) != EOF)
1590 if (ch ==
'>' && bufptr > (buffer + 4) &&
1591 bufptr[-3] !=
'-' && bufptr[-2] ==
'-' && bufptr[-1] ==
'-')
1593 else if (mxml_add_char(ch, &bufptr, &buffer, &bufsize))
1624 mxml_error(
"Unable to add comment node to parent <%s>!",
1640 else if (!strcmp(buffer,
"![CDATA["))
1646 while ((ch = (*getc_cb)(p, &encoding)) != EOF)
1648 if (ch ==
'>' && !strncmp(bufptr - 2,
"]]", 2))
1650 else if (mxml_add_char(ch, &bufptr, &buffer, &bufsize))
1681 mxml_error(
"Unable to add CDATA node to parent <%s>!",
1697 else if (buffer[0] ==
'?')
1703 while ((ch = (*getc_cb)(p, &encoding)) != EOF)
1705 if (ch ==
'>' && bufptr > buffer && bufptr[-1] ==
'?')
1707 else if (mxml_add_char(ch, &bufptr, &buffer, &bufsize))
1721 mxml_error(
"Early EOF in processing instruction node!");
1737 mxml_error(
"Unable to add processing instruction node to parent <%s>!",
1760 type = (*cb)(parent);
1764 else if (buffer[0] ==
'!')
1777 if ((ch = mxml_get_entity(parent, p, &encoding, getc_cb)) == EOF)
1780 if (mxml_add_char(ch, &bufptr, &buffer, &bufsize))
1784 while ((ch = (*getc_cb)(p, &encoding)) != EOF);
1796 mxml_error(
"Early EOF in declaration node!");
1812 mxml_error(
"Unable to add declaration node to parent <%s>!",
1835 type = (*cb)(parent);
1839 else if (buffer[0] ==
'/')
1851 mxml_error(
"Mismatched close tag <%s> under parent <%s>!",
1860 while (ch !=
'>' && ch != EOF)
1861 ch = (*getc_cb)(p, &encoding);
1878 type = (*cb)(parent);
1892 mxml_error(
"Unable to add element node to parent <%s>!",
1897 if (mxml_isspace(ch))
1899 if ((ch = mxml_parse_element(node, p, &encoding, getc_cb)) == EOF)
1904 if ((ch = (*getc_cb)(p, &encoding)) !=
'>')
1906 mxml_error(
"Expected > but got '%c' instead for element <%s/>!",
1933 type = (*cb)(parent);
1952 if ((ch = mxml_get_entity(parent, p, &encoding, getc_cb)) == EOF)
1955 if (mxml_add_char(ch, &bufptr, &buffer, &bufsize))
1964 if (mxml_add_char(ch, &bufptr, &buffer, &bufsize))
1988 mxml_error(
"Missing close tag </%s> under parent <%s>!",
1989 node->value.element.name,
1990 node->parent ? node->parent->value.element.name :
"(null)");
2043 mxml_error(
"Unable to allocate memory for name!");
2052 mxml_error(
"Unable to allocate memory for value!");
2062 while ((ch = (*getc_cb)(p, encoding)) != EOF)
2065 fprintf(stderr,
"parse_element: ch='%c'\n", ch);
2072 if (mxml_isspace(ch))
2079 if (ch ==
'/' || ch ==
'?')
2085 quote = (*getc_cb)(p, encoding);
2089 mxml_error(
"Expected '>' after '%c' for element %s, but got '%c'!",
2111 if (ch ==
'\"' || ch ==
'\'')
2119 while ((ch = (*getc_cb)(p, encoding)) != EOF)
2122 if ((ch = mxml_get_entity(node, p, encoding, getc_cb)) == EOF)
2125 if (mxml_add_char(ch, &ptr, &name, &namesize))
2138 while ((ch = (*getc_cb)(p, encoding)) != EOF)
2139 if (mxml_isspace(ch) || ch ==
'=' || ch ==
'/' || ch ==
'>' ||
2145 if ((ch = mxml_get_entity(node, p, encoding, getc_cb)) == EOF)
2148 if (mxml_add_char(ch, &ptr, &name, &namesize))
2158 while (ch != EOF && mxml_isspace(ch))
2159 ch = (*getc_cb)(p, encoding);
2167 while ((ch = (*getc_cb)(p, encoding)) != EOF && mxml_isspace(ch));
2171 mxml_error(
"Missing value for attribute '%s' in element %s!",
2176 if (ch ==
'\'' || ch ==
'\"')
2185 while ((ch = (*getc_cb)(p, encoding)) != EOF)
2191 if ((ch = mxml_get_entity(node, p, encoding, getc_cb)) == EOF)
2194 if (mxml_add_char(ch, &ptr, &value, &valsize))
2209 while ((ch = (*getc_cb)(p, encoding)) != EOF)
2210 if (mxml_isspace(ch) || ch ==
'=' || ch ==
'/' || ch ==
'>')
2215 if ((ch = mxml_get_entity(node, p, encoding, getc_cb)) == EOF)
2218 if (mxml_add_char(ch, &ptr, &value, &valsize))
2233 mxml_error(
"Missing value for attribute '%s' in element %s!",
2242 if (ch ==
'/' || ch ==
'?')
2248 quote = (*getc_cb)(p, encoding);
2252 mxml_error(
"Expected '>' after '%c' for element %s, but got '%c'!",
2290 mxml_string_getc(
void *p,
2297 s = (
const char **)p;
2313 printf(
"mxml_string_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
2318 mxml_error(
"Bad control character 0x%02x not allowed by XML standard!",
2325 else if (ch == 0xfe)
2331 if (((*s)[0] & 255) != 0xff)
2337 return (mxml_string_getc(p, encoding));
2339 else if (ch == 0xff)
2345 if (((*s)[0] & 255) != 0xfe)
2351 return (mxml_string_getc(p, encoding));
2353 else if ((ch & 0xe0) == 0xc0)
2359 if (((*s)[0] & 0xc0) != 0x80)
2362 ch = ((ch & 0x1f) << 6) | ((*s)[0] & 0x3f);
2368 mxml_error(
"Invalid UTF-8 sequence for character 0x%04x!", ch);
2373 printf(
"mxml_string_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
2378 else if ((ch & 0xf0) == 0xe0)
2384 if (((*s)[0] & 0xc0) != 0x80 ||
2385 ((*s)[1] & 0xc0) != 0x80)
2388 ch = ((((ch & 0x0f) << 6) | ((*s)[0] & 0x3f)) << 6) | ((*s)[1] & 0x3f);
2394 mxml_error(
"Invalid UTF-8 sequence for character 0x%04x!", ch);
2403 return (mxml_string_getc(p, encoding));
2406 printf(
"mxml_string_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
2411 else if ((ch & 0xf8) == 0xf0)
2417 if (((*s)[0] & 0xc0) != 0x80 ||
2418 ((*s)[1] & 0xc0) != 0x80 ||
2419 ((*s)[2] & 0xc0) != 0x80)
2422 ch = ((((((ch & 0x07) << 6) | ((*s)[0] & 0x3f)) << 6) |
2423 ((*s)[1] & 0x3f)) << 6) | ((*s)[2] & 0x3f);
2429 mxml_error(
"Invalid UTF-8 sequence for character 0x%04x!", ch);
2434 printf(
"mxml_string_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
2447 ch = (ch << 8) | ((*s)[0] & 255);
2452 mxml_error(
"Bad control character 0x%02x not allowed by XML standard!",
2456 else if (ch >= 0xd800 && ch <= 0xdbff)
2468 lch = (((*s)[0] & 255) << 8) | ((*s)[1] & 255);
2471 if (lch < 0xdc00 || lch >= 0xdfff)
2474 ch = (((ch & 0x3ff) << 10) | (lch & 0x3ff)) + 0x10000;
2478 printf(
"mxml_string_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
2488 ch = ch | (((*s)[0] & 255) << 8);
2500 mxml_error(
"Bad control character 0x%02x not allowed by XML standard!",
2504 else if (ch >= 0xd800 && ch <= 0xdbff)
2516 lch = (((*s)[1] & 255) << 8) | ((*s)[0] & 255);
2519 if (lch < 0xdc00 || lch >= 0xdfff)
2522 ch = (((ch & 0x3ff) << 10) | (lch & 0x3ff)) + 0x10000;
2526 printf(
"mxml_string_getc: %c (0x%04x)\n", ch <
' ' ?
'.' : ch, ch);
2542 mxml_string_putc(
int ch,
2564 mxml_write_name(
const char *s,
2566 int (*putc_cb)(
int,
void *))
2573 if (*s ==
'\"' || *s ==
'\'')
2579 if ((*putc_cb)(*s, p) < 0)
2584 while (*s && *s != quote)
2588 if ((*putc_cb)(
'&', p) < 0)
2593 if ((*putc_cb)(*name, p) < 0)
2599 if ((*putc_cb)(
';', p) < 0)
2602 else if ((*putc_cb)(*s, p) < 0)
2612 if ((*putc_cb)(quote, p) < 0)
2623 if ((*putc_cb)(*s, p) < 0)
2652 while (node != NULL)
2663 if ((*putc_cb)(
'<', p) < 0)
2678 if ((*putc_cb)(*ptr, p) < 0)
2690 width = (int)strlen(attr->
name);
2693 width += (int)strlen(attr->
value) + 3;
2695 if (global->
wrap > 0 && (col + width) > global->
wrap)
2697 if ((*putc_cb)(
'\n', p) < 0)
2704 if ((*putc_cb)(
' ', p) < 0)
2710 if (mxml_write_name(attr->
name, p, putc_cb) < 0)
2715 if ((*putc_cb)(
'=', p) < 0)
2717 if ((*putc_cb)(
'\"', p) < 0)
2719 if (mxml_write_string(attr->
value, p, putc_cb) < 0)
2721 if ((*putc_cb)(
'\"', p) < 0)
2734 if ((*putc_cb)(
'>', p) < 0)
2741 if ((col = mxml_write_node(node->
child, p, cb, col, putc_cb,
2754 if ((*putc_cb)(
'<', p) < 0)
2756 if ((*putc_cb)(
'/', p) < 0)
2760 if ((*putc_cb)(
'>', p) < 0)
2775 if ((*putc_cb)(
'>', p) < 0)
2784 if ((*putc_cb)(
' ', p) < 0)
2786 if ((*putc_cb)(
'/', p) < 0)
2788 if ((*putc_cb)(
'>', p) < 0)
2800 if (global->
wrap > 0 && col > global->
wrap)
2802 if ((*putc_cb)(
'\n', p) < 0)
2807 else if ((*putc_cb)(
' ', p) < 0)
2814 if (mxml_write_string(s, p, putc_cb) < 0)
2817 col += (int)strlen(s);
2821 if (mxml_write_string(node->
value.
opaque, p, putc_cb) < 0)
2830 if (global->
wrap > 0 && col > global->
wrap)
2832 if ((*putc_cb)(
'\n', p) < 0)
2837 else if ((*putc_cb)(
' ', p) < 0)
2844 if (mxml_write_string(s, p, putc_cb) < 0)
2847 col += (int)strlen(s);
2853 if (global->
wrap > 0 && col > global->
wrap)
2855 if ((*putc_cb)(
'\n', p) < 0)
2860 else if ((*putc_cb)(
' ', p) < 0)
2876 const char *newline;
2882 if (mxml_write_string(data, p, putc_cb) < 0)
2885 if ((newline = strrchr(data,
'\n')) == NULL)
2886 col += (int)strlen(data);
2888 col = (int)strlen(newline);
2926 if ((*putc_cb)(
'&', p) < 0)
2931 if ((*putc_cb)(*name, p) < 0)
2936 if ((*putc_cb)(
';', p) < 0)
2939 else if ((*putc_cb)(*s, p) < 0)
2964 if (cb && (s = (*cb)(node, ws)) != NULL)
2968 if ((*putc_cb)(*s, p) < 0)
2970 else if (*s ==
'\n')
2972 else if (*s ==
'\t')