summaryrefslogtreecommitdiffstats
path: root/dummy.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2008-11-24 14:24:55 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2008-11-24 14:24:55 +0000
commit3238820d08da942be84ccab704e810b0f6d8bcf4 (patch)
tree95aa8bf9dc7c3dfb08fb8b46d811fabd58008b44 /dummy.c
parenta73f55c2be0ca8e1deeeb05389879a52e46f05d2 (diff)
downloadmandoc-3238820d08da942be84ccab704e810b0f6d8bcf4.tar.gz
Split roff engine into roff.c.
Re-worked calling convention for md_*.
Diffstat (limited to 'dummy.c')
-rw-r--r--dummy.c55
1 files changed, 42 insertions, 13 deletions
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 <assert.h>
+#include <err.h>
#include <stdlib.h>
#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);
}