From: Eric S. Raymond Date: Fri, 26 Sep 2014 19:36:00 +0000 (-0400) Subject: ADD a man page. X-Git-Tag: 1.2~4^2 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=cc05239821a8e1981c1b75c2fa883b5214b8b377;p=microjson.git ADD a man page. --- diff --git a/Makefile b/Makefile index b95ce5f..110974f 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,13 @@ mjson.o: mjson.c mjson.h 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 @@ -47,5 +49,5 @@ microjson-$(VERSION).tar.gz: $(ALL) 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 diff --git a/mjson.asc b/mjson.asc new file mode 100644 index 0000000..e8e1ab8 --- /dev/null +++ b/mjson.asc @@ -0,0 +1,54 @@ += 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 . The project page is +at http://catb.org/~esr/microjson +