[Xcb] ListHosts entry lengths and padding to 4-byte alignment
Nigel Tao
nigel.tao.gnome at gmail.com
Mon Oct 11 19:56:39 PDT 2010
Hi. I maintain x-go-binding, a port of xcb to the Go programming language.
I'm hoping someone can clarify the rules about padding list replies so
that their elements' lengths are a multiple of 4.
For example, the X11 spec at
ftp://ftp.x.org/pub/X11R7.0/doc/PDF/proto.pdf says that ListHosts
(opcode 110, page 148) is marked "n always a multiple of 4" but
ListExtensions (opcode 99, page 145) is not similarly marked.
IIUC the relevent parts of xcb's xproto.xml are:
-----------
<request name="ListExtensions" opcode="99">
<reply>
<field type="CARD8" name="names_len" />
<pad bytes="24" />
<list type="STR" name="names">
<fieldref>names_len</fieldref>
</list>
</reply>
</request>
<!-- other elements elided -->
<struct name="HOST">
<field type="CARD8" name="family" enum="Family" />
<pad bytes="1" />
<field type="CARD16" name="address_len" />
<list type="BYTE" name="address">
<fieldref>address_len</fieldref>
</list>
</struct>
<request name="ListHosts" opcode="110">
<reply>
<field type="BYTE" name="mode" enum="AccessControl" />
<field type="CARD16" name="hosts_len" />
<pad bytes="22" />
<list type="HOST" name="hosts">
<fieldref>hosts_len</fieldref>
</list>
</reply>
</request>
-----------
How am I supposed to tell, from the XML file, that the elements of a
<list type="HOST"> should be 4-padded (and not 1-padded or 2-padded),
but a <list type="STR"> is 1-padded?
I can make up a number of rules that each seem to match what I see for
the core protocol, but I'd like to know the actual rule so that I can
also handle any extensions.
Apologies if this is documented somewhere and I've simply missed it,
Nigel.
More information about the Xcb
mailing list