-.\" $Id: mandoc.3,v 1.28 2014/11/26 21:40:17 schwarze Exp $
+.\" $Id: mandoc.3,v 1.31 2015/01/15 04:26:40 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
-.\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2010, 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 26 2014 $
+.Dd $Mdocdate: January 15 2015 $
.Dt MANDOC 3
.Os
.Sh NAME
.Nm mparse_strlevel
.Nm mparse_wait ,
.Nd mandoc macro compiler library
-.Sh LIBRARY
-.Lb libmandoc
.Sh SYNOPSIS
.In sys/types.h
.In mandoc.h
+.Pp
.Fd "#define ASCII_NBRSP"
.Fd "#define ASCII_HYPH"
.Fd "#define ASCII_BREAK"
and
.Fn mparse_alloc ;
.It
-parse files or file descriptors with
+open a file with
+.Xr open 2
+or
+.Fn mparse_open ;
+.It
+parse it with
.Fn mparse_readfd ;
.It
-retrieve a parsed syntax tree, if the parse was successful, with
+retrieve the syntax tree with
.Fn mparse_result ;
.It
iterate over parse nodes with
.Ss Types
.Bl -ohang
.It Vt "enum mandocerr"
-A fatal error, error, or warning message during parsing.
+An error or warning message during parsing.
.It Vt "enum mandoclevel"
A classification of an
.Vt "enum mandocerr"
.Fn mparse_reset
is called between parses.
.It Vt "mandocmsg"
-A prototype for a function to handle fatal error, error, and warning
+A prototype for a function to handle error and warning
messages emitted by the parser.
.El
.Ss Functions
to quickly build minimal databases.
.It Ar wlevel
Can be set to
-.Dv MANDOCLEVEL_FATAL ,
+.Dv MANDOCLEVEL_BADARG ,
.Dv MANDOCLEVEL_ERROR ,
or
.Dv MANDOCLEVEL_WARNING .
.Xr gunzip 1 ;
otherwise, with
.Xr open 2 .
+If
+.Xr open 2
+fails, append
+.Pa .gz
+and try with
+.Xr gunzip 1 .
Return a file descriptor open for reading in
.Fa fd ,
or -1 on failure.
implemented in
.Pa read.c .
.It Fn mparse_readfd
-Parse a file or file descriptor.
-If
-.Va fd
-is -1,
-.Va fname
-is opened for reading.
-Otherwise,
-.Va fname
-is assumed to be the name associated with
-.Va fd .
-This may be called multiple times with different parameters; however,
+Parse a file descriptor opened with
+.Xr open 2
+or
+.Fn mparse_open .
+Pass the associated filename in
+.Va fname .
+Calls
+.Fn mparse_wait
+before returning.
+This function may be called multiple times with different parameters; however,
.Fn mparse_reset
should be invoked between parses.
Declared in
.Pa read.c .
.It Fn mparse_result
Obtain the result of a parse.
-Only successful parses
-.Po
-i.e., those where
-.Fn mparse_readfd
-returned less than MANDOCLEVEL_FATAL
-.Pc
-should invoke this function, in which case one of the three pointers will
-be filled in.
+One of the three pointers will be filled in.
Declared in
.In mandoc.h ,
implemented in
.It Fn mparse_wait
Bury a
.Xr gunzip 1
-child process
-.Fa child_pid
-that was spawned with
+child process that was spawned with
.Fn mparse_open .
To be called after the parse sequence is complete.
+Not needed after
+.Fn mparse_readfd ,
+but does no harm in that case, either.
Returns
.Dv MANDOCLEVEL_OK
on success and