summaryrefslogtreecommitdiffstatshomepage
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
commitaee6df6eb688c812a34d9a363dda978f06095003 (patch)
treed99bb9b2ce6d25b71e560347d01dc9525953ad4b /man.c
parente0c48e25273aab3cab4440442865955afff07b02 (diff)
downloadmandoc-aee6df6eb688c812a34d9a363dda978f06095003.tar.gz
mandoc-aee6df6eb688c812a34d9a363dda978f06095003.tar.zst
mandoc-aee6df6eb688c812a34d9a363dda978f06095003.zip
Added man validator, renamed mdoc validator.
Diffstat (limited to 'man.c')
-rw-r--r--man.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/man.c b/man.c
index 86dc3e4f..c00fd6eb 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.3 2009/03/23 15:41:09 kristaps Exp $ */
+/* $Id: man.c,v 1.4 2009/03/25 15:17:49 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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));
+}
+
+