Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Aug 2014 17:13:22 -0400
From:      Eric van Gyzen <eric@vangyzen.net>
To:        Phil Shafer <phil@juniper.net>,  Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        arch@freebsd.org, John-Mark Gurney <jmg@funkthat.com>, marcel@freebsd.org, "Simon J. Gerraty" <sjg@juniper.net>
Subject:   Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML
Message-ID:  <53EBD4F2.5080908@vangyzen.net>
In-Reply-To: <201408131936.s7DJaA1r089174@idle.juniper.net>
References:  <201408131936.s7DJaA1r089174@idle.juniper.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 08/13/2014 15:36, Phil Shafer wrote:
> Phil Shafer writes:
>> FWIW, the UTF-8 strategy for libox is this:
>> - all format strings are UTF-8
>> - argument strings (%s) are UTF-8
>> - "%ls" handles wide characters
>> - "%hs" will handle locale-based strings
>> - XML, JSON, and HTML will be UTF-8 output
>> - text will be locale-based
> Sorry for the delay, but this code is now done.  Formatting widths
> are done using wcwidth() so things like "%15.15s" work correctly
> regardless of locale settings.  As a background task, I'm converting
> some basic commands to use libxo.  It's slow work, but needs done....
>
> I've a related topic:  when an app goes to run a child command, how
> can it determine whether that binary supports libxo-based encoding
> requests?  This should be known before the binary is run, since
> there's no means of auto-detecting the supported output after the
> fact.
>
> For example, say I want to make a JSON-based API for my server.  I
> can setenv("LIBXO_OPTIONS", "json") to get JSON output, but I won't
> know if the binary supports this or if the output needs to be wrapped
> and escaped.

Perhaps libxo can have an API to answer this question, so your app can
simply ask libxo if "netstat" supports libxo output.  How should the API
be implemented?  Perhaps libxo can consult a file that lists all
executables that support libxo.  This file can be maintained either
manually by committers or perhaps automatically by the build.  (Maybe it
could even be built into libxo.so itself, for efficiency, using a
fallback to a file, for flexibility.)  An alternative is to ask ELF if
the executable is linked with libxo.so, but this obviously doesn't work
when it's statically linked.

I haven't given these much thought...just tossing out ideas.

Eric

> I know ELF "Note" elements can be used to carry vendor-specific
> data, but have no experience with them.  Would it be reasonable to
> use them as a means of communicating this information to other bits
> of software?  Is FreeBSD using Notes for other information currently?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53EBD4F2.5080908>