From 3238820d08da942be84ccab704e810b0f6d8bcf4 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Mon, 24 Nov 2008 14:24:55 +0000 Subject: Split roff engine into roff.c. Re-worked calling convention for md_*. --- dummy.c | 55 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 13 deletions(-) (limited to 'dummy.c') diff --git a/dummy.c b/dummy.c index 808d2b9f..7e9cfdf2 100644 --- a/dummy.c +++ b/dummy.c @@ -17,28 +17,57 @@ * PERFORMANCE OF THIS SOFTWARE. */ #include +#include #include #include "libmdocml.h" #include "private.h" +struct md_dummy { + struct rofftree *tree; +}; + + +int +md_line_dummy(void *arg, char *buf, size_t sz) +{ + struct md_dummy *p; + + p = (struct md_dummy *)arg; + return(roff_engine(p->tree, buf, sz)); +} + + int -md_line_dummy(const struct md_args *args, - struct md_mbuf *out, const struct md_rbuf *in, - char *buf, size_t sz, void *data) +md_exit_dummy(void *data, int flush) +{ + int c; + struct md_dummy *p; + + p = (struct md_dummy *)data; + c = roff_free(p->tree, flush); + free(p); + + return(c); +} + + +void * +md_init_dummy(const struct md_args *args, + struct md_mbuf *mbuf, const struct md_rbuf *rbuf) { + struct md_dummy *p; - assert(buf); - assert(out); - assert(in); - assert(args); - assert(NULL == data); + if (NULL == (p = malloc(sizeof(struct md_dummy)))) { + warn("malloc"); + return(NULL); + } - if ( ! md_buf_puts(out, buf, sz)) - return(0); - if ( ! md_buf_putchar(out, '\n')) - return(0); + if (NULL == (p->tree = roff_alloc(args, mbuf, rbuf))) { + free(p); + return(NULL); + } - return(1); + return(p); } -- cgit