Import libxo-0.7.2; add xo_options.7.

Submitted by:	phil
Reviewed by:	sjg
Approved by:	sjg (mentor)
This commit is contained in:
phil 2017-05-16 18:46:56 +00:00
commit ce139526b6
29 changed files with 821 additions and 534 deletions

View File

@ -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 -Wno-portability])
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 <libintl.h>]
[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],

View File

@ -61,9 +61,9 @@ xolint.txt: ${top_srcdir}/xolint/xolint.pl
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"

File diff suppressed because it is too large Load Diff

View File

@ -1070,7 +1070,7 @@ 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".
@ -1464,6 +1464,8 @@ styles, flags, or features:
|-------------+-------------------------------------------------------|
| color | Enable colors/effects for display styles (TEXT, HTML) |
| dtrt | Enable "Do The Right Thing" mode |
| flush | Flush after every libxo function call |
| flush-line | Flush after every line (line-buffered) |
| html | Emit HTML output |
| indent=xx | Set the indentation level |
| info | Add info attributes (HTML) |
@ -1479,7 +1481,7 @@ styles, flags, or features:
| pretty | Emit pretty-printed output |
| retain | Force retaining formatting information |
| text | Emit TEXT output |
| underscores | Replace XML-friendly "-"s with JSON friendly "_"s e |
| underscores | Replace XML-friendly "-"s with JSON friendly "_"s |
| units | Add the 'units' (XML) or 'data-units (HTML) attribute |
| warn | Emit warnings when libxo detects bad calls |
| warn-xml | Emit warnings in XML |
@ -1489,6 +1491,29 @@ styles, flags, or features:
The brief options are detailed in ^LIBXO_OPTIONS^.
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.
* The libxo API
This section gives details about the functions in libxo, how to call
@ -1577,6 +1602,16 @@ To use the default handle, pass a NULL handle:
xo_set_style(NULL, XO_STYLE_XML);
*** 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);
**** Output Styles (XO_STYLE_*) @styles@
The libxo functions accept a set of output styles:
@ -2883,9 +2918,9 @@ which include the following:
Compiler warnings are a very good thing, but recent compiler version
have added some very pedantic checks. While every attempt is made to
keep libxo code warning-free, warnings are now optional. If you are
doing development work on libxo, it is required that you use
--enable-warnings to keep the code warning free, but most users need
not use this option.
doing development work on libxo, it is required that you
use --enable-warnings to keep the code warning free, but most users
need not use this option.
libxo provides the --enable-text-only option to reduce the footprint
of the library for smaller installations. XML, JSON, and HTML

View File

@ -72,7 +72,10 @@ man3_files = \
man5_files = \
xo_format.5
man_MANS = ${man3_files} ${man5_files}
man7_files = \
xo_options.7
man_MANS = ${man3_files} ${man5_files} ${man7_files}
EXTRA_DIST = \
${man_MANS}
@ -87,3 +90,5 @@ install-data-hook:
cat ../libxo/add.man >> ${DESTDIR}${man3dir}/$$file ; done
for file in ${man5_files}; do \
cat ../libxo/add.man >> ${DESTDIR}${man5dir}/$$file ; done
for file in ${man7_files}; do \
cat ../libxo/add.man >> ${DESTDIR}${man7dir}/$$file ; done

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <stdarg.h>
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
@ -39,7 +40,10 @@
* coward's path, we'll turn it on inside a #if that allows
* others to turn it off where needed. Not ideal, but functional.
*/
#if !defined(NO_PRINTFLIKE) && !defined(__linux__)
#if !defined(NO_PRINTFLIKE)
#if defined(__linux) && !defined(__printflike)
#define __printflike(_x, _y) __attribute__((__format__ (__printf__, _x, _y)))
#endif
#define PRINTFLIKE(_x, _y) __printflike(_x, _y)
#else
#define PRINTFLIKE(_x, _y)
@ -115,7 +119,18 @@ typedef struct xo_info_s {
struct xo_handle_s; /* Opaque structure forward */
typedef struct xo_handle_s xo_handle_t; /* Handle for XO output */
typedef int (*xo_write_func_t)(void *, const char *);
/*
* Early versions of the API used "int" instead of "size_t" for buffer
* sizes. We want to fix this but allow for backwards compatibility
* where needed.
*/
#ifdef USE_INT_RETURN_CODES
typedef int xo_ssize_t; /* Buffer size */
#else /* USE_INT_RETURN_CODES */
typedef ssize_t xo_ssize_t; /* Buffer size */
#endif /* USE_INT_RETURN_CODES */
typedef xo_ssize_t (*xo_write_func_t)(void *, const char *);
typedef void (*xo_close_func_t)(void *);
typedef int (*xo_flush_func_t)(void *);
typedef void *(*xo_realloc_func_t)(void *, size_t);
@ -126,7 +141,7 @@ typedef void (*xo_free_func_t)(void *);
* of the xo handle. The caller should return the number of bytes _needed_
* to fit the data, even if this exceeds 'len'.
*/
typedef int (*xo_formatter_t)(xo_handle_t *, char *, int,
typedef xo_ssize_t (*xo_formatter_t)(xo_handle_t *, char *, xo_ssize_t,
const char *, va_list);
typedef void (*xo_checkpointer_t)(xo_handle_t *, va_list, int);
@ -182,23 +197,23 @@ xo_set_formatter (xo_handle_t *xop, xo_formatter_t func, xo_checkpointer_t);
void
xo_set_depth (xo_handle_t *xop, int depth);
int
xo_ssize_t
xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap);
int
xo_ssize_t
xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
int
xo_ssize_t
xo_emit (const char *fmt, ...);
int
xo_ssize_t
xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
const char *fmt, va_list vap);
int
xo_ssize_t
xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...);
int
xo_ssize_t
xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...);
PRINTFLIKE(2, 0)
@ -260,97 +275,97 @@ xo_emit_fp (xo_emit_flags_t flags, const char *fmt, ...)
return rc;
}
int
xo_ssize_t
xo_open_container_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_container (const char *name);
int
xo_ssize_t
xo_open_container_hd (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_container_d (const char *name);
int
xo_ssize_t
xo_close_container_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_close_container (const char *name);
int
xo_ssize_t
xo_close_container_hd (xo_handle_t *xop);
int
xo_ssize_t
xo_close_container_d (void);
int
xo_ssize_t
xo_open_list_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_list (const char *name);
int
xo_ssize_t
xo_open_list_hd (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_list_d (const char *name);
int
xo_ssize_t
xo_close_list_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_close_list (const char *name);
int
xo_ssize_t
xo_close_list_hd (xo_handle_t *xop);
int
xo_ssize_t
xo_close_list_d (void);
int
xo_ssize_t
xo_open_instance_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_instance (const char *name);
int
xo_ssize_t
xo_open_instance_hd (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_instance_d (const char *name);
int
xo_ssize_t
xo_close_instance_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_close_instance (const char *name);
int
xo_ssize_t
xo_close_instance_hd (xo_handle_t *xop);
int
xo_ssize_t
xo_close_instance_d (void);
int
xo_ssize_t
xo_open_marker_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_open_marker (const char *name);
int
xo_ssize_t
xo_close_marker_h (xo_handle_t *xop, const char *name);
int
xo_ssize_t
xo_close_marker (const char *name);
int
xo_ssize_t
xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...);
int
xo_ssize_t
xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap);
int
xo_ssize_t
xo_attr (const char *name, const char *fmt, ...);
void
@ -362,16 +377,16 @@ xo_error_h (xo_handle_t *xop, const char *fmt, ...);
void
xo_error (const char *fmt, ...);
int
xo_ssize_t
xo_flush_h (xo_handle_t *xop);
int
xo_ssize_t
xo_flush (void);
int
xo_ssize_t
xo_finish_h (xo_handle_t *xop);
int
xo_ssize_t
xo_finish (void);
void
@ -644,16 +659,16 @@ char *
xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
xo_simplify_field_func_t field_cb);
int
xo_ssize_t
xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt,
va_list vap);
int
xo_ssize_t
xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);
int
xo_ssize_t
xo_emit_field (const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);

View File

@ -28,7 +28,7 @@
typedef struct xo_buffer_s {
char *xb_bufp; /* Buffer memory */
char *xb_curp; /* Current insertion point */
unsigned xb_size; /* Size of buffer */
ssize_t xb_size; /* Size of buffer */
} xo_buffer_t;
/*
@ -111,10 +111,10 @@ xo_buf_cleanup (xo_buffer_t *xbp)
* return 0 to tell the caller they are in trouble.
*/
static inline int
xo_buf_has_room (xo_buffer_t *xbp, int len)
xo_buf_has_room (xo_buffer_t *xbp, ssize_t len)
{
if (xbp->xb_curp + len >= xbp->xb_bufp + xbp->xb_size) {
int sz = xbp->xb_size + XO_BUFSIZ;
ssize_t sz = xbp->xb_size + XO_BUFSIZ;
char *bp = xo_realloc(xbp->xb_bufp, sz);
if (bp == NULL)
return 0;
@ -131,7 +131,7 @@ xo_buf_has_room (xo_buffer_t *xbp, int len)
* Append the given string to the given buffer
*/
static inline void
xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
xo_buf_append (xo_buffer_t *xbp, const char *str, ssize_t len)
{
if (!xo_buf_has_room(xbp, len))
return;
@ -146,7 +146,7 @@ xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
static inline void
xo_buf_append_str (xo_buffer_t *xbp, const char *str)
{
int len = strlen(str);
ssize_t len = strlen(str);
if (!xo_buf_has_room(xbp, len))
return;

View File

@ -139,7 +139,7 @@ xo_encoder_list_add (const char *name)
xo_encoder_node_t *xep = xo_realloc(NULL, sizeof(*xep));
if (xep) {
int len = strlen(name) + 1;
ssize_t len = strlen(name) + 1;
xep->xe_name = xo_realloc(NULL, len);
if (xep->xe_name == NULL) {
xo_free(xep);
@ -241,7 +241,7 @@ xo_encoder_discover (const char *name)
bzero(&xei, sizeof(xei));
xei.xei_version = XO_ENCODER_VERSION;
int rc = func(&xei);
ssize_t rc = func(&xei);
if (rc == 0 && xei.xei_handler) {
xep = xo_encoder_list_add(name);
if (xep) {

View File

@ -630,7 +630,7 @@ The format string has the form:
\(aq%\(aq format\-modifier * format\-character
.Ed
.Pp
The format\- modifier can be:
The format\-modifier can be:
.Bl -bullet
.It
a \(aq#\(aq character, indicating the output value should be prefixed with

View File

@ -0,0 +1,147 @@
.\" #
.\" # Copyright (c) 2014-2017, Juniper Networks, Inc.
.\" # All rights reserved.
.\" # This SOFTWARE is licensed under the LICENSE provided in the
.\" # ../Copyright file. By downloading, installing, copying, or
.\" # using the SOFTWARE, you agree to be bound by the terms of that
.\" # LICENSE.
.\" # Phil Shafer, July 2014
.\"
.Dd May 11, 2017
.Dt LIBXO 3
.Os
.Sh NAME
.Nm xo_options
.Nd common options for libxo\-based commands
.Sh DESCRIPTION
.Pp
.Nm libxo
allows the rendering of data into
various output styles, including
.Em text ,
.Em XML ,
.Em JSON ,
and
.Em HTML .
.Nm libxo
uses command line options to trigger rendering behavior.
Options are recognised in three forms:
.Bl -bullet
.It
\-\-libxo <options>
.It
\-\-libxo=<options>
.It
\-\-libxo:<brief\-options>
.El
.Pp
The first two forms accept a comma\-separated set of words, detailed
below, while the third form accepts a set of letters, also below.
The triggered functionality is identical.
.Bl -column "Token2341234"
.It Sy "Option " "Action"
.It "color " "Enable colors/effects for display styles (TEXT, HTML)"
.It "flush " "Flush after each emit call"
.It "flush\-line " "Flush each line of output"
.It "html " "Emit HTML output"
.It "indent=xx " "Set the indentation level"
.It "info " "Add info attributes (HTML)"
.It "json " "Emit JSON output"
.It "keys " "Emit the key attribute for keys (XML)"
.It "log\-gettext" "Log (via stderr) each gettext(3) string lookup"
.It "log\-syslog " "Log (via stderr) each syslog message (via xo_syslog)"
.It "no\-humanize" "Ignore the {h:} modifier (TEXT, HTML)"
.It "no\-locale " "Do not initialize the locale setting"
.It "no\-retain " "Prevent retaining formatting information"
.It "pretty " "Emit pretty\-printed output"
.It "retain " "Force retaining formatting information"
.It "text " "Emit TEXT output"
.It "underscores" "Replace XML\-friendly \"\-\"s with JSON friendly \"_\"s"
.It "units " "Add the 'units' (XML) or 'data\-units (HTML) attribute"
.It "warn " "Emit warnings when libxo detects bad calls"
.It "warn\-xml " "Emit warnings in XML"
.It "xml " "Emit XML output"
.It "xpath " "Add XPath expressions (HTML)"
.El
.Pp
The brief options are a set of single\-letter aliases for the longer
terms, used as a single string:
.Bl -column "Value" "Equivalent Token"
.It Sy "Value" "Equivalent Token"
.It "c
.It "f " "flush"
.It "F " "flush\-line"
.It "H " "html"
.It "I " "info"
.It "i<num>" "indent=<num>"
.It "J " "json"
.It "k " "keys"
.It "n " "no\-humanize"
.It "P " "pretty"
.It "T " "text"
.It "U " "units"
.It "u " "underscore
.It "W " "warn"
.It "X " "xml"
.It "x " "xpath"
.El
.Pp
Most of these option are simple and direct, but some require
additional details:
.Pp
.Fa "flush\-line"
performs line buffering, even when the output is not directed to
a TTY device.
.Pp
.Fa info
generates additional data for HTML, encoded in attributes using
names that state with "data\-".
.Pp
.Fa keys
adds a "key" attribute for XML output to indicate that a leaf is
an identifier for the list member.
.Pp
.Fa no\-humanize
avoids "humanizing" numeric output (see
.Xr humanize_number 3
for details).
.Pp
.Fa no\-locale
instructs
.Nm libxo
to avoid translating output to the current locale.
.Pp
.Fa no\-retain
disables the ability of
.Nm libxo
to internally retain "compiled" information about formatting strings.
.Pp
.Fa underscores
can be used with
.Em JSON
output to change
.Em XML \-friendly
names with dashes into
.Em JSON \-friendly
name with underscores.
.Pp
.Fa warn
allows
.Nm libxo
to emit warnings on stderr when application code make incorrect calls.
.Fa warn\-xml causes those warnings to be placed in
.Em XML
inside the output.
.Sh EXAMPLES
The following are three example invocations of
.Xr ps 1 :
.Bd -literal
ps \-\-libxo json,pretty,warn \-ux
ps \-\-libxo=xml \-lg
ps \-\-libxo:Hxc 1
.Ed
.Sh SEE ALSO
.Xr libxo 3 ,
.Xr xo_format 5

View File

@ -53,6 +53,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/time.h>
@ -94,11 +95,13 @@
#define XO_DEFAULT_EID 32473 /* Fallback to the "example" number */
#endif
#ifndef HOST_NAME_MAX
#ifdef _SC_HOST_NAME_MAX
#define HOST_NAME_MAX _SC_HOST_NAME_MAX
#else
#define HOST_NAME_MAX 255
#endif /* _SC_HOST_NAME_MAX */
#endif /* HOST_NAME_MAX */
#ifndef UNUSED
#define UNUSED __attribute__ ((__unused__))
@ -425,12 +428,13 @@ xo_set_syslog_handler (xo_syslog_open_t open_func,
xo_syslog_close = close_func;
}
static size_t
xo_snprintf (char *out, size_t outsize, const char *fmt, ...)
static ssize_t
xo_snprintf (char *out, ssize_t outsize, const char *fmt, ...)
{
int status;
size_t retval = 0;
ssize_t status;
ssize_t retval = 0;
va_list ap;
if (out && outsize) {
va_start(ap, fmt);
status = vsnprintf(out, outsize, fmt, ap);
@ -443,10 +447,11 @@ xo_snprintf (char *out, size_t outsize, const char *fmt, ...)
}
va_end(ap);
}
return retval;
}
static int
static xo_ssize_t
xo_syslog_handle_write (void *opaque, const char *data)
{
xo_buffer_t *xbp = opaque;

View File

@ -1,5 +1,7 @@
op create: [] []
op open_container: [top] []
op content: [kve_start] [0xdeadbeef]
op content: [kve_end] [0xcabb1e]
op string: [host] [my-box]
op string: [domain] [example.com]
op string: [host] [my-box]

View File

@ -1,2 +1,2 @@
{"top": {"host":"my-box","domain":"example.com","host":"my-box","domain":"example.com","label":"value","max-chaos":"very","min-chaos":42,"some-chaos":"[42]","host":"my-box","domain":"example.com", "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data2": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data3": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data4": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455,"mode":"mode","mode_octal":"octal","links":"links","user":"user","group":"group","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"}
{"top": {"kve_start":"0xdeadbeef","kve_end":"0xcabb1e","host":"my-box","domain":"example.com","host":"my-box","domain":"example.com","label":"value","max-chaos":"very","min-chaos":42,"some-chaos":"[42]","host":"my-box","domain":"example.com", "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data2": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data3": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data4": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455,"mode":"mode","mode_octal":"octal","links":"links","user":"user","group":"group","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"}
}

View File

@ -1,5 +1,7 @@
{
"top": {
"kve_start": "0xdeadbeef",
"kve_end": "0xcabb1e",
"host": "my-box",
"domain": "example.com",
"host": "my-box",

View File

@ -1 +1 @@
<top><host>my-box</host><domain>example.com</domain><host>my-box</host><domain>example.com</domain><label>value</label><max-chaos>very</max-chaos><min-chaos>42</min-chaos><some-chaos>[42]</some-chaos><host>my-box</host><domain>example.com</domain><data test="value"><item test2="value2"><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data2><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data2><data3><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data3><data4><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data4><cost>425</cost><cost>455</cost><mode>mode</mode><mode_octal>octal</mode_octal><links>links</links><user>user</user><group>group</group><mode>/some/file</mode><mode_octal>640</mode_octal><links>1</links><user>user</user><group>group</group></top>
<top><kve_start>0xdeadbeef</kve_start><kve_end>0xcabb1e</kve_end><host>my-box</host><domain>example.com</domain><host>my-box</host><domain>example.com</domain><label>value</label><max-chaos>very</max-chaos><min-chaos>42</min-chaos><some-chaos>[42]</some-chaos><host>my-box</host><domain>example.com</domain><data test="value"><item test2="value2"><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data2><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data2><data3><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data3><data4><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data4><cost>425</cost><cost>455</cost><mode>mode</mode><mode_octal>octal</mode_octal><links>links</links><user>user</user><group>group</group><mode>/some/file</mode><mode_octal>640</mode_octal><links>1</links><user>user</user><group>group</group></top>

View File

@ -1,4 +1,6 @@
<top>
<kve_start>0xdeadbeef</kve_start>
<kve_end>0xcabb1e</kve_end>
<host>my-box</host>
<domain>example.com</domain>
<host>my-box</host>

View File

@ -1 +1 @@
<top __version="3.1.4"><data test="value"><data test2="value2">bold</data><data>bold-ul</data><data>triple</data><data>inv-ul</data><data>underline</data><data>plain</data><item><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data><data><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data><cost>425</cost><cost>455</cost></top>
<top version="3.1.4"><data test="value"><data test2="value2">bold</data><data>bold-ul</data><data>triple</data><data>inv-ul</data><data>underline</data><data>plain</data><item><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data><data><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data><cost>425</cost><cost>455</cost></top>

View File

@ -1,4 +1,4 @@
<top __version="3.1.4">
<top version="3.1.4">
<data test="value">
<data test2="value2">bold</data>
<data>bold-ul</data>

View File

@ -14,4 +14,4 @@
{{test-program: }}
{{An application 1011 log entry}}
<top __version="3.1.4"></top>
<top version="3.1.4"></top>

View File

@ -14,5 +14,5 @@
{{test-program: }}
{{An application 1011 log entry}}
<top __version="3.1.4">
<top version="3.1.4">
</top>

View File

@ -9,6 +9,7 @@
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
@ -79,6 +80,9 @@ main (int argc, char **argv)
xo_open_container_h(NULL, "top");
xo_emit("{e:kve_start/%#jx}", (uintmax_t) 0xdeadbeef);
xo_emit("{e:kve_end/%#jx}", (uintmax_t) 0xcabb1e);
xo_emit("testing argument modifier {a:}.{a:}...\n",
"host", "my-box", "domain", "example.com");

View File

@ -1,2 +1,2 @@
{"top": {"adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay","adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay", "bytes": [0,1,2,3,4],"total":1234,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"marzlevanes":3,"version":"1.2.3","date":"Tue Jun 23 18:47:09 UTC 2015", "__warning": {"program":"gt_01.test","message":"Nableuay otay ectulatobjay orwardfay elocipingvay","verb":ectulatobjay,"error":"Ermissionpay eniedday"}, "__warning": {"program":"gt_01.test","message":"automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay","style":automaticyay,"type":"ardinalyay","target":"ammetersgray","error":"Ermissionpay eniedday"},"marzlevanes":6,"windings":"otuslay-oyay-eltayay"}
{"top": {"adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay","adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay", "bytes": [0,1,2,3,4],"total":1234,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"marzlevanes":3,"version":"1.2.3","date":"Tue Jun 23 18:47:09 UTC 2015", "__warning": {"program":"gt_01.test","message":"Nableuay otay ectulatobjay orwardfay elocipingvay","verb":ectulatobjay,"error":"Ermissionpay eniedday"}, "__warning": {"program":"gt_01.test","message":"automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay","style":"automaticyay","type":"ardinalyay","target":"ammetersgray","error":"Ermissionpay eniedday"},"marzlevanes":6,"windings":"otuslay-oyay-eltayay"}
}

View File

@ -42,7 +42,7 @@
"__warning": {
"program": "gt_01.test",
"message": "automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay",
"style": automaticyay,
"style": "automaticyay",
"type": "ardinalyay",
"target": "ammetersgray",
"error": "Ermissionpay eniedday"

View File

@ -90,8 +90,8 @@ checkpoint (xo_handle_t *xop UNUSED, va_list vap UNUSED, int restore)
* with our command line arguments to build strings. This involves faking
* some printf-style logic.
*/
static int
formatter (xo_handle_t *xop, char *buf, int bufsiz,
static xo_ssize_t
formatter (xo_handle_t *xop, char *buf, xo_ssize_t bufsiz,
const char *fmt, va_list vap UNUSED)
{
int lflag UNUSED = 0; /* Parse long flag, though currently ignored */

View File

@ -48,8 +48,11 @@ MAN+= xo_attr.3 \
xo_set_version.3 \
xo_set_writer.3 \
xo_syslog.3
MAN+= xo_format.5
MAN+= xo_options.7
MLINKS= xo_attr.3 xo_attr_h.3 \
xo_attr.3 xo_attr_hv.3 \
xo_create.3 xo_create_to_file.3 \

View File

@ -3,10 +3,10 @@
.Fx
uses
.Nm libxo
version 0.6.2.
version 0.7.2.
Complete documentation can be found on github:
.Bd -literal -offset indent
http://juniper.github.io/libxo/0.6.2/libxo\-manual.html
http://juniper.github.io/libxo/0.7.2/libxo\-manual.html
.Ed
.Pp
.Nm libxo

View File

@ -183,16 +183,16 @@
/* #undef LIBXO_TEXT_ONLY */
/* Version number as dotted value */
#define LIBXO_VERSION "0.6.2"
#define LIBXO_VERSION "0.7.2"
/* Version number extra information */
#define LIBXO_VERSION_EXTRA ""
/* Version number as a number */
#define LIBXO_VERSION_NUMBER 6002
#define LIBXO_VERSION_NUMBER 7002
/* Version number as string */
#define LIBXO_VERSION_STRING "6002"
#define LIBXO_VERSION_STRING "7002"
/* Enable local wcwidth implementation */
#define LIBXO_WCWIDTH 1
@ -210,7 +210,7 @@
#define PACKAGE_NAME "libxo"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libxo 0.6.2"
#define PACKAGE_STRING "libxo 0.7.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libxo"
@ -219,7 +219,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.6.2"
#define PACKAGE_VERSION "0.7.2"
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
@ -232,8 +232,11 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Use int return codes */
/* #undef USE_INT_RETURN_CODES */
/* Version number of package */
#define VERSION "0.6.2"
#define VERSION "0.7.2"
/* Retain hash bucket size */
/* #undef XO_RETAIN_SIZE */

View File

@ -4,6 +4,7 @@
LIBXOSRC= ${SRCTOP}/contrib/libxo
.PATH:
.PATH: ${LIBXOSRC}/xo
PROG= xo