diff options
Diffstat (limited to 'xml.c')
-rw-r--r-- | xml.c | 87 |
1 files changed, 34 insertions, 53 deletions
@@ -26,38 +26,27 @@ static int xml_alloc(void **); static void xml_free(void *); -static ssize_t xml_endtag(struct md_mbuf *, void *, - const struct md_args *, - enum md_ns, int); -static ssize_t xml_begintag(struct md_mbuf *, void *, - const struct md_args *, - enum md_ns, int, - const int *, const char **); -static ssize_t xml_beginstring(struct md_mbuf *, - const struct md_args *, +static ssize_t xml_beginstring(struct ml_args *, const char *, size_t); -static ssize_t xml_endstring(struct md_mbuf *, - const struct md_args *, +static ssize_t xml_endstring(struct ml_args *, const char *, size_t); -static int xml_begin(struct md_mbuf *, - const struct md_args *, - const struct tm *, +static int xml_begin(struct ml_args *, const struct tm *, const char *, const char *, enum roffmsec, enum roffvol); -static int xml_end(struct md_mbuf *, - const struct md_args *, - const struct tm *, +static int xml_end(struct ml_args *, const struct tm *, const char *, const char *, enum roffmsec, enum roffvol); -static ssize_t xml_printtagname(struct md_mbuf *, +static ssize_t xml_printtagname(struct ml_args *, enum md_ns, int); -static ssize_t xml_printtagargs(struct md_mbuf *, +static ssize_t xml_printtagargs(struct ml_args *, + const int *, const char **); +static ssize_t xml_endtag(struct ml_args *, enum md_ns, int); +static ssize_t xml_begintag(struct ml_args *, enum md_ns, int, const int *, const char **); static ssize_t -xml_printtagargs(struct md_mbuf *mbuf, const int *argc, - const char **argv) +xml_printtagargs(struct ml_args *p, const int *argc, const char **argv) { int i, c; size_t res; @@ -68,21 +57,21 @@ xml_printtagargs(struct md_mbuf *mbuf, const int *argc, /* LINTED */ for (res = 0, i = 0; ROFF_ARGMAX != (c = argc[i]); i++) { - if ( ! ml_nputs(mbuf, " ", 1, &res)) + if ( ! ml_nputs(p->mbuf, " ", 1, &res)) return(-1); /* FIXME: should puke on some, no? */ - if ( ! ml_puts(mbuf, tokargnames[c], &res)) + if ( ! ml_puts(p->mbuf, tokargnames[c], &res)) return(-1); - if ( ! ml_nputs(mbuf, "=\"", 2, &res)) + if ( ! ml_nputs(p->mbuf, "=\"", 2, &res)) return(-1); if (argv[i]) { - if ( ! ml_putstring(mbuf, argv[i], &res)) + if ( ! ml_putstring(p->mbuf, argv[i], &res)) return(-1); - } else if ( ! ml_nputs(mbuf, "true", 4, &res)) + } else if ( ! ml_nputs(p->mbuf, "true", 4, &res)) return(-1); - if ( ! ml_nputs(mbuf, "\"", 1, &res)) + if ( ! ml_nputs(p->mbuf, "\"", 1, &res)) return(-1); } @@ -91,33 +80,33 @@ xml_printtagargs(struct md_mbuf *mbuf, const int *argc, static ssize_t -xml_printtagname(struct md_mbuf *mbuf, enum md_ns ns, int tok) +xml_printtagname(struct ml_args *p, enum md_ns ns, int tok) { size_t res; res = 0; switch (ns) { case (MD_NS_BLOCK): - if ( ! ml_nputs(mbuf, "block:", 6, &res)) + if ( ! ml_nputs(p->mbuf, "block:", 6, &res)) return(-1); break; case (MD_NS_INLINE): - if ( ! ml_nputs(mbuf, "inline:", 7, &res)) + if ( ! ml_nputs(p->mbuf, "inline:", 7, &res)) return(-1); break; case (MD_NS_BODY): - if ( ! ml_nputs(mbuf, "body:", 5, &res)) + if ( ! ml_nputs(p->mbuf, "body:", 5, &res)) return(-1); break; case (MD_NS_HEAD): - if ( ! ml_nputs(mbuf, "head:", 5, &res)) + if ( ! ml_nputs(p->mbuf, "head:", 5, &res)) return(-1); break; default: break; } - if ( ! ml_puts(mbuf, toknames[tok], &res)) + if ( ! ml_puts(p->mbuf, toknames[tok], &res)) return(-1); return((ssize_t)res); } @@ -125,15 +114,14 @@ xml_printtagname(struct md_mbuf *mbuf, enum md_ns ns, int tok) /* ARGSUSED */ static int -xml_begin(struct md_mbuf *mbuf, const struct md_args *args, - const struct tm *tm, const char *os, +xml_begin(struct ml_args *p, const struct tm *tm, const char *os, const char *title, enum roffmsec sec, enum roffvol vol) { - if ( ! ml_puts(mbuf, "<?xml version=\"1.0\" " + if ( ! ml_puts(p->mbuf, "<?xml version=\"1.0\" " "encoding=\"UTF-8\"?>\n", NULL)) return(0); - return(ml_puts(mbuf, "<mdoc xmlns:block=\"block\" " + return(ml_puts(p->mbuf, "<mdoc xmlns:block=\"block\" " "xmlns:body=\"body\" " "xmlns:head=\"head\" " "xmlns:inline=\"inline\">", NULL)); @@ -142,20 +130,17 @@ xml_begin(struct md_mbuf *mbuf, const struct md_args *args, /* ARGSUSED */ static int -xml_end(struct md_mbuf *mbuf, const struct md_args *args, - const struct tm *tm, const char *os, +xml_end(struct ml_args *p, const struct tm *tm, const char *os, const char *title, enum roffmsec sec, enum roffvol vol) { - return(ml_puts(mbuf, "</mdoc>", NULL)); + return(ml_puts(p->mbuf, "</mdoc>", NULL)); } /* ARGSUSED */ static ssize_t -xml_beginstring(struct md_mbuf *mbuf, - const struct md_args *args, - const char *buf, size_t sz) +xml_beginstring(struct ml_args *p, const char *buf, size_t sz) { return(0); @@ -164,9 +149,7 @@ xml_beginstring(struct md_mbuf *mbuf, /* ARGSUSED */ static ssize_t -xml_endstring(struct md_mbuf *mbuf, - const struct md_args *args, - const char *buf, size_t sz) +xml_endstring(struct ml_args *p, const char *buf, size_t sz) { return(0); @@ -175,15 +158,14 @@ xml_endstring(struct md_mbuf *mbuf, /* ARGSUSED */ static ssize_t -xml_begintag(struct md_mbuf *mbuf, void *data, - const struct md_args *args, enum md_ns ns, +xml_begintag(struct ml_args *p, enum md_ns ns, int tok, const int *argc, const char **argv) { ssize_t res, sz; - if (-1 == (res = xml_printtagname(mbuf, ns, tok))) + if (-1 == (res = xml_printtagname(p, ns, tok))) return(-1); - if (-1 == (sz = xml_printtagargs(mbuf, argc, argv))) + if (-1 == (sz = xml_printtagargs(p, argc, argv))) return(-1); return(res + sz); } @@ -191,11 +173,10 @@ xml_begintag(struct md_mbuf *mbuf, void *data, /* ARGSUSED */ static ssize_t -xml_endtag(struct md_mbuf *mbuf, void *data, - const struct md_args *args, enum md_ns ns, int tok) +xml_endtag(struct ml_args *p, enum md_ns ns, int tok) { - return(xml_printtagname(mbuf, ns, tok)); + return(xml_printtagname(p, ns, tok)); } |