Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Aug 2014 16:02:15 -0700
From:      Marcel Moolenaar <marcel@xcllnt.net>
To:        Phil Shafer <phil@juniper.net>
Cc:        arch@freebsd.org, Poul-Henning Kamp <phk@phk.freebsd.dk>, Marcel Moolenaar <marcel@freebsd.org>, John-Mark Gurney <jmg@funkthat.com>, "Simon J. Gerraty" <sjg@juniper.net>
Subject:   Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML
Message-ID:  <613EB1A5-2932-446A-A9A2-8CBDD060A00B@xcllnt.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

--Apple-Mail=_8B5850B6-5F0C-4912-9740-380033E110CC
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii


On Aug 13, 2014, at 12:36 PM, Phil Shafer <phil@juniper.net> wrote:
> 
> 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.

Aside:
Using environment variables can be handy, but isn't always.
What do you think about calling a libxo init function from
main() and giving it argc and argv so that libxo options
are parsed and removed just like what xlib does?

> 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?

Notes are used to tag the binary as a FreeBSD one (note is
consumed by the kernel) or in core files for meta data
(consumed by the debugger).

A note section is definitely possible and reasonable.
Especially if it's a note section for listing features. A
special utility that consumes the note section to list
features and returns whether a feature is supported is then
very reasonable because it's generic. libxo would be the
first feature we can check for. The question is: do we have
more features we want to check for this way? If not, then
such a scheme could be perceived as "heavy handed".

Alternatives include looking for a particular symbol or
possibly even running the utility with a libxo option that
has predictable output. The last suggestion has some issues
with handling the behaviour when libxo isn't supported
therefore, a passive way to check seems better than having
to run the utility.

BTW: this is pretty powerful stuff! I feel FreeBSD is
maturing :-)

-- 
Marcel Moolenaar
marcel@xcllnt.net



--Apple-Mail=_8B5850B6-5F0C-4912-9740-380033E110CC
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAlPr7ncACgkQpgWlLWHuifYjDwCdG0O211KFAV3e0kh25bp5r4Zj
b3IAn0Y4qsFYAagnC3iiCm9DLUr0K9Y2
=A7HI
-----END PGP SIGNATURE-----

--Apple-Mail=_8B5850B6-5F0C-4912-9740-380033E110CC--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?613EB1A5-2932-446A-A9A2-8CBDD060A00B>