version 1.4, 2008/11/24 18:32:39 |
version 1.5, 2008/11/25 12:14:02 |
|
|
#include "libmdocml.h" |
#include "libmdocml.h" |
#include "private.h" |
#include "private.h" |
|
|
|
#ifdef __Linux__ |
|
#define strlcat strncat |
|
#endif |
|
|
static roffin in[ROFF_MAX]; |
static int md_dummy_blk_in(int); |
static roffout out[ROFF_MAX]; |
static int md_dummy_blk_out(int); |
static roffblkin blkin[ROFF_MAX]; |
static int md_dummy_text_in(int, int *, char **); |
static roffblkout blkout[ROFF_MAX]; |
static int md_dummy_text_out(int); |
|
|
static int md_dummy_blk_in(int); |
static void dbg_indent(void); |
static int md_dummy_blk_out(int); |
|
static int md_dummy_text_in(int, int *, char **); |
|
static int md_dummy_text_out(int); |
|
|
|
static void dbg_indent(void); |
static int dbg_lvl = 0; |
|
|
static int dbg_lvl = 0; |
|
|
|
struct md_dummy { |
struct md_dummy { |
struct rofftree *tree; |
struct rofftree *tree; |
}; |
}; |
|
|
|
static const char *const toknames[ROFF_MAX] = ROFF_NAMES; |
|
|
|
|
static void |
static void |
dbg_indent(void) |
dbg_indent(void) |
{ |
{ |
|
|
|
|
*buf = 0; |
*buf = 0; |
assert(dbg_lvl >= 0); |
assert(dbg_lvl >= 0); |
|
|
|
/* LINTED */ |
for (i = 0; i < dbg_lvl; i++) |
for (i = 0; i < dbg_lvl; i++) |
(void)strncat(buf, " ", sizeof(buf) - 1); |
(void)strlcat(buf, " ", sizeof(buf) - 1); |
|
|
(void)printf("%s", buf); |
(void)printf("%s", buf); |
} |
} |
Line 65 md_dummy_blk_in(int tok) |
|
Line 67 md_dummy_blk_in(int tok) |
|
{ |
{ |
|
|
dbg_indent(); |
dbg_indent(); |
(void)printf("+++blk\n"); |
(void)printf("%s\n", toknames[tok]); |
dbg_lvl++; |
dbg_lvl++; |
return(1); |
return(1); |
} |
} |
Line 78 md_dummy_blk_out(int tok) |
|
Line 80 md_dummy_blk_out(int tok) |
|
assert(dbg_lvl > 0); |
assert(dbg_lvl > 0); |
dbg_lvl--; |
dbg_lvl--; |
dbg_indent(); |
dbg_indent(); |
(void)printf("---blk\n"); |
(void)printf("%s\n", toknames[tok]); |
return(1); |
return(1); |
} |
} |
|
|
|
|
|
/* ARGSUSED */ |
static int |
static int |
md_dummy_text_in(int tok, int *argcp, char **argvp) |
md_dummy_text_in(int tok, int *argcp, char **argvp) |
{ |
{ |
|
|
dbg_indent(); |
dbg_indent(); |
(void)printf("in: text\n"); |
(void)printf("%s\n", toknames[tok]); |
return(1); |
return(1); |
} |
} |
|
|
Line 98 md_dummy_text_out(int tok) |
|
Line 101 md_dummy_text_out(int tok) |
|
{ |
{ |
|
|
dbg_indent(); |
dbg_indent(); |
(void)printf("out: text\n"); |
(void)printf("%s\n", toknames[tok]); |
return(1); |
return(1); |
} |
} |
|
|
Line 132 md_init_dummy(const struct md_args *args, |
|
Line 135 md_init_dummy(const struct md_args *args, |
|
struct md_mbuf *mbuf, const struct md_rbuf *rbuf) |
struct md_mbuf *mbuf, const struct md_rbuf *rbuf) |
{ |
{ |
struct md_dummy *p; |
struct md_dummy *p; |
int i; |
|
|
|
for (i = 0; i < ROFF_MAX; i++) { |
|
in[i] = md_dummy_text_in; |
|
out[i] = md_dummy_text_out; |
|
blkin[i] = md_dummy_blk_in; |
|
blkout[i] = md_dummy_blk_out; |
|
} |
|
|
|
if (NULL == (p = malloc(sizeof(struct md_dummy)))) { |
if (NULL == (p = malloc(sizeof(struct md_dummy)))) { |
warn("malloc"); |
warn("malloc"); |
return(NULL); |
return(NULL); |
} |
} |
|
|
p->tree = roff_alloc |
p->tree = roff_alloc(args, mbuf, rbuf, |
(args, mbuf, rbuf, in, out, blkin, blkout); |
md_dummy_text_in, md_dummy_text_out, |
|
md_dummy_blk_in, md_dummy_blk_out); |
|
|
if (NULL == p->tree) { |
if (NULL == p->tree) { |
free(p); |
free(p); |