From owner-freebsd-arch@FreeBSD.ORG Wed Aug 13 23:02:39 2014 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3EC9B5BF; Wed, 13 Aug 2014 23:02:39 +0000 (UTC) Received: from mail.xcllnt.net (mail.xcllnt.net [50.0.150.214]) (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 0D5CD2C93; Wed, 13 Aug 2014 23:02:38 +0000 (UTC) Received: from rcannon-sslvpn-nc.jnpr.net ([66.129.239.11]) (authenticated bits=0) by mail.xcllnt.net (8.14.9/8.14.9) with ESMTP id s7DN2L02000748 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 13 Aug 2014 16:02:23 -0700 (PDT) (envelope-from marcel@xcllnt.net) Content-Type: multipart/signed; boundary="Apple-Mail=_8B5850B6-5F0C-4912-9740-380033E110CC"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML From: Marcel Moolenaar In-Reply-To: <201408131936.s7DJaA1r089174@idle.juniper.net> Date: Wed, 13 Aug 2014 16:02:15 -0700 Message-Id: <613EB1A5-2932-446A-A9A2-8CBDD060A00B@xcllnt.net> References: <201408131936.s7DJaA1r089174@idle.juniper.net> To: Phil Shafer X-Mailer: Apple Mail (2.1878.6) Cc: arch@freebsd.org, Poul-Henning Kamp , Marcel Moolenaar , John-Mark Gurney , "Simon J. Gerraty" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Aug 2014 23:02:39 -0000 --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 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--