version 1.10, 2008/12/03 14:39:59 |
version 1.15, 2008/12/05 17:43:14 |
|
|
#include "ml.h" |
#include "ml.h" |
|
|
|
|
static ssize_t xml_endtag(struct md_mbuf *, |
static ssize_t xml_endtag(struct md_mbuf *, void *, |
const struct md_args *, |
const struct md_args *, |
enum md_ns, int); |
enum md_ns, int); |
static ssize_t xml_begintag(struct md_mbuf *, |
static ssize_t xml_begintag(struct md_mbuf *, void *, |
const struct md_args *, |
const struct md_args *, |
enum md_ns, int, |
enum md_ns, int, |
const int *, const char **); |
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, "<?xml version=\"1.0\" " |
|
"encoding=\"UTF-8\"?>\n", &res)) |
|
return(0); |
|
if ( ! ml_puts(mbuf, "<mdoc xmlns:block=\"block\" " |
|
"xmlns:special=\"special\" " |
|
"xmlns:inline=\"inline\">", &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, "</mdoc>", &res)) |
|
return(0); |
|
|
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
static ssize_t |
static ssize_t |
xml_begintag(struct md_mbuf *mbuf, const struct md_args *args, |
xml_begintag(struct md_mbuf *mbuf, void *data, |
enum md_ns ns, int tok, |
const struct md_args *args, enum md_ns ns, |
const int *argc, const char **argv) |
int tok, const int *argc, const char **argv) |
{ |
{ |
size_t res; |
size_t res; |
|
|
|
/* FIXME: doesn't print arguments! */ |
|
|
res = 0; |
res = 0; |
|
|
switch (ns) { |
switch (ns) { |
Line 46 xml_begintag(struct md_mbuf *mbuf, const struct md_arg |
|
Line 92 xml_begintag(struct md_mbuf *mbuf, const struct md_arg |
|
if ( ! ml_nputs(mbuf, "block:", 6, &res)) |
if ( ! ml_nputs(mbuf, "block:", 6, &res)) |
return(-1); |
return(-1); |
break; |
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): |
case (MD_NS_INLINE): |
if ( ! ml_nputs(mbuf, "inline:", 7, &res)) |
if ( ! ml_nputs(mbuf, "inline:", 7, &res)) |
return(-1); |
return(-1); |
break; |
break; |
default: |
default: |
if ( ! ml_nputs(mbuf, "mbuf", 4, &res)) |
break; |
return(-1); |
|
return((ssize_t)res); |
|
} |
} |
|
|
if ( ! ml_nputs(mbuf, toknames[tok], |
if ( ! ml_puts(mbuf, toknames[tok], &res)) |
strlen(toknames[tok]), &res)) |
|
return(-1); |
return(-1); |
|
|
return((ssize_t)res); |
return((ssize_t)res); |
} |
} |
|
|
|
|
|
/* ARGSUSED */ |
static ssize_t |
static ssize_t |
xml_endtag(struct md_mbuf *mbuf, const struct md_args *args, |
xml_endtag(struct md_mbuf *mbuf, void *data, |
enum md_ns ns, int tok) |
const struct md_args *args, enum md_ns ns, int tok) |
{ |
{ |
size_t res; |
size_t res; |
|
|
Line 81 xml_endtag(struct md_mbuf *mbuf, const struct md_args |
|
Line 133 xml_endtag(struct md_mbuf *mbuf, const struct md_args |
|
if ( ! ml_nputs(mbuf, "inline:", 7, &res)) |
if ( ! ml_nputs(mbuf, "inline:", 7, &res)) |
return(-1); |
return(-1); |
break; |
break; |
default: |
case (MD_NS_BODY): |
if ( ! ml_nputs(mbuf, "mbuf", 4, &res)) |
if ( ! ml_nputs(mbuf, "body:", 5, &res)) |
return(-1); |
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], |
if ( ! ml_puts(mbuf, toknames[tok], &res)) |
strlen(toknames[tok]), &res)) |
|
return(-1); |
return(-1); |
|
|
return((ssize_t)res); |
return((ssize_t)res); |
Line 116 md_init_xml(const struct md_args *args, |
|
Line 173 md_init_xml(const struct md_args *args, |
|
struct md_mbuf *mbuf, const struct md_rbuf *rbuf) |
struct md_mbuf *mbuf, const struct md_rbuf *rbuf) |
{ |
{ |
|
|
return(mlg_alloc(args, rbuf, mbuf, xml_begintag, xml_endtag)); |
return(mlg_alloc(args, NULL, rbuf, mbuf, xml_begintag, |
|
xml_endtag, xml_begin, xml_end)); |
} |
} |
|
|