Marshalling of empty string, object_path, signatures and NUL byte
simon.mcvittie at collabora.co.uk
Wed May 25 15:43:11 UTC 2016
On 25/05/16 09:06, marcin at saepia.net wrote:
> what is the correct approach to marshall empty strings, object paths and
> sinatures? (with length == 0)?
> Should it contain just NUL byte after length of just length alone?
I'm fairly sure empty strings aren't special. Non-empty strings are
marshalled as a length, followed by some data, followed by a NUL; empty
strings are marshalled as a length, followed by no data, followed by a NUL.
(Strings are encoded this way so that a C implementation like libdbus
can point directly into the message buffer and get a NUL-terminated
const char * that it can provide to the library user, without having to
memcpy it out.)
If in doubt, look at what the D-Bus Specification says, or at what a
high-quality interoperable implementation (for instance libdbus, GDBus,
Collabora Ltd. <http://www.collabora.com/>
More information about the dbus