Subject: Re: binary plist support
To: Jason Thorpe <thorpej@shagadelic.org>
From: Jachym Holecek <freza@NetBSD.org>
List: tech-kern
Date: 10/17/2007 10:02:05
# Jason Thorpe 2007-10-16:
> On Oct 6, 2007, at 1:25 PM, Jachym Holecek wrote:
> >The binary encoding, which is rather size-efficient and supposedly  
> >very
> >fast as well (but I don't have numbers yet), is basically Apple bplist
> >format. But because Apple doesn't distinguish signed integers vs.  
> >unsigned,
> >the format differs slightly and uses different version number to avoid
> >confusion.
> 
> I would like to avoid having a different format.  Is there any  
> pressing need to distinguish between signed and unsigned in the  
> serialized format?

If we switch the ioctl() plist protocol to binary encoding, which I'd
like to see happen, at least DIOCGDISKINFO and 'get-device-properties'
will have problems.

Other than that, in my tree cfdata is a plist and the 'flags' member
is unsigned, so prop_dictionary_get_uint64() would fail if we couldn't
tell unsigned number from signed in the external format.

> > [... API ...]
> 
> I would like to see some API changes, here:
> 
> - Add new prop_*_externalize_with_encoding() routines that take a  
> prop_encoding_t as a final argument:
> 
> typedef enum {
> 	PROP_ENCODING_DEFAULT = 0,
> 	PROP_ENCODING_XML = 1,
> 	PROP_ENCODING_BINARY = 2,
> } prop_encoding_t;

Fine, it would go like:

  bool prop_array_externalize_with_encoding(prop_array_t, uint8_t **,
      size_t *, prop_encoding_t);

so that it can accomodate both XML (cstring) and binary (byte array).

> - prop_*_externalize() should remain, and should be simple wrappers  
> around prop_*_externalize_with_encoding(..., PROP_ENCODING_DEFAULT);
> 
> - Internally, prop_*_externalize_with_encoding() should map  
> PROP_ENCODING_DEFAULT to PROP_ENCODING_XML.
>
> - prop_*_internalize() should simply recognize which encoding is being  
> used and handle it.

Ok.

	-- Jachym