test_microjson: test_microjson.o mjson.o
$(CC) $(CFLAGS) -o test_microjson test_microjson.o mjson.o
-.SUFFIXES: .html .asc
+.SUFFIXES: .html .asc .3
# Requires asciidoc and xsltproc/docbook stylesheets.
.asc.html:
asciidoc $*.asc
+.asc.3:
+ a2x --doctype manpage --format manpage $*.asc
# Regression test
check: test_microjson
dist: microjson-$(VERSION).tar.gz
-release: microjson-$(VERSION).tar.gz microjson.html
+release: microjson-$(VERSION).tar.gz microjson.html mjson.html
shipper version=$(VERSION) | sh -e -x
--- /dev/null
+= mjson(1) =
+:doctype: manpage
+
+== NAME ==
+mjson - fast parse of JSON to fixed-extent C structures
+
+== FUNCTIONS ==
+#include "mjson.h"
+
+int json_read_object(const char *, const struct json_attr_t *, const char **);
+
+int json_read_array(const char *, const struct json_array_t *, const char **);
+
+const char *json_error_string(int);
+
+void json_enable_debug(int, FILE *);
+
+== DESCRIPTION ==
++json_read_object()+ attempts to parse a whole JSON object from the
+buffer pointed at by the first argument. The second argument points
+at an array of template structures describing the expected shape of
+the JSON object (that is, the set of attribute names and their
+expected value types. order-independent) and specifying for each
+attribute a C address where the parsed value should ve deivered.
+The third argument, if non-null, is where a copy of a pointer
+to just past the parsed object is placed.
+
++json_read_object()+ attempts to parse a whole JSON object from the
+buffer pointed at by the first argument. The second argument points
+at a template structure describing the array's elenent type and where
+successive elements are to be placed. The third argument, if non-null,
+is where a copy of a pointer to just past the parsed object is placed.
+
+Objects may contain arrays as attribute values, and an array may be
+composed of JSON objects. These functions mutually recurse as
+required.
+
++void json_enable_debug(int, FILE *)+ enables the generation of trace
+messages to the indicated file pointer while parsing.
+
+For details on how to build template structures, consult the document
+_Building Static JSON Parsers With Microjson_ shipped with the
+distribution.
+
+== RETURN VALUE ==
+
+The two main functions return 0 for success, a nonzero error code for
+failure. The function +json_error_string()+ maps error codes to
+explanatory messages.
+
+== REPORTING BUGS ==
+Report bugs to Eric S. Raymond <esr@thyrsus.com>. The project page is
+at http://catb.org/~esr/microjson
+