summaryrefslogtreecommitdiffstats
path: root/man.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-25 15:17:49 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-25 15:17:49 +0000
commit12bf2f26f8d476960eba07e14e64fd26661da3b3 (patch)
treeb759d2d2e7467b1cffc89fb98e9d6e4ccb5bdbed /man.c
parent4b4e799e741ce5040d46930f13430debab688774 (diff)
downloadmandoc-12bf2f26f8d476960eba07e14e64fd26661da3b3.tar.gz
Added man validator, renamed mdoc validator.
Diffstat (limited to 'man.c')
-rw-r--r--man.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/man.c b/man.c
index e66315c6..27976280 100644
--- a/man.c
+++ b/man.c
@@ -83,7 +83,7 @@ man_free(struct man *man)
struct man *
-man_alloc(void)
+man_alloc(void *data, const struct man_cb *cb)
{
struct man *p;
@@ -93,7 +93,11 @@ man_alloc(void)
man_alloc1(p);
+ if (cb)
+ (void)memcpy(&p->cb, cb, sizeof(struct man_cb));
+
p->htab = man_hash_alloc();
+ p->data = data;
return(p);
}
@@ -175,8 +179,6 @@ man_node_append(struct man *man, struct man_node *p)
}
#if 0
- if ( ! man_valid_pre(man, p))
- return(0);
if ( ! man_action_pre(man, p))
return(0);
#endif
@@ -185,9 +187,9 @@ man_node_append(struct man *man, struct man_node *p)
switch (p->type) {
case (MAN_TEXT):
-#if 0
if ( ! man_valid_post(man))
return(0);
+#if 0
if ( ! man_action_post(man))
return(0);
#endif
@@ -339,3 +341,36 @@ err: /* Error out. */
return(0);
}
+
+int
+man_verr(struct man *man, int ln, int pos, const char *fmt, ...)
+{
+ char buf[256];
+ va_list ap;
+
+ if (NULL == man->cb.man_err)
+ return(0);
+
+ va_start(ap, fmt);
+ (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
+ va_end(ap);
+ return((*man->cb.man_err)(man->data, ln, pos, buf));
+}
+
+
+int
+man_vwarn(struct man *man, int ln, int pos, const char *fmt, ...)
+{
+ char buf[256];
+ va_list ap;
+
+ if (NULL == man->cb.man_warn)
+ return(0);
+
+ va_start(ap, fmt);
+ (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
+ va_end(ap);
+ return((*man->cb.man_warn)(man->data, ln, pos, buf));
+}
+
+