=================================================================== RCS file: /cvs/mandoc/Attic/xml.c,v retrieving revision 1.10 retrieving revision 1.13 diff -u -p -r1.10 -r1.13 --- mandoc/Attic/xml.c 2008/12/03 14:39:59 1.10 +++ mandoc/Attic/xml.c 2008/12/04 11:25:29 1.13 @@ -1,4 +1,4 @@ -/* $Id: xml.c,v 1.10 2008/12/03 14:39:59 kristaps Exp $ */ +/* $Id: xml.c,v 1.13 2008/12/04 11:25:29 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -31,7 +31,51 @@ static ssize_t xml_begintag(struct md_mbuf *, const struct md_args *, enum md_ns, int, const int *, const char **); +static int xml_begin(struct md_mbuf *, + const struct md_args *, + const struct tm *, + const char *, const char *, + const char *, const char *); +static int xml_end(struct md_mbuf *, + const struct md_args *); + +/* ARGSUSED */ +static int +xml_begin(struct md_mbuf *mbuf, const struct md_args *args, + const struct tm *tm, const char *os, + const char *title, const char *section, + const char *vol) +{ + size_t res; + + if ( ! ml_puts(mbuf, "\n", &res)) + return(0); + if ( ! ml_puts(mbuf, "", &res)) + return(0); + + return(1); +} + + +/* ARGSUSED */ +static int +xml_end(struct md_mbuf *mbuf, const struct md_args *args) +{ + size_t res; + + res = 0; + if ( ! ml_puts(mbuf, "", &res)) + return(0); + + return(1); +} + + +/* ARGSUSED */ static ssize_t xml_begintag(struct md_mbuf *mbuf, const struct md_args *args, enum md_ns ns, int tok, @@ -46,24 +90,30 @@ xml_begintag(struct md_mbuf *mbuf, const struct md_arg if ( ! ml_nputs(mbuf, "block:", 6, &res)) return(-1); break; + case (MD_NS_BODY): + if ( ! ml_nputs(mbuf, "body:", 5, &res)) + return(-1); + break; + case (MD_NS_HEAD): + if ( ! ml_nputs(mbuf, "head:", 5, &res)) + return(-1); + break; case (MD_NS_INLINE): if ( ! ml_nputs(mbuf, "inline:", 7, &res)) return(-1); break; default: - if ( ! ml_nputs(mbuf, "mbuf", 4, &res)) - return(-1); - return((ssize_t)res); + break; } - if ( ! ml_nputs(mbuf, toknames[tok], - strlen(toknames[tok]), &res)) + if ( ! ml_puts(mbuf, toknames[tok], &res)) return(-1); return((ssize_t)res); } +/* ARGSUSED */ static ssize_t xml_endtag(struct md_mbuf *mbuf, const struct md_args *args, enum md_ns ns, int tok) @@ -81,14 +131,19 @@ xml_endtag(struct md_mbuf *mbuf, const struct md_args if ( ! ml_nputs(mbuf, "inline:", 7, &res)) return(-1); break; - default: - if ( ! ml_nputs(mbuf, "mbuf", 4, &res)) + case (MD_NS_BODY): + if ( ! ml_nputs(mbuf, "body:", 5, &res)) return(-1); - return((ssize_t)res); + break; + case (MD_NS_HEAD): + if ( ! ml_nputs(mbuf, "head:", 5, &res)) + return(-1); + break; + default: + break; } - if ( ! ml_nputs(mbuf, toknames[tok], - strlen(toknames[tok]), &res)) + if ( ! ml_puts(mbuf, toknames[tok], &res)) return(-1); return((ssize_t)res); @@ -116,6 +171,7 @@ md_init_xml(const struct md_args *args, struct md_mbuf *mbuf, const struct md_rbuf *rbuf) { - return(mlg_alloc(args, rbuf, mbuf, xml_begintag, xml_endtag)); + return(mlg_alloc(args, rbuf, mbuf, xml_begintag, + xml_endtag, xml_begin, xml_end)); }