From owner-svn-src-all@freebsd.org Tue May 16 18:41:49 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C4FB0D70B61; Tue, 16 May 2017 18:41:49 +0000 (UTC) (envelope-from phil@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 081E31306; Tue, 16 May 2017 18:41:48 +0000 (UTC) (envelope-from phil@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4GIfbNV069577; Tue, 16 May 2017 18:41:37 GMT (envelope-from phil@FreeBSD.org) Received: (from phil@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4GIfblf069573; Tue, 16 May 2017 18:41:37 GMT (envelope-from phil@FreeBSD.org) Message-Id: <201705161841.v4GIfblf069573@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: phil set sender to phil@FreeBSD.org using -f From: Phil Shafer Date: Tue, 16 May 2017 18:41:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r318361 - in vendor/Juniper/libxo/dist: . doc libxo tests/core tests/core/saved tests/gettext tests/gettext/po/pig_latin tests/gettext/saved xo X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 May 2017 18:41:49 -0000 Author: phil Date: Tue May 16 18:41:36 2017 New Revision: 318361 URL: https://svnweb.freebsd.org/changeset/base/318361 Log: Import libxo 0.7.2 Added: vendor/Juniper/libxo/dist/libxo/xo_options.7 (contents, props changed) Modified: vendor/Juniper/libxo/dist/configure.ac vendor/Juniper/libxo/dist/doc/Makefile.am vendor/Juniper/libxo/dist/doc/libxo-manual.html vendor/Juniper/libxo/dist/doc/libxo.txt vendor/Juniper/libxo/dist/libxo/Makefile.am vendor/Juniper/libxo/dist/libxo/libxo.c vendor/Juniper/libxo/dist/libxo/xo.h vendor/Juniper/libxo/dist/libxo/xo_buf.h vendor/Juniper/libxo/dist/libxo/xo_encoder.c vendor/Juniper/libxo/dist/libxo/xo_format.5 vendor/Juniper/libxo/dist/libxo/xo_syslog.c vendor/Juniper/libxo/dist/tests/core/saved/test_01.E.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.J.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.JP.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.X.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.XP.out vendor/Juniper/libxo/dist/tests/core/saved/test_10.X.out vendor/Juniper/libxo/dist/tests/core/saved/test_10.XP.out vendor/Juniper/libxo/dist/tests/core/saved/test_11.X.out vendor/Juniper/libxo/dist/tests/core/saved/test_11.XP.out vendor/Juniper/libxo/dist/tests/core/test_01.c vendor/Juniper/libxo/dist/tests/gettext/po/pig_latin/strerror.po vendor/Juniper/libxo/dist/tests/gettext/saved/gt_01.J.out vendor/Juniper/libxo/dist/tests/gettext/saved/gt_01.JP.out vendor/Juniper/libxo/dist/tests/gettext/strerror.pot vendor/Juniper/libxo/dist/xo/xo.c Modified: vendor/Juniper/libxo/dist/configure.ac ============================================================================== --- vendor/Juniper/libxo/dist/configure.ac Tue May 16 18:39:23 2017 (r318360) +++ vendor/Juniper/libxo/dist/configure.ac Tue May 16 18:41:36 2017 (r318361) @@ -12,7 +12,7 @@ # AC_PREREQ(2.2) -AC_INIT([libxo], [0.6.3], [phil@juniper.net]) +AC_INIT([libxo], [0.7.2], [phil@juniper.net]) AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability]) # Support silent build rules. Requires at least automake-1.11. @@ -20,7 +20,6 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_PROG_CC -AM_PROG_AR AC_PROG_INSTALL AC_CONFIG_MACRO_DIR([m4]) AC_PROG_LN_S @@ -135,6 +134,21 @@ if test "$GETTEXT_ENABLE" != "no"; then AC_MSG_RESULT([$HAVE_GETTEXT]) fi + + if test "$HAVE_GETTEXT" != "yes"; then + GETTEXT_PREFIX=/usr/local + AC_MSG_CHECKING([gettext in ${GETTEXT_PREFIX}]) + + _save_cflags="$CFLAGS" + CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror -lintl" + AC_LINK_IFELSE([AC_LANG_SOURCE([[#include ] + [int main() {char *cp = dgettext(NULL, "xx"); return 0; }]])], + [HAVE_GETTEXT=yes], + [HAVE_GETTEXT=no]) + CFLAGS="$_save_cflags" + + AC_MSG_RESULT([$HAVE_GETTEXT]) + fi fi if test "$HAVE_GETTEXT" = "yes"; then @@ -278,6 +292,13 @@ AC_ARG_ENABLE([debug], AC_MSG_RESULT([$LIBXO_DEBUG]) AM_CONDITIONAL([LIBXO_DEBUG], [test "$LIBXO_DEBUG" != "no"]) +AC_MSG_CHECKING([whether to use int return codes]) +AC_ARG_ENABLE([int-return-codes], + [ --enable-int-return-codes Use int return codes (instead of ssize_t)], + [USE_INT_RETURN_CODES=yes; AC_DEFINE([USE_INT_RETURN_CODES], [1], [Use int return codes])], + [USE_INT_RETURN_CODES=no]) +AC_MSG_RESULT([$USE_INT_RETURN_CODES]) + AC_MSG_CHECKING([whether to build with text-only rendering]) AC_ARG_ENABLE([text-only], [ --enable-text-only Turn on text-only rendering], Modified: vendor/Juniper/libxo/dist/doc/Makefile.am ============================================================================== --- vendor/Juniper/libxo/dist/doc/Makefile.am Tue May 16 18:39:23 2017 (r318360) +++ vendor/Juniper/libxo/dist/doc/Makefile.am Tue May 16 18:41:36 2017 (r318361) @@ -61,9 +61,9 @@ xolint.txt: ${top_srcdir}/xolint/xolint. CLEANFILES = \ xolint.txt \ ${INPUT}.xml \ -${INPUT}.txt \ ${INPUT}.fxml \ -${INPUT}.html +${OUTPUT}.txt \ +${OUTPUT}.html else doc docs: @${ECHO} "The 'oxtradoc' tool is not installed; see libslax.org" Modified: vendor/Juniper/libxo/dist/doc/libxo-manual.html ============================================================================== --- vendor/Juniper/libxo/dist/doc/libxo-manual.html Tue May 16 18:39:23 2017 (r318360) +++ vendor/Juniper/libxo/dist/doc/libxo-manual.html Tue May 16 18:41:36 2017 (r318361) @@ -515,7 +515,7 @@ li.indline1 { } @top-right { - content: "May 2016"; + content: "May 2017"; } @top-center { @@ -22009,7 +22009,7 @@ jQuery(function ($) { -May 28, 2016 +May 15, 2017

libxo: The Easy Way to Generate text, XML, JSON, and HTML output
libxo-manual

@@ -22271,36 +22271,40 @@ jQuery(function ($) {
  • 3.1.4   
    -xo_set_style @@ -23879,7 +23883,7 @@ jQuery(function ($) {

    For strings, the 'h' and 'l' modifiers affect the interpretation of the bytes pointed to argument. The default '%s' string is a 'char *' pointer to a string encoded as UTF-8. Since UTF-8 is compatible with ASCII data, a normal 7-bit ASCII string can be used. '%ls' expects a 'wchar_t *' pointer to a wide-character string, encoded as a 32-bit Unicode values. '%hs' expects a 'char *' pointer to a multi-byte string encoded with the current locale, as given by the LC_CTYPE, LANG, or LC_ALL environment varibles. The first of this list of variables is used and if none of the variables are set, the locale defaults to "UTF‑8".

    libxo will convert these arguments as needed to either UTF-8 (for XML, JSON, and HTML styles) or locale-based strings for display in text style.

    -   xo_emit("Alll strings are utf-8 content {:tag/%ls}",
    +   xo_emit("All strings are utf-8 content {:tag/%ls}",
                L"except for wide strings");
     	    

    "%S" is equivalent to "%ls".

    @@ -24316,6 +24320,14 @@ jQuery(function ($) { + + + + + + + + @@ -24377,7 +24389,7 @@ jQuery(function ($) { - + @@ -24402,6 +24414,19 @@ jQuery(function ($) {
    Enable "Do The Right Thing" mode
    flushFlush after every libxo function call
    flush-lineFlush after every line (line-buffered)
    html Emit HTML output
    underscoresReplace XML-friendly "-"s with JSON friendly "_"s eReplace XML-friendly "-"s with JSON friendly "_"s
    units

    The brief options are detailed in Section 3.4.6.

    +

    Most of these option are simple and direct, but some require additional details:

    +

    +
      +
    • "flush‑line" performs line buffering, even when the output is not directed to a TTY device.
    • +
    • "info" generates additional data for HTML, encoded in attributes using names that state with "data‑".
    • +
    • "keys" adds a "key" attribute for XML output to indicate that a leaf is an identifier for the list member.
    • +
    • "no‑humanize"avoids "humanizing" numeric output (see humanize_number(3) for details).
    • +
    • "no‑locale" instructs libxo to avoid translating output to the current locale.
    • +
    • "no‑retain" disables the ability of libxo to internally retain "compiled" information about formatting strings.
    • +
    • "underscores" can be used with JSON output to change XML-friendly names with dashes into JSON-friendly name with underscores.
    • +
    • "warn" allows libxo to emit warnings on stderr when application code make incorrect calls.
    • +
    • "warn‑xml" causes those warnings to be placed in XML inside the output.
    • +

    @@ -24443,8 +24468,9 @@ jQuery(function ($) {
  • Section 3.1.2
  • Section 3.1.3
  • Section 3.1.4
  • -
  • Section 3.1.5
  • -
  • Section 3.1.6
  • +
  • Section 3.1.5
  • +
  • Section 3.1.6
  • +
  • Section 3.1.7
  • @@ -24460,7 +24486,7 @@ jQuery(function ($) { xo_handle_t *xop = xo_create(XO_STYLE_JSON, XOF_WARN); .... xo_emit_h(xop, "testing\n"); -

    See also Section 3.1.4.1 and Section 3.1.5.1.

    +

    See also Section 3.1.5.1 and Section 3.1.6.1.

    @@ -24499,18 +24525,31 @@ jQuery(function ($) {

    To use the default handle, pass a NULL handle:

         xo_set_style(NULL, XO_STYLE_XML);
    -	    

    Section Contents:

    +

    +
    +

    +
    +3.1.5 
    +xo_get_style +

    +

    To find the current style, use the xo_get_style() function:

    +
    +    xo_style_t xo_get_style(xo_handle_t *xop);
    +	    

    To use the default handle, pass a NULL handle:

    +
    +    style = xo_get_style(NULL);
    +	    

    Section Contents:

    -

    +

    +3.1.5.1 

    Output Styles (XO_STYLE_*) -

    The libxo functions accept a set of output styles:

    +

    The libxo functions accept a set of output styles:

    @@ -24537,45 +24576,45 @@ jQuery(function ($) {
    Flag
    -

    +

    +3.1.5.2 

    xo_set_style_name -

    The xo_set_style_name() can be used to set the style based on a name encoded as a string:

    -
    +

    The xo_set_style_name() can be used to set the style based on a name encoded as a string:

    +
         int xo_set_style_name (xo_handle_t *xop, const char *style);
    -	    

    The name can be any of the styles: "text", "xml", "json", or "html".

    -
    +	    

    The name can be any of the styles: "text", "xml", "json", or "html".

    +
         EXAMPLE:
             xo_set_style_name(NULL, "html");
     	    
    -

    +

    -3.1.5 
    +3.1.6 

    xo_set_flags -

    To set the flags, use the xo_set_flags() function:

    -
    +

    To set the flags, use the xo_set_flags() function:

    +
         void xo_set_flags(xo_handle_t *xop, unsigned flags);
    -	    

    To use the default handle, pass a NULL handle:

    -
    +	    

    To use the default handle, pass a NULL handle:

    +
         xo_set_style(NULL, XO_STYLE_XML);
    -	    

    Section Contents:

    +

    Section Contents:

    -

    +

    +3.1.6.1 

    Flags (XOF_*) -

    The set of valid flags include:

    +

    The set of valid flags include:

    @@ -24648,12 +24687,12 @@ jQuery(function ($) {
    Flag
    -

    The XOF_CLOSE_FP flag will trigger the call of the close_func (provided via xo_set_writer()) when the handle is destroyed.

    -

    The XOF_COLOR flag enables color and effects in output regardless of output device, while the XOF_COLOR_ALLOWED flag allows color and effects only if the output device is a terminal.

    -

    The XOF_PRETTY flag requests 'pretty printing', which will trigger the addition of indentation and newlines to enhance the readability of XML, JSON, and HTML output. Text output is not affected.

    -

    The XOF_WARN flag requests that warnings will trigger diagnostic output (on standard error) when the library notices errors during operations, or with arguments to functions. Without warnings enabled, such conditions are ignored.

    -

    Warnings allow developers to debug their interaction with libxo. The function "xo_failure" can used as a breakpoint for a debugger, regardless of whether warnings are enabled.

    -

    If the style is XO_STYLE_HTML, the following additional flags can be used:

    +

    The XOF_CLOSE_FP flag will trigger the call of the close_func (provided via xo_set_writer()) when the handle is destroyed.

    +

    The XOF_COLOR flag enables color and effects in output regardless of output device, while the XOF_COLOR_ALLOWED flag allows color and effects only if the output device is a terminal.

    +

    The XOF_PRETTY flag requests 'pretty printing', which will trigger the addition of indentation and newlines to enhance the readability of XML, JSON, and HTML output. Text output is not affected.

    +

    The XOF_WARN flag requests that warnings will trigger diagnostic output (on standard error) when the library notices errors during operations, or with arguments to functions. Without warnings enabled, such conditions are ignored.

    +

    Warnings allow developers to debug their interaction with libxo. The function "xo_failure" can used as a breakpoint for a debugger, regardless of whether warnings are enabled.

    +

    If the style is XO_STYLE_HTML, the following additional flags can be used:

    @@ -24670,9 +24709,9 @@ jQuery(function ($) {
    Flag
    -

    The XOF_XPATH flag enables the emission of XPath expressions detailing the hierarchy of XML elements used to encode the data field, if the XPATH style of output were requested.

    -

    The XOF_INFO flag encodes additional informational fields for HTML output. See Section 3.4.4 for details.

    -

    If the style is XO_STYLE_XML, the following additional flags can be used:

    +

    The XOF_XPATH flag enables the emission of XPath expressions detailing the hierarchy of XML elements used to encode the data field, if the XPATH style of output were requested.

    +

    The XOF_INFO flag encodes additional informational fields for HTML output. See Section 3.4.4 for details.

    +

    If the style is XO_STYLE_XML, the following additional flags can be used:

    @@ -24683,43 +24722,43 @@ jQuery(function ($) {
    FlagFlag 'key' fields for xml
    -

    The XOF_KEYS flag adds 'key' attribute to the XML encoding for field definitions that use the 'k' modifier. The key attribute has the value "key":

    -
    +

    The XOF_KEYS flag adds 'key' attribute to the XML encoding for field definitions that use the 'k' modifier. The key attribute has the value "key":

    +
         xo_emit("{k:name}", item);
     
       XML:
           <name key="key">truck</name>
     	    
    -

    +

    +3.1.6.2 

    xo_clear_flags -

    The xo_clear_flags() function turns off the given flags in a specific handle.

    -
    +

    The xo_clear_flags() function turns off the given flags in a specific handle.

    +
         void xo_clear_flags (xo_handle_t *xop, xo_xof_flags_t flags);
     	    
    -

    +

    +3.1.6.3 

    xo_set_options -

    The xo_set_options() function accepts a comma-separated list of styles and flags and enables them for a specific handle.

    -
    +

    The xo_set_options() function accepts a comma-separated list of styles and flags and enables them for a specific handle.

    +
         int xo_set_options (xo_handle_t *xop, const char *input);
    -	    

    The options are identical to those listed in Section 2.4.

    +

    The options are identical to those listed in Section 2.4.

    -

    +

    -3.1.6 
    +3.1.7 

    xo_destroy -

    The xo_destroy function releases a handle and any resources it is using. Calling xo_destroy with a NULL handle will release any resources associated with the default handle.

    -
    +

    The xo_destroy function releases a handle and any resources it is using. Calling xo_destroy with a NULL handle will release any resources associated with the default handle.

    +
         void xo_destroy(xo_handle_t *xop);
     	    
    @@ -24730,7 +24769,7 @@ jQuery(function ($) { Emitting Content (xo_emit)

    The following functions are used to emit output:

    -
    +
         int xo_emit (const char *fmt, ...);
         int xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
         int xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap);
    @@ -24750,7 +24789,7 @@ jQuery(function ($) {
     Single Field Emitting Functions (xo_emit_field)
     
     

    The following functions can also make output, but only make a single field at a time:

    -
    +
         int xo_emit_field_hv (xo_handle_t *xop, const char *rolmod,
                       const char *contents, const char *fmt, 
                       const char *efmt, va_list vap);
    @@ -24762,7 +24801,7 @@ jQuery(function ($) {
         int xo_emit_field (const char *rolmod, const char *contents,
                      const char *fmt, const char *efmt, ...);
     	    

    These functions are intended to avoid the scenario where one would otherwise need to compose a format descriptors using snprintf(). The individual parts of the format descriptor are passed in distinctly.

    -
    +
         xo_emit("T", "Host name is ", NULL, NULL);
         xo_emit("V", "host-name", NULL, NULL, host-name);
     	    
    @@ -24773,14 +24812,14 @@ jQuery(function ($) { Attributes (xo_attr)

    The xo_attr() function emits attributes for the XML output style.

    -
    +
         int xo_attr (const char *name, const char *fmt, ...);
         int xo_attr_h (xo_handle_t *xop, const char *name, 
                        const char *fmt, ...);
         int xo_attr_hv (xo_handle_t *xop, const char *name, 
                        const char *fmt, va_list vap);
     	    

    The name parameter give the name of the attribute to be encoded. The fmt parameter gives a printf-style format string used to format the value of the attribute using any remaining arguments, or the vap parameter passed to xo_attr_hv().

    -
    +
         EXAMPLE:
           xo_attr("seconds", "%ld", (unsigned long) login_time);
           struct tm *tmp = localtime(login_time);
    @@ -24798,7 +24837,7 @@ jQuery(function ($) {
     Flushing Output (xo_flush)
     
     

    libxo buffers data, both for performance and consistency, but also to allow some advanced features to work properly. At various times, the caller may wish to flush any data buffered within the library. The xo_flush() call is used for this:

    -
    +
         void xo_flush (void);
         void xo_flush_h (xo_handle_t *xop);
     	    

    Calling xo_flush also triggers the flush function associated with the handle. For the default handle, this is equivalent to "fflush(stdio);".

    @@ -24810,7 +24849,7 @@ jQuery(function ($) { Finishing Output (xo_finish)

    When the program is ready to exit or close a handle, a call to xo_finish() is required. This flushes any buffered data, closes open libxo constructs, and completes any pending operations.

    -
    +
         int xo_finish (void);
         int xo_finish_h (xo_handle_t *xop);
         void xo_finish_atexit (void);
    @@ -24826,7 +24865,7 @@ jQuery(function ($) {
     
     

    libxo represents to types of hierarchy: containers and lists. A container appears once under a given parent where a list contains instances that can appear multiple times. A container is used to hold related fields and to give the data organization and scope.

    To create a container, use the xo_open_container and xo_close_container functions:

    -
    +
         int xo_open_container (const char *name);
         int xo_open_container_h (xo_handle_t *xop, const char *name);
         int xo_open_container_hd (xo_handle_t *xop, const char *name);
    @@ -24840,7 +24879,7 @@ jQuery(function ($) {
     

    The close functions with the "_d" suffix are used in "Do The Right Thing" mode, where the name of the open containers, lists, and instances are maintained internally by libxo to allow the caller to avoid keeping track of the open container name.

    Use the XOF_WARN flag to generate a warning if the name given on the close does not match the current open container.

    For TEXT and HTML output, containers are not rendered into output text, though for HTML they are used when the XOF_XPATH flag is set.

    -
    +
         EXAMPLE:
            xo_open_container("system");
            xo_emit("The host name is {:host-name}\n", hn);
    @@ -24857,7 +24896,7 @@ jQuery(function ($) {
     
     

    Lists are sequences of instances of homogeneous data objects. Two distinct levels of calls are needed to represent them in our output styles. Calls must be made to open and close a list, and for each instance of data in that list, calls must be make to open and close that instance.

    The name given to all calls must be identical, and it is strongly suggested that the name be singular, not plural, as a matter of style and usage expectations.

    -
    +
         EXAMPLE:
             xo_open_list("user");
             for (i = 0; i < num_users; i++) {
    @@ -24926,7 +24965,7 @@ jQuery(function ($) {
     Parsing Command-line Arguments (xo_parse_args)
     
     

    The xo_parse_args() function is used to process a program's arguments. libxo-specific options are processed and removed from the argument list so the calling application does not need to process them. If successful, a new value for argc is returned. On failure, a message it emitted and -1 is returned.

    -
    +
         argc = xo_parse_args(argc, argv);
         if (argc < 0)
             exit(EXIT_FAILURE);
    @@ -24939,7 +24978,7 @@ jQuery(function ($) {
     xo_set_program
     
     

    The xo_set_program function sets name of the program as reported by functions like xo_failure, xo_warn, xo_err, etc. The program name is initialized by xo_parse_args, but subsequent calls to xo_set_program can override this value.

    -
    +
         xo_set_program(argv[0]);
     	    

    Note that the value is not copied, so the memory passed to xo_set_program (and xo_parse_args) must be maintained by the caller.

    @@ -24950,7 +24989,7 @@ jQuery(function ($) { xo_set_version

    The xo_set_version function records a version number to be emitted as part of the data for encoding styles (XML and JSON). This version number is suitable for tracking changes in the content, allowing a user of the data to discern which version of the data model is in use.

    -
    +
          void xo_set_version (const char *version);
          void xo_set_version_h (xo_handle_t *xop, const char *version);
     	    
    @@ -24963,7 +25002,7 @@ jQuery(function ($) {

    HTML data can include additional information in attributes that begin with "data‑". To enable this, three things must occur:

    First the application must build an array of xo_info_t structures, one per tag. The array must be sorted by name, since libxo uses a binary search to find the entry that matches names from format instructions.

    Second, the application must inform libxo about this information using the xo_set_info() call:

    -
    +
         typedef struct xo_info_s {
             const char *xi_name;    /* Name of the element */
             const char *xi_type;    /* Type of field */
    @@ -24973,7 +25012,7 @@ jQuery(function ($) {
         void xo_set_info (xo_handle_t *xop, xo_info_t *infop, int count);
     	    

    Like other libxo calls, passing NULL for the handle tells libxo to use the default handle.

    If the count is -1, libxo will count the elements of infop, but there must be an empty element at the end. More typically, the number is known to the application:

    -
    +
         xo_info_t info[] = {
             { "in-stock", "number", "Number of items in stock" },
             { "name", "string", "Name of the item" },
    @@ -24986,7 +25025,7 @@ jQuery(function ($) {
         xo_set_info(NULL, info, info_count);
     	    

    Third, the emission of info must be triggered with the XOF_INFO flag using either the xo_set_flags() function or the "‑‑libxo=info" command line argument.

    The type and help values, if present, are emitted as the "data‑type" and "data‑help" attributes:

    -
    +
       <div class="data" data-tag="sku" data-type="string" 
            data-help="Stock Keeping Unit">GRO-000-533</div>
     	    
    @@ -24997,7 +25036,7 @@ jQuery(function ($) { Memory Allocation

    The xo_set_allocator function allows libxo to be used in environments where the standard realloc() and free() functions are not available.

    -
    +
         void xo_set_allocator (xo_realloc_func_t realloc_func,
                                xo_free_func_t free_func);
     	    

    realloc_func should expect the same arguments as realloc(3) and return a pointer to memory following the same convention. free_func will receive the same argument as free(3) and should release it, as appropriate for the environment.

    @@ -25079,10 +25118,10 @@ jQuery(function ($) {

    For example, warnings can be enabled by:

    -
    +
         % env LIBXO_OPTIONS=W my-app
     	    

    Complete HTML output can be generated with:

    -
    +
         % env LIBXO_OPTIONS=HXI my-app
     	    

    Since environment variables are inherited, child processes will have the same options, which may be undesirable, making the use of the "‑‑libxo" option is preferable in most situations.

    @@ -25093,7 +25132,7 @@ jQuery(function ($) { Errors, Warnings, and Messages

    Many programs make use of the standard library functions err() and warn() to generate errors and warnings for the user. libxo wants to pass that information via the current output style, and provides compatible functions to allow this:

    -
    +
         void xo_warn (const char *fmt, ...);
         void xo_warnx (const char *fmt, ...);
         void xo_warn_c (int code, const char *fmt, ...);
    @@ -25109,7 +25148,7 @@ jQuery(function ($) {
         void xo_message_hcv (xo_handle_t *xop, int code, 
                              const char *fmt, va_list vap);
     	    

    These functions display the program name, a colon, a formatted message based on the arguments, and then optionally a colon and an error message associated with either "errno" or the "code" parameter.

    -
    +
         EXAMPLE:
             if (open(filename, O_RDONLY) < 0)
                 xo_err(1, "cannot open file '%s'", filename);
    @@ -25121,7 +25160,7 @@ jQuery(function ($) {
     xo_error
     
     

    The xo_error function can be used for generic errors that should be reported over the handle, rather than to stderr. The xo_error function behaves like xo_err for TEXT and HTML output styles, but puts the error into XML or JSON elements:

    -
    +
         EXAMPLE::
             xo_error("Does not %s", "compute");
         XML::
    @@ -25136,7 +25175,7 @@ jQuery(function ($) {
     xo_no_setlocale
     
     

    libxo automatically initializes the locale based on setting of the environment variables LC_CTYPE, LANG, and LC_ALL. The first of this list of variables is used and if none of the variables, the locale defaults to "UTF‑8". The caller may wish to avoid this behavior, and can do so by calling the xo_no_setlocale() function.

    -
    +
         void xo_no_setlocale (void);
     	    
    @@ -25152,7 +25191,7 @@ jQuery(function ($) {

    https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers

    Use the Section 3.5.3.5() function to set the Enterprise ID, as needed.

    The message name should follow the conventions in Section 8.1.3, as should the fields within the message.

    -
    +
         /* Both of these calls are optional */
         xo_set_syslog_enterprise_id(32473);
         xo_open_log("my-program", 0, LOG_DAEMON);
    @@ -25180,7 +25219,7 @@ jQuery(function ($) {
     Priority, Facility, and Flags
     
     

    The xo_syslog, xo_vsyslog, and xo_open_log functions accept a set of flags which provide the priority of the message, the source facility, and some additional features. These values are OR'd together to create a single integer argument:

    -
    +
         xo_syslog(LOG_ERR | LOG_AUTH, "login-failed",
                  "Login failed; user '{:user}' from host '{:address}'",
                  user, addr);
    @@ -25325,7 +25364,7 @@ jQuery(function ($) {
     
     

    Use the xo_syslog function to generate syslog messages by calling it with a log priority and facility, a message name, a format string, and a set of arguments. The priority/facility argument are discussed above, as is the message name.

    The format string follows the same conventions as xo_emit's format string, with each field being rendered as an SD-PARAM pair.

    -
    +
         xo_syslog(LOG_ERR, "poofd-missing-file",
                   "'{:filename}' not found: {:error/%m}", filename);
     
    @@ -25354,7 +25393,7 @@ jQuery(function ($) {
     xo_vsyslog
     
     

    xo_vsyslog is identical in function to xo_syslog, but takes the set of arguments using a va_list.

    -
    +
         void my_log (const char *name, const char *fmt, ...)
         {
             va_list vap;
    @@ -25370,7 +25409,7 @@ jQuery(function ($) {
     xo_open_log
     
     

    xo_open_log functions similar to openlog(3), allowing customization of the program name, the log facility number, and the additional option flags described in Section 3.5.1.

    -
    +
         void
         xo_open_log (const char *ident, int logopt, int facility);
     	    
    @@ -25381,7 +25420,7 @@ jQuery(function ($) { xo_close_log

    xo_close_log functions similar to closelog(3), closing the log file and releasing any associated resources.

    -
    +
         void
         xo_close_log (void);
     	    
    @@ -25392,7 +25431,7 @@ jQuery(function ($) { xo_set_logmask

    xo_set_logmask function similar to setlogmask(3), restricting the set of generated log event to those whose associated bit is set in maskpri. Use LOG_MASK(pri) to find the appropriate bit, or LOG_UPTO(toppri) to create a mask for all priorities up to and including toppri.

    -
    +
         int
         xo_set_logmask (int maskpri);
     
    @@ -25407,7 +25446,7 @@ jQuery(function ($) {
     
     

    Use the xo_set_syslog_enterprise_id to supply a platform- or application-specific enterprise id. This value is used in any future syslog messages.

    Ideally, the operating system should supply a default value via the "kern.syslog.enterprise_id" sysctl value. Lacking that, the application should provide a suitable value.

    -
    +
         void
         xo_set_syslog_enterprise_id (unsigned short eid);
     	    

    Enterprise IDs are administered by IANA, the Internet Assigned Number Authority. The complete list is EIDs on their web site:

    @@ -25449,7 +25488,7 @@ jQuery(function ($) { Loading Encoders

    Encoders can be registered statically or discovered dynamically. Applications can choose to call the xo_encoder_register() function to explicitly register encoders, but more typically they are built as shared libraries, placed in the libxo/extensions directory, and loaded based on name. libxo looks for a file with the name of the encoder and an extension of ".enc". This can be a file or a symlink to the shared library file that supports the encoder.

    -
    +
         % ls -1 lib/libxo/extensions/*.enc
         lib/libxo/extensions/cbor.enc
         lib/libxo/extensions/test.enc
    @@ -25461,7 +25500,7 @@ jQuery(function ($) {
     Encoder Initialization
     
     

    Each encoder must export a symbol used to access the library, which must have the following signature:

    -
    +
         int xo_encoder_library_init (XO_ENCODER_INIT_ARGS);
     	    

    XO_ENCODER_INIT_ARGS is a macro defined in xo_encoder.h that defines an argument called "arg", a pointer of the type xo_encoder_init_args_t. This structure contains two fields:

    @@ -25566,7 +25605,7 @@ jQuery(function ($) {

    The "xo" utility allows command line access to the functionality of the libxo library. Using "xo", shell scripts can emit XML, JSON, and HTML using the same commands that emit text output.

    The style of output can be selected using a specific option: "‑X" for XML, "‑J" for JSON, "‑H" for HTML, or "‑T" for TEXT, which is the default. The "--style <style>" option can also be used. The LIBXO_OPTIONS environment variable can also be used to set the style, as well as other flags.

    The "xo" utility accepts a format string suitable for xo_emit() and a set of zero or more arguments used to supply data for that string.

    -
    +
         xo "The {k:name} weighs {:weight/%d} pounds.\n" fish 6
     
       TEXT:
    @@ -25586,7 +25625,7 @@ jQuery(function ($) {
           <div class="text"> pounds.</div>
         </div>
     	    

    The "--wrap <path>" option can be used to wrap emitted content in a specific hierarchy. The path is a set of hierarchical names separated by the '/' character.

    -
    +
         xo --wrap top/a/b/c '{:tag}' value
     
       XML:
    @@ -25610,7 +25649,7 @@ jQuery(function ($) {
           }
         }
     	    

    The "--open <path>" and "--close <path>" can be used to emit hierarchical information without the matching close and open tag. This allows a shell script to emit open tags, data, and then close tags. The "‑‑depth" option may be used to set the depth for indentation. The "‑‑leading‑xpath" may be used to prepend data to the XPath values used for HTML output style.

    -
    +
         #!/bin/sh
         xo --open top/data
         xo --depth 2 '{tag}' value
    @@ -25639,7 +25678,7 @@ jQuery(function ($) {
     Command Line Options
     
     

    Usage: xo [options] format [fields]

    -
    +
       --close <path>        Close tags for the given path
       --depth <num>         Set the depth for pretty printing
       --help                Display this help text
    @@ -25663,7 +25702,7 @@ jQuery(function ($) {
     4.2 
     Example
     
    -
    +
       % xo 'The {:product} is {:status}\n' stereo "in route"
       The stereo is in route
       % ./xo/xo -p -X 'The {:product} is {:status}\n' stereo "in route"
    @@ -25721,7 +25760,7 @@ jQuery(function ($) {
     
     
     

    The output message will contain the source filename and line number, the class of the message, the message, and, if -p is given, the line that contains the error:

    -
    +
         % xolint.pl -t xolint.c
         xolint.c: 16: error: anchor format should be "%d"
         16         xo_emit("{[:/%s}");
    @@ -25789,7 +25828,7 @@ jQuery(function ($) {
     
     
     
    -
    +
         EXAMPLE:
             % xopo -s "There are {:count/%u} {:event/%.6s} events\n"
             There are {:count} {:event} events\n
    @@ -25848,7 +25887,7 @@ jQuery(function ($) {
     Did the complex semantics of format strings evolve over time?
     
     

    The history is both long and short: libxo's functionality is based on what JUNOS does in a data modeling language called ODL (output definition language). In JUNOS, all subcomponents generate XML, which is feed to the CLI, where data from the ODL files tell is how to render that XML into text. ODL might had a set of tags like:

    -
    +
          tag docsis-state {
              help "State of the DOCSIS interface";
              type string;
    @@ -25927,7 +25966,7 @@ jQuery(function ($) {
     
    Reuse existing field names
    Nothing's worse than writing expressions like:
    -
    +
         if ($src1/process[pid == $pid]/name == 
             $src2/proc-table/proc-list
                        /proc-entry[process-id == $pid]/proc-name) {
    @@ -25988,10 +26027,10 @@ jQuery(function ($) {
     'A percent sign appearing in text is a literal'
     
     

    The message "A percent sign appearing in text is a literal" can be caused by code like:

    -
    +
         xo_emit("cost: %d", cost);
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{L:cost}: {:cost/%d}", cost);
     	    

    This can be a bit surprising and could be a field that was not properly converted to a libxo-style format string.

    @@ -26002,10 +26041,10 @@ jQuery(function ($) { 'Unknown long name for role/modifier'

    The message "Unknown long name for role/modifier" can be caused by code like:

    -
    +
         xo_emit("{,humanization:value}", value);
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{,humanize:value}", value);
     	    

    The hn-* modifiers (hn-decimal, hn-space, hn-1000) are only valid for fields with the {h:} modifier.

    @@ -26017,10 +26056,10 @@ jQuery(function ($) {

    The message "Last character before field definition is a field type" can be caused by code like:

    A common typo:

    -
    +
         xo_emit("{T:Min} T{:Max}");
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{T:Min} {T:Max}");
     	    

    Twiddling the "{" and the field role is a common typo.

    @@ -26031,10 +26070,10 @@ jQuery(function ($) { 'Encoding format uses different number of arguments'

    The message "Encoding format uses different number of arguments" can be caused by code like:

    -
    +
         xo_emit("{:name/%6.6s %%04d/%s}", name, number);
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{:name/%6.6s %04d/%s-%d}", name, number);
     	    

    Both format should consume the same number of arguments off the stack

    @@ -26045,10 +26084,10 @@ jQuery(function ($) { 'Only one field role can be used'

    The message "Only one field role can be used" can be caused by code like:

    -
    +
         xo_emit("{LT:Max}");
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{T:Max}");
     	    
    @@ -26058,10 +26097,10 @@ jQuery(function ($) { 'Potential missing slash after C, D, N, L, or T with format'

    The message "Potential missing slash after C, D, N, L, or T with format" can be caused by code like:

    -
    +
         xo_emit("{T:%6.6s}\n", "Max");
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{T:/%6.6s}\n", "Max");
     	    

    The "%6.6s" will be a literal, not a field format. While it's possibly valid, it's likely a missing "/".

    @@ -26072,7 +26111,7 @@ jQuery(function ($) { 'An encoding format cannot be given (roles: DNLT)'

    The message "An encoding format cannot be given (roles: DNLT)" can be caused by code like:

    -
    +
         xo_emit("{T:Max//%s}", "Max");
     	    

    Fields with the C, D, N, L, and T roles are not emitted in the 'encoding' style (JSON, XML), so an encoding format would make no sense.

    @@ -26083,7 +26122,7 @@ jQuery(function ($) { 'Format cannot be given when content is present (roles: CDLN)'

    The message "Format cannot be given when content is present (roles: CDLN)" can be caused by code like:

    -
    +
         xo_emit("{N:Max/%6.6s}", "Max");
     	    

    Fields with the C, D, L, or N roles can't have both static literal content ("{L:Label}") and a format ("{L:/%s}"). This error will also occur when the content has a backslash in it, like "{N:Type of I/O}"; backslashes should be escaped, like "{N:Type of I\\/O}". Note the double backslash, one for handling 'C' strings, and one for libxo.

    @@ -26094,10 +26133,10 @@ jQuery(function ($) { 'Field has color without fg- or bg- (role: C)'

    The message "Field has color without fg- or bg- (role: C)" can be caused by code like:

    -
    +
         xo_emit("{C:green}{:foo}{C:}", x);
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{C:fg-green}{:foo}{C:}", x);
     	    

    Colors must be prefixed by either "fg‑" or "bg‑".

    @@ -26108,10 +26147,10 @@ jQuery(function ($) { 'Field has invalid color or effect (role: C)'

    The message "Field has invalid color or effect (role: C)" can be caused by code like:

    -
    +
         xo_emit("{C:fg-purple,bold}{:foo}{C:gween}", x);
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{C:fg-red,bold}{:foo}{C:fg-green}", x);
     	    

    The list of colors and effects are limited. The set of colors includes default, black, red, green, yellow, blue, magenta, cyan, and white, which must be prefixed by either "fg‑" or "bg‑". Effects are limited to bold, no-bold, underline, no-underline, inverse, no-inverse, normal, and reset. Values must be separated by commas.

    @@ -26122,10 +26161,10 @@ jQuery(function ($) { 'Field has humanize modifier but no format string'

    The message "Field has humanize modifier but no format string" can be caused by code like:

    -
    +
         xo_emit("{h:value}", value);
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{h:value/%d}", value);
     	    

    Humanization is only value for numbers, which are not likely to use the default format ("%s").

    @@ -26136,10 +26175,10 @@ jQuery(function ($) { 'Field has hn-* modifier but not 'h' modifier'

    The message "Field has hn-* modifier but not 'h' modifier" can be caused by code like:

    -
    +
         xo_emit("{,hn-1000:value}", value);
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{h,hn-1000:value}", value);
     	    

    The hn-* modifiers (hn-decimal, hn-space, hn-1000) are only valid for fields with the {h:} modifier.

    @@ -26150,10 +26189,10 @@ jQuery(function ($) { 'Value field must have a name (as content)")'

    The message "Value field must have a name (as content)")" can be caused by code like:

    -
    +
         xo_emit("{:/%s}", "value");
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{:tag-name/%s}", "value");
     	    

    The field name is used for XML and JSON encodings. These tags names are static and must appear directly in the field descriptor.

    @@ -26164,10 +26203,10 @@ jQuery(function ($) { 'Use hyphens, not underscores, for value field name'

    The message "Use hyphens, not underscores, for value field name" can be caused by code like:

    -
    +
         xo_emit("{:no_under_scores}", "bad");
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{:no-under-scores}", "bad");
     	    

    Use of hyphens is traditional in XML, and the XOF_UNDERSCORES flag can be used to generate underscores in JSON, if desired. But the raw field name should use hyphens.

    @@ -26178,10 +26217,10 @@ jQuery(function ($) { 'Value field name cannot start with digit'

    The message "Value field name cannot start with digit" can be caused by code like:

    -
    +
         xo_emit("{:10-gig/}");
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{:ten-gig/}");
     	    

    XML element names cannot start with a digit.

    @@ -26192,10 +26231,10 @@ jQuery(function ($) { 'Value field name should be lower case'

    The message "Value field name should be lower case" can be caused by code like:

    -
    +
         xo_emit("{:WHY-ARE-YOU-SHOUTING}", "NO REASON");
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{:why-are-you-shouting}", "no reason");
     	    

    Lower case is more civilized. Even TLAs should be lower case to avoid scenarios where the differences between "XPath" and "Xpath" drive your users crazy. Lower case rules the seas.

    @@ -26206,10 +26245,10 @@ jQuery(function ($) { 'Value field name should be longer than two characters'

    The message "Value field name should be longer than two characters" can be caused by code like:

    -
    +
         xo_emit("{:x}", "mumble");
     	    

    This code should be replaced with code like:

    -
    +
         xo_emit("{:something-meaningful}", "mumble");
     	    

    Field names should be descriptive, and it's hard to be descriptive in less than two characters. Consider your users and try to make something more useful. Note that this error often occurs when the field type is placed after the colon ("{:T/%20s}"), instead of before it ("{T:/20s}").

    @@ -26220,10 +26259,10 @@ jQuery(function ($) { 'Value field name contains invalid character'

    The message "Value field name contains invalid character" can be caused by code like:

    -
    +
         xo_emit("{:cost-in-$$/%u}", 15);
     	    

    This code should be replaced with code like:

    -
    
    *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***