Ethereal-dev: [Ethereal-dev] support for X11 replies and events

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Michael Shuldman <michaels@xxxxxxx>
Date: Wed, 24 Dec 2003 20:22:19 +0100
[ignore last mail.]

Hello, I hoped to complete this before sending it to you guys, but
it's just been laying here for half a year now, so since I don't know
if/when I can finish it, I've patched it up the current release
of ethereal and done a quick test to see that it still works.

This patch adds support for parsing some X11 replies and events (+
the framework for handling X11 errors it looks like) to the
existing X11 code, which parses X11 requeests.

It parses what is the most difficult part of the replies/events,
they Keycode stuff by parsing the Keyboardmapping replies and etc,
and then KeyPress, KeyRelease events and some related stuff (used
for a specific project).

It was originally developed with ethereal-0.9.7 and then 
tested on i386 and ultrasparc.


Adding support for parsing the rest of the event/replies should not
be difficult, I think it will mostly consist of going through every
event/reply and add the missing calls for each dataitem i.e.  register
the data, the remaining the eventcodes/replies are pretty
straightforward if I remember correctly.

All events and replies are reported, it's the "detailed" (-V option)
that's missing for most.


List over other misc. stuff added that I see from the rcslog:
 - handle multiple outstanding requests.
 - add AllocNamedColor to list of requests expecting a reply.
 - body for parsing error replies.
 - each packet can be sent to us multiple times, try to handle that.
 - change request_length display to be what the client actually sends
   for x11_request, not what it means (don't multiply by four).
 - add some more opcodes expecting a reply (gone through all listed
   in the ref. now, so should be complete).
 - use hashtable and sequencenumber for matching reply to request.


When doing a quick test now I noticed that it crashed due
to the following code in dissect_x11_request():

/* In the interest of speed, if "tree" is NULL, avoid building a
   protocol tree and adding stuff to it if possible.  Note,
   however, that you must call subdissectors regardless of whether
   "tree" is NULL or not. */
        if (!tree)
		return;

That didn't work since we need run through some of the code
coming in order to handle the later reply.  I don't know 
why we get a NULL tree now but not in 0.9.7.  I don't remember what
a NULL tree means either, so I removed the return statement.

Also one other problem, tcp desegmentation needs to be switched
on for the parsing of keypresses and related stuff to work,
the X11 keyboardmap is too big to fit in a single ip packet.


I want to thank Christophe Tronche <ch.tronche@xxxxxxxxxxxx> (who
wrote the orignal X11 code here) for the tips he gave me before I
had yet started on the work, that and his code made the work quite
a bit easier.

I also want to thank Open-IT (www.open-it.com) for letting me
give the code back to your project.


-- 
  _ // 
  \X/ -- Michael Shuldman <michaels@xxxxxxx>
/* packet-x11-keysym.h
 *
 * $Id: packet-x11-keysym.h,v 1.6 2002/08/28 21:00:40 jmayer Exp $
 *
 * Put there so as to make packet-x11.c lighter. See packet-x11.c
 */

#ifndef __PACKET_X11_KEYSYM_H__
#define __PACKET_X11_KEYSYM_H__

static const value_string keysym_vals_source[] = {
      { 0, "NoSymbol" }, { 0x020, "space" }, { 0x021, "!" }, { 0x022, "\"" },
      { 0x023, "#" }, { 0x024, "$" }, { 0x025, "%" }, { 0x026, "&" },
      { 0x027, "'" }, { 0x028, "(" }, { 0x029, ")" }, { 0x02a, "*" },
      { 0x02b, "+" }, { 0x02c, "," }, { 0x02d, "-" }, { 0x02e, "." },
      { 0x02f, "/" }, { 0x030, "0" }, { 0x031, "1" }, { 0x032, "2" },
      { 0x033, "3" }, { 0x034, "4" }, { 0x035, "5" }, { 0x036, "6" },
      { 0x037, "7" }, { 0x038, "8" }, { 0x039, "9" }, { 0x03a, ":" },
      { 0x03b, ";" }, { 0x03c, "<" }, { 0x03d, "=" }, { 0x03e, ">" },
      { 0x03f, "?" }, { 0x040, "@" }, { 0x041, "A" }, { 0x042, "B" },
      { 0x043, "C" }, { 0x044, "D" }, { 0x045, "E" }, { 0x046, "F" },
      { 0x047, "G" }, { 0x048, "H" }, { 0x049, "I" }, { 0x04a, "J" },
      { 0x04b, "K" }, { 0x04c, "L" }, { 0x04d, "M" }, { 0x04e, "N" },
      { 0x04f, "O" }, { 0x050, "P" }, { 0x051, "Q" }, { 0x052, "R" },
      { 0x053, "S" }, { 0x054, "T" }, { 0x055, "U" }, { 0x056, "V" },
      { 0x057, "W" }, { 0x058, "X" }, { 0x059, "Y" }, { 0x05a, "Z" },
      { 0x05b, "[" }, { 0x05c, "\\" }, { 0x05d, "]" }, { 0x05e, "^" },
      { 0x05f, "_" }, { 0x060, "`" }, { 0x061, "a" }, { 0x062, "b" },
      { 0x063, "c" }, { 0x064, "d" }, { 0x065, "e" }, { 0x066, "f" },
      { 0x067, "g" }, { 0x068, "h" }, { 0x069, "i" }, { 0x06a, "j" },
      { 0x06b, "k" }, { 0x06c, "l" }, { 0x06d, "m" }, { 0x06e, "n" },
      { 0x06f, "o" }, { 0x070, "p" }, { 0x071, "q" }, { 0x072, "r" },
      { 0x073, "s" }, { 0x074, "t" }, { 0x075, "u" }, { 0x076, "v" },
      { 0x077, "w" }, { 0x078, "x" }, { 0x079, "y" }, { 0x07a, "z" },
      { 0x07b, "{" }, { 0x07c, "|" }, { 0x07d, ", HFILL }" }, { 0x07e, "~" },
      { 0x0a0, "nobreakspace" }, { 0x0a1, "\x0a1" }, { 0x0a2, "\x0a2" }, { 0x0a3, "\x0a3" },
      { 0x0a4, "\x0a4" }, { 0x0a5, "\x0a5" }, { 0x0a6, "\x0a6" }, { 0x0a7, "\x0a7" },
      { 0x0a8, "\x0a8" }, { 0x0a9, "\x0a9" }, { 0x0aa, "\x0aa" }, { 0x0ab, "\x0ab" },
      { 0x0ac, "\x0ac" }, { 0x0ad, "\x0ad" }, { 0x0ae, "\x0ae" }, { 0x0af, "\x0af" },
      { 0x0b0, "\x0b0" }, { 0x0b1, "\x0b1" }, { 0x0b2, "\x0b2" }, { 0x0b3, "\x0b3" },
      { 0x0b4, "\x0b4" }, { 0x0b5, "\x0b5" }, { 0x0b6, "\x0b6" }, { 0x0b7, "\x0b7" },
      { 0x0b8, "\x0b8" }, { 0x0b9, "\x0b9" }, { 0x0ba, "\x0ba" }, { 0x0bb, "\x0bb" },
      { 0x0bc, "\x0bc" }, { 0x0bd, "\x0bd" }, { 0x0be, "\x0be" }, { 0x0bf, "\x0bf" },
      { 0x0c0, "\x0c0" }, { 0x0c1, "\x0c1" }, { 0x0c2, "\x0c2" }, { 0x0c3, "\x0c3" },
      { 0x0c4, "\x0c4" }, { 0x0c5, "\x0c5" }, { 0x0c6, "\x0c6" }, { 0x0c7, "\x0c7" },
      { 0x0c8, "\x0c8" }, { 0x0c9, "\x0c9" }, { 0x0ca, "\x0ca" }, { 0x0cb, "\x0cb" },
      { 0x0cc, "\x0cc" }, { 0x0cd, "\x0cd" }, { 0x0ce, "\x0ce" }, { 0x0cf, "\x0cf" },

      { 0x0d0, "\x0d0" }, { 0x0d1, "\x0d1" }, { 0x0d2, "\x0d2" }, { 0x0d3, "\x0d3" },
      { 0x0d4, "\x0d4" }, { 0x0d5, "\x0d5" }, { 0x0d6, "\x0d6" }, { 0x0d7, "\x0d7" },
      { 0x0d8, "\x0d8" }, { 0x0d9, "\x0d9" }, { 0x0da, "\x0da" }, { 0x0db, "\x0db" },
      { 0x0dc, "\x0dc" }, { 0x0dd, "\x0dd" }, { 0x0de, "\x0de" }, { 0x0df, "\x0df" },
      { 0x0e0, "\x0e0" }, { 0x0e1, "\x0e1" }, { 0x0e2, "\x0e2" }, { 0x0e3, "\x0e3" },
      { 0x0e4, "\x0e4" }, { 0x0e5, "\x0e5" }, { 0x0e6, "\x0e6" }, { 0x0e7, "\x0e7" },
      { 0x0e8, "\x0e8" }, { 0x0e9, "\x0e9" }, { 0x0ea, "\x0ea" }, { 0x0eb, "\x0eb" },
      { 0x0ec, "\x0ec" }, { 0x0ed, "\x0ed" }, { 0x0ee, "\x0ee" }, { 0x0ef, "\x0ef" },
      { 0x0f0, "\x0f0" }, { 0x0f1, "\x0f1" }, { 0x0f2, "\x0f2" }, { 0x0f3, "\x0f3" },
      { 0x0f4, "\x0f4" }, { 0x0f5, "\x0f5" }, { 0x0f6, "\x0f6" }, { 0x0f7, "\x0f7" },
      { 0x0f8, "\x0f8" }, { 0x0f9, "\x0f9" }, { 0x0fa, "\x0fa" }, { 0x0fb, "\x0fb" },
      { 0x0fc, "\x0fc" }, { 0x0fd, "\x0fd" }, { 0x0fe, "\x0fe" }, { 0x0ff, "\x0ff" },
      { 0x13bc, "OE" }, { 0x13bd, "oe" }, { 0x13be, "Ydiaeresis" },
      { 0x1a1, "Aogonek" }, { 0x1a2, "breve" }, { 0x1a3, "Lstroke" }, { 0x1a5, "Lcaron" },
      { 0x1a6, "Sacute" }, { 0x1a9, "Scaron" }, { 0x1aa, "Scedilla" }, { 0x1ab, "Tcaron" },
      { 0x1ac, "Zacute" }, { 0x1ae, "Zcaron" }, { 0x1af, "Zabovedot" }, { 0x1b1, "aogonek" },
      { 0x1b2, "ogonek" }, { 0x1b3, "lstroke" }, { 0x1b5, "lcaron" }, { 0x1b6, "sacute" },
      { 0x1b7, "caron" }, { 0x1b9, "scaron" }, { 0x1ba, "scedilla" }, { 0x1bb, "tcaron" },
      { 0x1bc, "zacute" }, { 0x1bd, "doubleacute" }, { 0x1be, "zcaron" }, { 0x1bf, "zabovedot" },
      { 0x1c0, "Racute" }, { 0x1c3, "Abreve" }, { 0x1c5, "Lacute" }, { 0x1c6, "Cacute" },
      { 0x1c8, "Ccaron" }, { 0x1ca, "Eogonek" }, { 0x1cc, "Ecaron" }, { 0x1cf, "Dcaron" },
      { 0x1d0, "Dstroke" }, { 0x1d1, "Nacute" }, { 0x1d2, "Ncaron" }, { 0x1d5, "Odoubleacute" },
      { 0x1d8, "Rcaron" }, { 0x1d9, "Uring" }, { 0x1db, "Udoubleacute" }, { 0x1de, "Tcedilla" },
      { 0x1e0, "racute" }, { 0x1e3, "abreve" }, { 0x1e5, "lacute" }, { 0x1e6, "cacute" },
      { 0x1e8, "ccaron" }, { 0x1ea, "eogonek" }, { 0x1ec, "ecaron" }, { 0x1ef, "dcaron" },
      { 0x1f0, "dstroke" }, { 0x1f1, "nacute" }, { 0x1f2, "ncaron" }, { 0x1f5, "odoubleacute" },
      { 0x1f8, "rcaron" }, { 0x1f9, "uring" }, { 0x1fb, "udoubleacute" }, { 0x1fe, "tcedilla" },
      { 0x1ff, "abovedot" }, { 0x20a0, "EcuSign" }, { 0x20a1, "ColonSign" }, { 0x20a2, "CruzeiroSign" },
      { 0x20a3, "FFrancSign" }, { 0x20a4, "LiraSign" }, { 0x20a5, "MillSign" }, { 0x20a6, "NairaSign" },
      { 0x20a7, "PesetaSign" }, { 0x20a8, "RupeeSign" }, { 0x20a9, "WonSign" }, { 0x20aa, "NewSheqelSign" },
      { 0x20ab, "DongSign" }, { 0x20ac, "EuroSign" }, { 0x2a1, "Hstroke" }, { 0x2a6, "Hcircumflex" },
      { 0x2a9, "Iabovedot" }, { 0x2ab, "Gbreve" }, { 0x2ac, "Jcircumflex" }, { 0x2b1, "hstroke" },
      { 0x2b6, "hcircumflex" }, { 0x2b9, "idotless" }, { 0x2bb, "gbreve" }, { 0x2bc, "jcircumflex" },
      { 0x2c5, "Cabovedot" }, { 0x2c6, "Ccircumflex" }, { 0x2d5, "Gabovedot" }, { 0x2d8, "Gcircumflex" },
      { 0x2dd, "Ubreve" }, { 0x2de, "Scircumflex" }, { 0x2e5, "cabovedot" }, { 0x2e6, "ccircumflex" },
      { 0x2f5, "gabovedot" }, { 0x2f8, "gcircumflex" }, { 0x2fd, "ubreve" }, { 0x2fe, "scircumflex" },
      { 0x3a2, "kappa" }, { 0x3a2, "kra" }, { 0x3a3, "Rcedilla" }, { 0x3a5, "Itilde" },
      { 0x3a6, "Lcedilla" }, { 0x3aa, "Emacron" }, { 0x3ab, "Gcedilla" }, { 0x3ac, "Tslash" },
      { 0x3b3, "rcedilla" }, { 0x3b5, "itilde" }, { 0x3b6, "lcedilla" }, { 0x3ba, "emacron" },
      { 0x3bb, "gcedilla" }, { 0x3bc, "tslash" }, { 0x3bd, "ENG" }, { 0x3bf, "eng" },
      { 0x3c0, "Amacron" }, { 0x3c7, "Iogonek" }, { 0x3cc, "Eabovedot" }, { 0x3cf, "Imacron" },
      { 0x3d1, "Ncedilla" }, { 0x3d2, "Omacron" }, { 0x3d3, "Kcedilla" }, { 0x3d9, "Uogonek" },
      { 0x3dd, "Utilde" }, { 0x3de, "Umacron" }, { 0x3e0, "amacron" }, { 0x3e7, "iogonek" },
      { 0x3ec, "eabovedot" }, { 0x3ef, "imacron" }, { 0x3f1, "ncedilla" }, { 0x3f2, "omacron" },
      { 0x3f3, "kcedilla" }, { 0x3f9, "uogonek" }, { 0x3fd, "utilde" }, { 0x3fe, "umacron" },
      { 0x47e, "overline" }, { 0x4a1, "kana_fullstop" }, { 0x4a2, "kana_openingbracket" }, { 0x4a3, "kana_closingbracket" },
      { 0x4a4, "kana_comma" }, { 0x4a5, "kana_conjunctive" }, { 0x4a5, "kana_middledot" }, { 0x4a6, "kana_WO" },
      { 0x4a7, "kana_a" }, { 0x4a8, "kana_i" }, { 0x4a9, "kana_u" }, { 0x4aa, "kana_e" },
      { 0x4ab, "kana_o" }, { 0x4ac, "kana_ya" }, { 0x4ad, "kana_yu" }, { 0x4ae, "kana_yo" },
      { 0x4af, "kana_tsu" }, { 0x4af, "kana_tu" }, { 0x4b0, "prolongedsound" }, { 0x4b1, "kana_A" },
      { 0x4b2, "kana_I" }, { 0x4b3, "kana_U" }, { 0x4b4, "kana_E" }, { 0x4b5, "kana_O" },
      { 0x4b6, "kana_KA" }, { 0x4b7, "kana_KI" }, { 0x4b8, "kana_KU" }, { 0x4b9, "kana_KE" },
      { 0x4ba, "kana_KO" }, { 0x4bb, "kana_SA" }, { 0x4bc, "kana_SHI" }, { 0x4bd, "kana_SU" },
      { 0x4be, "kana_SE" }, { 0x4bf, "kana_SO" }, { 0x4c0, "kana_TA" }, { 0x4c1, "kana_CHI" },
      { 0x4c1, "kana_TI" }, { 0x4c2, "kana_TSU" }, { 0x4c2, "kana_TU" }, { 0x4c3, "kana_TE" },
      { 0x4c4, "kana_TO" }, { 0x4c5, "kana_NA" }, { 0x4c6, "kana_NI" }, { 0x4c7, "kana_NU" },
      { 0x4c8, "kana_NE" }, { 0x4c9, "kana_NO" }, { 0x4ca, "kana_HA" }, { 0x4cb, "kana_HI" },
      { 0x4cc, "kana_FU" }, { 0x4cc, "kana_HU" }, { 0x4cd, "kana_HE" }, { 0x4ce, "kana_HO" },
      { 0x4cf, "kana_MA" }, { 0x4d0, "kana_MI" }, { 0x4d1, "kana_MU" }, { 0x4d2, "kana_ME" },
      { 0x4d3, "kana_MO" }, { 0x4d4, "kana_YA" }, { 0x4d5, "kana_YU" }, { 0x4d6, "kana_YO" },
      { 0x4d7, "kana_RA" }, { 0x4d8, "kana_RI" }, { 0x4d9, "kana_RU" }, { 0x4da, "kana_RE" },
      { 0x4db, "kana_RO" }, { 0x4dc, "kana_WA" }, { 0x4dd, "kana_N" }, { 0x4de, "voicedsound" },
      { 0x4df, "semivoicedsound" }, { 0x5ac, "Arabic_comma" }, { 0x5bb, "Arabic_semicolon" }, { 0x5bf, "Arabic_question_mark" },
      { 0x5c1, "Arabic_hamza" }, { 0x5c2, "Arabic_maddaonalef" }, { 0x5c3, "Arabic_hamzaonalef" }, { 0x5c4, "Arabic_hamzaonwaw" },
      { 0x5c5, "Arabic_hamzaunderalef" }, { 0x5c6, "Arabic_hamzaonyeh" }, { 0x5c7, "Arabic_alef" }, { 0x5c8, "Arabic_beh" },
      { 0x5c9, "Arabic_tehmarbuta" }, { 0x5ca, "Arabic_teh" }, { 0x5cb, "Arabic_theh" }, { 0x5cc, "Arabic_jeem" },
      { 0x5cd, "Arabic_hah" }, { 0x5ce, "Arabic_khah" }, { 0x5cf, "Arabic_dal" }, { 0x5d0, "Arabic_thal" },
      { 0x5d1, "Arabic_ra" }, { 0x5d2, "Arabic_zain" }, { 0x5d3, "Arabic_seen" }, { 0x5d4, "Arabic_sheen" },
      { 0x5d5, "Arabic_sad" }, { 0x5d6, "Arabic_dad" }, { 0x5d7, "Arabic_tah" }, { 0x5d8, "Arabic_zah" },
      { 0x5d9, "Arabic_ain" }, { 0x5da, "Arabic_ghain" }, { 0x5e0, "Arabic_tatweel" }, { 0x5e1, "Arabic_feh" },
      { 0x5e2, "Arabic_qaf" }, { 0x5e3, "Arabic_kaf" }, { 0x5e4, "Arabic_lam" }, { 0x5e5, "Arabic_meem" },
      { 0x5e6, "Arabic_noon" }, { 0x5e7, "Arabic_ha" }, { 0x5e7, "Arabic_heh" }, { 0x5e8, "Arabic_waw" },
      { 0x5e9, "Arabic_alefmaksura" }, { 0x5ea, "Arabic_yeh" }, { 0x5eb, "Arabic_fathatan" }, { 0x5ec, "Arabic_dammatan" },
      { 0x5ed, "Arabic_kasratan" }, { 0x5ee, "Arabic_fatha" }, { 0x5ef, "Arabic_damma" }, { 0x5f0, "Arabic_kasra" },
      { 0x5f1, "Arabic_shadda" }, { 0x5f2, "Arabic_sukun" }, { 0x6a1, "Serbian_dje" }, { 0x6a2, "Macedonia_gje" },
      { 0x6a3, "Cyrillic_io" }, { 0x6a4, "Ukrainian_ie" }, { 0x6a4, "Ukranian_je" }, { 0x6a5, "Macedonia_dse" },
      { 0x6a6, "Ukrainian_i" }, { 0x6a6, "Ukranian_i" }, { 0x6a7, "Ukrainian_yi" }, { 0x6a7, "Ukranian_yi" },
      { 0x6a8, "Cyrillic_je" }, { 0x6a8, "Serbian_je" }, { 0x6a9, "Cyrillic_lje" }, { 0x6a9, "Serbian_lje" },
      { 0x6aa, "Cyrillic_nje" }, { 0x6aa, "Serbian_nje" }, { 0x6ab, "Serbian_tshe" }, { 0x6ac, "Macedonia_kje" },
      { 0x6ae, "Byelorussian_shortu" }, { 0x6af, "Cyrillic_dzhe" }, { 0x6af, "Serbian_dze" }, { 0x6b0, "numerosign" },
      { 0x6b1, "Serbian_DJE" }, { 0x6b2, "Macedonia_GJE" }, { 0x6b3, "Cyrillic_IO" }, { 0x6b4, "Ukrainian_IE" },
      { 0x6b4, "Ukranian_JE" }, { 0x6b5, "Macedonia_DSE" }, { 0x6b6, "Ukrainian_I" }, { 0x6b6, "Ukranian_I" },
      { 0x6b7, "Ukrainian_YI" }, { 0x6b7, "Ukranian_YI" }, { 0x6b8, "Cyrillic_JE" }, { 0x6b8, "Serbian_JE" },
      { 0x6b9, "Cyrillic_LJE" }, { 0x6b9, "Serbian_LJE" }, { 0x6ba, "Cyrillic_NJE" }, { 0x6ba, "Serbian_NJE" },
      { 0x6bb, "Serbian_TSHE" }, { 0x6bc, "Macedonia_KJE" }, { 0x6be, "Byelorussian_SHORTU" }, { 0x6bf, "Cyrillic_DZHE" },
      { 0x6bf, "Serbian_DZE" }, { 0x6c0, "Cyrillic_yu" }, { 0x6c1, "Cyrillic_a" }, { 0x6c2, "Cyrillic_be" },
      { 0x6c3, "Cyrillic_tse" }, { 0x6c4, "Cyrillic_de" }, { 0x6c5, "Cyrillic_ie" }, { 0x6c6, "Cyrillic_ef" },
      { 0x6c7, "Cyrillic_ghe" }, { 0x6c8, "Cyrillic_ha" }, { 0x6c9, "Cyrillic_i" }, { 0x6ca, "Cyrillic_shorti" },
      { 0x6cb, "Cyrillic_ka" }, { 0x6cc, "Cyrillic_el" }, { 0x6cd, "Cyrillic_em" }, { 0x6ce, "Cyrillic_en" },
      { 0x6cf, "Cyrillic_o" }, { 0x6d0, "Cyrillic_pe" }, { 0x6d1, "Cyrillic_ya" }, { 0x6d2, "Cyrillic_er" },
      { 0x6d3, "Cyrillic_es" }, { 0x6d4, "Cyrillic_te" }, { 0x6d5, "Cyrillic_u" }, { 0x6d6, "Cyrillic_zhe" },
      { 0x6d7, "Cyrillic_ve" }, { 0x6d8, "Cyrillic_softsign" }, { 0x6d9, "Cyrillic_yeru" }, { 0x6da, "Cyrillic_ze" },
      { 0x6db, "Cyrillic_sha" }, { 0x6dc, "Cyrillic_e" }, { 0x6dd, "Cyrillic_shcha" }, { 0x6de, "Cyrillic_che" },
      { 0x6df, "Cyrillic_hardsign" }, { 0x6e0, "Cyrillic_YU" }, { 0x6e1, "Cyrillic_A" }, { 0x6e2, "Cyrillic_BE" },
      { 0x6e3, "Cyrillic_TSE" }, { 0x6e4, "Cyrillic_DE" }, { 0x6e5, "Cyrillic_IE" }, { 0x6e6, "Cyrillic_EF" },
      { 0x6e7, "Cyrillic_GHE" }, { 0x6e8, "Cyrillic_HA" }, { 0x6e9, "Cyrillic_I" }, { 0x6ea, "Cyrillic_SHORTI" },
      { 0x6eb, "Cyrillic_KA" }, { 0x6ec, "Cyrillic_EL" }, { 0x6ed, "Cyrillic_EM" }, { 0x6ee, "Cyrillic_EN" },
      { 0x6ef, "Cyrillic_O" }, { 0x6f0, "Cyrillic_PE" }, { 0x6f1, "Cyrillic_YA" }, { 0x6f2, "Cyrillic_ER" },
      { 0x6f3, "Cyrillic_ES" }, { 0x6f4, "Cyrillic_TE" }, { 0x6f5, "Cyrillic_U" }, { 0x6f6, "Cyrillic_ZHE" },
      { 0x6f7, "Cyrillic_VE" }, { 0x6f8, "Cyrillic_SOFTSIGN" }, { 0x6f9, "Cyrillic_YERU" }, { 0x6fa, "Cyrillic_ZE" },
      { 0x6fb, "Cyrillic_SHA" }, { 0x6fc, "Cyrillic_E" }, { 0x6fd, "Cyrillic_SHCHA" }, { 0x6fe, "Cyrillic_CHE" },
      { 0x6ff, "Cyrillic_HARDSIGN" }, { 0x7a1, "Greek_ALPHAaccent" }, { 0x7a2, "Greek_EPSILONaccent" }, { 0x7a3, "Greek_ETAaccent" },
      { 0x7a4, "Greek_IOTAaccent" }, { 0x7a5, "Greek_IOTAdiaeresis" }, { 0x7a7, "Greek_OMICRONaccent" }, { 0x7a8, "Greek_UPSILONaccent" },
      { 0x7a9, "Greek_UPSILONdieresis" }, { 0x7ab, "Greek_OMEGAaccent" }, { 0x7ae, "Greek_accentdieresis" }, { 0x7af, "Greek_horizbar" },
      { 0x7b1, "Greek_alphaaccent" }, { 0x7b2, "Greek_epsilonaccent" }, { 0x7b3, "Greek_etaaccent" }, { 0x7b4, "Greek_iotaaccent" },
      { 0x7b5, "Greek_iotadieresis" }, { 0x7b6, "Greek_iotaaccentdieresis" }, { 0x7b7, "Greek_omicronaccent" }, { 0x7b8, "Greek_upsilonaccent" },
      { 0x7b9, "Greek_upsilondieresis" }, { 0x7ba, "Greek_upsilonaccentdieresis" }, { 0x7bb, "Greek_omegaaccent" }, { 0x7c1, "Greek_ALPHA" },
      { 0x7c2, "Greek_BETA" }, { 0x7c3, "Greek_GAMMA" }, { 0x7c4, "Greek_DELTA" }, { 0x7c5, "Greek_EPSILON" },
      { 0x7c6, "Greek_ZETA" }, { 0x7c7, "Greek_ETA" }, { 0x7c8, "Greek_THETA" }, { 0x7c9, "Greek_IOTA" },
      { 0x7ca, "Greek_KAPPA" }, { 0x7cb, "Greek_LAMBDA" }, { 0x7cb, "Greek_LAMDA" }, { 0x7cc, "Greek_MU" },
      { 0x7cd, "Greek_NU" }, { 0x7ce, "Greek_XI" }, { 0x7cf, "Greek_OMICRON" }, { 0x7d0, "Greek_PI" },
      { 0x7d1, "Greek_RHO" }, { 0x7d2, "Greek_SIGMA" }, { 0x7d4, "Greek_TAU" }, { 0x7d5, "Greek_UPSILON" },
      { 0x7d6, "Greek_PHI" }, { 0x7d7, "Greek_CHI" }, { 0x7d8, "Greek_PSI" }, { 0x7d9, "Greek_OMEGA" },
      { 0x7e1, "Greek_alpha" }, { 0x7e2, "Greek_beta" }, { 0x7e3, "Greek_gamma" }, { 0x7e4, "Greek_delta" },
      { 0x7e5, "Greek_epsilon" }, { 0x7e6, "Greek_zeta" }, { 0x7e7, "Greek_eta" }, { 0x7e8, "Greek_theta" },
      { 0x7e9, "Greek_iota" }, { 0x7ea, "Greek_kappa" }, { 0x7eb, "Greek_lambda" }, { 0x7eb, "Greek_lamda" },
      { 0x7ec, "Greek_mu" }, { 0x7ed, "Greek_nu" }, { 0x7ee, "Greek_xi" }, { 0x7ef, "Greek_omicron" },
      { 0x7f0, "Greek_pi" }, { 0x7f1, "Greek_rho" }, { 0x7f2, "Greek_sigma" }, { 0x7f3, "Greek_finalsmallsigma" },
      { 0x7f4, "Greek_tau" }, { 0x7f5, "Greek_upsilon" }, { 0x7f6, "Greek_phi" }, { 0x7f7, "Greek_chi" },
      { 0x7f8, "Greek_psi" }, { 0x7f9, "Greek_omega" }, { 0x8a1, "leftradical" }, { 0x8a2, "topleftradical" },
      { 0x8a3, "horizconnector" }, { 0x8a4, "topintegral" }, { 0x8a5, "botintegral" }, { 0x8a6, "vertconnector" },
      { 0x8a7, "topleftsqbracket" }, { 0x8a8, "botleftsqbracket" }, { 0x8a9, "toprightsqbracket" }, { 0x8aa, "botrightsqbracket" },
      { 0x8ab, "topleftparens" }, { 0x8ac, "botleftparens" }, { 0x8ad, "toprightparens" }, { 0x8ae, "botrightparens" },
      { 0x8af, "leftmiddlecurlybrace" }, { 0x8b0, "rightmiddlecurlybrace" }, { 0x8b1, "topleftsummation" }, { 0x8b2, "botleftsummation" },
      { 0x8b3, "topvertsummationconnector" }, { 0x8b4, "botvertsummationconnector" }, { 0x8b5, "toprightsummation" }, { 0x8b6, "botrightsummation" },
      { 0x8b7, "rightmiddlesummation" }, { 0x8bc, "lessthanequal" }, { 0x8bd, "notequal" }, { 0x8be, "greaterthanequal" },
      { 0x8bf, "integral" }, { 0x8c0, "therefore" }, { 0x8c1, "variation" }, { 0x8c2, "infinity" },
      { 0x8c5, "nabla" }, { 0x8c8, "approximate" }, { 0x8c9, "similarequal" }, { 0x8cd, "ifonlyif" },
      { 0x8ce, "implies" }, { 0x8cf, "identical" }, { 0x8d6, "radical" }, { 0x8da, "includedin" },
      { 0x8db, "includes" }, { 0x8dc, "intersection" }, { 0x8dd, "union" }, { 0x8de, "logicaland" },
      { 0x8df, "logicalor" }, { 0x8ef, "partialderivative" }, { 0x8f6, "function" }, { 0x8fb, "leftarrow" },
      { 0x8fc, "uparrow" }, { 0x8fd, "rightarrow" }, { 0x8fe, "downarrow" }, { 0x9df, "blank" },
      { 0x9e0, "soliddiamond" }, { 0x9e1, "checkerboard" }, { 0x9e2, "ht" }, { 0x9e3, "ff" },
      { 0x9e4, "cr" }, { 0x9e5, "lf" }, { 0x9e8, "nl" }, { 0x9e9, "vt" },
      { 0x9ea, "lowrightcorner" }, { 0x9eb, "uprightcorner" }, { 0x9ec, "upleftcorner" }, { 0x9ed, "lowleftcorner" },
      { 0x9ee, "crossinglines" }, { 0x9ef, "horizlinescan1" }, { 0x9f0, "horizlinescan3" }, { 0x9f1, "horizlinescan5" },
      { 0x9f2, "horizlinescan7" }, { 0x9f3, "horizlinescan9" }, { 0x9f4, "leftt" }, { 0x9f5, "rightt" },
      { 0x9f6, "bott" }, { 0x9f7, "topt" }, { 0x9f8, "vertbar" }, { 0xaa1, "emspace" },
      { 0xaa2, "enspace" }, { 0xaa3, "em3space" }, { 0xaa4, "em4space" }, { 0xaa5, "digitspace" },
      { 0xaa6, "punctspace" }, { 0xaa7, "thinspace" }, { 0xaa8, "hairspace" }, { 0xaa9, "emdash" },
      { 0xaaa, "endash" }, { 0xaac, "signifblank" }, { 0xaae, "ellipsis" }, { 0xaaf, "doubbaselinedot" },
      { 0xab0, "onethird" }, { 0xab1, "twothirds" }, { 0xab2, "onefifth" }, { 0xab3, "twofifths" },
      { 0xab4, "threefifths" }, { 0xab5, "fourfifths" }, { 0xab6, "onesixth" }, { 0xab7, "fivesixths" },
      { 0xab8, "careof" }, { 0xabb, "figdash" }, { 0xabc, "leftanglebracket" }, { 0xabd, "decimalpoint" },
      { 0xabe, "rightanglebracket" }, { 0xabf, "marker" }, { 0xac3, "oneeighth" }, { 0xac4, "threeeighths" },
      { 0xac5, "fiveeighths" }, { 0xac6, "seveneighths" }, { 0xac9, "trademark" }, { 0xaca, "signaturemark" },
      { 0xacb, "trademarkincircle" }, { 0xacc, "leftopentriangle" }, { 0xacd, "rightopentriangle" }, { 0xace, "emopencircle" },
      { 0xacf, "emopenrectangle" }, { 0xad0, "leftsinglequotemark" }, { 0xad1, "rightsinglequotemark" }, { 0xad2, "leftdoublequotemark" },
      { 0xad3, "rightdoublequotemark" }, { 0xad4, "prescription" }, { 0xad6, "minutes" }, { 0xad7, "seconds" },
      { 0xad9, "latincross" }, { 0xada, "hexagram" }, { 0xadb, "filledrectbullet" }, { 0xadc, "filledlefttribullet" },
      { 0xadd, "filledrighttribullet" }, { 0xade, "emfilledcircle" }, { 0xadf, "emfilledrect" }, { 0xae0, "enopencircbullet" },
      { 0xae1, "enopensquarebullet" }, { 0xae2, "openrectbullet" }, { 0xae3, "opentribulletup" }, { 0xae4, "opentribulletdown" },
      { 0xae5, "openstar" }, { 0xae6, "enfilledcircbullet" }, { 0xae7, "enfilledsqbullet" }, { 0xae8, "filledtribulletup" },
      { 0xae9, "filledtribulletdown" }, { 0xaea, "leftpointer" }, { 0xaeb, "rightpointer" }, { 0xaec, "club" },
      { 0xaed, "diamond" }, { 0xaee, "heart" }, { 0xaf0, "maltesecross" }, { 0xaf1, "dagger" },
      { 0xaf2, "doubledagger" }, { 0xaf3, "checkmark" }, { 0xaf4, "ballotcross" }, { 0xaf5, "musicalsharp" },
      { 0xaf6, "musicalflat" }, { 0xaf7, "malesymbol" }, { 0xaf8, "femalesymbol" }, { 0xaf9, "telephone" },
      { 0xafa, "telephonerecorder" }, { 0xafb, "phonographcopyright" }, { 0xafc, "caret" }, { 0xafd, "singlelowquotemark" },
      { 0xafe, "doublelowquotemark" }, { 0xaff, "cursor" }, { 0xba3, "leftcaret" }, { 0xba6, "rightcaret" },
      { 0xba8, "downcaret" }, { 0xba9, "upcaret" }, { 0xbc0, "overbar" }, { 0xbc2, "downtack" },
      { 0xbc3, "upshoe" }, { 0xbc4, "downstile" }, { 0xbc6, "underbar" }, { 0xbca, "jot" },
      { 0xbcc, "quad" }, { 0xbce, "uptack" }, { 0xbcf, "circle" }, { 0xbd3, "upstile" },
      { 0xbd6, "downshoe" }, { 0xbd8, "rightshoe" }, { 0xbda, "leftshoe" }, { 0xbdc, "lefttack" },
      { 0xbfc, "righttack" }, { 0xcdf, "hebrew_doublelowline" }, { 0xce0, "hebrew_aleph" }, { 0xce1, "hebrew_bet" },
      { 0xce1, "hebrew_beth" }, { 0xce2, "hebrew_gimel" }, { 0xce2, "hebrew_gimmel" }, { 0xce3, "hebrew_dalet" },
      { 0xce3, "hebrew_daleth" }, { 0xce4, "hebrew_he" }, { 0xce5, "hebrew_waw" }, { 0xce6, "hebrew_zain" },
      { 0xce6, "hebrew_zayin" }, { 0xce7, "hebrew_chet" }, { 0xce7, "hebrew_het" }, { 0xce8, "hebrew_tet" },
      { 0xce8, "hebrew_teth" }, { 0xce9, "hebrew_yod" }, { 0xcea, "hebrew_finalkaph" }, { 0xceb, "hebrew_kaph" },
      { 0xcec, "hebrew_lamed" }, { 0xced, "hebrew_finalmem" }, { 0xcee, "hebrew_mem" }, { 0xcef, "hebrew_finalnun" },
      { 0xcf0, "hebrew_nun" }, { 0xcf1, "hebrew_samech" }, { 0xcf1, "hebrew_samekh" }, { 0xcf2, "hebrew_ayin" },
      { 0xcf3, "hebrew_finalpe" }, { 0xcf4, "hebrew_pe" }, { 0xcf5, "hebrew_finalzade" }, { 0xcf5, "hebrew_finalzadi" },
      { 0xcf6, "hebrew_zade" }, { 0xcf6, "hebrew_zadi" }, { 0xcf7, "hebrew_kuf" }, { 0xcf7, "hebrew_qoph" },
      { 0xcf8, "hebrew_resh" }, { 0xcf9, "hebrew_shin" }, { 0xcfa, "hebrew_taf" }, { 0xcfa, "hebrew_taw" },
      { 0xda1, "Thai_kokai" }, { 0xda2, "Thai_khokhai" }, { 0xda3, "Thai_khokhuat" }, { 0xda4, "Thai_khokhwai" },
      { 0xda5, "Thai_khokhon" }, { 0xda6, "Thai_khorakhang" }, { 0xda7, "Thai_ngongu" }, { 0xda8, "Thai_chochan" },
      { 0xda9, "Thai_choching" }, { 0xdaa, "Thai_chochang" }, { 0xdab, "Thai_soso" }, { 0xdac, "Thai_chochoe" },
      { 0xdad, "Thai_yoying" }, { 0xdae, "Thai_dochada" }, { 0xdaf, "Thai_topatak" }, { 0xdb0, "Thai_thothan" },
      { 0xdb1, "Thai_thonangmontho" }, { 0xdb2, "Thai_thophuthao" }, { 0xdb3, "Thai_nonen" }, { 0xdb4, "Thai_dodek" },
      { 0xdb5, "Thai_totao" }, { 0xdb6, "Thai_thothung" }, { 0xdb7, "Thai_thothahan" }, { 0xdb8, "Thai_thothong" },
      { 0xdb9, "Thai_nonu" }, { 0xdba, "Thai_bobaimai" }, { 0xdbb, "Thai_popla" }, { 0xdbc, "Thai_phophung" },
      { 0xdbd, "Thai_fofa" }, { 0xdbe, "Thai_phophan" }, { 0xdbf, "Thai_fofan" }, { 0xdc0, "Thai_phosamphao" },
      { 0xdc1, "Thai_moma" }, { 0xdc2, "Thai_yoyak" }, { 0xdc3, "Thai_rorua" }, { 0xdc4, "Thai_ru" },
      { 0xdc5, "Thai_loling" }, { 0xdc6, "Thai_lu" }, { 0xdc7, "Thai_wowaen" }, { 0xdc8, "Thai_sosala" },
      { 0xdc9, "Thai_sorusi" }, { 0xdca, "Thai_sosua" }, { 0xdcb, "Thai_hohip" }, { 0xdcc, "Thai_lochula" },
      { 0xdcd, "Thai_oang" }, { 0xdce, "Thai_honokhuk" }, { 0xdcf, "Thai_paiyannoi" }, { 0xdd0, "Thai_saraa" },
      { 0xdd1, "Thai_maihanakat" }, { 0xdd2, "Thai_saraaa" }, { 0xdd3, "Thai_saraam" }, { 0xdd4, "Thai_sarai" },
      { 0xdd5, "Thai_saraii" }, { 0xdd6, "Thai_saraue" }, { 0xdd7, "Thai_sarauee" }, { 0xdd8, "Thai_sarau" },
      { 0xdd9, "Thai_sarauu" }, { 0xdda, "Thai_phinthu" }, { 0xdde, "Thai_maihanakat_maitho" }, { 0xddf, "Thai_baht" },
      { 0xde0, "Thai_sarae" }, { 0xde1, "Thai_saraae" }, { 0xde2, "Thai_sarao" }, { 0xde3, "Thai_saraaimaimuan" },
      { 0xde4, "Thai_saraaimaimalai" }, { 0xde5, "Thai_lakkhangyao" }, { 0xde6, "Thai_maiyamok" }, { 0xde7, "Thai_maitaikhu" },
      { 0xde8, "Thai_maiek" }, { 0xde9, "Thai_maitho" }, { 0xdea, "Thai_maitri" }, { 0xdeb, "Thai_maichattawa" },
      { 0xdec, "Thai_thanthakhat" }, { 0xded, "Thai_nikhahit" }, { 0xdf0, "Thai_leksun" }, { 0xdf1, "Thai_leknung" },
      { 0xdf2, "Thai_leksong" }, { 0xdf3, "Thai_leksam" }, { 0xdf4, "Thai_leksi" }, { 0xdf5, "Thai_lekha" },
      { 0xdf6, "Thai_lekhok" }, { 0xdf7, "Thai_lekchet" }, { 0xdf8, "Thai_lekpaet" }, { 0xdf9, "Thai_lekkao" },
      { 0xea1, "Hangul_Kiyeog" }, { 0xea2, "Hangul_SsangKiyeog" }, { 0xea3, "Hangul_KiyeogSios" }, { 0xea4, "Hangul_Nieun" },
      { 0xea5, "Hangul_NieunJieuj" }, { 0xea6, "Hangul_NieunHieuh" }, { 0xea7, "Hangul_Dikeud" }, { 0xea8, "Hangul_SsangDikeud" },
      { 0xea9, "Hangul_Rieul" }, { 0xeaa, "Hangul_RieulKiyeog" }, { 0xeab, "Hangul_RieulMieum" }, { 0xeac, "Hangul_RieulPieub" },
      { 0xead, "Hangul_RieulSios" }, { 0xeae, "Hangul_RieulTieut" }, { 0xeaf, "Hangul_RieulPhieuf" }, { 0xeb0, "Hangul_RieulHieuh" },
      { 0xeb1, "Hangul_Mieum" }, { 0xeb2, "Hangul_Pieub" }, { 0xeb3, "Hangul_SsangPieub" }, { 0xeb4, "Hangul_PieubSios" },
      { 0xeb5, "Hangul_Sios" }, { 0xeb6, "Hangul_SsangSios" }, { 0xeb7, "Hangul_Ieung" }, { 0xeb8, "Hangul_Jieuj" },
      { 0xeb9, "Hangul_SsangJieuj" }, { 0xeba, "Hangul_Cieuc" }, { 0xebb, "Hangul_Khieuq" }, { 0xebc, "Hangul_Tieut" },
      { 0xebd, "Hangul_Phieuf" }, { 0xebe, "Hangul_Hieuh" }, { 0xebf, "Hangul_A" }, { 0xec0, "Hangul_AE" },
      { 0xec1, "Hangul_YA" }, { 0xec2, "Hangul_YAE" }, { 0xec3, "Hangul_EO" }, { 0xec4, "Hangul_E" },
      { 0xec5, "Hangul_YEO" }, { 0xec6, "Hangul_YE" }, { 0xec7, "Hangul_O" }, { 0xec8, "Hangul_WA" },
      { 0xec9, "Hangul_WAE" }, { 0xeca, "Hangul_OE" }, { 0xecb, "Hangul_YO" }, { 0xecc, "Hangul_U" },
      { 0xecd, "Hangul_WEO" }, { 0xece, "Hangul_WE" }, { 0xecf, "Hangul_WI" }, { 0xed0, "Hangul_YU" },
      { 0xed1, "Hangul_EU" }, { 0xed2, "Hangul_YI" }, { 0xed3, "Hangul_I" }, { 0xed4, "Hangul_J_Kiyeog" },
      { 0xed5, "Hangul_J_SsangKiyeog" }, { 0xed6, "Hangul_J_KiyeogSios" }, { 0xed7, "Hangul_J_Nieun" }, { 0xed8, "Hangul_J_NieunJieuj" },
      { 0xed9, "Hangul_J_NieunHieuh" }, { 0xeda, "Hangul_J_Dikeud" }, { 0xedb, "Hangul_J_Rieul" }, { 0xedc, "Hangul_J_RieulKiyeog" },
      { 0xedd, "Hangul_J_RieulMieum" }, { 0xede, "Hangul_J_RieulPieub" }, { 0xedf, "Hangul_J_RieulSios" }, { 0xee0, "Hangul_J_RieulTieut" },
      { 0xee1, "Hangul_J_RieulPhieuf" }, { 0xee2, "Hangul_J_RieulHieuh" }, { 0xee3, "Hangul_J_Mieum" }, { 0xee4, "Hangul_J_Pieub" },
      { 0xee5, "Hangul_J_PieubSios" }, { 0xee6, "Hangul_J_Sios" }, { 0xee7, "Hangul_J_SsangSios" }, { 0xee8, "Hangul_J_Ieung" },
      { 0xee9, "Hangul_J_Jieuj" }, { 0xeea, "Hangul_J_Cieuc" }, { 0xeeb, "Hangul_J_Khieuq" }, { 0xeec, "Hangul_J_Tieut" },
      { 0xeed, "Hangul_J_Phieuf" }, { 0xeee, "Hangul_J_Hieuh" }, { 0xeef, "Hangul_RieulYeorinHieuh" }, { 0xef0, "Hangul_SunkyeongeumMieum" },
      { 0xef1, "Hangul_SunkyeongeumPieub" }, { 0xef2, "Hangul_PanSios" }, { 0xef3, "Hangul_KkogjiDalrinIeung" }, { 0xef4, "Hangul_SunkyeongeumPhieuf" },
      { 0xef5, "Hangul_YeorinHieuh" }, { 0xef6, "Hangul_AraeA" }, { 0xef7, "Hangul_AraeAE" }, { 0xef8, "Hangul_J_PanSios" },
      { 0xef9, "Hangul_J_KkogjiDalrinIeung" }, { 0xefa, "Hangul_J_YeorinHieuh" }, { 0xeff, "Korean_Won" }, { 0xFD01, "3270_Duplicate" },
      { 0xFD02, "3270_FieldMark" }, { 0xFD03, "3270_Right2" }, { 0xFD04, "3270_Left2" }, { 0xFD05, "3270_BackTab" },
      { 0xFD06, "3270_EraseEOF" }, { 0xFD07, "3270_EraseInput" }, { 0xFD08, "3270_Reset" }, { 0xFD09, "3270_Quit" },
      { 0xFD0A, "3270_PA1" }, { 0xFD0B, "3270_PA2" }, { 0xFD0C, "3270_PA3" }, { 0xFD0D, "3270_Test" },
      { 0xFD0E, "3270_Attn" }, { 0xFD0F, "3270_CursorBlink" }, { 0xFD10, "3270_AltCursor" }, { 0xFD11, "3270_KeyClick" },
      { 0xFD12, "3270_Jump" }, { 0xFD13, "3270_Ident" }, { 0xFD14, "3270_Rule" }, { 0xFD15, "3270_Copy" },
      { 0xFD16, "3270_Play" }, { 0xFD17, "3270_Setup" }, { 0xFD18, "3270_Record" }, { 0xFD19, "3270_ChangeScreen" },
      { 0xFD1A, "3270_DeleteWord" }, { 0xFD1B, "3270_ExSelect" }, { 0xFD1C, "3270_CursorSelect" }, { 0xFD1D, "3270_PrintScreen" },
      { 0xFD1E, "3270_Enter" }, { 0xFE01, "ISO_Lock" }, { 0xFE02, "ISO_Level2_Latch" }, { 0xFE03, "ISO_Level3_Shift" },
      { 0xFE04, "ISO_Level3_Latch" }, { 0xFE05, "ISO_Level3_Lock" }, { 0xFE06, "ISO_Group_Latch" }, { 0xFE07, "ISO_Group_Lock" },
      { 0xFE08, "ISO_Next_Group" }, { 0xFE09, "ISO_Next_Group_Lock" }, { 0xFE0A, "ISO_Prev_Group" }, { 0xFE0B, "ISO_Prev_Group_Lock" },
      { 0xFE0C, "ISO_First_Group" }, { 0xFE0D, "ISO_First_Group_Lock" }, { 0xFE0E, "ISO_Last_Group" }, { 0xFE0F, "ISO_Last_Group_Lock" },
      { 0xFE20, "ISO_Left_Tab" }, { 0xFE21, "ISO_Move_Line_Up" }, { 0xFE22, "ISO_Move_Line_Down" }, { 0xFE23, "ISO_Partial_Line_Up" },
      { 0xFE24, "ISO_Partial_Line_Down" }, { 0xFE25, "ISO_Partial_Space_Left" }, { 0xFE26, "ISO_Partial_Space_Right" }, { 0xFE27, "ISO_Set_Margin_Left" },
      { 0xFE28, "ISO_Set_Margin_Right" }, { 0xFE29, "ISO_Release_Margin_Left" }, { 0xFE2A, "ISO_Release_Margin_Right" }, { 0xFE2B, "ISO_Release_Both_Margins" },
      { 0xFE2C, "ISO_Fast_Cursor_Left" }, { 0xFE2D, "ISO_Fast_Cursor_Right" }, { 0xFE2E, "ISO_Fast_Cursor_Up" }, { 0xFE2F, "ISO_Fast_Cursor_Down" },
      { 0xFE30, "ISO_Continuous_Underline" }, { 0xFE31, "ISO_Discontinuous_Underline" }, { 0xFE32, "ISO_Emphasize" }, { 0xFE33, "ISO_Center_Object" },
      { 0xFE34, "ISO_Enter" }, { 0xFE50, "dead_grave" }, { 0xFE51, "dead_acute" }, { 0xFE52, "dead_circumflex" },
      { 0xFE53, "dead_tilde" }, { 0xFE54, "dead_macron" }, { 0xFE55, "dead_breve" }, { 0xFE56, "dead_abovedot" },
      { 0xFE57, "dead_diaeresis" }, { 0xFE58, "dead_abovering" }, { 0xFE59, "dead_doubleacute" }, { 0xFE5A, "dead_caron" },
      { 0xFE5B, "dead_cedilla" }, { 0xFE5C, "dead_ogonek" }, { 0xFE5D, "dead_iota" }, { 0xFE5E, "dead_voiced_sound" },
      { 0xFE5F, "dead_semivoiced_sound" }, { 0xFE60, "dead_belowdot" }, { 0xFE70, "AccessX_Enable" }, { 0xFE71, "AccessX_Feedback_Enable" },
      { 0xFE72, "RepeatKeys_Enable" }, { 0xFE73, "SlowKeys_Enable" }, { 0xFE74, "BounceKeys_Enable" }, { 0xFE75, "StickyKeys_Enable" },
      { 0xFE76, "MouseKeys_Enable" }, { 0xFE77, "MouseKeys_Accel_Enable" }, { 0xFE78, "Overlay1_Enable" }, { 0xFE79, "Overlay2_Enable" },
      { 0xFE7A, "AudibleBell_Enable" }, { 0xFED0, "First_Virtual_Screen" }, { 0xFED1, "Prev_Virtual_Screen" }, { 0xFED2, "Next_Virtual_Screen" },
      { 0xFED4, "Last_Virtual_Screen" }, { 0xFED5, "Terminate_Server" }, { 0xFEE0, "Pointer_Left" }, { 0xFEE1, "Pointer_Right" },
      { 0xFEE2, "Pointer_Up" }, { 0xFEE3, "Pointer_Down" }, { 0xFEE4, "Pointer_UpLeft" }, { 0xFEE5, "Pointer_UpRight" },
      { 0xFEE6, "Pointer_DownLeft" }, { 0xFEE7, "Pointer_DownRight" }, { 0xFEE8, "Pointer_Button_Dflt" }, { 0xFEE9, "Pointer_Button1" },
      { 0xFEEA, "Pointer_Button2" }, { 0xFEEB, "Pointer_Button3" }, { 0xFEEC, "Pointer_Button4" }, { 0xFEED, "Pointer_Button5" },
      { 0xFEEE, "Pointer_DblClick_Dflt" }, { 0xFEEF, "Pointer_DblClick1" }, { 0xFEF0, "Pointer_DblClick2" }, { 0xFEF1, "Pointer_DblClick3" },
      { 0xFEF2, "Pointer_DblClick4" }, { 0xFEF3, "Pointer_DblClick5" }, { 0xFEF4, "Pointer_Drag_Dflt" }, { 0xFEF5, "Pointer_Drag1" },
      { 0xFEF6, "Pointer_Drag2" }, { 0xFEF7, "Pointer_Drag3" }, { 0xFEF8, "Pointer_Drag4" }, { 0xFEF9, "Pointer_EnableKeys" },
      { 0xFEFA, "Pointer_Accelerate" }, { 0xFEFB, "Pointer_DfltBtnNext" }, { 0xFEFC, "Pointer_DfltBtnPrev" }, { 0xFEFD, "Pointer_Drag5" },
      { 0xFF08, "BackSpace" }, { 0xFF09, "Tab" }, { 0xFF0A, "Linefeed" }, { 0xFF0B, "Clear" },
      { 0xFF0D, "Return" }, { 0xFF13, "Pause" }, { 0xFF14, "Scroll_Lock" }, { 0xFF15, "Sys_Req" },
      { 0xFF1B, "Escape" }, { 0xFF20, "Multi_key" }, { 0xFF21, "Kanji" }, { 0xFF22, "Muhenkan" },
      { 0xFF23, "Henkan" }, { 0xFF23, "Henkan_Mode" }, { 0xFF24, "Romaji" }, { 0xFF25, "Hiragana" },
      { 0xFF26, "Katakana" }, { 0xFF27, "Hiragana_Katakana" }, { 0xFF28, "Zenkaku" }, { 0xFF29, "Hankaku" },
      { 0xFF2A, "Zenkaku_Hankaku" }, { 0xFF2B, "Touroku" }, { 0xFF2C, "Massyo" }, { 0xFF2D, "Kana_Lock" },
      { 0xFF2E, "Kana_Shift" }, { 0xFF2F, "Eisu_Shift" }, { 0xFF30, "Eisu_toggle" }, { 0xff31, "Hangul" },
      { 0xff32, "Hangul_Start" }, { 0xff33, "Hangul_End" }, { 0xff34, "Hangul_Hanja" }, { 0xff35, "Hangul_Jamo" },
      { 0xff36, "Hangul_Romaja" }, { 0xFF37, "Codeinput" }, { 0xff37, "Hangul_Codeinput" }, { 0xFF37, "Kanji_Bangou" },
      { 0xff38, "Hangul_Jeonja" }, { 0xff39, "Hangul_Banja" }, { 0xff3a, "Hangul_PreHanja" }, { 0xff3b, "Hangul_PostHanja" },
      { 0xff3c, "Hangul_SingleCandidate" }, { 0xFF3C, "SingleCandidate" }, { 0xff3d, "Hangul_MultipleCandidate" }, { 0xFF3D, "MultipleCandidate" },
      { 0xFF3D, "Zen_Koho" }, { 0xff3e, "Hangul_PreviousCandidate" }, { 0xFF3E, "Mae_Koho" }, { 0xFF3E, "PreviousCandidate" },
      { 0xff3f, "Hangul_Special" }, { 0xFF50, "Home" }, { 0xFF51, "Left" }, { 0xFF52, "Up" },
      { 0xFF53, "Right" }, { 0xFF54, "Down" }, { 0xFF55, "Page_Up" }, { 0xFF55, "Prior" },
      { 0xFF56, "Next" }, { 0xFF56, "Page_Down" }, { 0xFF57, "End" }, { 0xFF58, "Begin" },
      { 0xFF60, "Select" }, { 0xFF61, "Print" }, { 0xFF62, "Execute" }, { 0xFF63, "Insert" },
      { 0xFF65, "Undo" }, { 0xFF66, "Redo" }, { 0xFF67, "Menu" }, { 0xFF68, "Find" },
      { 0xFF69, "Cancel" }, { 0xFF6A, "Help" }, { 0xFF6B, "Break" }, { 0xFF7E, "Arabic_switch" },
      { 0xFF7E, "Greek_switch" }, { 0xFF7E, "Hangul_switch" }, { 0xFF7E, "Hebrew_switch" }, { 0xFF7E, "ISO_Group_Shift" },
      { 0xFF7E, "kana_switch" }, { 0xFF7E, "Mode_switch" }, { 0xFF7E, "script_switch" }, { 0xFF7F, "Num_Lock" },
      { 0xFF80, "KP_Space" }, { 0xFF89, "KP_Tab" }, { 0xFF8D, "KP_Enter" }, { 0xFF91, "KP_F1" },
      { 0xFF92, "KP_F2" }, { 0xFF93, "KP_F3" }, { 0xFF94, "KP_F4" }, { 0xFF95, "KP_Home" },
      { 0xFF96, "KP_Left" }, { 0xFF97, "KP_Up" }, { 0xFF98, "KP_Right" }, { 0xFF99, "KP_Down" },
      { 0xFF9A, "KP_Page_Up" }, { 0xFF9A, "KP_Prior" }, { 0xFF9B, "KP_Next" }, { 0xFF9B, "KP_Page_Down" },
      { 0xFF9C, "KP_End" }, { 0xFF9D, "KP_Begin" }, { 0xFF9E, "KP_Insert" }, { 0xFF9F, "KP_Delete" },
      { 0xFFAA, "KP_Multiply" }, { 0xFFAB, "KP_Add" }, { 0xFFAC, "KP_Separator" }, { 0xFFAD, "KP_Subtract" },
      { 0xFFAE, "KP_Decimal" }, { 0xFFAF, "KP_Divide" }, { 0xFFB0, "KP_0" }, { 0xFFB1, "KP_1" },
      { 0xFFB2, "KP_2" }, { 0xFFB3, "KP_3" }, { 0xFFB4, "KP_4" }, { 0xFFB5, "KP_5" },
      { 0xFFB6, "KP_6" }, { 0xFFB7, "KP_7" }, { 0xFFB8, "KP_8" }, { 0xFFB9, "KP_9" },
      { 0xFFBD, "KP_Equal" }, { 0xFFBE, "F1" }, { 0xFFBF, "F2" }, { 0xFFC0, "F3" },
      { 0xFFC1, "F4" }, { 0xFFC2, "F5" }, { 0xFFC3, "F6" }, { 0xFFC4, "F7" },
      { 0xFFC5, "F8" }, { 0xFFC6, "F9" }, { 0xFFC7, "F10" }, { 0xFFC8, "F11" },
      { 0xFFC8, "L1" }, { 0xFFC9, "F12" }, { 0xFFC9, "L2" }, { 0xFFCA, "F13" },
      { 0xFFCA, "L3" }, { 0xFFCB, "F14" }, { 0xFFCB, "L4" }, { 0xFFCC, "F15" },
      { 0xFFCC, "L5" }, { 0xFFCD, "F16" }, { 0xFFCD, "L6" }, { 0xFFCE, "F17" },
      { 0xFFCE, "L7" }, { 0xFFCF, "F18" }, { 0xFFCF, "L8" }, { 0xFFD0, "F19" },
      { 0xFFD0, "L9" }, { 0xFFD1, "F20" }, { 0xFFD1, "L10" }, { 0xFFD2, "F21" },
      { 0xFFD2, "R1" }, { 0xFFD3, "F22" }, { 0xFFD3, "R2" }, { 0xFFD4, "F23" },
      { 0xFFD4, "R3" }, { 0xFFD5, "F24" }, { 0xFFD5, "R4" }, { 0xFFD6, "F25" },
      { 0xFFD6, "R5" }, { 0xFFD7, "F26" }, { 0xFFD7, "R6" }, { 0xFFD8, "F27" },
      { 0xFFD8, "R7" }, { 0xFFD9, "F28" }, { 0xFFD9, "R8" }, { 0xFFDA, "F29" },
      { 0xFFDA, "R9" }, { 0xFFDB, "F30" }, { 0xFFDB, "R10" }, { 0xFFDC, "F31" },
      { 0xFFDC, "R11" }, { 0xFFDD, "F32" }, { 0xFFDD, "R12" }, { 0xFFDE, "F33" },
      { 0xFFDE, "R13" }, { 0xFFDF, "F34" }, { 0xFFDF, "R14" }, { 0xFFE0, "F35" },
      { 0xFFE0, "R15" }, { 0xFFE1, "Shift_L" }, { 0xFFE2, "Shift_R" }, { 0xFFE3, "Control_L" },
      { 0xFFE4, "Control_R" }, { 0xFFE5, "Caps_Lock" }, { 0xFFE6, "Shift_Lock" }, { 0xFFE7, "Meta_L" },
      { 0xFFE8, "Meta_R" }, { 0xFFE9, "Alt_L" }, { 0xFFEA, "Alt_R" }, { 0xFFEB, "Super_L" },
      { 0xFFEC, "Super_R" }, { 0xFFED, "Hyper_L" }, { 0xFFEE, "Hyper_R" }, { 0xFFFF, "Delete" },
      { 0xFFFFFF, "VoidSymbol" }, { 0, NULL }
};

#endif
/* packet-x11.c
 * Routines for X11 dissection
 * Copyright 2000, Christophe Tronche <ch.tronche@xxxxxxxxxxxx>
 * Copyright 2003, Michael Shuldman <michaels@xxxxxxx>
 *
 * $Id: packet-x11.c,v 1.9 2003/12/24 18:39:57 michaels Exp michaels $
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@xxxxxxxxxxxx>
 * Copyright 1998 Gerald Combs
 *
 * Copied from README.developer
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

/* TODO (in no particular order):
 *
 * - keep track of Atom creation by server to be able to display
 *   non-predefined atoms
 * - Idem for keysym <-> keycode ???
 * - Idem for fonts
 * - Subtree the request ids (that is x11.create-window.window and
 *   x11.change-window.window should be  distinct), and add hidden fields
 *   (so we still have x11.window).
 * - add hidden fields so we can have x11.circulate-window in addition to
 *   x11.opcode == 13 (but you could match on x11.opcode == "CirculateWindow"
 *   now)
 * - add hidden fields so we have x11.listOfStuff.length
 * - use a faster scheme that linear list searching for the opcode.
 * - correct display of Unicode chars.
 * - Not everything is homogeneous, in particular the handling of items in
 *   list is a total mess.
 */

/* By the way, I wrote a program to generate every request and test
 * that stuff. If you're interested, you can get it at
 * http://tronche.com/gui/x/
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/conversation.h>

#include "prefs.h"
#include "packet-frame.h"
#include "packet-x11.h"
#include "keysymdef.h"

#define cVALS(x) (const value_string*)(x)

/*
 * Data structure associated with a conversation; keeps track of the
 * request for which we're expecting a reply, the frame number of
 * the initial connection request, and the byte order of the connection.
 *
 * An opcode of -3 means we haven't yet seen any requests yet.
 * An opcode of -2 means we're not expecting a reply.
 * An opcode of -1 means means we're waiting for a reply to the initial
 * connection request.
 * Other values are the opcode of the request for which we're expecting
 * a reply.
 *
 */
#define NOTHING_SEEN		-3
#define NOTHING_EXPECTED	-2
#define INITIAL_CONN		-1

#define BYTE_ORDER_BE		0
#define BYTE_ORDER_LE		1
#define BYTE_ORDER_UNKNOWN	-1

static const char *modifiers[] = { "Shift", "Lock", "Control", "Mod1", "Mod2", "Mod3", "Mod4", "Mod5" };

static const int modifiermask[] = { ShiftMask, LockMask, ControlMask,
Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask };

typedef struct {
      GHashTable *seqtable;	/* hashtable of sequncenumber <-> opcode.  */	
      int	sequencenumber;	/* sequencenumber of current packet.	   */
      guint32	iconn_frame;	/* frame # of initial connection request   */
      guint32	iconn_reply;	/* frame # of initial connection reply     */
      int	byte_order;	/* byte order of connection */

      int 	*keycodemap[256]; /* keycode to keysymvalue map. */
      int	keysyms_per_keycode;
      int 	first_keycode;
      int 	*modifiermap[array_length(modifiers)];/* modifier to keycode. */
      int	keycodes_per_modifier;

      union {
	struct {
		int	first_keycode;
	} GetKeyboardMapping;
      } request;
} x11_conv_data_t;

static GMemChunk *x11_state_chunk = NULL;


/* Initialize the protocol and registered fields */
static int proto_x11 = -1;

#include "x11-declarations.h"

/* Initialize the subtree pointers */
static gint ett_x11 = -1;
static gint ett_x11_color_flags = -1;
static gint ett_x11_list_of_arc = -1;
static gint ett_x11_arc = -1;
static gint ett_x11_list_of_atom = -1;
static gint ett_x11_list_of_card32 = -1;
static gint ett_x11_list_of_color_item = -1;
static gint ett_x11_color_item = -1;
static gint ett_x11_list_of_keycode = -1;
static gint ett_x11_list_of_keysyms = -1;
static gint ett_x11_keysym = -1;
static gint ett_x11_list_of_point = -1;
static gint ett_x11_point = -1;
static gint ett_x11_list_of_rectangle = -1;
static gint ett_x11_rectangle = -1;
static gint ett_x11_list_of_segment = -1;
static gint ett_x11_segment = -1;
static gint ett_x11_list_of_string8 = -1;
static gint ett_x11_list_of_text_item = -1;
static gint ett_x11_text_item = -1;
static gint ett_x11_gc_value_mask = -1;
static gint ett_x11_event_mask = -1;
static gint ett_x11_do_not_propagate_mask = -1;
static gint ett_x11_set_of_key_mask = -1;
static gint ett_x11_pointer_event_mask = -1;
static gint ett_x11_window_value_mask = -1;
static gint ett_x11_configure_window_mask = -1;
static gint ett_x11_keyboard_value_mask = -1;

/* desegmentation of X11 messages */
static gboolean x11_desegment = TRUE;

static dissector_handle_t data_handle;

#define TCP_PORT_X11			6000
#define TCP_PORT_X11_2			6001
#define TCP_PORT_X11_3			6002

/*
 * Round a length to a multiple of 4 bytes.
 */
#define ROUND_LENGTH(n)	((((n) + 3)/4) * 4)

/************************************************************************
 ***                                                                  ***
 ***         E N U M   T A B L E S   D E F I N I T I O N S            ***
 ***                                                                  ***
 ************************************************************************/

static const value_string byte_order_vals[] = {
     { 'B', "Big-endian" },
     { 'l', "Little-endian" },
     { 0,   NULL }
};

static const value_string image_byte_order_vals[] = {
     { 0, "LSBFirst" },
     { 1, "MSBFirst" }
};

static const value_string access_mode_vals[] = {
      { 0, "Disable" },
      { 1, "Enable" },
      { 0, NULL }
};

static const value_string all_temporary_vals[] = {
      { 0, "AllTemporary" },
      { 0, NULL }
};

static const value_string alloc_vals[] = {
      { 0, "None" },
      { 1, "All" },
      { 0, NULL }
};

static const value_string allow_events_mode_vals[] = {
      { 0, "AsyncPointer" },
      { 1, "SyncPointer" },
      { 2, "ReplayPointer" },
      { 3, "AsyncKeyboard" },
      { 4, "SyncKeyboard" },
      { 5, "ReplayKeyboard" },
      { 6, "AsyncBoth" },
      { 7, "SyncBoth" },
      { 0, NULL }
};

static const value_string arc_mode_vals[] = {
      { 0, "Chord" },
      { 1, "PieSlice" },
      { 0, NULL }
};

static const char *atom_predefined_interpretation[] = {
      "<error>",
      "PRIMARY",
      "SECONDARY",
      "ARC",
      "ATOM",
      "BITMAP",
      "CARDINAL",
      "COLORMAP",
      "CURSOR",
      "CUT_BUFFER0",
      "CUT_BUFFER1",
      "CUT_BUFFER2",
      "CUT_BUFFER3",
      "CUT_BUFFER4",
      "CUT_BUFFER5",
      "CUT_BUFFER6",
      "CUT_BUFFER7",
      "DRAWABLE",
      "FONT",
      "INTEGER",
      "PIXMAP",
      "POINT",
      "RECTANGLE",
      "RESOURCE_MANAGER",
      "RGB_COLOR_MAP",
      "RGB_BEST_MAP",
      "RGB_BLUE_MAP",
      "RGB_DEFAULT_MAP",
      "RGB_GRAY_MAP",
      "RGB_GREEN_MAP",
      "RGB_RED_MAP",
      "STRING",
      "VISUALID",
      "WINDOW",
      "WM_COMMAND",
      "WM_HINTS",
      "WM_CLIENT_MACHINE",
      "WM_ICON_NAME",
      "WM_ICON_SIZE",
      "WM_NAME",
      "WM_NORMAL_HINTS",
      "WM_SIZE_HINTS",
      "WM_ZOOM_HINTS",
      "MIN_SPACE",
      "NORM_SPACE",
      "MAX_SPACE",
      "END_SPACE",
      "SUPERSCRIPT_X",
      "SUPERSCRIPT_Y",
      "SUBSCRIPT_X",
      "SUBSCRIPT_Y",
      "UNDERLINE_POSITION",
      "UNDERLINE_THICKNESS",
      "STRIKEOUT_ASCENT",
      "STRIKEOUT_DESCENT",
      "ITALIC_ANGLE",
      "X_HEIGHT",
      "QUAD_WIDTH",
      "WEIGHT",
      "POINT_SIZE",
      "RESOLUTION",
      "COPYRIGHT",
      "NOTICE",
      "FONT_NAME",
      "FAMILY_NAME",
      "FULL_NAME",
      "CAP_HEIGHT",
      "WM_CLASS",
      "WM_TRANSIENT_FOR",
};

static const value_string auto_repeat_mode_vals[] = {
      { 0, "Off" },
      { 1, "On" },
      { 2, "Default" },
      { 0, NULL }
};

static const value_string background_pixmap_vals[] = {
      { 0, "None" },
      { 1, "ParentRelative" },
      { 0, NULL }
};

static const value_string backing_store_vals[] = {
      { 0, "NotUseful" },
      { 1, "WhenMapped" },
      { 2, "Always" },
      { 0, NULL }
};

static const value_string border_pixmap_vals[] = {
      { 0, "CopyFromParent" },
      { 0, NULL }
};

static const value_string button_vals[] = {
      { 0x8000, "AnyButton" },
      { 0, NULL }
};

static const value_string cap_style_vals[] = {
      { 0, "NotLast" },
      { 1, "Butt" },
      { 2, "Round" },
      { 3, "Projecting" },
      { 0, NULL }
};

static const value_string class_vals[] = {
      { 0, "Cursor" },
      { 1, "Tile" },
      { 2, "Stipple" },
      { 0, NULL }
};

static const value_string close_down_mode_vals[] = {
      { 0, "Destroy" },
      { 1, "RetainPermanent" },
      { 2, "RetainTemporary" },
      { 0, NULL }
};

static const value_string coordinate_mode_vals[] = {
      { 0, "Origin" },
      { 1, "Previous" },
      { 0, NULL }
};

static const value_string direction_vals[] = {
      { 0, "RaiseLowest" },
      { 1, "LowerHighest" },
      { 0, NULL }
};

#define FAMILY_INTERNET	0
#define FAMILY_DECNET	1
#define FAMILY_CHAOS	2

static const value_string family_vals[] = {
      { FAMILY_INTERNET, "Internet" },
      { FAMILY_DECNET,   "DECnet" },
      { FAMILY_CHAOS,    "Chaos" },
      { 0, NULL }
};

static const value_string fill_rule_vals[] = {
      { 0, "EvenOdd" },
      { 1, "Winding" },
      { 0, NULL }
};

static const value_string fill_style_vals[] = {
      { 0, "Solid" },
      { 1, "Tiled" },
      { 2, "Stippled" },
      { 3, "OpaqueStippled" },
      { 0, NULL }
};

static const value_string focus_vals[] = {
      { 0, "None" },
      { 1, "PointerRoot" },
      { 0, NULL }
};

static const value_string function_vals[] = {
      {  0, "Clear" },
      {  1, "And" },
      {  2, "AndReverse" },
      {  3, "Copy" },
      {  4, "AndInverted" },
      {  5, "NoOp" },
      {  6, "Xor" },
      {  7, "Or" },
      {  8, "Nor" },
      {  9, "Equiv" },
      { 10, "Invert" },
      { 11, "OrReverse" },
      { 12, "CopyInverted" },
      { 13, "OrInverted" },
      { 14, "Nand" },
      { 15, "Set" },
      {  0, NULL }
};

static const value_string gravity_vals[] = {
      {  1, "NorthWest" },
      {  2, "North" },
      {  3, "NorthEast" },
      {  4, "West" },
      {  5, "Center" },
      {  6, "East" },
      {  7, "SouthWest" },
      {  8, "South" },
      {  9, "SouthEast" },
      { 10, "Static" },
      {  0, NULL }
};

static const value_string image_format_vals[] = {
      { 0, "Bitmap" },
      { 1, "XYPixmap" },
      { 2, "ZPixmap" },
      { 0, NULL }
};

static const value_string image_pixmap_format_vals[] = {
      { 1, "XYPixmap" },
      { 2, "ZPixmap" },
      { 0, NULL }
};

static const value_string join_style_vals[] = {
      { 0, "Miter" },
      { 1, "Round" },
      { 2, "Bevel" },
      { 0, NULL }
};

static const value_string key_vals[] = {
      { 0, "AnyKey" },
      { 0, NULL }
};

#include "packet-x11-keysym.h"

static const value_string line_style_vals[] = {
      { 0, "Solid" },
      { 1, "OnOffDash" },
      { 2, "DoubleDash" },
      { 0, NULL }
};

static const value_string mode_vals[] = {
      { 0, "Replace" },
      { 1, "Prepend" },
      { 2, "Append" },
      { 0, NULL }
};

static const value_string on_off_vals[] = {
      { 0, "Off" },
      { 1, "On" },
      { 0, NULL }
};

static const value_string opcode_vals[] = {
      { INITIAL_CONN, "Initial connection request" },
      { X_CreateWindow, "CreateWindow" },
      { X_ChangeWindowAttributes, "ChangeWindowAttributes" },
      { X_GetWindowAttributes, "GetWindowAttributes" },
      { X_DestroyWindow, "DestroyWindow" },
      { X_DestroySubwindows, "DestroySubwindows" },
      { X_ChangeSaveSet, "ChangeSaveSet" },
      { X_ReparentWindow, "ReparentWindow" },
      { X_MapWindow, "MapWindow" },
      { X_MapSubwindows, "MapSubwindows" },
      { X_UnmapWindow, "UnmapWindow" },
      { X_UnmapSubwindows, "UnmapSubwindows" },
      { X_ConfigureWindow, "ConfigureWindow" },
      { X_CirculateWindow, "CirculateWindow" },
      { X_GetGeometry, "GetGeometry" },
      { X_QueryTree, "QueryTree" },
      { X_InternAtom, "InternAtom" },
      { X_GetAtomName, "GetAtomName" },
      { X_ChangeProperty, "ChangeProperty" },
      { X_DeleteProperty, "DeleteProperty" },
      { X_GetProperty, "GetProperty" },
      { X_ListProperties, "ListProperties" },
      { X_SetSelectionOwner, "SetSelectionOwner" },
      { X_GetSelectionOwner, "GetSelectionOwner" },
      { X_ConvertSelection, "ConvertSelection" },
      { X_GrabPointer, "GrabPointer" },
      { X_UngrabPointer, "UngrabPointer" },
      { X_GrabButton, "GrabButton" },
      { X_UngrabButton, "UngrabButton" },
      { X_ChangeActivePointerGrab, "ChangeActivePointerGrab" },
      { X_GrabKeyboard, "GrabKeyboard" },
      { X_UngrabKeyboard, "UngrabKeyboard" },
      { X_GrabKey, "GrabKey" },
      { X_UngrabKey, "UngrabKey" },
      { X_AllowEvents, "AllowEvents" },
      { X_GrabServer, "GrabServer" },
      { X_UngrabServer, "UngrabServer" },
      { X_QueryPointer, "QueryPointer" },
      { X_GetMotionEvents, "GetMotionEvents" },
      { X_TranslateCoords, "TranslateCoordinates" },
      { X_WarpPointer, "WarpPointer" },
      { X_SetInputFocus, "SetInputFocus" },
      { X_GetInputFocus, "GetInputFocus" },
      { X_QueryKeymap, "QueryKeymap" },
      { X_OpenFont, "OpenFont" },
      { X_CloseFont, "CloseFont" },
      { X_QueryFont, "QueryFont" },
      { X_QueryTextExtents, "QueryTextExtents" },
      { X_ListFonts, "ListFonts" },
      { X_ListFontsWithInfo, "ListFontsWithInfo" },
      { X_SetFontPath, "SetFontPath" },
      { X_GetFontPath, "GetFontPath" },
      { X_CreatePixmap, "CreatePixmap" },
      { X_FreePixmap, "FreePixmap" },
      { X_CreateGC, "CreateGC" },
      { X_ChangeGC, "ChangeGC" },
      { X_CopyGC, "CopyGC" },
      { X_SetDashes, "SetDashes" },
      { X_SetClipRectangles, "SetClipRectangles" },
      { X_FreeGC, "FreeGC" },
      { X_ClearArea, "ClearArea" },
      { X_CopyArea, "CopyArea" },
      { X_CopyPlane, "CopyPlane" },
      { X_PolyPoint, "PolyPoint" },
      { X_PolyLine, "PolyLine" },
      { X_PolySegment, "PolySegment" },
      { X_PolyRectangle, "PolyRectangle" },
      { X_PolyArc, "PolyArc" },
      { X_FillPoly, "FillPoly" },
      { X_PolyFillRectangle, "PolyFillRectangle" },
      { X_PolyFillArc, "PolyFillArc" },
      { X_PutImage, "PutImage" },
      { X_GetImage, "GetImage" },
      { X_PolyText8, "PolyText8" },
      { X_PolyText16, "PolyText16" },
      { X_ImageText8, "ImageText8" },
      { X_ImageText16, "ImageText16" },
      { X_CreateColormap, "CreateColormap" },
      { X_FreeColormap, "FreeColormap" },
      { X_CopyColormapAndFree, "CopyColormapAndFree" },
      { X_InstallColormap, "InstallColormap" },
      { X_UninstallColormap, "UninstallColormap" },
      { X_ListInstalledColormaps, "ListInstalledColormaps" },
      { X_AllocColor, "AllocColor" },
      { X_AllocNamedColor, "AllocNamedColor" },
      { X_AllocColorCells, "AllocColorCells" },
      { X_AllocColorPlanes, "AllocColorPlanes" },
      { X_FreeColors, "FreeColors" },
      { X_StoreColors, "StoreColors" },
      { X_StoreNamedColor, "StoreNamedColor" },
      { X_QueryColors, "QueryColors" },
      { X_LookupColor, "LookupColor" },
      { X_CreateCursor, "CreateCursor" },
      { X_CreateGlyphCursor, "CreateGlyphCursor" },
      { X_FreeCursor, "FreeCursor" },
      { X_RecolorCursor, "RecolorCursor" },
      { X_QueryBestSize, "QueryBestSize" },
      { X_QueryExtension, "QueryExtension" },
      { X_ListExtensions, "ListExtensions" },
      { X_ChangeKeyboardMapping, "ChangeKeyboardMapping" },
      { X_GetKeyboardMapping, "GetKeyboardMapping" },
      { X_ChangeKeyboardControl, "ChangeKeyboardControl" },
      { X_GetKeyboardControl, "GetKeyboardControl" },
      { X_Bell, "Bell" },
      { X_ChangePointerControl, "ChangePointerControl" },
      { X_GetPointerControl, "GetPointerControl" },
      { X_SetScreenSaver, "SetScreenSaver" },
      { X_GetScreenSaver, "GetScreenSaver" },
      { X_ChangeHosts, "ChangeHosts" },
      { X_ListHosts, "ListHosts" },
      { X_SetAccessControl, "SetAccessControl" },
      { X_SetCloseDownMode, "SetCloseDownMode" },
      { X_KillClient, "KillClient" },
      { X_RotateProperties, "RotateProperties" },
      { X_ForceScreenSaver, "ForceScreenSaver" },
      { X_SetPointerMapping, "SetPointerMapping" },
      { X_GetPointerMapping, "GetPointerMapping" },
      { X_SetModifierMapping, "SetModifierMapping" },
      { X_GetModifierMapping, "GetModifierMapping" },
      { X_NoOperation, "NoOperation" },
      { 0, NULL }
};

static const value_string eventcode_vals[] = {
	{ 2, 	 "KeyPress" },
	{ 3, 	 "KeyRelease" },
	{ 4, 	 "ButtonPress" },
	{ 5, 	 "ButtonRelease" },
	{ 6, 	 "MotionNotify" },
	{ 7, 	 "EnterNotify" },
	{ 8, 	 "LeaveNotify" },
	{ 9, 	 "FocusIn" },
	{ 10, 	 "FocusOut" },
	{ 11, 	 "KeymapNotify" },
	{ 12, 	 "Expose" },
	{ 13, 	 "GraphicsExpose" },
	{ 14, 	 "NoExpose" },
	{ 15, 	 "VisibilityNotify" },
	{ 16, 	 "CreateNotify" },
	{ 17, 	 "DestroyNotify" },
	{ 18, 	 "UnmapNotify" },
	{ 19, 	 "MapNotify" },
	{ 20, 	 "MapRequest" },
	{ 21, 	 "ReparentNotify" },
	{ 22, 	 "ConfigureNotify" },
	{ 23, 	 "ConfigureRequest" },
	{ 24, 	 "GravityNotify" },
	{ 25, 	 "ResizeRequest" },
	{ 26, 	 "CirculateNotify" },
	{ 27, 	 "CirculateRequest" },
	{ 28, 	 "PropertyNotify" },
	{ 29, 	 "SelectionClear" },
	{ 30, 	 "SelectionRequest" },
	{ 31, 	 "SelectionNotify" },
	{ 32, 	 "ColormapNotify" },
	{ 33, 	 "ClientMessage" },
	{ 34, 	 "MappingNotify" },
      	{ 0, NULL }
};

static const value_string errorcode_vals[] = {
	{ 0, "Success" },
	{ 1, "BadRequest" },
	{ 2, "BadValue" },
	{ 3, "BadWindow" },
	{ 4, "BadPixmap" },
	{ 5, "BadAtom" },
	{ 6, "BadCursor" },
	{ 7, "BadFont" },
	{ 8, "BadMatch" },
	{ 9, "BadDrawable" },
	{ 10, "BadAccess" },
	{ 11, "BadAlloc" },
	{ 12, "BadColor" },
	{ 13, "BadGC" },
	{ 14, "BadIDChoice" },
	{ 15, "BadName" },
	{ 16, "BadLength" },
	{ 17, "BadImplementation" },

	{ 128, "FirstExtensionError" },
	{ 255, "LastExtensionError" }
};

static const value_string ordering_vals[] = {
      { 0, "UnSorted" },
      { 1, "YSorted" },
      { 2, "YXSorted" },
      { 3, "YXBanded" },
      { 0, NULL }
};

static const value_string plane_mask_vals[] = {
      { 0xFFFFFFFF, "AllPlanes" },
      { 0, NULL }
};

static const value_string pointer_keyboard_mode_vals[] = {
      { 0, "Synchronous" },
      { 1, "Asynchronous" },
      { 0, NULL }
};

static const value_string revert_to_vals[] = {
      { 0, "None" },
      { 1, "PointerRoot" },
      { 2, "Parent" },
      { 0, NULL }
};

static const value_string insert_delete_vals[] = {
      { 0, "Insert" },
      { 1, "Delete" },
      { 0, NULL }
};

static const value_string screen_saver_mode_vals[] = {
      { 0, "Reset" },
      { 1, "Activate" },
      { 0, NULL }
};

static const value_string shape_vals[] = {
      { 0, "Complex" },
      { 1, "Nonconvex" },
      { 2, "Convex" },
      { 0, NULL }
};

static const value_string stack_mode_vals[] = {
      { 0, "Above" },
      { 1, "Below" },
      { 2, "TopIf" },
      { 3, "BottomIf" },
      { 4, "Opposite" },
      { 0, NULL }
};

static const value_string subwindow_mode_vals[] = {
      { 0, "ClipByChildren" },
      { 1, "IncludeInferiors" },
      { 0, NULL }
};

static const value_string window_class_vals[] = {
      { 0, "CopyFromParent" },
      { 1, "InputOutput" },
      { 2, "InputOnly" },
      { 0, NULL }
};

static const value_string yes_no_default_vals[] = {
      { 0, "No" },
      { 1, "Yes" },
      { 2, "Default" },
      { 0, NULL }
};

static const value_string zero_is_any_property_type_vals[] = {
      { 0, "AnyPropertyType" },
      { 0, NULL }
};

static const value_string zero_is_none_vals[] = {
      { 0, "None" },
      { 0, NULL }
};

/* we have not seen packet before. */
#define PACKET_IS_NEW(pinfo) \
	(!((pinfo)->fd->flags.visited))

/************************************************************************
 ***                                                                  ***
 ***           F I E L D   D E C O D I N G   M A C R O S              ***
 ***                                                                  ***
 ************************************************************************/

#define VALUE8(tvb, offset) (tvb_get_guint8(tvb, offset))
#define VALUE16(tvb, offset) (little_endian ? tvb_get_letohs(tvb, offset) : tvb_get_ntohs(tvb, offset))
#define VALUE32(tvb, offset) (little_endian ? tvb_get_letohl(tvb, offset) : tvb_get_ntohl(tvb, offset))

#define FIELD8(name)  (field8(tvb, offsetp, t, hf_x11_##name, little_endian))
#define FIELD16(name) (field16(tvb, offsetp, t, hf_x11_##name, little_endian))
#define FIELD32(name) (field32(tvb, offsetp, t, hf_x11_##name, little_endian))

#define BITFIELD(TYPE, position, name) {\
  int unused;\
  int save = *offsetp;\
  proto_tree_add_item(bitmask_tree, hf_x11_##position##_##name, tvb, bitmask_offset, \
                      bitmask_size, little_endian); \
  if (bitmask_value & proto_registrar_get_nth(hf_x11_##position##_##name) -> bitmask) {\
       TYPE(name);\
       unused = save + 4 - *offsetp;\
       if (unused)\
           proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, unused, little_endian);\
       *offsetp = save + 4;\
 }\
}

#define FLAG(position, name) {\
       proto_tree_add_boolean(bitmask_tree, hf_x11_##position##_mask##_##name, tvb, bitmask_offset, bitmask_size, bitmask_value); }

#define FLAG_IF_NONZERO(position, name) do {\
  if (bitmask_value & proto_registrar_get_nth(hf_x11_##position##_mask##_##name) -> bitmask)\
       proto_tree_add_boolean(bitmask_tree, hf_x11_##position##_mask##_##name, tvb, bitmask_offset, bitmask_size, bitmask_value); } while (0)

#define ATOM(name)     { atom(tvb, offsetp, t, hf_x11_##name, little_endian); }
#define BITGRAVITY(name) { gravity(tvb, offsetp, t, hf_x11_##name, "Forget"); }
#define BITMASK(name, size) {\
      proto_item *ti; \
      guint32 bitmask_value; \
      int bitmask_offset; \
      int bitmask_size; \
      proto_tree *bitmask_tree; \
      bitmask_value = ((size == 1) ? (guint32)VALUE8(tvb, *offsetp) : \
		       ((size == 2) ? (guint32)VALUE16(tvb, *offsetp) : \
			              (guint32)VALUE32(tvb, *offsetp))); \
      bitmask_offset = *offsetp; \
      bitmask_size = size; \
      ti = proto_tree_add_uint(t, hf_x11_##name##_mask, tvb, *offsetp, size, bitmask_value); \
      bitmask_tree = proto_item_add_subtree(ti, ett_x11_##name##_mask); \
      *offsetp += size;
#define ENDBITMASK	}
#define BITMASK8(name)	BITMASK(name, 1);
#define BITMASK16(name)	BITMASK(name, 2);
#define BITMASK32(name) BITMASK(name, 4);
#define BOOL(name)     (add_boolean(tvb, offsetp, t, hf_x11_##name))
#define BUTTON(name)   FIELD8(name)
#define CARD8(name)    FIELD8(name)
#define CARD16(name)   (FIELD16(name))
#define CARD32(name)   (FIELD32(name))
#define COLOR_FLAGS(name) colorFlags(tvb, offsetp, t)
#define COLORMAP(name) FIELD32(name)
#define CURSOR(name)   FIELD32(name)
#define DRAWABLE(name) FIELD32(name)
#define ENUM8(name)    (FIELD8(name))
#define ENUM16(name)   FIELD16(name)
#define FONT(name)     FIELD32(name)
#define FONTABLE(name) FIELD32(name)
#define GCONTEXT(name) FIELD32(name)
#define INT8(name)     FIELD8(name)
#define INT16(name)    FIELD16(name)
#define INT32(name)    FIELD32(name)
#define KEYCODE(name)  FIELD8(name)
#define KEYCODE_DECODED(name, keycode, mask)  do {			\
	proto_tree_add_uint_format(t, hf_x11_##name, tvb, offset, 1, 	\
	keycode, "keycode: %d (%s)",				\
	keycode,  keycode2keysymString(state->keycodemap, 		\
	state->first_keycode, state->keysyms_per_keycode,		\
	state->modifiermap, state->keycodes_per_modifier,		\
	keycode, mask));						\
	++offset;							\
} while (0)

#define LISTofARC(name) { listOfArc(tvb, offsetp, t, hf_x11_##name, (next_offset - *offsetp) / 12, little_endian); }
#define LISTofATOM(name, length) { listOfAtom(tvb, offsetp, t, hf_x11_##name, (length) / 4, little_endian); }
#define LISTofBYTE(name, length) { listOfByte(tvb, offsetp, t, hf_x11_##name, (length), little_endian); }
#define LISTofCARD8(name, length) { listOfByte(tvb, offsetp, t, hf_x11_##name, (length), little_endian); }
#define LISTofCARD32(name, length) { listOfCard32(tvb, offsetp, t, hf_x11_##name, hf_x11_##name##_item, (length) / 4, little_endian); }
#define LISTofCOLORITEM(name, length) { listOfColorItem(tvb, offsetp, t, hf_x11_##name, (length) / 12, little_endian); }
#define LISTofKEYCODE(map, name, length) { listOfKeycode(tvb, offsetp, t, hf_x11_##name, map, (length), little_endian); }
#define LISTofKEYSYM(name, map, keycode_first, keycode_count, \
keysyms_per_keycode) {\
      listOfKeysyms(tvb, offsetp, t, hf_x11_##name, hf_x11_##name##_item, map, (keycode_first), (keycode_count), (keysyms_per_keycode), little_endian); }
#define LISTofPOINT(name, length) { listOfPoint(tvb, offsetp, t, hf_x11_##name, (length) / 4, little_endian); }
#define LISTofRECTANGLE(name) { listOfRectangle(tvb, offsetp, t, hf_x11_##name, (next_offset - *offsetp) / 8, little_endian); }
#define LISTofSEGMENT(name) { listOfSegment(tvb, offsetp, t, hf_x11_##name, (next_offset - *offsetp) / 8, little_endian); }
#define LISTofSTRING8(name, length) { listOfString8(tvb, offsetp, t, hf_x11_##name, hf_x11_##name##_string, (length), little_endian); }
#define LISTofTEXTITEM8(name) { listOfTextItem(tvb, offsetp, t, hf_x11_##name, FALSE, next_offset, little_endian); }
#define LISTofTEXTITEM16(name) { listOfTextItem(tvb, offsetp, t, hf_x11_##name, TRUE, next_offset, little_endian); }
#define OPCODE()       { opcode = FIELD8(opcode); }
#define PIXMAP(name)   { FIELD32(name); }
#define REQUEST_LENGTH() (requestLength(tvb, offsetp, t, little_endian))
#define SETofEVENT(name) { setOfEvent(tvb, offsetp, t, little_endian); }
#define SETofDEVICEEVENT(name) { setOfDeviceEvent(tvb, offsetp, t, little_endian);}
#define SETofKEYMASK(name) { setOfKeyButMask(tvb, offsetp, t, little_endian, 0); }
#define SETofPOINTEREVENT(name) { setOfPointerEvent(tvb, offsetp, t, little_endian); }
#define STRING8(name, length)  { string8(tvb, offsetp, t, hf_x11_##name, length); }
#define STRING16(name, length)  { string16(tvb, offsetp, t, hf_x11_##name, hf_x11_##name##_bytes, length, little_endian); }
#define TIMESTAMP(name){ timestamp(tvb, offsetp, t, hf_x11_##name, little_endian); }
#define UNDECODED(x)   { proto_tree_add_item(t, hf_x11_undecoded, tvb, *offsetp,  x, little_endian); *offsetp += x; }
#define UNUSED(x)      { proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp,  x, little_endian); *offsetp += x; }
#define PAD()          { if (next_offset - *offsetp > 0) proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, next_offset - *offsetp, little_endian); *offsetp = next_offset; }
#define WINDOW(name)   { FIELD32(name); }
#define WINGRAVITY(name) { gravity(tvb, offsetp, t, hf_x11_##name, "Unmap"); }

#define VISUALID(name) { gint32 v = VALUE32(tvb, *offsetp); \
    proto_tree_add_uint_format(t, hf_x11_##name, tvb, *offsetp, 4, v, "Visualid: 0x%08x%s", v, \
			       v ? "" : " (CopyFromParent)"); *offsetp += 4; }
#define REPLY(name)       FIELD8(name);
#define REPLYLENGTH(name) FIELD32(name);

#define EVENTCONTENTS_COMMON() do { 					     \
			TIMESTAMP(time); 				     \
			WINDOW(rootwindow);				     \
			WINDOW(eventwindow);				     \
			WINDOW(childwindow);				     \
			INT16(root_x);					     \
			INT16(root_y);					     \
			INT16(event_x);					     \
			INT16(event_y);					     \
			setOfKeyButMask(tvb, offsetp, t, little_endian, 1);  \
} while (0)

#define SEQUENCENUMBER_REPLY(name) do {					\
	guint16 seqno;                                                  \
                                                                       	\
	seqno = VALUE16(tvb, *offsetp);                                 \
	proto_tree_add_uint_format(t, hf_x11_reply_##name, tvb,         \
	*offsetp, sizeof(seqno), seqno,                                 \
	"sequencenumber: %d (%s)",                             		\
	(int)seqno,                                                     \
	val_to_str(opcode, opcode_vals, "<Unknown>"));			\
	*offsetp += sizeof(seqno);                                      \
} while (0) 

#define REPLYCONTENTS_COMMON() do { 					\
	REPLY(reply);							\
	proto_tree_add_item(t, hf_x11_undecoded, tvb, offset, 		\
	1, little_endian);						\
	++offset;							\
	SEQUENCENUMBER_REPLY(sequencenumber);				\
	REPLYLENGTH(replylength);					\
	proto_tree_add_item(t, hf_x11_undecoded, tvb, offset, 		\
	tvb_reported_length_remaining(tvb, offset), little_endian);	\
	offset += tvb_reported_length_remaining(tvb, offset);		\
} while (0)


#define HANDLE_REPLY(plen, length_remaining, func) do {			\
	if (length_remaining < plen)					\
		if (x11_desegment && pinfo->can_desegment) {		\
			pinfo->desegment_offset = offset;		\
			pinfo->desegment_len 	= plen - length_remaining;\
			return;						\
		}							\
		else							\
			; /* XXX yes, what then?  Need to skip/join. */ \
									\
	if (length_remaining > plen)					\
		length_remaining = plen;				\
	next_tvb = tvb_new_subset(tvb, offset, length_remaining, plen);	\
									\
	TRY {								\
		func(next_tvb, pinfo, tree, state, little_endian);	\
	}								\
									\
	CATCH(BoundsError) {						\
		RETHROW;						\
	}								\
	CATCH(ReportedBoundsError) {					\
		show_reported_bounds_error(next_tvb, pinfo, tree);	\
	}								\
	ENDTRY;								\
} while (0)	

static void
dissect_x11_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
		  x11_conv_data_t *volatile state, gboolean little_endian);

static void
dissect_x11_error(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
		  x11_conv_data_t *volatile state, gboolean little_endian);

static void
dissect_x11_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
		  x11_conv_data_t *volatile state, gboolean little_endian);

static void
x11_stateinit(x11_conv_data_t **state, conversation_t *conversation);

static const char *
keysymString(guint32 v);


/************************************************************************
 ***                                                                  ***
 ***                  D E C O D I N G   F I E L D S                   ***
 ***                                                                  ***
 ************************************************************************/

static void atom(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
		 gboolean little_endian)
{
      const char *interpretation = NULL;

      guint32 v = VALUE32(tvb, *offsetp);
      if (v >= 1 && v < array_length(atom_predefined_interpretation))
	    interpretation = atom_predefined_interpretation[v];
      else if (v)
	    interpretation = "Not a predefined atom";
      else {
	    header_field_info *hfi = proto_registrar_get_nth(hf);
	    if (hfi -> strings)
		  interpretation = match_strval(v, cVALS(hfi -> strings));
      }
      if (!interpretation) interpretation = "error in Xlib client program ?";
      proto_tree_add_uint_format(t, hf, tvb, *offsetp, 4, v, "%s: %u (%s)",
				 proto_registrar_get_nth(hf) -> name, v, interpretation);
      *offsetp += 4;
}

static guint32 add_boolean(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf)
{
      guint32 v = VALUE8(tvb, *offsetp);
      proto_tree_add_boolean(t, hf, tvb, *offsetp, 1, v);
      *offsetp += 1;
      return v;
}

static void colorFlags(tvbuff_t *tvb, int *offsetp, proto_tree *t)
{
      unsigned do_red_green_blue = VALUE8(tvb, *offsetp);
      proto_item *ti;
      proto_tree *tt;

      if (do_red_green_blue) {
	    int sep = FALSE;
	    char buffer[512];
	    char *bp = buffer + sprintf(buffer, "flags: ");

	    if (do_red_green_blue & 0x1) {
		  bp += sprintf(bp, "DoRed");
		  sep = TRUE;
	    }

	    if (do_red_green_blue & 0x2) {
		  if (sep) bp += sprintf(bp, " | ");
		  bp += sprintf(bp, "DoGreen");
		  sep = TRUE;
	    }

	    if (do_red_green_blue & 0x4) {
		  if (sep) bp += sprintf(bp, " | ");
		  bp += sprintf(bp, "DoBlue");
		  sep = TRUE;
	    }

	    if (do_red_green_blue & 0xf8) {
		  if (sep) bp += sprintf(bp, " + ");
		  sprintf(bp, "trash");
	    }

	    ti = proto_tree_add_uint_format(t, hf_x11_coloritem_flags, tvb, *offsetp, 1, do_red_green_blue,
					    "%s", buffer);
	    tt = proto_item_add_subtree(ti, ett_x11_color_flags);
	    if (do_red_green_blue & 0x1)
		  proto_tree_add_boolean(tt, hf_x11_coloritem_flags_do_red, tvb, *offsetp, 1,
					 do_red_green_blue & 0x1);
	    if (do_red_green_blue & 0x2)
		  proto_tree_add_boolean(tt, hf_x11_coloritem_flags_do_green, tvb, *offsetp, 1,
					 do_red_green_blue & 0x2);
	    if (do_red_green_blue & 0x4)
		  proto_tree_add_boolean(tt, hf_x11_coloritem_flags_do_blue, tvb, *offsetp, 1,
					 do_red_green_blue & 0x4);
	    if (do_red_green_blue & 0xf8)
		  proto_tree_add_boolean(tt, hf_x11_coloritem_flags_unused, tvb, *offsetp, 1,
					 do_red_green_blue & 0xf8);
      } else
	    proto_tree_add_uint_format(t, hf_x11_coloritem_flags, tvb, *offsetp, 1, do_red_green_blue,
				       "flags: none");
      *offsetp += 1;
}

static void gravity(tvbuff_t *tvb, int *offsetp, proto_tree *t,
    int hf, const char *nullInterpretation)
{
      guint8 v = VALUE8(tvb, *offsetp);

      if (!v)
	    proto_tree_add_uint_format(t, hf, tvb, *offsetp, 1, v, "%s: 0 (%s)",
	    			       proto_registrar_get_nth(hf) -> name,
				       nullInterpretation);
      else
	    proto_tree_add_uint(t, hf, tvb, *offsetp, 1, v);
      *offsetp += 1;
}

static void listOfArc(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
		      int length, gboolean little_endian)
{
      proto_item *ti = proto_tree_add_item(t, hf, tvb, *offsetp, length * 8, little_endian);
      proto_tree *tt = proto_item_add_subtree(ti, ett_x11_list_of_arc);
      while(length--) {
	    gint16 x = VALUE16(tvb, *offsetp);
	    gint16 y = VALUE16(tvb, *offsetp + 2);
	    guint16 width = VALUE16(tvb, *offsetp + 4);
	    guint16 height = VALUE16(tvb, *offsetp + 6);
	    gint16 angle1 = VALUE16(tvb, *offsetp + 8);
	    gint16 angle2 = VALUE16(tvb, *offsetp + 10);

	    proto_item *tti = proto_tree_add_none_format(tt, hf_x11_arc, tvb, *offsetp, 12,
							     "arc: %dx%d+%d+%d, angle %d -> %d (%f degrees -> %f degrees)",
							     width, height, x, y, angle1, angle2,
							     angle1 / 64.0, angle2 / 64.0);
	    proto_tree *ttt = proto_item_add_subtree(tti, ett_x11_arc);
	    proto_tree_add_int(ttt, hf_x11_arc_x, tvb, *offsetp, 2, x);
	    *offsetp += 2;
	    proto_tree_add_int(ttt, hf_x11_arc_y, tvb, *offsetp, 2, y);
	    *offsetp += 2;
	    proto_tree_add_uint(ttt, hf_x11_arc_width, tvb, *offsetp, 2, y);
	    *offsetp += 2;
	    proto_tree_add_uint(ttt, hf_x11_arc_height, tvb, *offsetp, 2, y);
	    *offsetp += 2;
	    proto_tree_add_int(ttt, hf_x11_arc_angle1, tvb, *offsetp, 2, y);
	    *offsetp += 2;
	    proto_tree_add_int(ttt, hf_x11_arc_angle2, tvb, *offsetp, 2, y);
	    *offsetp += 2;
      }
}

static void listOfAtom(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
		       int length, gboolean little_endian)
{
      proto_item *ti = proto_tree_add_item(t, hf, tvb, *offsetp, length * 4, little_endian);
      proto_tree *tt = proto_item_add_subtree(ti, ett_x11_list_of_atom);
      while(length--)
	    atom(tvb, offsetp, tt, hf_x11_properties_item, little_endian);
}

static void listOfByte(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
		       int length, gboolean little_endian)
{
      if (length <= 0) length = 1;
      proto_tree_add_item(t, hf, tvb, *offsetp, length, little_endian);
      *offsetp += length;
}

static void listOfCard32(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
			 int hf_item, int length, gboolean little_endian)
{
      proto_item *ti = proto_tree_add_item(t, hf, tvb, *offsetp, length * 4, little_endian);
      proto_tree *tt = proto_item_add_subtree(ti, ett_x11_list_of_card32);
      while(length--) {
	    proto_tree_add_uint(tt, hf_item, tvb, *offsetp, 4, VALUE32(tvb, *offsetp));
	    *offsetp += 4;
      }
}

static void listOfColorItem(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
			    int length, gboolean little_endian)
{
      proto_item *ti = proto_tree_add_item(t, hf, tvb, *offsetp, length * 8, little_endian);
      proto_tree *tt = proto_item_add_subtree(ti, ett_x11_list_of_color_item);
      while(length--) {
	    proto_item *tti;
	    proto_tree *ttt;
	    unsigned do_red_green_blue;
	    guint16 red, green, blue;
	    char buffer[1024];
	    char *bp;
	    const char *sep;

	    red = VALUE16(tvb, *offsetp + 4);
	    green = VALUE16(tvb, *offsetp + 6);
	    blue = VALUE16(tvb, *offsetp + 8);
	    do_red_green_blue = VALUE8(tvb, *offsetp + 10);

	    bp = buffer + sprintf(buffer, "colorItem: ");
	    sep = "";
	    if (do_red_green_blue & 0x1) {
		bp += sprintf(bp, "red = %d", red);
		sep = ", ";
	    }
	    if (do_red_green_blue & 0x2) {
		bp += sprintf(bp, "%sgreen = %d", sep, green);
		sep = ", ";
	    }
	    if (do_red_green_blue & 0x4)
		bp += sprintf(bp, "%sblue = %d", sep, blue);

	    tti = proto_tree_add_none_format(tt, hf_x11_coloritem, tvb, *offsetp, 12, "%s", buffer);
	    ttt = proto_item_add_subtree(tti, ett_x11_color_item);
	    proto_tree_add_item(ttt, hf_x11_coloritem_pixel, tvb, *offsetp, 4, little_endian);
	    *offsetp += 4;
	    proto_tree_add_item(ttt, hf_x11_coloritem_red, tvb, *offsetp, 2, little_endian);
	    *offsetp += 2;
	    proto_tree_add_item(ttt, hf_x11_coloritem_green, tvb, *offsetp, 2, little_endian);
	    *offsetp += 2;
	    proto_tree_add_item(ttt, hf_x11_coloritem_blue, tvb, *offsetp, 2, little_endian);
	    *offsetp += 2;
	    colorFlags(tvb, offsetp, ttt);
	    proto_tree_add_item(ttt, hf_x11_coloritem_unused, tvb, *offsetp, 1, little_endian);
	    *offsetp += 1;
      }
}

static GTree *keysymTable = NULL;

static gint compareGuint32(gconstpointer a, gconstpointer b)
{
      return GPOINTER_TO_INT(b) - GPOINTER_TO_INT(a);
}

static const char *
keycode2keysymString(int *keycodemap[256], int first_keycode,
		     int keysyms_per_keycode, 
		     int *modifiermap[array_length(modifiers)],
		     int keycodes_per_modifier,
		     guint32 keycode, guint32 bitmask)
{
	static char buf[32];
	int *syms;
	int groupmodkc, numlockkc, numlockmod, groupmod;
	int lockmod_is_capslock = 0, lockmod_is_shiftlock = 0;
	int lockmod_is_nosymbol = 1;
	int modifier, kc, keysym;

	if ((syms = keycodemap[keycode]) == NULL)
		return "<Unknown>";

	for (kc = first_keycode, groupmodkc = numlockkc = -1; kc < 256; ++kc)
		for (keysym = 0; keysym < keysyms_per_keycode; ++keysym)
			switch (keycodemap[kc][keysym]) {
				case 0xff7e:
					groupmodkc = kc;
					break;

				case 0xff7f:
					numlockkc = kc;
					break;

				case 0xffe5:
					lockmod_is_capslock = kc;
					break;

				case 0xffe6:
					lockmod_is_shiftlock = kc;
					break;
			}


	/*
	 * If we have not seen the modifiermap we don't know what the
	 * keycode translates to, but we do know it's one of the keys 
	 * in syms (give or take a case-conversion), so we could in 
	 * theory list them all.
	 */
	if (modifiermap[array_length(modifiers) - 1] == NULL) /* all or none */
		return "<Unknown>";

	/* find out what the numlockmodifer and groupmodifier is. */
	for (modifier = 0, numlockmod = groupmod = -1;
	modifier < (int)array_length(modifiers) && numlockmod == -1;
	++modifier)
		for (kc = 0; kc < keycodes_per_modifier; ++kc)
			if (modifiermap[modifier][kc] == numlockkc)
				numlockmod = modifier;
			else if (modifiermap[modifier][kc] == groupmodkc)
				groupmod = modifier;

	/*
	 * ... and what the lockmodifier is interpreted as.
	 * (X11v4r6 ref, keyboard and pointers section.)
	 */
	for (kc = 0; kc < keycodes_per_modifier; ++kc)
		if (modifiermap[1][kc] == lockmod_is_capslock) {
			lockmod_is_shiftlock = lockmod_is_nosymbol = 0;
			break;
		}
		else if (modifiermap[0][kc] == lockmod_is_shiftlock) {
			lockmod_is_capslock = lockmod_is_nosymbol = 0;
			break;
		}

#if 0 
	/* 
	 * This is (how I understand) the X11v4R6 protocol description given
	 * in A. Nye's book.  It is quite different from the
	 * code in _XTranslateKey() in the file 
	 * "$XConsortium: KeyBind.c /main/55 1996/02/02 14:08:55 kaleb $"
	 * as shipped with XFree, and doesn't work correctly, nor do I see
	 * how it could (e.g. the case of lower/uppercase-letters).
	 */

	if (numlockmod >= 0 && (bitmask & modifiermask[numlockmod])
	&& ((keycodemap[keycode][1] >= 0xff80
	 && keycodemap[keycode][1] <= 0xffbd)
	 || (keycodemap[keycode][1] >= 0x11000000
	 && keycodemap[keycode][1] <= 0x1100ffff))) {
		if ((bitmask & ShiftMask) || lockmod_is_shiftlock)
			return keysymString(keycodemap[keycode][groupmod + 0]);
		else
			if (keycodemap[keycode][groupmod + 1] == NoSymbol)
				return keysymString(keycodemap[keycode]
				[groupmod + 0]);
			else
				return keysymString(keycodemap[keycode]
				[groupmod + 1]);
	}
	else if (!(bitmask & ShiftMask) && !(bitmask & LockMask))
		return keysymString(keycodemap[keycode][groupmod + 0]);
	else if (!(bitmask & ShiftMask)
	&& ((bitmask & LockMask) && lockmod_is_capslock))
		if (islower(keycodemap[keycode][groupmod + 0]))
/*			return toupper(keysymString(keycodemap[keycode][groupmod + 0])); */
			return "Uppercase"; /* XXX */
		else
			return keysymString(keycodemap[keycode][groupmod + 0]);

	else if ((bitmask & ShiftMask) 
	&& ((bitmask & LockMask) && lockmod_is_capslock))
		if (islower(keycodemap[keycode][groupmod + 1]))
/*			return toupper(keysymString(keycodemap[keycode][groupmod + 1])); */
			return "Uppercase"; /* XXX */
		else
			return keysymString(keycodemap[keycode][groupmod + 1]);

	else if ((bitmask & ShiftMask) 
	||  ((bitmask & LockMask) && lockmod_is_shiftlock))
			return keysymString(keycodemap[keycode][groupmod + 1]);
#else /* _XTranslateKey() based code. */

	while (keysyms_per_keycode > 2
	&& keycodemap[keysyms_per_keycode - 1] == NoSymbol)
		--keysyms_per_keycode;
	if (keysyms_per_keycode > 2
	&& (groupmod >= 0 && (modifiermask[groupmod] & bitmask))) {
		syms += 2;
		keysyms_per_keycode -= 2;
	}
	
	if (numlockmod >= 0 && (bitmask & modifiermask[numlockmod])
	&& keysyms_per_keycode > 1 && ((syms[1] >= 0xff80 && syms[1] <= 0xffbd)
	 || (syms[1] >= 0x11000000 && syms[1] <= 0x1100ffff))) {
		if ((bitmask & ShiftMask)
		|| (bitmask & LockMask && lockmod_is_shiftlock))
			keysym = syms[0];
		else
			keysym = syms[1];
	}
	else if (!(bitmask & ShiftMask)
	&& (!(bitmask & LockMask) || lockmod_is_nosymbol)) {
		if (keysyms_per_keycode == 1
		|| (keysyms_per_keycode > 1 && syms[1] == NoSymbol)) {
			int usym;

			XConvertCase(syms[0], &keysym, &usym);
		}
		else
			keysym = syms[0];
	}
	else if (!(bitmask & LockMask) || !lockmod_is_capslock) {
		int lsym, usym;

		if (keysyms_per_keycode == 1
		|| (keysyms_per_keycode > 1 && (usym = syms[1]) == NoSymbol))
			XConvertCase(syms[0], &lsym, &usym);
		keysym = usym;
	}
	else {
		int lsym, usym;

		if (keysyms_per_keycode == 1
		|| (keysyms_per_keycode > 1 && syms[1] == NoSymbol))
			keysym = syms[0];

		XConvertCase(keysym, &lsym, &usym);

		if (!(bitmask & ShiftMask) && keysym != syms[0]
		&& ((keysym != usym) || (lsym == usym)))
			XConvertCase(syms[0], &lsym, &usym);
		keysym = usym;
	}
	
	if (keysym == XK_VoidSymbol)
		keysym = NoSymbol;

	sprintf(buf, "%d, \"%s\"", keysym, keysymString(keysym));
	return buf;
#endif
}

static const char *keysymString(guint32 v)
{
      gpointer res;
      if (!keysymTable) {

            /* This table is so big that we built it only if necessary */

	    const value_string *p = keysym_vals_source;
	    keysymTable = g_tree_new(compareGuint32);
	    for(; p -> strptr; p++)
		  g_tree_insert(keysymTable, GINT_TO_POINTER(p -> value), p -> strptr);
      }
      res = g_tree_lookup(keysymTable, GINT_TO_POINTER(v));
      return res ? res : "<Unknown>";
}

static void listOfKeycode(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
			  int *modifiermap[], int keycodes_per_modifier,
			  gboolean little_endian)
{
      char buffer[1024];
      proto_item *ti = proto_tree_add_item(t, hf, tvb, *offsetp,
      array_length(modifiers) * keycodes_per_modifier, little_endian);

      proto_tree *tt = proto_item_add_subtree(ti, ett_x11_list_of_keycode);
      size_t m;

      for (m = 0; m < array_length(modifiers);
      ++m, *offsetp += keycodes_per_modifier) {
	    char *bp = buffer;
	    int i;

            modifiermap[m] = g_malloc(keycodes_per_modifier);

	    for(i = 0; i < keycodes_per_modifier; ++i) {
		guchar c = tvb_get_guint8(tvb, *offsetp + i);

		if (c)
		    bp += sprintf(bp, " %s=%d", modifiers[m], c);

		modifiermap[m][i] = c;
	    }

	    proto_tree_add_bytes_format(tt, hf_x11_keycodes_item, tvb,
	    *offsetp, keycodes_per_modifier,
	    tvb_get_ptr(tvb, *offsetp, keycodes_per_modifier),
	    "item: %s", buffer);
      }
}

static void listOfKeysyms(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
			  int hf_item, int *keycodemap[256],
			  int keycode_first, int keycode_count,
			  int keysyms_per_keycode, gboolean little_endian)
{
      proto_item *ti = proto_tree_add_item(t, hf, tvb, *offsetp, keycode_count * keysyms_per_keycode * 4, little_endian);
      proto_tree *tt = proto_item_add_subtree(ti, ett_x11_list_of_keysyms);
      proto_item *tti;
      proto_tree *ttt;
      int i, keycode;

      g_assert(keycode_first >= 0);
      g_assert(keycode_count >= 0);
      g_assert((size_t)(keycode_first + keycode_count) <= 256);


      for (keycode = keycode_first; keycode_count > 0;
      ++keycode, --keycode_count) {
	    tti = proto_tree_add_none_format(tt, hf_item, tvb, *offsetp,
	    keysyms_per_keycode * 4, "keysyms (keycode %d):", keycode);

	    ttt = proto_item_add_subtree(tti, ett_x11_keysym);

	    keycodemap[keycode]
	    = g_malloc(sizeof(*keycodemap[keycode]) * keysyms_per_keycode);

	    for(i = 0; i < keysyms_per_keycode; ++i) {
		  /* keysymvalue = byte3 * 256 + byte4. */
		  guint32 v = VALUE32(tvb, *offsetp);

		  proto_item_append_text(tti, " %s", keysymString(v));
		  proto_tree_add_uint_format(ttt, hf_x11_keysyms_item_keysym,
		  tvb, *offsetp, 4, v,
		  "keysym (keycode %d): 0x%08x (%s)",
		  keycode, v, keysymString(v));

		  keycodemap[keycode][i] = v;
		  *offsetp += 4;
	    }
	
	    for (i = 1; i < keysyms_per_keycode; ++i)
		if (keycodemap[keycode][i] != NoSymbol)
			break;

	    if (i == keysyms_per_keycode) {
	        /* all but (possibly) first were NoSymbol. */
		if (keysyms_per_keycode == 4) {
			keycodemap[keycode][1] = NoSymbol;
			keycodemap[keycode][2] = keycodemap[keycode][0];
			keycodemap[keycode][3] = NoSymbol;
		}

		continue;
	    }

	    for (i = 2; i < keysyms_per_keycode; ++i)
		if (keycodemap[keycode][i] != NoSymbol)
			break;
	    if (i == keysyms_per_keycode) {
	        /* all but (possibly) first two were NoSymbol. */
		if (keysyms_per_keycode == 4) {
			keycodemap[keycode][2] = keycodemap[keycode][0];
			keycodemap[keycode][3] =  keycodemap[keycode][1];
		}

		continue;
	    }
      }
}

static void listOfPoint(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
			int length, gboolean little_endian)
{
      proto_item *ti = proto_tree_add_item(t, hf, tvb, *offsetp, length * 4, little_endian);
      proto_tree *tt = proto_item_add_subtree(ti, ett_x11_list_of_point);
      while(length--) {
	    gint16 x, y;
	    proto_item *tti;
	    proto_tree *ttt;

	    x = VALUE16(tvb, *offsetp);
	    y = VALUE16(tvb, *offsetp + 2);

	    tti = proto_tree_add_none_format(tt, hf_x11_point, tvb, *offsetp, 4, "point: (%d,%d)", x, y);
	    ttt = proto_item_add_subtree(tti, ett_x11_point);
	    proto_tree_add_int(ttt, hf_x11_point_x, tvb, *offsetp, 2, x);
	    *offsetp += 2;
	    proto_tree_add_int(ttt, hf_x11_point_y, tvb, *offsetp, 2, y);
	    *offsetp += 2;
      }
}

static void listOfRectangle(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
			    int length, gboolean little_endian)
{
      proto_item *ti = proto_tree_add_item(t, hf, tvb, *offsetp, length * 8, little_endian);
      proto_tree *tt = proto_item_add_subtree(ti, ett_x11_list_of_rectangle);
      while(length--) {
	    gint16 x, y;
	    unsigned width, height;
	    proto_item *tti;
	    proto_tree *ttt;

	    x = VALUE16(tvb, *offsetp);
	    y = VALUE16(tvb, *offsetp + 2);
	    width = VALUE16(tvb, *offsetp + 4);
	    height = VALUE16(tvb, *offsetp + 6);

	    tti = proto_tree_add_none_format(tt, hf_x11_rectangle, tvb, *offsetp, 8,
						 "rectangle: %dx%d+%d+%d", width, height, x, y);
	    ttt = proto_item_add_subtree(tti, ett_x11_rectangle);
	    proto_tree_add_int(ttt, hf_x11_rectangle_x, tvb, *offsetp, 2, x);
	    *offsetp += 2;
	    proto_tree_add_int(ttt, hf_x11_rectangle_y, tvb, *offsetp, 2, y);
	    *offsetp += 2;
	    proto_tree_add_uint(ttt, hf_x11_rectangle_width, tvb, *offsetp, 2, width);
	    *offsetp += 2;
	    proto_tree_add_uint(ttt, hf_x11_rectangle_height, tvb, *offsetp, 2, height);
	    *offsetp += 2;
      }
}

static void listOfSegment(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
			  int length, gboolean little_endian)
{
      proto_item *ti = proto_tree_add_item(t, hf, tvb, *offsetp, length * 8, little_endian);
      proto_tree *tt = proto_item_add_subtree(ti, ett_x11_list_of_segment);
      while(length--) {
	    gint16 x1, y1, x2, y2;
	    proto_item *tti;
	    proto_tree *ttt;

	    x1 = VALUE16(tvb, *offsetp);
	    y1 = VALUE16(tvb, *offsetp + 2);
	    x2 = VALUE16(tvb, *offsetp + 4);
	    y2 = VALUE16(tvb, *offsetp + 6);

	    tti = proto_tree_add_none_format(tt, hf_x11_segment, tvb, *offsetp, 8,
						 "segment: (%d,%d)-(%d,%d)", x1, y1, x2, y2);
	    ttt = proto_item_add_subtree(tti, ett_x11_segment);
	    proto_tree_add_item(ttt, hf_x11_segment_x1, tvb, *offsetp, 2, little_endian);
	    *offsetp += 2;
	    proto_tree_add_item(ttt, hf_x11_segment_y1, tvb, *offsetp, 2, little_endian);
	    *offsetp += 2;
	    proto_tree_add_item(ttt, hf_x11_segment_x2, tvb, *offsetp, 2, little_endian);
	    *offsetp += 2;
	    proto_tree_add_item(ttt, hf_x11_segment_y2, tvb, *offsetp, 2, little_endian);
	    *offsetp += 2;
      }
}

/* XXX - the protocol tree code should handle non-printable characters.
   Note that "non-printable characters" may depend on your locale.... */
static void stringCopy(char *dest, const char *source, int length)
{
      guchar c;
      while(length--) {
	    c = *source++;
	    if (!isgraph(c) && c != ' ') c = '.';
	    *dest++ = c;
      }
      *dest++ = '\0';
}

static void listOfString8(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
			  int hf_item, int length, gboolean little_endian)
{
      char *s = NULL;
      guint allocated = 0;
      proto_item *ti;
      proto_tree *tt;
      int i;

      /* Compute total length */

      int scanning_offset = *offsetp; /* Scanning pointer */
      int l;
      for(i = length; i; i--) {
	    l = tvb_get_guint8(tvb, scanning_offset);
	    scanning_offset += 1 + l;
      }

      ti = proto_tree_add_item(t, hf, tvb, *offsetp, scanning_offset - *offsetp, little_endian);
      tt = proto_item_add_subtree(ti, ett_x11_list_of_string8);

      /*
       * In case we throw an exception, clean up whatever stuff we've
       * allocated (if any).
       */
      CLEANUP_PUSH(g_free, s);

      while(length--) {
	    unsigned l = VALUE8(tvb, *offsetp);
	    if (allocated < (l + 1)) {
		  /* g_realloc doesn't work ??? */
		  g_free(s);
		  s = g_malloc(l + 1);
		  allocated = l + 1;
	    }
	    stringCopy(s, tvb_get_ptr(tvb, *offsetp + 1, l), l); /* Nothing better for now. We need a better string handling API. */
	    proto_tree_add_string_format(tt, hf_item, tvb, *offsetp, l + 1, s, "\"%s\"", s);
	    *offsetp += l + 1;
      }

      /*
       * Call the cleanup handler to free the string and pop the handler.
       */
      CLEANUP_CALL_AND_POP;
}

#define STRING16_MAX_DISPLAYED_LENGTH 150

static int stringIsActuallyAn8BitString(tvbuff_t *tvb, int offset, unsigned length)
{
      if (length > STRING16_MAX_DISPLAYED_LENGTH) length = STRING16_MAX_DISPLAYED_LENGTH;
      for(; length > 0; offset += 2, length--) {
	    if (tvb_get_guint8(tvb, offset))
		return FALSE;
      }
      return TRUE;
}

/* length is the length of the _byte_zone_ (that is, twice the length of the string) */

static void string16_with_buffer_preallocated(tvbuff_t *tvb, proto_tree *t,
					      int hf, int hf_bytes,
					      int offset, unsigned length,
					      char **s, int *sLength,
					      gboolean little_endian)
{
      int truncated = FALSE;
      unsigned l = length / 2;

      if (stringIsActuallyAn8BitString(tvb, offset, l)) {
	    char *dp;
	    int soffset = offset;

	    if (l > STRING16_MAX_DISPLAYED_LENGTH) {
		  truncated = TRUE;
		  l = STRING16_MAX_DISPLAYED_LENGTH;
	    }
	    if (*sLength < (int) l + 3) {
		  g_free(*s);
		  *s = g_malloc(l + 3);
		  *sLength = l + 3;
	    }
	    dp = *s;
	    *dp++ = '"';
	    if (truncated) l -= 3;

	    while(l--) {
		  soffset++;
		  *dp++ = tvb_get_guint8(tvb, soffset);
		  soffset++;
	    }
	    *dp++ = '"';

	    /* If truncated, add an ellipsis */
	    if (truncated) { *dp++ = '.'; *dp++ = '.'; *dp++ = '.'; }

	    *dp++ = '\0';
	    proto_tree_add_string_format(t, hf, tvb, offset, length, tvb_get_ptr(tvb, offset, length), "%s: %s",
					proto_registrar_get_nth(hf) -> name, *s);
      } else
	    proto_tree_add_item(t, hf_bytes, tvb, offset, length, little_endian);

}

static void listOfTextItem(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
    int sizeIs16, int next_offset, gboolean little_endian)
{
      int allocated = 0;
      char *s = NULL;
      proto_item *ti;
      proto_tree *tt;
      guint32 fid;

      /* Compute total length */

      int scanning_offset = *offsetp; /* Scanning pointer */
      int l;                            /* Length of an individual item */
      int n = 0;                        /* Number of items */

      while(scanning_offset < next_offset) {
	    l = tvb_get_guint8(tvb, scanning_offset);
	    scanning_offset++;
	    if (!l) break;
	    n++;
	    scanning_offset += l == 255 ? 4 : l + (sizeIs16 ? l : 0) + 1;
      }

      ti = proto_tree_add_item(t, hf, tvb, *offsetp, scanning_offset - *offsetp, little_endian);
      tt = proto_item_add_subtree(ti, ett_x11_list_of_text_item);

      /*
       * In case we throw an exception, clean up whatever stuff we've
       * allocated (if any).
       */
      CLEANUP_PUSH(g_free, s);

      while(n--) {
	    unsigned l = VALUE8(tvb, *offsetp);
	    if (l == 255) { /* Item is a font */
		  fid = tvb_get_ntohl(tvb, *offsetp + 1);
		  proto_tree_add_uint(tt, hf_x11_textitem_font, tvb, *offsetp, 5, fid);
		  *offsetp += 5;
	    } else { /* Item is a string */
		  proto_item *tti;
		  proto_tree *ttt;
		  gint8 delta = VALUE8(tvb, *offsetp + 1);
		  if (sizeIs16) l += l;
		  if ((unsigned) allocated < l + 1) {
			/* g_realloc doesn't work ??? */
			g_free(s);
			s = g_malloc(l + 1);
			allocated = l + 1;
		  }
		  stringCopy(s, tvb_get_ptr(tvb, *offsetp + 2, l), l);
		  tti = proto_tree_add_none_format(tt, hf_x11_textitem_string, tvb, *offsetp, l + 2,
						       "textitem (string): delta = %d, \"%s\"",
						       delta, s);
		  ttt = proto_item_add_subtree(tti, ett_x11_text_item);
		  proto_tree_add_item(ttt, hf_x11_textitem_string_delta, tvb, *offsetp + 1, 1, little_endian);
		  if (sizeIs16)
			string16_with_buffer_preallocated(tvb, ttt, hf_x11_textitem_string_string16,
							  hf_x11_textitem_string_string16_bytes,
							  *offsetp + 2, l,
							  &s, &allocated,
							  little_endian);
		  else
			proto_tree_add_string_format(ttt, hf_x11_textitem_string_string8, tvb,
						     *offsetp + 2, l, s, "\"%s\"", s);
		  *offsetp += l + 2;
	    }
      }

      /*
       * Call the cleanup handler to free the string and pop the handler.
       */
      CLEANUP_CALL_AND_POP;
}

static guint32 field8(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
		      gboolean little_endian)
{
      guint32 v = VALUE8(tvb, *offsetp);
      header_field_info *hfi = proto_registrar_get_nth(hf);
      gchar *enumValue = NULL;

      if (hfi -> strings)
	    enumValue = match_strval(v, cVALS(hfi -> strings));
      if (enumValue)
	    proto_tree_add_uint_format(t, hf, tvb, *offsetp, 1, v,
            hfi -> display == BASE_DEC ? "%s: %u (%s)" : "%s: 0x%02x (%s)",
	    hfi -> name, v, enumValue);
      else
	    proto_tree_add_item(t, hf, tvb, *offsetp, 1, little_endian);
      *offsetp += 1;
      return v;
}

static guint32 field16(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
		       gboolean little_endian)
{
      guint32 v = VALUE16(tvb, *offsetp);
      header_field_info *hfi = proto_registrar_get_nth(hf);
      gchar *enumValue = NULL;

      if (hfi -> strings)
	    enumValue = match_strval(v, cVALS(hfi -> strings));
      if (enumValue)
	    proto_tree_add_uint_format(t, hf, tvb, *offsetp, 2, v,
       	    hfi -> display == BASE_DEC ? "%s: %u (%s)" : "%s: 0x%02x (%s)",
	    hfi -> name, v, enumValue);
      else
	    proto_tree_add_item(t, hf, tvb, *offsetp, 2, little_endian);
      *offsetp += 2;
      return v;
}

static guint32 field32(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
		       gboolean little_endian)
{
      guint32 v = VALUE32(tvb, *offsetp);
      header_field_info *hfi = proto_registrar_get_nth(hf);
      gchar *enumValue = NULL;
      gchar *nameAsChar = hfi -> name;

      if (hfi -> strings)
	    enumValue = match_strval(v, cVALS(hfi -> strings));
      if (enumValue)
	    proto_tree_add_uint_format(t, hf, tvb, *offsetp, 4, v,
				       hfi -> display == BASE_DEC ? "%s: %u (%s)" : "%s: 0x%08x (%s)",
				       nameAsChar, v, enumValue);
      else
	    proto_tree_add_uint_format(t, hf, tvb, *offsetp, 4, v,
				       hfi -> display == BASE_DEC ? "%s: %u" : "%s: 0x%08x",
				       nameAsChar, v);
      *offsetp += 4;
      return v;
}

static void gcAttributes(tvbuff_t *tvb, int *offsetp, proto_tree *t,
			 gboolean little_endian)
{
      BITMASK32(gc_value);
      BITFIELD(ENUM8,  gc_value_mask, function);
      BITFIELD(CARD32, gc_value_mask, plane_mask);
      BITFIELD(CARD32, gc_value_mask, foreground);
      BITFIELD(CARD32, gc_value_mask, background);
      BITFIELD(CARD16, gc_value_mask, line_width);
      BITFIELD(ENUM8,  gc_value_mask, line_style);
      BITFIELD(ENUM8,  gc_value_mask, cap_style);
      BITFIELD(ENUM8,  gc_value_mask, join_style);
      BITFIELD(ENUM8,  gc_value_mask, fill_style);
      BITFIELD(ENUM8,  gc_value_mask, fill_rule);
      BITFIELD(PIXMAP, gc_value_mask, tile);
      BITFIELD(PIXMAP, gc_value_mask, stipple);
      BITFIELD(INT16,  gc_value_mask, tile_stipple_x_origin);
      BITFIELD(INT16,  gc_value_mask, tile_stipple_y_origin);
      BITFIELD(FONT,   gc_value_mask, font);
      BITFIELD(ENUM8,  gc_value_mask, subwindow_mode);
      BITFIELD(BOOL,   gc_value_mask, graphics_exposures);
      BITFIELD(INT16,  gc_value_mask, clip_x_origin);
      BITFIELD(INT16,  gc_value_mask, clip_y_origin);
      BITFIELD(PIXMAP, gc_value_mask, clip_mask);
      BITFIELD(CARD16, gc_value_mask, dash_offset);
      BITFIELD(CARD8,  gc_value_mask, gc_dashes);
      BITFIELD(ENUM8,  gc_value_mask, arc_mode);
      ENDBITMASK;
}

static void gcMask(tvbuff_t *tvb, int *offsetp, proto_tree *t,
		   gboolean little_endian)
{
      BITMASK32(gc_value);
      FLAG(gc_value, function);
      FLAG(gc_value, plane_mask);
      FLAG(gc_value, foreground);
      FLAG(gc_value, background);
      FLAG(gc_value, line_width);
      FLAG(gc_value, line_style);
      FLAG(gc_value, cap_style);
      FLAG(gc_value, join_style);
      FLAG(gc_value, fill_style);
      FLAG(gc_value, fill_rule);
      FLAG(gc_value, tile);
      FLAG(gc_value, stipple);
      FLAG(gc_value, tile_stipple_x_origin);
      FLAG(gc_value, tile_stipple_y_origin);
      FLAG(gc_value, font);
      FLAG(gc_value, subwindow_mode);
      FLAG(gc_value, graphics_exposures);
      FLAG(gc_value, clip_x_origin);
      FLAG(gc_value, clip_y_origin);
      FLAG(gc_value, clip_mask);
      FLAG(gc_value, dash_offset);
      FLAG(gc_value, gc_dashes);
      FLAG(gc_value, arc_mode);
      ENDBITMASK;
}

static guint32 requestLength(tvbuff_t *tvb, int *offsetp, proto_tree *t,
			     gboolean little_endian)
{
      guint32 res = VALUE16(tvb, *offsetp);
      proto_tree_add_uint(t, hf_x11_request_length, tvb, *offsetp, 2, res);
      *offsetp += 2;
      return res * 4;
}

static void setOfEvent(tvbuff_t *tvb, int *offsetp, proto_tree *t,
		       gboolean little_endian)
{
      BITMASK32(event);
      FLAG(event, KeyPress);
      FLAG(event, KeyRelease);
      FLAG(event, ButtonPress);
      FLAG(event, ButtonRelease);
      FLAG(event, EnterWindow);
      FLAG(event, LeaveWindow);
      FLAG(event, PointerMotion);
      FLAG(event, PointerMotionHint);
      FLAG(event, Button1Motion);
      FLAG(event, Button2Motion);
      FLAG(event, Button3Motion);
      FLAG(event, Button4Motion);
      FLAG(event, Button5Motion);
      FLAG(event, ButtonMotion);
      FLAG(event, KeymapState);
      FLAG(event, Exposure);
      FLAG(event, VisibilityChange);
      FLAG(event, StructureNotify);
      FLAG(event, ResizeRedirect);
      FLAG(event, SubstructureNotify);
      FLAG(event, SubstructureRedirect);
      FLAG(event, FocusChange);
      FLAG(event, PropertyChange);
      FLAG(event, ColormapChange);
      FLAG(event, OwnerGrabButton);
      FLAG_IF_NONZERO(event, erroneous_bits);
      ENDBITMASK;
}

static void setOfDeviceEvent(tvbuff_t *tvb, int *offsetp, proto_tree *t,
			     gboolean little_endian)
{
      BITMASK32(do_not_propagate);
      FLAG(do_not_propagate, KeyPress);
      FLAG(do_not_propagate, KeyRelease);
      FLAG(do_not_propagate, ButtonPress);
      FLAG(do_not_propagate, ButtonRelease);
      FLAG(do_not_propagate, PointerMotion);
      FLAG(do_not_propagate, Button1Motion);
      FLAG(do_not_propagate, Button2Motion);
      FLAG(do_not_propagate, Button3Motion);
      FLAG(do_not_propagate, Button4Motion);
      FLAG(do_not_propagate, Button5Motion);
      FLAG(do_not_propagate, ButtonMotion);
      FLAG_IF_NONZERO(do_not_propagate, erroneous_bits);
      ENDBITMASK;
}


static void setOfKeyButMask(tvbuff_t *tvb, int *offsetp, proto_tree *t,
			 gboolean little_endian, gboolean butmask)
{
      proto_item *ti;
      guint32 bitmask_value;
      int bitmask_offset;
      int bitmask_size;
      proto_tree *bitmask_tree;

      bitmask_value = VALUE16(tvb, *offsetp);
      bitmask_offset = *offsetp;
      bitmask_size = 2;

      if (!butmask && bitmask_value == 0x8000)
	    proto_tree_add_uint_format(t, hf_x11_modifiers_mask_AnyModifier, tvb, *offsetp, 2, 0x8000,
				       "modifiers-masks: 0x8000 (AnyModifier)");
      else {
	    ti = proto_tree_add_uint(t, hf_x11_modifiers_mask, tvb, *offsetp, 2,
						 bitmask_value);
	    bitmask_tree = proto_item_add_subtree(ti, ett_x11_set_of_key_mask);
	    FLAG(modifiers, Shift);
	    FLAG(modifiers, Lock);
	    FLAG(modifiers, Control);
	    FLAG(modifiers, Mod1);
	    FLAG(modifiers, Mod2);
	    FLAG(modifiers, Mod3);
	    FLAG(modifiers, Mod4);
	    FLAG(modifiers, Mod5);

	    if (butmask) {
		    FLAG(modifiers, Button1);
		    FLAG(modifiers, Button2);
		    FLAG(modifiers, Button3);
		    FLAG(modifiers, Button4);
		    FLAG(modifiers, Button5);
	    }

	    if (butmask)
		    FLAG_IF_NONZERO(keybut, erroneous_bits);
	    else
		    FLAG_IF_NONZERO(modifiers, erroneous_bits);
      }
      *offsetp += 2;
}


static void setOfPointerEvent(tvbuff_t *tvb, int *offsetp, proto_tree *t,
			      gboolean little_endian)
{
      BITMASK16(pointer_event);
      FLAG(pointer_event, ButtonPress);
      FLAG(pointer_event, ButtonRelease);
      FLAG(pointer_event, EnterWindow);
      FLAG(pointer_event, LeaveWindow);
      FLAG(pointer_event, PointerMotion);
      FLAG(pointer_event, PointerMotionHint);
      FLAG(pointer_event, Button1Motion);
      FLAG(pointer_event, Button2Motion);
      FLAG(pointer_event, Button3Motion);
      FLAG(pointer_event, Button4Motion);
      FLAG(pointer_event, Button5Motion);
      FLAG(pointer_event, ButtonMotion);
      FLAG(pointer_event, KeymapState);
      FLAG_IF_NONZERO(pointer_event, erroneous_bits);
      ENDBITMASK;
}

static void string8(tvbuff_t *tvb, int *offsetp, proto_tree *t,
    int hf, unsigned length)
{
      char *s = g_malloc(length + 1);

      /*
       * In case we throw an exception, clean up whatever stuff we've
       * allocated (if any).
       */
      CLEANUP_PUSH(g_free, s);

      stringCopy(s, tvb_get_ptr(tvb, *offsetp, length), length);
      proto_tree_add_string(t, hf, tvb, *offsetp, length, s);

      /*
       * Call the cleanup handler to free the string and pop the handler.
       */
      CLEANUP_CALL_AND_POP;

      *offsetp += length;
}

/* The length is the length of the _byte_zone_ (twice the length of the string) */

static void string16(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
    int hf_bytes, unsigned length, gboolean little_endian)
{
      char *s = NULL;
      unsigned l = 0;

      /*
       * In case we throw an exception, clean up whatever stuff we've
       * allocated (if any).
       */
      CLEANUP_PUSH(g_free, s);

      length += length;
      string16_with_buffer_preallocated(tvb, t, hf, hf_bytes, *offsetp, length,
					&s, &l, little_endian);

      /*
       * Call the cleanup handler to free the string and pop the handler.
       */
      CLEANUP_CALL_AND_POP;

      *offsetp += length;
}

static void timestamp(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
		      gboolean little_endian)
{
      guint32 v = VALUE32(tvb, *offsetp);

      if (!v)
	    proto_tree_add_uint_format(t, hf, tvb, *offsetp, 4, 0, "%s: 0 (CurrentTime)",
		proto_registrar_get_nth(hf) -> name);
      else
	    proto_tree_add_uint(t, hf, tvb, *offsetp, 4, v);
      *offsetp += 4;
}

static void windowAttributes(tvbuff_t *tvb, int *offsetp, proto_tree *t,
			     gboolean little_endian)
{
      BITMASK32(window_value);
      BITFIELD(PIXMAP, window_value_mask, background_pixmap);
      BITFIELD(CARD32, window_value_mask, background_pixel);
      BITFIELD(PIXMAP, window_value_mask, border_pixmap);
      BITFIELD(CARD32, window_value_mask, border_pixel);
      BITFIELD(BITGRAVITY, window_value_mask, bit_gravity);
      BITFIELD(WINGRAVITY, window_value_mask, win_gravity);
      BITFIELD(ENUM8, window_value_mask, backing_store);
      BITFIELD(CARD32, window_value_mask, backing_planes);
      BITFIELD(CARD32, window_value_mask, backing_pixel);
      BITFIELD(BOOL,   window_value_mask, override_redirect);
      BITFIELD(BOOL,   window_value_mask, save_under);
      BITFIELD(SETofEVENT, window_value_mask, event_mask);
      BITFIELD(SETofDEVICEEVENT, window_value_mask, do_not_propagate_mask);
      BITFIELD(COLORMAP, window_value_mask, colormap);
      BITFIELD(CURSOR, window_value_mask, cursor);
      ENDBITMASK;
}

static void x11_init_protocol(void)
{
      if (x11_state_chunk != NULL)
	    g_mem_chunk_destroy(x11_state_chunk);

      x11_state_chunk = g_mem_chunk_new("x11_state_chunk",
					sizeof (x11_conv_data_t),
					128 * sizeof (x11_conv_data_t),
					G_ALLOC_ONLY);
}

/************************************************************************
 ***                                                                  ***
 ***         G U E S S I N G   T H E   B Y T E   O R D E R I N G      ***
 ***                                                                  ***
 ************************************************************************/

/* If we can't guess, we return TRUE (that is little_endian), cause
   I'm developing on a Linux box :-). The (non-)guess isn't cached
   however, so we may have more luck next time. I'm quite conservative
   in my assertions, cause once it's cached, it's stay in cache, and
   we may be fooled up by a packet starting with the end of a request
   started in a previous packet...
*/

static int numberOfBitSetTable[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };

static int numberOfBitSet(tvbuff_t *tvb, int offset, int maskLength)
{
      int res = 0;
      while(maskLength--) {
	    int c = tvb_get_guint8(tvb, offset);
	    offset++;
	    res += numberOfBitSetTable[c & 0xf] + numberOfBitSetTable[c >> 4];
      }
      return res;
}

static int listOfStringLengthConsistent(tvbuff_t *tvb, int offset, int length, int listLength)
{
      if (listLength > length) return FALSE;
      while(listLength--) {
	    int l;
	    if (!tvb_bytes_exist(tvb, offset, 1)) return TRUE;
	    l = tvb_get_guint8(tvb, offset);
	    if (!l) break;
	    l++;
	    if (l > length) return FALSE;
	    if (!tvb_bytes_exist(tvb, offset, l)) return TRUE;
	    offset += l;
	    length -= l;
      }
      if (length > 3) return FALSE;
      return TRUE;
}

static int rounded4(int n)
{
      int remainder = n % 4;
      int res = n / 4;
      if (remainder) res++;
      return res;
}

/* We assume the order to be consistent, until proven wrong. */

static gboolean consistentWithOrder(int length, tvbuff_t *tvb, int offset, guint16 (*v16)(tvbuff_t *, gint))
{
      switch(tvb_get_guint8(tvb, offset)) {
	  case X_CreateWindow:
	    return !tvb_bytes_exist(tvb, offset, 32) || length == 8 + numberOfBitSet(tvb, offset + 7 * 4, 4);

	  case X_ChangeWindowAttributes:
	  case X_ChangeGC:
	    return !tvb_bytes_exist(tvb, offset, 12) || length == 3 + numberOfBitSet(tvb, offset + 8, 4);

	  case X_GetWindowAttributes:
	  case X_DestroyWindow:
	  case X_DestroySubwindows:
	  case X_ChangeSaveSet:
	  case X_MapWindow:
	  case X_MapSubwindows:
	  case X_UnmapWindow:
	  case X_UnmapSubwindows:
	  case X_CirculateWindow:
	  case X_GetGeometry:
	  case X_QueryTree:
	  case X_GetAtomName:
	  case X_ListProperties:
	  case X_GetSelectionOwner:
	  case X_UngrabPointer:
	  case X_UngrabKeyboard:
	  case X_AllowEvents:
	  case X_QueryPointer:
	  case X_CloseFont:
	  case X_QueryFont:
	  case X_FreePixmap:
	  case X_FreeGC:
	  case X_FreeColormap:
	  case X_InstallColormap:
	  case X_UninstallColormap:
	  case X_ListInstalledColormaps:
	  case X_FreeCursor:
	  case X_GetKeyboardMapping:
	  case X_KillClient:
	    return length == 2;

	  case X_ReparentWindow:
	  case X_SetSelectionOwner:
	  case X_ChangeActivePointerGrab:
	  case X_GrabKeyboard:
	  case X_GrabKey:
	  case X_GetMotionEvents:
	  case X_TranslateCoords:
	  case X_CreatePixmap:
	  case X_CopyGC:
	  case X_ClearArea:
	  case X_CreateColormap:
	  case X_AllocColor:
	  case X_AllocColorPlanes:
	    return length == 4;

	  case X_ConfigureWindow:
	    return !tvb_bytes_exist(tvb, offset, 10) || length == 3 + numberOfBitSet(tvb, offset + 8, 2);

	  case X_InternAtom:
	  case X_QueryExtension:
	    return !tvb_bytes_exist(tvb, offset, 6) || length == 2 + rounded4(v16(tvb, offset + 4));

	  case X_ChangeProperty:
	    {
		  int multiplier, type;
		  if (!tvb_bytes_exist(tvb, offset, 17)) return TRUE;
		  type = tvb_get_guint8(tvb, 16);
		  if (type != 8 && type != 16 && type != 32) return FALSE;
		  multiplier = type == 8 ? 1 : type == 16 ? 2 : 4;
		  if (!tvb_bytes_exist(tvb, offset, 24)) return TRUE;
		  return length == 6 + rounded4((v16 == tvb_get_letohs ? tvb_get_letohl : tvb_get_ntohl)(tvb, offset + 20) * multiplier);
	    }

	  case X_DeleteProperty:
	  case X_UngrabButton:
	  case X_UngrabKey:
	  case X_SetInputFocus:
	  case X_CopyColormapAndFree:
	  case X_AllocColorCells:
	  case X_QueryBestSize:
	  case X_ChangePointerControl:
	  case X_SetScreenSaver:
	    return length == 3;

	  case X_GetProperty:
	  case X_ConvertSelection:
	  case X_GrabPointer:
	  case X_GrabButton:
	  case X_WarpPointer:
	    return length == 6;

	  case X_SendEvent:
	    return length == 11;

	  case X_GrabServer:
	  case X_UngrabServer:
	  case X_GetInputFocus:
	  case X_QueryKeymap:
	  case X_GetFontPath:
	  case X_ListExtensions:
	  case X_GetKeyboardControl:
	  case X_Bell:
	  case X_GetPointerControl:
	  case X_GetScreenSaver:
	  case X_ListHosts:
	  case X_SetAccessControl:
	  case X_SetCloseDownMode:
	  case X_ForceScreenSaver:
	  case X_GetPointerMapping:
	  case X_GetModifierMapping:
	    return length == 1;

	  case X_OpenFont:
	  case X_AllocNamedColor:
	  case X_LookupColor:
	    return !tvb_bytes_exist(tvb, offset, 10) || length == 3 + rounded4(v16(tvb, offset + 8));

	  case X_QueryTextExtents:
	    return length >= 2;

	  case X_ListFonts:
	  case X_ListFontsWithInfo:
	  case X_ChangeHosts:
	    return !tvb_bytes_exist(tvb, offset, 8) || length == 2 + rounded4(v16(tvb, offset + 6));

	  case X_SetFontPath:
	    if (length < 2) return FALSE;
	    if (!tvb_bytes_exist(tvb, offset, 8)) return TRUE;
	    return listOfStringLengthConsistent(tvb, offset + 8, (length - 2) * 4, v16(tvb, offset + 4));

	  case X_CreateGC:
	    return !tvb_bytes_exist(tvb, offset, 16) || length == 4 + numberOfBitSet(tvb, offset + 12, 4);

	  case X_SetDashes:
	    return !tvb_bytes_exist(tvb, offset, 12) || length == 3 + rounded4(v16(tvb, offset + 10));

	  case X_SetClipRectangles:
	  case X_PolySegment:
	  case X_PolyRectangle:
	  case X_PolyFillRectangle:
	    return length >= 3 && (length - 3) % 2 == 0;

	  case X_CopyArea:
	    return length == 7;

	  case X_CopyPlane:
	  case X_CreateCursor:
	  case X_CreateGlyphCursor:
	    return length == 8;

	  case X_PolyPoint:
	  case X_PolyLine:
	  case X_FreeColors:
	    return length >= 3;

	  case X_PolyArc:
	  case X_PolyFillArc:
	    return length >= 3 && (length - 3) % 3 == 0;

	  case X_FillPoly:
	  case X_ImageText8:
	    return length >= 4;

	  case X_PutImage:
	    return length >= 6;

	  case X_GetImage:
	  case X_RecolorCursor:
	    return length == 5;

	  case X_PolyText8:
	    if (length < 4) return FALSE;
	    return TRUE; /* We don't perform many controls on this one */

	  case X_PolyText16:
	    if (length < 4) return FALSE;
	    return TRUE; /* We don't perform many controls on this one */

	  case X_ImageText16:
	    return length >= 4;

	  case X_StoreColors:
	    return length > 2 && (length - 2) % 3 == 0;

	  case X_StoreNamedColor:
	    return !tvb_bytes_exist(tvb, offset, 14) || length == 4 + rounded4(v16(tvb, offset + 12));

	  case X_QueryColors:
	    return length >= 2;

	  case X_ChangeKeyboardMapping:
	    return !tvb_bytes_exist(tvb, offset, 6) || length == 2 + tvb_get_guint8(tvb, 1) * tvb_get_guint8(tvb, 5);

	  case X_ChangeKeyboardControl:
	    return !tvb_bytes_exist(tvb, offset, 6) || length == 2 + numberOfBitSet(tvb, offset + 4, 2);

	  case X_RotateProperties:
	    return !tvb_bytes_exist(tvb, offset, 10) || length == 3 + v16(tvb, offset + 8);

	  case X_SetPointerMapping:
	    return length == 1 + rounded4(tvb_get_guint8(tvb, 1));

	  case X_SetModifierMapping:
	    return length == 1 + tvb_get_guint8(tvb, 1) * 2;

	  case X_NoOperation:
	    return length >= 1;

	  default:
	    return TRUE;
      }
}

/* -1 means doesn't match, +1 means match, 0 means don't know */

static int x_endian_match(tvbuff_t *tvb, guint16 (*v16)(tvbuff_t *, gint))
{
      int offset, nextoffset;
      int atLeastOne = 0;

      for(offset = 0; tvb_bytes_exist(tvb, offset, 4); offset = nextoffset) {
	    int length;
	    length = v16(tvb, offset + 2);
	    if (!length) return -1;
	    nextoffset = offset + length * 4;
	    if (!consistentWithOrder(length, tvb, offset, v16)) return -1;
	    atLeastOne = 1;
      }
      return atLeastOne;
}

static gboolean
guess_byte_ordering(tvbuff_t *tvb, packet_info *pinfo,
		    x11_conv_data_t *state)
{
      /* With X the client gives the byte ordering for the protocol,
	 and the port on the server tells us we're speaking X. */

      int le, be, decision, decisionToCache;

      if (state->byte_order == BYTE_ORDER_BE)
	    return FALSE;	/* known to be big-endian */
      else if (state->byte_order == BYTE_ORDER_LE)
	    return TRUE;	/* known to be little-endian */

      if (pinfo->srcport == pinfo->match_port) {
      	    /*
      	     * This is a reply or event; we don't try to guess the
      	     * byte order on it for now.
      	     */
	    return TRUE;
      }

      le = x_endian_match(tvb, tvb_get_letohs);
      be = x_endian_match(tvb, tvb_get_ntohs);

      /* remember that "decision" really means "little_endian". */
      if (le == be) {
	    /* We have no reason to believe it's little- rather than
	       big-endian, so we guess the shortest length is the
	       right one.
	    */
	    if (!tvb_bytes_exist(tvb, 0, 4))
		  /* Not even a way to get the length. We're biased
		     toward little endianness here (essentially the
		     x86 world right now). Decoding won't go very far
		     anyway.
		  */
		  decision = TRUE;
	    else
		  decision = tvb_get_letohs(tvb, 2) <= tvb_get_ntohs(tvb, 2);
      } else
	  decision = le >= be;

      decisionToCache = (le < 0 && be > 0) || (le > 0 && be < 0);
      if (decisionToCache) {
	    /*
	     * Remember the decision.
	     */
	    state->byte_order = decision ? BYTE_ORDER_LE : BYTE_ORDER_BE;
      }

      /*
      fprintf(stderr, "packet %d\tle %d\tbe %d\tlittle_endian %d\tcache %d\n",
	      pinfo->fd -> num, le, be, decision, decisionToCache);
      */
      return decision;
}

/************************************************************************
 ***                                                                  ***
 ***              D E C O D I N G   O N E   P A C K E T               ***
 ***                                                                  ***
 ************************************************************************/

/*
 * Decode an initial connection request.
 */
static void dissect_x11_initial_conn(tvbuff_t *tvb, packet_info *pinfo,
    proto_tree *tree, x11_conv_data_t *state, gboolean little_endian)
{
      int offset = 0;
      int *offsetp = &offset;
      proto_item *ti;
      proto_tree *t;
      guint16 auth_proto_name_length, auth_proto_data_length;
      gint left;

      ti = proto_tree_add_item(tree, proto_x11, tvb, 0, -1, FALSE);
      t = proto_item_add_subtree(ti, ett_x11);

      CARD8(byte_order);
      UNUSED(1);
      CARD16(protocol_major_version);
      CARD16(protocol_minor_version);
      auth_proto_name_length = CARD16(authorization_protocol_name_length);
      auth_proto_data_length = CARD16(authorization_protocol_data_length);
      UNUSED(2);
      if (auth_proto_name_length != 0) {
	    STRING8(authorization_protocol_name, auth_proto_name_length);
	    offset = ROUND_LENGTH(offset);
      }
      if (auth_proto_data_length != 0) {
	    STRING8(authorization_protocol_data, auth_proto_data_length);
	    offset = ROUND_LENGTH(offset);
      }

      if ((left = tvb_reported_length_remaining(tvb, offset)) > 0)
	   	proto_tree_add_item(t, hf_x11_undecoded, tvb, offset, left,
	   	little_endian);

      /*
       * This is the initial connection request...
       */
      state->iconn_frame = pinfo->fd->num;

      /*
       * ...and we're expecting a reply to it.
       */
      state->sequencenumber = 0;
      g_hash_table_insert(state->seqtable, (int *)state->sequencenumber,
      (int *)INITIAL_CONN);
}

static void dissect_x11_initial_reply(tvbuff_t *tvb, packet_info *pinfo,
    proto_tree *tree, x11_conv_data_t *state, gboolean little_endian)
{
      	int offset = 0, *offsetp = &offset, left;
	unsigned char success;
	int length_of_vendor;
	proto_item *ti;
	proto_tree *t;

	ti = proto_tree_add_item(tree, proto_x11, tvb, 0, -1, FALSE);
	t = proto_item_add_subtree(ti, ett_x11);

	if (check_col(pinfo->cinfo, COL_INFO))
		col_add_fstr(pinfo->cinfo, COL_INFO,
		"Initial connection reply");


	state->iconn_reply = pinfo->fd->num;
	success = INT8(success);
	if (success == 0) {
		UNDECODED(1);
	}
	else {
		UNUSED(1);
	}

	INT16(protocol_major_version);
	INT16(protocol_minor_version);
	INT16(replylength);
	INT32(release_number);
	INT32(resource_id_base);
	INT32(resource_id_mask);
	INT32(motion_buffer_size);
	length_of_vendor = INT16(length_of_vendor);
	INT16(maximum_request_length);
	INT8(number_of_screens_in_roots);
	INT8(number_of_formats_in_pixmap_formats);
	INT8(image_byte_order);
	INT8(bitmap_format_bit_order);
	INT8(bitmap_format_scanline_unit);
	INT8(bitmap_format_scanline_pad);
	INT8(min_keycode);
	INT8(max_keycode);
	UNUSED(4);
	STRING8(vendor, length_of_vendor);

      	if ((left = tvb_reported_length_remaining(tvb, offset)) > 0)
	    UNDECODED(left);
}

static void dissect_x11_request(tvbuff_t *tvb, packet_info *pinfo,
    proto_tree *tree, const char *sep, x11_conv_data_t *state,
    gboolean little_endian)
{
      int offset = 0;
      int *offsetp = &offset;
      int next_offset;
      proto_item *ti;
      proto_tree *t;
      int length, opcode;
      guint8 v8, v8_2, v8_3;
      guint16 v16;
      guint32 v32;
      gint left;

      length = VALUE16(tvb, 2) * 4;

      if (length < 4) {
	    /* Bogus message length? */
	    return;
      }

      next_offset = offset + length;

      ti = proto_tree_add_item(tree, proto_x11, tvb, 0, -1, FALSE);
      t = proto_item_add_subtree(ti, ett_x11);

      if (PACKET_IS_NEW(pinfo))
            ++state->sequencenumber;

      OPCODE();

      if (check_col(pinfo->cinfo, COL_INFO))
	  col_append_fstr(pinfo->cinfo, COL_INFO, "%s %s", sep,
			  val_to_str(opcode, opcode_vals, "<Unknown> (%u)"));

      /*
       * Does this request expect a reply?
       */
      switch(opcode) {
      case X_AllocColor:
      case X_AllocColorCells:
      case X_AllocColorPlanes:
      case X_AllocNamedColor:
      case X_GetAtomName:
      case X_GetFontPath:
      case X_GetGeometry:
      case X_GetImage:
      case X_GetInputFocus:
      case X_GetKeyboardControl:
      case X_GetKeyboardMapping:
      case X_GetModifierMapping:
      case X_GetMotionEvents:
      case X_GetPointerControl:
      case X_GetPointerMapping:
      case X_GetProperty:
      case X_GetScreenSaver:
      case X_GetSelectionOwner:
      case X_GetWindowAttributes:
      case X_GrabKeyboard:
      case X_GrabPointer:
      case X_InternAtom:
      case X_ListExtensions:
      case X_ListFonts:
      case X_ListFontsWithInfo:
      case X_ListHosts:
      case X_ListInstalledColormaps:
      case X_ListProperties:
      case X_LookupColor:
      case X_QueryBestSize:
      case X_QueryColors:
      case X_QueryExtension:
      case X_QueryFont:
      case X_QueryKeymap:
      case X_QueryPointer:
      case X_QueryTextExtents:
      case X_QueryTree:
      case X_SetModifierMapping:
      case X_SetPointerMapping:
      case X_TranslateCoords:
	    	/*
	     	* Those requests expect a reply.
	     	*/

		g_hash_table_insert(state->seqtable,
		(int *)state->sequencenumber, (int *)opcode);

	    	break;

      default:
	    /*
	     * No reply is expected from any other request.
	     */
      }

/*      if (!tree) return; */

      switch(opcode) {

      case X_CreateWindow:
	    CARD8(depth);
	    REQUEST_LENGTH();
	    WINDOW(wid);
	    WINDOW(parent);
	    INT16(x);
	    INT16(y);
	    CARD16(width);
	    CARD16(height);
	    CARD16(border_width);
	    ENUM16(window_class);
	    VISUALID(visual);
	    windowAttributes(tvb, offsetp, t, little_endian);
	    break;

      case X_ChangeWindowAttributes:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    windowAttributes(tvb, offsetp, t, little_endian);
	    break;

      case X_GetWindowAttributes:
      case X_DestroyWindow:
      case X_DestroySubwindows:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    break;

      case X_ChangeSaveSet:
	    ENUM8(save_set_mode);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    break;

      case X_ReparentWindow:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    WINDOW(parent);
	    INT16(x);
	    INT16(y);
	    break;

      case X_MapWindow:
      case X_MapSubwindows:
      case X_UnmapWindow:
      case X_UnmapSubwindows:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    break;

      case X_ConfigureWindow:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    BITMASK16(configure_window);
	    UNUSED(2);
	    BITFIELD(INT16,  configure_window_mask, x);
	    BITFIELD(INT16,  configure_window_mask, y);
	    BITFIELD(CARD16, configure_window_mask, width);
	    BITFIELD(CARD16, configure_window_mask, height);
	    BITFIELD(CARD16, configure_window_mask, border_width);
	    BITFIELD(WINDOW, configure_window_mask, sibling);
	    BITFIELD(ENUM8,  configure_window_mask, stack_mode);
	    ENDBITMASK;
	    PAD();
	    break;

      case X_CirculateWindow:
	    ENUM8(direction);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    break;

      case X_GetGeometry:
      case X_QueryTree:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    break;

      case X_InternAtom:
	    BOOL(only_if_exists);
	    REQUEST_LENGTH();
	    v16 = FIELD16(name_length);
	    UNUSED(2);
	    STRING8(name, v16);
	    PAD();
	    break;

      case X_GetAtomName:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    ATOM(atom);
	    break;

      case X_ChangeProperty:
	    ENUM8(mode);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    ATOM(property);
	    ATOM(type);
	    CARD8(format);
	    UNUSED(3);
	    v32 = CARD32(data_length);
	    LISTofBYTE(data, v32);
	    PAD();
	    break;

      case X_DeleteProperty:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    ATOM(property);
	    break;

      case X_GetProperty:
	    BOOL(delete);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    ATOM(property);
	    ATOM(get_property_type);
	    CARD32(long_offset);
	    CARD32(long_length);
	    break;

      case X_ListProperties:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    break;

      case X_SetSelectionOwner:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(owner);
	    ATOM(selection);
	    TIMESTAMP(time);
	    break;

      case X_GetSelectionOwner:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    ATOM(selection);
	    break;

      case X_ConvertSelection:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(requestor);
	    ATOM(selection);
	    ATOM(target);
	    ATOM(property);
	    TIMESTAMP(time);
	    break;

      case X_GrabPointer:
	    BOOL(owner_events);
	    REQUEST_LENGTH();
	    WINDOW(grab_window);
	    SETofPOINTEREVENT(pointer_event_mask);
	    ENUM8(pointer_mode);
	    ENUM8(keyboard_mode);
	    WINDOW(confine_to);
	    CURSOR(cursor);
	    TIMESTAMP(time);
	    break;

      case X_UngrabPointer:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    TIMESTAMP(time);
	    break;

      case X_GrabButton:
	    BOOL(owner_events);
	    REQUEST_LENGTH();
	    WINDOW(grab_window);
	    SETofPOINTEREVENT(event_mask);
	    ENUM8(pointer_mode);
	    ENUM8(keyboard_mode);
	    WINDOW(confine_to);
	    CURSOR(cursor);
	    BUTTON(button);
	    UNUSED(1);
	    SETofKEYMASK(modifiers);
	    break;

      case X_UngrabButton:
	    BUTTON(button);
	    REQUEST_LENGTH();
	    WINDOW(grab_window);
	    SETofKEYMASK(modifiers);
	    UNUSED(2);
	    break;

      case X_ChangeActivePointerGrab:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    CURSOR(cursor);
	    TIMESTAMP(time);
	    SETofPOINTEREVENT(event_mask);
	    UNUSED(2);
	    break;

      case X_GrabKeyboard:
	    BOOL(owner_events);
	    REQUEST_LENGTH();
	    WINDOW(grab_window);
	    TIMESTAMP(time);
	    ENUM8(pointer_mode);
	    ENUM8(keyboard_mode);
	    UNUSED(2);
	    break;

      case X_UngrabKeyboard:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    TIMESTAMP(time);
	    break;

      case X_GrabKey:
	    BOOL(owner_events);
	    REQUEST_LENGTH();
	    WINDOW(grab_window);
	    SETofKEYMASK(modifiers);
	    KEYCODE(key);
	    ENUM8(pointer_mode);
	    ENUM8(keyboard_mode);
	    UNUSED(3);
	    break;

      case X_UngrabKey:
	    KEYCODE(key);
	    REQUEST_LENGTH();
	    WINDOW(grab_window);
	    SETofKEYMASK(modifiers);
	    UNUSED(2);
	    break;

      case X_AllowEvents:
	    ENUM8(allow_events_mode);
	    REQUEST_LENGTH();
	    TIMESTAMP(time);
	    break;

      case X_GrabServer:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_UngrabServer:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_QueryPointer:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    break;

      case X_GetMotionEvents:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    TIMESTAMP(start);
	    TIMESTAMP(stop);
	    break;

      case X_TranslateCoords:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(src_window);
	    WINDOW(dst_window);
	    INT16(src_x);
	    INT16(src_y);
	    break;

      case X_WarpPointer:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(warp_pointer_src_window);
	    WINDOW(warp_pointer_dst_window);
	    INT16(src_x);
	    INT16(src_y);
	    CARD16(src_width);
	    CARD16(src_height);
	    INT16(dst_x);
	    INT16(dst_y);
	    break;

      case X_SetInputFocus:
	    ENUM8(revert_to);
	    REQUEST_LENGTH();
	    WINDOW(focus);
	    TIMESTAMP(time);
	    break;

      case X_GetInputFocus:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_QueryKeymap:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_OpenFont:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    FONT(fid);
	    v16 = FIELD16(name_length);
	    UNUSED(2);
	    STRING8(name, v16);
	    PAD();
	    break;

      case X_CloseFont:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    FONT(font);
	    break;

      case X_QueryFont:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    FONTABLE(font);
	    break;

      case X_QueryTextExtents:
	    v8 = BOOL(odd_length);
	    REQUEST_LENGTH();
	    FONTABLE(font);
	    STRING16(string16, (next_offset - offset - (v8 ? 2 : 0)) / 2);
	    PAD();
	    break;

      case X_ListFonts:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    CARD16(max_names);
	    v16 = FIELD16(pattern_length);
	    STRING8(pattern, v16);
	    PAD();
	    break;

      case X_ListFontsWithInfo:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    CARD16(max_names);
	    v16 = FIELD16(pattern_length);
	    STRING8(pattern, v16);
	    PAD();
	    break;

      case X_SetFontPath:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    v16 = CARD16(str_number_in_path);
	    UNUSED(2);
	    LISTofSTRING8(path, v16);
	    PAD();
	    break;

      case X_GetFontPath:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_CreatePixmap:
	    CARD8(depth);
	    REQUEST_LENGTH();
	    PIXMAP(pid);
	    DRAWABLE(drawable);
	    CARD16(width);
	    CARD16(height);
	    break;

      case X_FreePixmap:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    PIXMAP(pixmap);
	    break;

      case X_CreateGC:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    GCONTEXT(cid);
	    DRAWABLE(drawable);
	    gcAttributes(tvb, offsetp, t, little_endian);
	    break;

      case X_ChangeGC:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    GCONTEXT(gc);
	    gcAttributes(tvb, offsetp, t, little_endian);
	    break;

      case X_CopyGC:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    GCONTEXT(src_gc);
	    GCONTEXT(dst_gc);
	    gcMask(tvb, offsetp, t, little_endian);
	    break;

      case X_SetDashes:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    GCONTEXT(gc);
	    CARD16(dash_offset);
	    v16 = FIELD16(dashes_length);
	    LISTofCARD8(dashes, v16);
	    PAD();
	    break;

      case X_SetClipRectangles:
	    ENUM8(ordering);
	    REQUEST_LENGTH();
	    GCONTEXT(gc);
	    INT16(clip_x_origin);
	    INT16(clip_y_origin);
	    LISTofRECTANGLE(rectangles);
	    break;

      case X_FreeGC:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    GCONTEXT(gc);
	    break;

      case X_ClearArea:
	    BOOL(exposures);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    INT16(x);
	    INT16(y);
	    CARD16(width);
	    CARD16(height);
	    break;

      case X_CopyArea:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    DRAWABLE(src_drawable);
	    DRAWABLE(dst_drawable);
	    GCONTEXT(gc);
	    INT16(src_x);
	    INT16(src_y);
	    INT16(dst_x);
	    INT16(dst_y);
	    CARD16(width);
	    CARD16(height);
	    break;

      case X_CopyPlane:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    DRAWABLE(src_drawable);
	    DRAWABLE(dst_drawable);
	    GCONTEXT(gc);
	    INT16(src_x);
	    INT16(src_y);
	    INT16(dst_x);
	    INT16(dst_y);
	    CARD16(width);
	    CARD16(height);
	    CARD32(bit_plane);
	    break;

      case X_PolyPoint:
	    ENUM8(coordinate_mode);
	    v16 = REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    LISTofPOINT(points, v16 - 12);
	    break;

      case X_PolyLine:
	    ENUM8(coordinate_mode);
	    v16 = REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    LISTofPOINT(points, v16 - 12);
	    break;

      case X_PolySegment:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    LISTofSEGMENT(segments);
	    break;

      case X_PolyRectangle:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    LISTofRECTANGLE(rectangles);
	    break;

      case X_PolyArc:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    LISTofARC(arcs);
	    break;

      case X_FillPoly:
	    UNUSED(1);
	    v16 = REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    ENUM8(shape);
	    ENUM8(coordinate_mode);
	    UNUSED(2);
	    LISTofPOINT(points, v16 - 16);
	    break;

      case X_PolyFillRectangle:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    LISTofRECTANGLE(rectangles);
	    break;

      case X_PolyFillArc:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    LISTofARC(arcs);
	    break;

      case X_PutImage:
	    ENUM8(image_format);
	    v16 = REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    CARD16(width);
	    CARD16(height);
	    INT16(dst_x);
	    INT16(dst_y);
	    CARD8(left_pad);
	    CARD8(depth);
	    UNUSED(2);
	    LISTofBYTE(data, v16 - 24);
	    PAD();
	    break;

      case X_GetImage:
	    ENUM8(image_pixmap_format);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    INT16(x);
	    INT16(y);
	    CARD16(width);
	    CARD16(height);
	    CARD32(plane_mask);
	    break;

      case X_PolyText8:
	    UNUSED(1);
	    v16 = REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    INT16(x);
	    INT16(y);
	    LISTofTEXTITEM8(items);
	    PAD();
	    break;

      case X_PolyText16:
	    UNUSED(1);
	    v16 = REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    INT16(x);
	    INT16(y);
	    LISTofTEXTITEM16(items);
	    PAD();
	    break;

      case X_ImageText8:
	    v8 = FIELD8(string_length);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    INT16(x);
	    INT16(y);
	    STRING8(string, v8);
	    PAD();
	    break;

      case X_ImageText16:
	    v8 = FIELD8(string_length);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    GCONTEXT(gc);
	    INT16(x);
	    INT16(y);
	    STRING16(string16, v8);
	    PAD();
	    break;

      case X_CreateColormap:
	    ENUM8(alloc);
	    REQUEST_LENGTH();
	    COLORMAP(mid);
	    WINDOW(window);
	    VISUALID(visual);
	    break;

      case X_FreeColormap:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    COLORMAP(cmap);
	    break;

      case X_CopyColormapAndFree:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    COLORMAP(mid);
	    COLORMAP(src_cmap);
	    break;

      case X_InstallColormap:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    COLORMAP(cmap);
	    break;

      case X_UninstallColormap:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    COLORMAP(cmap);
	    break;

      case X_ListInstalledColormaps:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    WINDOW(window);
	    break;

      case X_AllocColor:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    COLORMAP(cmap);
	    CARD16(red);
	    CARD16(green);
	    CARD16(blue);
	    UNUSED(2);
	    break;

      case X_AllocNamedColor:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    COLORMAP(cmap);
	    v16 = FIELD16(name_length);
	    UNUSED(2);
	    STRING8(name, v16);
	    PAD();
	    break;

      case X_AllocColorCells:
	    BOOL(contiguous);
	    REQUEST_LENGTH();
	    COLORMAP(cmap);
	    CARD16(colors);
	    CARD16(planes);
	    break;

      case X_AllocColorPlanes:
	    BOOL(contiguous);
	    REQUEST_LENGTH();
	    COLORMAP(cmap);
	    CARD16(colors);
	    CARD16(reds);
	    CARD16(greens);
	    CARD16(blues);
	    break;

      case X_FreeColors:
	    UNUSED(1);
	    v16 = REQUEST_LENGTH();
	    COLORMAP(cmap);
	    CARD32(plane_mask);
	    LISTofCARD32(pixels, v16 - 12);
	    break;

      case X_StoreColors:
	    UNUSED(1);
	    v16 = REQUEST_LENGTH();
	    COLORMAP(cmap);
	    LISTofCOLORITEM(color_items, v16 - 8);
	    break;

      case X_StoreNamedColor:
	    COLOR_FLAGS(color);
	    REQUEST_LENGTH();
	    COLORMAP(cmap);
	    CARD32(pixel);
	    v16 = FIELD16(name_length);
	    UNUSED(2);
	    STRING8(name, v16);
	    PAD();
	    break;

      case X_QueryColors:
	    UNUSED(1);
	    v16 = REQUEST_LENGTH();
	    COLORMAP(cmap);
	    LISTofCARD32(pixels, v16 - 8);
	    break;

      case X_LookupColor:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    COLORMAP(cmap);
	    v16 = FIELD16(name_length);
	    UNUSED(2);
	    STRING8(name, v16);
	    PAD();
	    break;

      case X_CreateCursor:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    CURSOR(cid);
	    PIXMAP(source_pixmap);
	    PIXMAP(mask);
	    CARD16(fore_red);
	    CARD16(fore_green);
	    CARD16(fore_blue);
	    CARD16(back_red);
	    CARD16(back_green);
	    CARD16(back_blue);
	    CARD16(x);
	    CARD16(y);
	    break;

      case X_CreateGlyphCursor:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    CURSOR(cid);
	    FONT(source_font);
	    FONT(mask_font);
	    CARD16(source_char);
	    CARD16(mask_char);
	    CARD16(fore_red);
	    CARD16(fore_green);
	    CARD16(fore_blue);
	    CARD16(back_red);
	    CARD16(back_green);
	    CARD16(back_blue);
	    break;

      case X_FreeCursor:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    CURSOR(cursor);
	    break;

      case X_RecolorCursor:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    CURSOR(cursor);
	    CARD16(fore_red);
	    CARD16(fore_green);
	    CARD16(fore_blue);
	    CARD16(back_red);
	    CARD16(back_green);
	    CARD16(back_blue);
	    break;

      case X_QueryBestSize:
	    ENUM8(class);
	    REQUEST_LENGTH();
	    DRAWABLE(drawable);
	    CARD16(width);
	    CARD16(height);
	    break;

      case X_QueryExtension:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    v16 = FIELD16(name_length);
	    UNUSED(2);
	    STRING8(name, v16);
	    PAD();
	    break;

      case X_ListExtensions:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_ChangeKeyboardMapping:
	    v8 = FIELD8(keycode_count);
	    REQUEST_LENGTH();
	    v8_2 = KEYCODE(first_keycode);
	    v8_3 = FIELD8(keysyms_per_keycode);
	    UNUSED(2);
	    LISTofKEYSYM(keysyms, state->keycodemap, v8_2, v8, v8_3);
	    break;

      case X_GetKeyboardMapping:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    state->request.GetKeyboardMapping.first_keycode
	    = KEYCODE(first_keycode);
	    FIELD8(count);
	    UNUSED(2);
	    break;

      case X_ChangeKeyboardControl:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    BITMASK32(keyboard_value);
	    BITFIELD(INT8, keyboard_value_mask, key_click_percent);
	    BITFIELD(INT8, keyboard_value_mask, bell_percent);
	    BITFIELD(INT16, keyboard_value_mask, bell_pitch);
	    BITFIELD(INT16, keyboard_value_mask, bell_duration);
	    BITFIELD(INT16, keyboard_value_mask, led);
	    BITFIELD(ENUM8, keyboard_value_mask, led_mode);
	    BITFIELD(KEYCODE, keyboard_value_mask, keyboard_key);
	    BITFIELD(ENUM8, keyboard_value_mask, auto_repeat_mode);
	    ENDBITMASK;
	    break;

      case X_GetKeyboardControl:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_Bell:
	    INT8(percent);
	    REQUEST_LENGTH();
	    break;

      case X_ChangePointerControl:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    INT16(acceleration_numerator);
	    INT16(acceleration_denominator);
	    INT16(threshold);
	    BOOL(do_acceleration);
	    BOOL(do_threshold);
	    break;

      case X_GetPointerControl:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_SetScreenSaver:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    INT16(timeout);
	    INT16(interval);
	    ENUM8(prefer_blanking);
	    ENUM8(allow_exposures);
	    UNUSED(2);
	    break;

      case X_GetScreenSaver:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_ChangeHosts:
	    ENUM8(change_host_mode);
	    REQUEST_LENGTH();
	    v8 = ENUM8(family);
	    UNUSED(1);
	    v16 = CARD16(address_length);
	    if (v8 == FAMILY_INTERNET && v16 == 4) {
		  /*
		   * IPv4 addresses.
		   * XXX - what about IPv6?  Is that a family of
		   * FAMILY_INTERNET (0) with a length of 16?
		   */
		  LISTofCARD8(ip_address, v16);
	    } else
		  LISTofCARD8(address, v16);
	    break;

      case X_ListHosts:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_SetAccessControl:
	    ENUM8(access_mode);
	    REQUEST_LENGTH();
	    break;

      case X_SetCloseDownMode:
	    ENUM8(close_down_mode);
	    REQUEST_LENGTH();
	    break;

      case X_KillClient:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    CARD32(resource);
	    break;

      case X_RotateProperties:
	    UNUSED(1);
	    v16 = REQUEST_LENGTH();
	    WINDOW(window);
	    CARD16(property_number);
	    INT16(delta);
	    LISTofATOM(properties, (v16 - 12));
	    break;

      case X_ForceScreenSaver:
	    ENUM8(screen_saver_mode);
	    REQUEST_LENGTH();
	    break;

      case X_SetPointerMapping:
	    v8 = FIELD8(map_length);
	    REQUEST_LENGTH();
	    LISTofCARD8(map, v8);
	    PAD();
	    break;

      case X_GetPointerMapping:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_SetModifierMapping:
	    v8 = FIELD8(keycodes_per_modifier);
	    REQUEST_LENGTH();
	    LISTofKEYCODE(state->modifiermap, keycodes, v8);
	    break;

      case X_GetModifierMapping:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;

      case X_NoOperation:
	    UNUSED(1);
	    REQUEST_LENGTH();
	    break;
      }

      if (left = tvb_reported_length_remaining(tvb, offset))
	    UNDECODED(left);
}

static void dissect_x11_requests(tvbuff_t *tvb, packet_info *pinfo,
    proto_tree *tree)
{
      volatile int offset = 0;
      int length_remaining;
      volatile gboolean little_endian;
      guint8 opcode;
      volatile int plen;
      proto_item *ti;
      proto_tree *t;
      volatile gboolean is_initial_creq;
      guint16 auth_proto_len, auth_data_len;
      const char *volatile sep = NULL;
      conversation_t *conversation;
      x11_conv_data_t *state;
      int length;
      tvbuff_t *next_tvb;

      while ((length_remaining = tvb_reported_length_remaining(tvb, offset))
      > 0) {
	    /*
	     * Can we do reassembly?
	     */
	    if (x11_desegment && pinfo->can_desegment) {
		  /*
		   * Yes - is the X11 request header split across
		   * segment boundaries?
		   */
		  if (length_remaining < 4) {
			/*
			 * Yes.  Tell the TCP dissector where the data
			 * for this message starts in the data it handed
			 * us, and how many more bytes we need, and return.
			 */
			pinfo->desegment_offset = offset;
			pinfo->desegment_len = 4 - length_remaining;
			return;
		  }
	    }

	    /*
	     * Get the state for this conversation; create the conversation
	     * if we don't have one, and create the state if we don't have
	     * any.
	     */
	    conversation = find_conversation(&pinfo->src, &pinfo->dst,
		pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
	    if (conversation == NULL) {
		  /*
		   * No - create one.
		   */
		  conversation = conversation_new(&pinfo->src,
			&pinfo->dst, pinfo->ptype, pinfo->srcport,
			pinfo->destport, 0);
	    }

	    /*
	     * Is there state attached to this conversation?
	     */
	    if ((state = conversation_get_proto_data(conversation, proto_x11))
	    == NULL)
		x11_stateinit(&state, conversation);

	    /*
	     * Guess the byte order if we don't already know it.
	     */
	    little_endian = guess_byte_ordering(tvb, pinfo, state);

	    /*
	     * Get the opcode and length of the putative X11 request.
	     */
	    opcode = VALUE8(tvb, 0);
	    plen = VALUE16(tvb, offset + 2);

	    if (plen == 0) {
		  /*
		   * This can't be 0, as it includes the header length.
		   * A different choice of byte order wouldn't have
		   * helped.
		   * Give up.
		   */
		  ti = proto_tree_add_item(tree, proto_x11, tvb, offset, -1,
		  FALSE);
		  t = proto_item_add_subtree(ti, ett_x11);
		  proto_tree_add_text(t, tvb, offset, -1,
		  "Bogus request length (0)");
		  return;
	    }

	    if (state->iconn_frame == pinfo->fd->num ||
		(g_hash_table_lookup(state->seqtable,
		(int *)state->sequencenumber) == (int *)NOTHING_SEEN &&
	         (opcode == 'B' || opcode == 'l') &&
	         (plen == 11 || plen == 2816))) {
		  /*
		   * Either
		   *
		   *	we saw this on the first pass and this is
		   *    it again
		   *
		   * or
		   *    we haven't already seen any requests, the first
		   *    byte of the message is 'B' or 'l', and the 16-bit
		   *    integer 2 bytes into the data stream is either 11
		   *    or a byte-swapped 11.
		   *
		   * This means it's probably an initial connection
		   * request, not a message.
		   *
		   * 'B' is decimal 66, which is the opcode for a
		   * PolySegment request; unfortunately, 11 is a valid
		   * length for a PolySegment request request, so we
		   * might mis-identify that request.  (Are there any
		   * other checks we can do?)
		   *
		   * 'l' is decimal 108, which is the opcode for a
		   * GetScreenSaver request; the only valid length
		   * for that request is 1.
		   */
		  is_initial_creq = TRUE;

		  /*
		   * We now know the byte order.  Override the guess.
		   */
		  if (state->byte_order == BYTE_ORDER_UNKNOWN) {
		  	if (opcode == 'B') {
			      /*
			       * Big-endian.
			       */
			      state->byte_order = BYTE_ORDER_BE;
			      little_endian = FALSE;
			} else {
			      /*
			       * Little-endian.
			       */
			      state->byte_order = BYTE_ORDER_LE;
			      little_endian = TRUE;
			}
		  }

		  /*
		   * Can we do reassembly?
		   */
		  if (x11_desegment && pinfo->can_desegment) {
			/*
			 * Yes - is the fixed-length portion of the
			 * initial connection header split across
			 * segment boundaries?
			 */
			if (length_remaining < 10) {
			      /*
			       * Yes.  Tell the TCP dissector where the
			       * data for this message starts in the data
			       * it handed us, and how many more bytes we
			       * need, and return.
			       */
			      pinfo->desegment_offset = offset;
			      pinfo->desegment_len = 10 - length_remaining;
			      return;
			}
		  }

		  /*
		   * Get the lengths of the authorization protocol and
		   * the authorization data.
		   */
		  auth_proto_len = VALUE16(tvb, offset + 6);
		  auth_data_len = VALUE16(tvb, offset + 8);
		  plen = 12 + ROUND_LENGTH(auth_proto_len) +
			ROUND_LENGTH(auth_data_len);
	    } else {
		  /*
		   * This is probably an ordinary request.
		   */
		  is_initial_creq = FALSE;

		  /*
		   * The length of a request is in 4-byte words.
		   */
		  plen *= 4;
	    }

	    /*
	     * Can we do reassembly?
	     */
	    if (x11_desegment && pinfo->can_desegment) {
		  /*
		   * Yes - is the X11 request split across segment
		   * boundaries?
		   */
		  if (length_remaining < plen) {
			/*
			 * Yes.  Tell the TCP dissector where the data
			 * for this message starts in the data it handed
			 * us, and how many more bytes we need, and return.
			 */
			pinfo->desegment_offset = offset;
			pinfo->desegment_len = plen - length_remaining;
			return;
		  }
	    }

	    /*
	     * Construct a tvbuff containing the amount of the payload
	     * we have available.  Make its reported length the
	     * amount of data in the X11 request.
	     *
	     * XXX - if reassembly isn't enabled. the subdissector
	     * will throw a BoundsError exception, rather than a
	     * ReportedBoundsError exception.  We really want a tvbuff
	     * where the length is "length", the reported length is "plen",
	     * and the "if the snapshot length were infinite" length is the
	     * minimum of the reported length of the tvbuff handed to us
	     * and "plen", with a new type of exception thrown if the offset
	     * is within the reported length but beyond that third length,
	     * with that exception getting the "Unreassembled Packet" error.
	     */
	    length = length_remaining;
	    if (length > plen)
		  length = plen;
	    next_tvb = tvb_new_subset(tvb, offset, length, plen);

	    /*
	     * Set the column appropriately.
	     */
	    if (is_initial_creq) {
		  if (check_col(pinfo->cinfo, COL_INFO))
			col_set_str(pinfo->cinfo, COL_INFO,
			"Initial connection request");
	    } else {
		  if (sep == NULL) {
			/*
			 * We haven't set the column yet; set it.
			 */
			if (check_col(pinfo->cinfo, COL_INFO))
			      col_add_str(pinfo->cinfo, COL_INFO, "Requests");

			/*
			 * Initialize the separator.
			 */
			sep = ":";
		  }
	    }

	    /*
	     * Dissect the X11 request.
	     *
	     * Catch the ReportedBoundsError exception; if this
	     * particular message happens to get a ReportedBoundsError
	     * exception, that doesn't mean that we should stop
	     * dissecting X11 requests within this frame or chunk of
	     * reassembled data.
	     *
	     * If it gets a BoundsError, we can stop, as there's nothing
	     * more to see, so we just re-throw it.
	     */
	    TRY {
		  if (is_initial_creq) {
			dissect_x11_initial_conn(next_tvb, pinfo, tree,
			    state, little_endian);
		  } else {
			dissect_x11_request(next_tvb, pinfo, tree, sep,
			    state, little_endian);
		  }
	    }
	    CATCH(BoundsError) {
		  RETHROW;
	    }
	    CATCH(ReportedBoundsError) {
		  show_reported_bounds_error(tvb, pinfo, tree);
	    }
	    ENDTRY;

	    /*
	     * Skip the X11 message.
	     */
	    offset += plen;

	    sep = ",";
      }
}

static void
x11_stateinit(x11_conv_data_t **state, conversation_t *conversation)
{

	/*
	 * No - create a state structure and attach it.
	*/
	static x11_conv_data_t stateinit;

	*state = g_mem_chunk_alloc(x11_state_chunk);
	**state = stateinit; 

	(*state)->seqtable = g_hash_table_new(g_direct_hash, g_direct_equal);
      	g_hash_table_insert((*state)->seqtable, (int *)0, (int *)NOTHING_SEEN);
	(*state)->byte_order = BYTE_ORDER_UNKNOWN; /* don't know yet*/
	conversation_add_proto_data(conversation, proto_x11, *state);
}


static void
dissect_x11_replies(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
/* Set up structures we will need to add the protocol subtree and manage it */
	volatile int offset, plen;
	conversation_t *conversation;
	x11_conv_data_t *state;
	gboolean little_endian;
	int length_remaining;
	tvbuff_t *next_tvb;


	/*
	* Get the state for this conversation; create the conversation
	* if we don't have one, and create the state if we don't have
	* any.
	*/
	conversation = find_conversation(&pinfo->src, &pinfo->dst,
	pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
	if (conversation == NULL) {
		/*
	   	* No - create one.
	   	*/
		conversation = conversation_new(&pinfo->src, &pinfo->dst,
		pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
	}

	/*
	 * Is there state attached to this conversation?
	*/
	if ((state = conversation_get_proto_data(conversation, proto_x11))
	== NULL)
		x11_stateinit(&state, conversation);

	/*
	 * Guess the byte order if we don't already know it.
	 */
	little_endian = guess_byte_ordering(tvb, pinfo, state);

	offset = 0;
	while ((length_remaining = tvb_reported_length_remaining(tvb, offset))
	> 0) {
	    	/*
	     	* Can we do reassembly?
	     	*/
	    	if (x11_desegment && pinfo->can_desegment) {
			  /*
			   * Yes - is the X11 reply header split across
			   * segment boundaries?
			   */
			  if (length_remaining < 8) {
				/*
				 * Yes.  Tell the TCP dissector where the data
				 * for this message starts in the data it handed
				 * us, and how many more bytes we need, and
				 * return.
				 */
				pinfo->desegment_offset = offset;
				pinfo->desegment_len = 4 - length_remaining;
				return;
		  	}
	    	}

		/*
		 * Find out what kind of a reply it is.
		 * There are three possible:
		 *	- errorreply (a request generated an error)
		 * 	- requestreply (reply to a request)
		 *	- eventreply (some event occured)
		 */

		switch (tvb_get_guint8(tvb, offset)) {
		       case 0:
			       	plen = 32;
			       	HANDLE_REPLY(plen, length_remaining,
			       	dissect_x11_error); 
				break;

			case 1:
				/* replylength is in units of four. */
				if (g_hash_table_lookup(state->seqtable,
				(int *)state->sequencenumber)
				== (int *)INITIAL_CONN 
	    			|| (state->iconn_reply == pinfo->fd->num)) {
					/*
					 * ref. by A. Nye. says all
					 * replies are 32 + "additional bytes".
					 * Initial serverreply seems to be
					 * the exception, it's 8 + "additional
					 * bytes".
					 */
					plen = 8 + VALUE16(tvb, offset + 6) * 4;

					HANDLE_REPLY(plen, length_remaining,
					dissect_x11_initial_reply); 
				}
				else {
					plen
					= 32 + VALUE32(tvb, offset + 4) * 4;

					HANDLE_REPLY(plen, length_remaining,
					dissect_x11_reply); 
				}
				break;

		       	default:
				plen = 32;
				HANDLE_REPLY(plen, length_remaining,
				dissect_x11_event);
				break;
	       }

		offset += plen;
	}

	return;
}

static void
dissect_x11_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
		  x11_conv_data_t *volatile state, gboolean little_endian)
{
	int offset = 0, *offsetp = &offset, length, left, opcode;
	proto_item *ti;
	proto_tree *t;

	ti = proto_tree_add_item(tree, proto_x11, tvb, 0,
	tvb_reported_length_remaining(tvb, offset), FALSE);
	t = proto_item_add_subtree(ti, ett_x11);

	opcode = (int)g_hash_table_lookup(state->seqtable,
	(int *)VALUE16(tvb, offset + 2));

	if (check_col(pinfo->cinfo, COL_INFO))
		col_add_fstr(pinfo->cinfo, COL_INFO, "Reply: %s",
		  	     val_to_str(opcode, opcode_vals, "<Unknown>"));

	switch (opcode) {
      		/*
       		 * Requests that expect a reply.
      		*/

		case X_GetWindowAttributes:
		case X_GetGeometry:
		case X_QueryTree:
		case X_InternAtom:
		case X_GetAtomName:
			REPLYCONTENTS_COMMON();
			break; 

		case X_GetProperty:
			REPLY(reply);
			CARD8(format);
			SEQUENCENUMBER_REPLY(sequencenumber);
			length = REPLYLENGTH(replylength);
			ATOM(get_property_type);
			CARD32(bytes_after);
			CARD32(value_length);
			UNUSED(12);
			break;

		case X_ListProperties:
		case X_GetSelectionOwner:
		case X_GrabPointer:
		case X_GrabKeyboard:
		case X_QueryPointer:
		case X_GetMotionEvents:
		case X_TranslateCoords:
			REPLYCONTENTS_COMMON();
			break; 

		case X_QueryKeymap:
		case X_QueryFont:
		case X_QueryTextExtents:
		case X_ListFonts:
		case X_GetImage:
		case X_ListInstalledColormaps:
		case X_AllocColor:
		case X_QueryColors:
		case X_LookupColor:
		case X_QueryBestSize:
		case X_QueryExtension:
		case X_ListExtensions:
			REPLYCONTENTS_COMMON();
			break; 

		case X_GetKeyboardMapping:
			state->first_keycode
			= state->request.GetKeyboardMapping.first_keycode, 
			REPLY(reply);
			state->keysyms_per_keycode
			= FIELD8(keysyms_per_keycode);
			SEQUENCENUMBER_REPLY(sequencenumber);
			length = REPLYLENGTH(replylength);
			UNUSED(24);
			LISTofKEYSYM(keysyms, state->keycodemap,
			state->request.GetKeyboardMapping.first_keycode, 
			length / state->keysyms_per_keycode,
			state->keysyms_per_keycode);
			break; 

		case X_GetKeyboardControl:
		case X_GetPointerControl:
		case X_GetScreenSaver:
		case X_ListHosts:
		case X_SetPointerMapping:
		case X_GetPointerMapping:
		case X_SetModifierMapping:
			REPLYCONTENTS_COMMON();
			break; 

		case X_GetModifierMapping:
			REPLY(reply);
			state->keycodes_per_modifier
			= FIELD8(keycodes_per_modifier);
			SEQUENCENUMBER_REPLY(sequencenumber);
			REPLYLENGTH(replylength);
			UNUSED(24);
			LISTofKEYCODE(state->modifiermap, keycodes,
			state->keycodes_per_modifier);
			break; 

		default:
			REPLYCONTENTS_COMMON();
	}

      	if ((left = tvb_reported_length_remaining(tvb, offset)) > 0)
	    UNDECODED(left);
}

static void
dissect_x11_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
		  x11_conv_data_t *volatile state, gboolean little_endian)
{
	int offset = 0, *offsetp = &offset, left;
	unsigned char eventcode;
	proto_item *ti;
	proto_tree *t;

	ti = proto_tree_add_item(tree, proto_x11, tvb, 0, -1, FALSE);
	t = proto_item_add_subtree(ti, ett_x11);

	eventcode = tvb_get_guint8(tvb, offset);

	if (check_col(pinfo->cinfo, COL_INFO))
		col_add_fstr(pinfo->cinfo, COL_INFO, "Event: %s",
			  	val_to_str(eventcode, eventcode_vals,
			  	"<Unknown> (%u)"));


	proto_tree_add_uint_format(t, hf_x11_eventcode, tvb, offset, 1,
				   eventcode, 
				   "eventcode: %d (%s)",
				   eventcode, 
				   val_to_str(eventcode, eventcode_vals,
				   "<Unknown>"));
	++offset;

	switch (eventcode) {
		case KeyPress:
		case KeyRelease: {
			int code, mask;

			/* need to do some prefetching here ... */
			code = VALUE8(tvb, offset);
			mask = VALUE16(tvb, 28);

			KEYCODE_DECODED(keycode, code, mask);
			CARD16(event_sequencenumber);
			EVENTCONTENTS_COMMON();
			BOOL(same_screen);
			UNUSED(1);
			break;
		}

		case ButtonPress:
		case ButtonRelease:
			BUTTON(eventbutton);
			CARD16(event_sequencenumber);
			EVENTCONTENTS_COMMON();
			BOOL(same_screen);
			UNUSED(1);
			break;

		case MotionNotify:
			CARD8(detail);
			CARD16(event_sequencenumber);
			EVENTCONTENTS_COMMON();
			BOOL(same_screen);
			UNUSED(1);
			break;

		case EnterNotify:
		case LeaveNotify:
			CARD8(detail);
			CARD16(event_sequencenumber);
			EVENTCONTENTS_COMMON();
			CARD8(same_screen);
			break;

		case FocusIn:
		case FocusOut:
		case KeymapNotify:
		case Expose:
		case GraphicsExpose:
		case NoExpose:
		case VisibilityNotify:
		case CreateNotify:
		case DestroyNotify:
		case UnmapNotify:
		case MapNotify:
		case MapRequest:
		case ReparentNotify:
		case ConfigureNotify:
		case ConfigureRequest:
		case GravityNotify:
		case ResizeRequest:
		case CirculateNotify:
		case CirculateRequest:
		case PropertyNotify:
		case SelectionClear:
		case SelectionRequest:
		case SelectionNotify:
		case ColormapNotify:
		case ClientMessage:
		case MappingNotify:
		default:
	}

      	if ((left = tvb_reported_length_remaining(tvb, offset)) > 0) 
	    UNDECODED(left);

	return;
}

static void
dissect_x11_error(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
		  x11_conv_data_t *volatile state, gboolean little_endian)
{
	int offset = 0, *offsetp = &offset, left;
	unsigned char errorcode, error;
	proto_item *ti;
	proto_tree *t;

	ti = proto_tree_add_item(tree, proto_x11, tvb, 0, -1, FALSE);
	t = proto_item_add_subtree(ti, ett_x11);

	error = tvb_get_guint8(tvb, offset);
	CARD8(error);

	errorcode = tvb_get_guint8(tvb, offset);
	if (check_col(pinfo->cinfo, COL_INFO))
		col_add_fstr(pinfo->cinfo, COL_INFO, "Error: %s",
	  	val_to_str(errorcode, errorcode_vals, "<Unknown>"));

	proto_tree_add_uint_format(t, hf_x11_errorcode, tvb, offset, 1,
				   errorcode, 
				   "errorcode: %d (%s)",
				   errorcode, 
				   val_to_str(errorcode, errorcode_vals,
				   "<Unknown>"));
	++offset;

	CARD16(error_sequencenumber);

	switch (errorcode) {
		case BadValue:
			CARD32(error_badvalue);
			break;

		default:
			UNDECODED(4);
	}

	CARD16(minor_opcode);
	CARD8(major_opcode);

      	if (left = tvb_reported_length_remaining(tvb, offset)) 
	    UNDECODED(left);
}

			

/************************************************************************
 ***                                                                  ***
 ***         I N I T I A L I Z A T I O N   A N D   M A I N            ***
 ***                                                                  ***
 ************************************************************************/

static void
dissect_x11(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
      if (check_col(pinfo->cinfo, COL_PROTOCOL))
	    col_set_str(pinfo->cinfo, COL_PROTOCOL, "X11");

      if (pinfo->match_port == pinfo->srcport)
	    dissect_x11_replies(tvb, pinfo, tree);
      else
	    dissect_x11_requests(tvb, pinfo, tree);
}

/* Register the protocol with Ethereal */
void proto_register_x11(void)
{

/* Setup list of header fields */
      static hf_register_info hf[] = {
/*
  { &hf_x11_FIELDABBREV,
  { "FIELDNAME",           "x11.FIELDABBREV",
  FIELDTYPE, FIELDBASE, FIELDCONVERT, BITMASK,
  "FIELDDESCR", HFILL }
  },
*/
#include "x11-register-info.h"
      };

/* Setup protocol subtree array */
      static gint *ett[] = {
	    &ett_x11,
	    &ett_x11_color_flags,
	    &ett_x11_list_of_arc,
	    &ett_x11_arc,
	    &ett_x11_list_of_atom,
	    &ett_x11_list_of_card32,
	    &ett_x11_list_of_color_item,
	    &ett_x11_color_item,
	    &ett_x11_list_of_keycode,
	    &ett_x11_list_of_keysyms,
	    &ett_x11_keysym,
	    &ett_x11_list_of_point,
	    &ett_x11_point,
	    &ett_x11_list_of_rectangle,
	    &ett_x11_rectangle,
	    &ett_x11_list_of_segment,
	    &ett_x11_segment,
	    &ett_x11_list_of_string8,
	    &ett_x11_list_of_text_item,
	    &ett_x11_text_item,
	    &ett_x11_gc_value_mask,
	    &ett_x11_event_mask,
	    &ett_x11_do_not_propagate_mask,
	    &ett_x11_set_of_key_mask,
	    &ett_x11_pointer_event_mask,
	    &ett_x11_window_value_mask,
	    &ett_x11_configure_window_mask,
	    &ett_x11_keyboard_value_mask,
      };
      module_t *x11_module;

/* Register the protocol name and description */
      proto_x11 = proto_register_protocol("X11", "X11", "x11");

/* Required function calls to register the header fields and subtrees used */
      proto_register_field_array(proto_x11, hf, array_length(hf));
      proto_register_subtree_array(ett, array_length(ett));

      register_init_routine(x11_init_protocol);

      x11_module = prefs_register_protocol(proto_x11, NULL);
      prefs_register_bool_preference(x11_module, "desegment",
	    "Desegment all X11 messages spanning multiple TCP segments",
	    "Whether the X11 dissector should desegment all messages spanning multiple TCP segments",
	    &x11_desegment);
}

void
proto_reg_handoff_x11(void)
{
  dissector_handle_t x11_handle;

  x11_handle = create_dissector_handle(dissect_x11, proto_x11);
  dissector_add("tcp.port", TCP_PORT_X11, x11_handle);
  dissector_add("tcp.port", TCP_PORT_X11_2, x11_handle);
  dissector_add("tcp.port", TCP_PORT_X11_3, x11_handle);
  data_handle = find_dissector("data");
}

/* Requestcodes.  From <X11/Xproto.h>. */
#define X_CreateWindow                  1              
#define X_ChangeWindowAttributes        2        
#define X_GetWindowAttributes           3     
#define X_DestroyWindow                 4
#define X_DestroySubwindows             5   
#define X_ChangeSaveSet                 6
#define X_ReparentWindow                7
#define X_MapWindow                     8
#define X_MapSubwindows                 9
#define X_UnmapWindow                  10
#define X_UnmapSubwindows              11  
#define X_ConfigureWindow              12  
#define X_CirculateWindow              13  
#define X_GetGeometry                  14
#define X_QueryTree                    15
#define X_InternAtom                   16
#define X_GetAtomName                  17
#define X_ChangeProperty               18 
#define X_DeleteProperty               19 
#define X_GetProperty                  20
#define X_ListProperties               21 
#define X_SetSelectionOwner            22    
#define X_GetSelectionOwner            23    
#define X_ConvertSelection             24   
#define X_SendEvent                    25
#define X_GrabPointer                  26
#define X_UngrabPointer                27
#define X_GrabButton                   28
#define X_UngrabButton                 29
#define X_ChangeActivePointerGrab      30          
#define X_GrabKeyboard                 31
#define X_UngrabKeyboard               32 
#define X_GrabKey                      33
#define X_UngrabKey                    34
#define X_AllowEvents                  35       
#define X_GrabServer                   36      
#define X_UngrabServer                 37        
#define X_QueryPointer                 38        
#define X_GetMotionEvents              39           
#define X_TranslateCoords              40                
#define X_WarpPointer                  41       
#define X_SetInputFocus                42         
#define X_GetInputFocus                43         
#define X_QueryKeymap                  44       
#define X_OpenFont                     45    
#define X_CloseFont                    46     
#define X_QueryFont                    47
#define X_QueryTextExtents             48     
#define X_ListFonts                    49  
#define X_ListFontsWithInfo    	       50 
#define X_SetFontPath                  51 
#define X_GetFontPath                  52 
#define X_CreatePixmap                 53        
#define X_FreePixmap                   54      
#define X_CreateGC                     55    
#define X_ChangeGC                     56    
#define X_CopyGC                       57  
#define X_SetDashes                    58     
#define X_SetClipRectangles            59             
#define X_FreeGC                       60  
#define X_ClearArea                    61             
#define X_CopyArea                     62    
#define X_CopyPlane                    63     
#define X_PolyPoint                    64     
#define X_PolyLine                     65    
#define X_PolySegment                  66       
#define X_PolyRectangle                67         
#define X_PolyArc                      68   
#define X_FillPoly                     69    
#define X_PolyFillRectangle            70             
#define X_PolyFillArc                  71       
#define X_PutImage                     72    
#define X_GetImage                     73 
#define X_PolyText8                    74     
#define X_PolyText16                   75      
#define X_ImageText8                   76      
#define X_ImageText16                  77       
#define X_CreateColormap               78          
#define X_FreeColormap                 79        
#define X_CopyColormapAndFree          80               
#define X_InstallColormap              81           
#define X_UninstallColormap            82             
#define X_ListInstalledColormaps       83                  
#define X_AllocColor                   84      
#define X_AllocNamedColor              85           
#define X_AllocColorCells              86           
#define X_AllocColorPlanes             87            
#define X_FreeColors                   88      
#define X_StoreColors                  89       
#define X_StoreNamedColor              90           
#define X_QueryColors                  91       
#define X_LookupColor                  92       
#define X_CreateCursor                 93        
#define X_CreateGlyphCursor            94             
#define X_FreeCursor                   95      
#define X_RecolorCursor                96         
#define X_QueryBestSize                97         
#define X_QueryExtension               98          
#define X_ListExtensions               99          
#define X_ChangeKeyboardMapping        100
#define X_GetKeyboardMapping           101
#define X_ChangeKeyboardControl        102                
#define X_GetKeyboardControl           103             
#define X_Bell                         104
#define X_ChangePointerControl         105
#define X_GetPointerControl            106
#define X_SetScreenSaver               107          
#define X_GetScreenSaver               108          
#define X_ChangeHosts                  109       
#define X_ListHosts                    110     
#define X_SetAccessControl             111               
#define X_SetCloseDownMode             112
#define X_KillClient                   113 
#define X_RotateProperties	       114
#define X_ForceScreenSaver	       115
#define X_SetPointerMapping            116
#define X_GetPointerMapping            117
#define X_SetModifierMapping	       118
#define X_GetModifierMapping	       119
#define X_NoOperation                  127

/* Eventscodes.  From <X11/X.h>. */
#define KeyPress		2
#define KeyRelease		3
#define ButtonPress		4
#define ButtonRelease		5
#define MotionNotify		6
#define EnterNotify		7
#define LeaveNotify		8
#define FocusIn			9
#define FocusOut		10
#define KeymapNotify		11
#define Expose			12
#define GraphicsExpose		13
#define NoExpose		14
#define VisibilityNotify	15
#define CreateNotify		16
#define DestroyNotify		17
#define UnmapNotify		18
#define MapNotify		19
#define MapRequest		20
#define ReparentNotify		21
#define ConfigureNotify		22
#define ConfigureRequest	23
#define GravityNotify		24
#define ResizeRequest		25
#define CirculateNotify		26
#define CirculateRequest	27
#define PropertyNotify		28
#define SelectionClear		29
#define SelectionRequest	30
#define SelectionNotify		31
#define ColormapNotify		32
#define ClientMessage		33
#define MappingNotify		34

/* Errorcodes.  From <X11/X.h> */
#define Success		   	0	/* everything's okay */
#define BadRequest	   	1	/* bad request code */
#define BadValue	   	2	/* int parameter out of range */
#define BadWindow	   	3	/* parameter not a Window */
#define BadPixmap	   	4	/* parameter not a Pixmap */
#define BadAtom		   	5	/* parameter not an Atom */
#define BadCursor	   	6	/* parameter not a Cursor */
#define BadFont		   	7	/* parameter not a Font */
#define BadMatch	   	8	/* parameter mismatch */
#define BadDrawable	   	9	/* parameter not a Pixmap or Window */
#define BadAccess	  	10	/* depending on context:
					 - key/button already grabbed
					 - attempt to free an illegal 
					   cmap entry 
					- attempt to store into a read-only 
					   color map entry.
 					- attempt to modify the access control
					   list from other than the local host.
					*/
#define BadAlloc	  	11	/* insufficient resources */
#define BadColor	  	12	/* no such colormap */
#define BadGC		  	13	/* parameter not a GC */
#define BadIDChoice	  	14	/* choice not in range or already used */
#define BadName		  	15	/* font or color name doesn't exist */
#define BadLength	  	16	/* Request length incorrect */
#define BadImplementation 	17	/* server is defective */

#define FirstExtensionError	128
#define LastExtensionError	255



/* Keymasks.  From <X11/X.h>. */
#define ShiftMask		(1<<0)
#define LockMask		(1<<1)
#define ControlMask		(1<<2)
#define Mod1Mask		(1<<3)
#define Mod2Mask		(1<<4)
#define Mod3Mask		(1<<5)
#define Mod4Mask		(1<<6)
#define Mod5Mask		(1<<7)

/* from <X11/X.h> */
#define NoSymbol             0L /* special KeySym */

static int hf_x11_acceleration_denominator = -1;
static int hf_x11_acceleration_numerator = -1;
static int hf_x11_access_mode = -1;
static int hf_x11_address = -1;
static int hf_x11_address_length = -1;
static int hf_x11_alloc = -1;
static int hf_x11_allow_events_mode = -1;
static int hf_x11_allow_exposures = -1;
static int hf_x11_arc = -1;
static int hf_x11_arc_angle1 = -1;
static int hf_x11_arc_angle2 = -1;
static int hf_x11_arc_height = -1;
static int hf_x11_arc_mode = -1;
static int hf_x11_arc_width = -1;
static int hf_x11_arc_x = -1;
static int hf_x11_arc_y = -1;
static int hf_x11_arcs = -1;
static int hf_x11_atom = -1;
static int hf_x11_authorization_protocol_data = -1;
static int hf_x11_authorization_protocol_data_length = -1;
static int hf_x11_authorization_protocol_name = -1;
static int hf_x11_authorization_protocol_name_length = -1;
static int hf_x11_auto_repeat_mode = -1;
static int hf_x11_back_blue = -1;
static int hf_x11_back_green = -1;
static int hf_x11_back_red = -1;
static int hf_x11_background = -1;
static int hf_x11_background_pixel = -1;
static int hf_x11_background_pixmap = -1;
static int hf_x11_backing_pixel = -1;
static int hf_x11_backing_planes = -1;
static int hf_x11_backing_store = -1;
static int hf_x11_bell_duration = -1;
static int hf_x11_bell_percent = -1;
static int hf_x11_bell_pitch = -1;
static int hf_x11_bit_gravity = -1;
static int hf_x11_bit_plane = -1;
static int hf_x11_blue = -1;
static int hf_x11_blues = -1;
static int hf_x11_border_pixel = -1;
static int hf_x11_border_pixmap = -1;
static int hf_x11_border_width = -1;
static int hf_x11_button = -1;
static int hf_x11_byte_order = -1;
static int hf_x11_cap_style = -1;
static int hf_x11_change_host_mode = -1;
static int hf_x11_childwindow = -1;
static int hf_x11_cid = -1;
static int hf_x11_class = -1;
static int hf_x11_clip_mask = -1;
static int hf_x11_clip_x_origin = -1;
static int hf_x11_clip_y_origin = -1;
static int hf_x11_close_down_mode = -1;
static int hf_x11_cmap = -1;
static int hf_x11_color_items = -1;
static int hf_x11_coloritem = -1;
static int hf_x11_coloritem_blue = -1;
static int hf_x11_coloritem_flags = -1;
static int hf_x11_coloritem_flags_do_blue = -1;
static int hf_x11_coloritem_flags_do_green = -1;
static int hf_x11_coloritem_flags_do_red = -1;
static int hf_x11_coloritem_flags_unused = -1;
static int hf_x11_coloritem_green = -1;
static int hf_x11_coloritem_pixel = -1;
static int hf_x11_coloritem_red = -1;
static int hf_x11_coloritem_unused = -1;
static int hf_x11_colormap = -1;
static int hf_x11_colors = -1;
static int hf_x11_configure_window_mask = -1;
static int hf_x11_configure_window_mask_border_width = -1;
static int hf_x11_configure_window_mask_height = -1;
static int hf_x11_configure_window_mask_sibling = -1;
static int hf_x11_configure_window_mask_stack_mode = -1;
static int hf_x11_configure_window_mask_width = -1;
static int hf_x11_configure_window_mask_x = -1;
static int hf_x11_configure_window_mask_y = -1;
static int hf_x11_confine_to = -1;
static int hf_x11_contiguous = -1;
static int hf_x11_coordinate_mode = -1;
static int hf_x11_count = -1;
static int hf_x11_cursor = -1;
static int hf_x11_dash_offset = -1;
static int hf_x11_dashes = -1;
static int hf_x11_dashes_length = -1;
static int hf_x11_data = -1;
static int hf_x11_data_length = -1;
static int hf_x11_delete = -1;
static int hf_x11_delta = -1;
static int hf_x11_depth = -1;
static int hf_x11_detail = -1;
static int hf_x11_direction = -1;
static int hf_x11_do_acceleration = -1;
static int hf_x11_do_not_propagate_mask = -1;
static int hf_x11_do_not_propagate_mask_Button1Motion = -1;
static int hf_x11_do_not_propagate_mask_Button2Motion = -1;
static int hf_x11_do_not_propagate_mask_Button3Motion = -1;
static int hf_x11_do_not_propagate_mask_Button4Motion = -1;
static int hf_x11_do_not_propagate_mask_Button5Motion = -1;
static int hf_x11_do_not_propagate_mask_ButtonMotion = -1;
static int hf_x11_do_not_propagate_mask_ButtonPress = -1;
static int hf_x11_do_not_propagate_mask_ButtonRelease = -1;
static int hf_x11_do_not_propagate_mask_KeyPress = -1;
static int hf_x11_do_not_propagate_mask_KeyRelease = -1;
static int hf_x11_do_not_propagate_mask_PointerMotion = -1;
static int hf_x11_do_not_propagate_mask_erroneous_bits = -1;
static int hf_x11_do_threshold = -1;
static int hf_x11_drawable = -1;
static int hf_x11_dst_drawable = -1;
static int hf_x11_dst_gc = -1;
static int hf_x11_dst_window = -1;
static int hf_x11_dst_x = -1;
static int hf_x11_dst_y = -1;
static int hf_x11_error_sequencenumber = -1;
static int hf_x11_errorcode = -1;
static int hf_x11_event_mask = -1;
static int hf_x11_event_mask_Button1Motion = -1;
static int hf_x11_event_mask_Button2Motion = -1;
static int hf_x11_event_mask_Button3Motion = -1;
static int hf_x11_event_mask_Button4Motion = -1;
static int hf_x11_event_mask_Button5Motion = -1;
static int hf_x11_event_mask_ButtonMotion = -1;
static int hf_x11_event_mask_ButtonPress = -1;
static int hf_x11_event_mask_ButtonRelease = -1;
static int hf_x11_event_mask_ColormapChange = -1;
static int hf_x11_event_mask_EnterWindow = -1;
static int hf_x11_event_mask_Exposure = -1;
static int hf_x11_event_mask_FocusChange = -1;
static int hf_x11_event_mask_KeyPress = -1;
static int hf_x11_event_mask_KeyRelease = -1;
static int hf_x11_event_mask_KeymapState = -1;
static int hf_x11_event_mask_LeaveWindow = -1;
static int hf_x11_event_mask_OwnerGrabButton = -1;
static int hf_x11_event_mask_PointerMotion = -1;
static int hf_x11_event_mask_PointerMotionHint = -1;
static int hf_x11_event_mask_PropertyChange = -1;
static int hf_x11_event_mask_ResizeRedirect = -1;
static int hf_x11_event_mask_StructureNotify = -1;
static int hf_x11_event_mask_SubstructureNotify = -1;
static int hf_x11_event_mask_SubstructureRedirect = -1;
static int hf_x11_event_mask_VisibilityChange = -1;
static int hf_x11_event_mask_erroneous_bits = -1;
static int hf_x11_event_sequencenumber = -1;
static int hf_x11_event_x = -1;
static int hf_x11_event_y = -1;
static int hf_x11_eventbutton = -1;
static int hf_x11_eventcode = -1;
static int hf_x11_eventwindow = -1;
static int hf_x11_exposures = -1;
static int hf_x11_family = -1;
static int hf_x11_fid = -1;
static int hf_x11_fill_rule = -1;
static int hf_x11_fill_style = -1;
static int hf_x11_first_keycode = -1;
static int hf_x11_focus = -1;
static int hf_x11_font = -1;
static int hf_x11_fore_blue = -1;
static int hf_x11_fore_green = -1;
static int hf_x11_fore_red = -1;
static int hf_x11_foreground = -1;
static int hf_x11_format = -1;
static int hf_x11_function = -1;
static int hf_x11_gc = -1;
static int hf_x11_gc_dashes = -1;
static int hf_x11_gc_value_mask = -1;
static int hf_x11_gc_value_mask_arc_mode = -1;
static int hf_x11_gc_value_mask_background = -1;
static int hf_x11_gc_value_mask_cap_style = -1;
static int hf_x11_gc_value_mask_clip_mask = -1;
static int hf_x11_gc_value_mask_clip_x_origin = -1;
static int hf_x11_gc_value_mask_clip_y_origin = -1;
static int hf_x11_gc_value_mask_dash_offset = -1;
static int hf_x11_gc_value_mask_fill_rule = -1;
static int hf_x11_gc_value_mask_fill_style = -1;
static int hf_x11_gc_value_mask_font = -1;
static int hf_x11_gc_value_mask_foreground = -1;
static int hf_x11_gc_value_mask_function = -1;
static int hf_x11_gc_value_mask_gc_dashes = -1;
static int hf_x11_gc_value_mask_graphics_exposures = -1;
static int hf_x11_gc_value_mask_join_style = -1;
static int hf_x11_gc_value_mask_line_style = -1;
static int hf_x11_gc_value_mask_line_width = -1;
static int hf_x11_gc_value_mask_plane_mask = -1;
static int hf_x11_gc_value_mask_stipple = -1;
static int hf_x11_gc_value_mask_subwindow_mode = -1;
static int hf_x11_gc_value_mask_tile = -1;
static int hf_x11_gc_value_mask_tile_stipple_x_origin = -1;
static int hf_x11_gc_value_mask_tile_stipple_y_origin = -1;
static int hf_x11_get_property_type = -1;
static int hf_x11_grab_window = -1;
static int hf_x11_graphics_exposures = -1;
static int hf_x11_green = -1;
static int hf_x11_greens = -1;
static int hf_x11_height = -1;
static int hf_x11_image_format = -1;
static int hf_x11_image_pixmap_format = -1;
static int hf_x11_initial_connection = -1;
static int hf_x11_interval = -1;
static int hf_x11_ip_address = -1;
static int hf_x11_items = -1;
static int hf_x11_join_style = -1;
static int hf_x11_key = -1;
static int hf_x11_key_click_percent = -1;
static int hf_x11_keyboard_key = -1;
static int hf_x11_keyboard_mode = -1;
static int hf_x11_keyboard_value_mask = -1;
static int hf_x11_keyboard_value_mask_auto_repeat_mode = -1;
static int hf_x11_keyboard_value_mask_bell_duration = -1;
static int hf_x11_keyboard_value_mask_bell_percent = -1;
static int hf_x11_keyboard_value_mask_bell_pitch = -1;
static int hf_x11_keyboard_value_mask_key_click_percent = -1;
static int hf_x11_keyboard_value_mask_keyboard_key = -1;
static int hf_x11_keyboard_value_mask_led = -1;
static int hf_x11_keyboard_value_mask_led_mode = -1;
static int hf_x11_keybut_mask_erroneous_bits = -1;
static int hf_x11_keycode = -1;
static int hf_x11_keycode_count = -1;
static int hf_x11_keycodes = -1;
static int hf_x11_keycodes_item = -1;
static int hf_x11_keycodes_per_modifier = -1;
static int hf_x11_keysyms = -1;
static int hf_x11_keysyms_item = -1;
static int hf_x11_keysyms_item_keysym = -1;
static int hf_x11_keysyms_per_keycode = -1;
static int hf_x11_led = -1;
static int hf_x11_led_mode = -1;
static int hf_x11_left_pad = -1;
static int hf_x11_line_style = -1;
static int hf_x11_line_width = -1;
static int hf_x11_long_length = -1;
static int hf_x11_long_offset = -1;
static int hf_x11_major_opcode = -1;
static int hf_x11_map = -1;
static int hf_x11_map_length = -1;
static int hf_x11_mask = -1;
static int hf_x11_mask_char = -1;
static int hf_x11_mask_font = -1;
static int hf_x11_max_names = -1;
static int hf_x11_mid = -1;
static int hf_x11_minor_opcode = -1;
static int hf_x11_mode = -1;
static int hf_x11_modifiers_mask = -1;
static int hf_x11_modifiers_mask_AnyModifier = -1;
static int hf_x11_modifiers_mask_Button1 = -1;
static int hf_x11_modifiers_mask_Button2 = -1;
static int hf_x11_modifiers_mask_Button3 = -1;
static int hf_x11_modifiers_mask_Button4 = -1;
static int hf_x11_modifiers_mask_Button5 = -1;
static int hf_x11_modifiers_mask_Control = -1;
static int hf_x11_modifiers_mask_Lock = -1;
static int hf_x11_modifiers_mask_Mod1 = -1;
static int hf_x11_modifiers_mask_Mod2 = -1;
static int hf_x11_modifiers_mask_Mod3 = -1;
static int hf_x11_modifiers_mask_Mod4 = -1;
static int hf_x11_modifiers_mask_Mod5 = -1;
static int hf_x11_modifiers_mask_Shift = -1;
static int hf_x11_modifiers_mask_erroneous_bits = -1;
static int hf_x11_name = -1;
static int hf_x11_name_length = -1;
static int hf_x11_odd_length = -1;
static int hf_x11_only_if_exists = -1;
static int hf_x11_opcode = -1;
static int hf_x11_ordering = -1;
static int hf_x11_override_redirect = -1;
static int hf_x11_owner = -1;
static int hf_x11_owner_events = -1;
static int hf_x11_parent = -1;
static int hf_x11_path = -1;
static int hf_x11_path_string = -1;
static int hf_x11_pattern = -1;
static int hf_x11_pattern_length = -1;
static int hf_x11_percent = -1;
static int hf_x11_pid = -1;
static int hf_x11_pixel = -1;
static int hf_x11_pixels = -1;
static int hf_x11_pixels_item = -1;
static int hf_x11_pixmap = -1;
static int hf_x11_plane_mask = -1;
static int hf_x11_planes = -1;
static int hf_x11_point = -1;
static int hf_x11_point_x = -1;
static int hf_x11_point_y = -1;
static int hf_x11_pointer_event_mask = -1;
static int hf_x11_pointer_event_mask_Button1Motion = -1;
static int hf_x11_pointer_event_mask_Button2Motion = -1;
static int hf_x11_pointer_event_mask_Button3Motion = -1;
static int hf_x11_pointer_event_mask_Button4Motion = -1;
static int hf_x11_pointer_event_mask_Button5Motion = -1;
static int hf_x11_pointer_event_mask_ButtonMotion = -1;
static int hf_x11_pointer_event_mask_ButtonPress = -1;
static int hf_x11_pointer_event_mask_ButtonRelease = -1;
static int hf_x11_pointer_event_mask_EnterWindow = -1;
static int hf_x11_pointer_event_mask_KeymapState = -1;
static int hf_x11_pointer_event_mask_LeaveWindow = -1;
static int hf_x11_pointer_event_mask_PointerMotion = -1;
static int hf_x11_pointer_event_mask_PointerMotionHint = -1;
static int hf_x11_pointer_event_mask_erroneous_bits = -1;
static int hf_x11_pointer_mode = -1;
static int hf_x11_points = -1;
static int hf_x11_prefer_blanking = -1;
static int hf_x11_properties = -1;
static int hf_x11_properties_item = -1;
static int hf_x11_property = -1;
static int hf_x11_property_number = -1;
static int hf_x11_protocol_major_version = -1;
static int hf_x11_protocol_minor_version = -1;
static int hf_x11_rectangle = -1;
static int hf_x11_rectangle_height = -1;
static int hf_x11_rectangle_width = -1;
static int hf_x11_rectangle_x = -1;
static int hf_x11_rectangle_y = -1;
static int hf_x11_rectangles = -1;
static int hf_x11_red = -1;
static int hf_x11_reds = -1;
static int hf_x11_reply = -1;
static int hf_x11_reply_sequencenumber = -1;
static int hf_x11_bytes_after = -1;
static int hf_x11_value_length = -1;
static int hf_x11_replylength = -1;
static int hf_x11_replyopcode = -1;
static int hf_x11_request = -1;
static int hf_x11_request_length = -1;
static int hf_x11_requestor = -1;
static int hf_x11_resource = -1;
static int hf_x11_revert_to = -1;
static int hf_x11_root_x = -1;
static int hf_x11_root_y = -1;
static int hf_x11_rootwindow = -1;
static int hf_x11_same_screen = -1;
static int hf_x11_save_set_mode = -1;
static int hf_x11_save_under = -1;
static int hf_x11_screen_saver_mode = -1;
static int hf_x11_segment = -1;
static int hf_x11_segment_x1 = -1;
static int hf_x11_segment_x2 = -1;
static int hf_x11_segment_y1 = -1;
static int hf_x11_segment_y2 = -1;
static int hf_x11_segments = -1;
static int hf_x11_selection = -1;
static int hf_x11_shape = -1;
static int hf_x11_sibling = -1;
static int hf_x11_source_char = -1;
static int hf_x11_source_font = -1;
static int hf_x11_source_pixmap = -1;
static int hf_x11_src_cmap = -1;
static int hf_x11_src_drawable = -1;
static int hf_x11_src_gc = -1;
static int hf_x11_src_height = -1;
static int hf_x11_src_width = -1;
static int hf_x11_src_window = -1;
static int hf_x11_src_x = -1;
static int hf_x11_src_y = -1;
static int hf_x11_stack_mode = -1;
static int hf_x11_start = -1;
static int hf_x11_stipple = -1;
static int hf_x11_stop = -1;
static int hf_x11_str_number_in_path = -1;
static int hf_x11_string = -1;
static int hf_x11_string16 = -1;
static int hf_x11_string16_bytes = -1;
static int hf_x11_string_length = -1;
static int hf_x11_subwindow_mode = -1;
static int hf_x11_target = -1;
static int hf_x11_textitem = -1;
static int hf_x11_textitem_font = -1;
static int hf_x11_textitem_string = -1;
static int hf_x11_textitem_string_delta = -1;
static int hf_x11_textitem_string_string16 = -1;
static int hf_x11_textitem_string_string16_bytes = -1;
static int hf_x11_textitem_string_string8 = -1;
static int hf_x11_threshold = -1;
static int hf_x11_tile = -1;
static int hf_x11_tile_stipple_x_origin = -1;
static int hf_x11_tile_stipple_y_origin = -1;
static int hf_x11_time = -1;
static int hf_x11_timeout = -1;
static int hf_x11_type = -1;
static int hf_x11_undecoded = -1;
static int hf_x11_unused = -1;
static int hf_x11_visual = -1;
static int hf_x11_visualid = -1;
static int hf_x11_warp_pointer_dst_window = -1;
static int hf_x11_warp_pointer_src_window = -1;
static int hf_x11_wid = -1;
static int hf_x11_width = -1;
static int hf_x11_win_gravity = -1;
static int hf_x11_window = -1;
static int hf_x11_window_class = -1;
static int hf_x11_window_value_mask = -1;
static int hf_x11_window_value_mask_background_pixel = -1;
static int hf_x11_window_value_mask_background_pixmap = -1;
static int hf_x11_window_value_mask_backing_pixel = -1;
static int hf_x11_window_value_mask_backing_planes = -1;
static int hf_x11_window_value_mask_backing_store = -1;
static int hf_x11_window_value_mask_bit_gravity = -1;
static int hf_x11_window_value_mask_border_pixel = -1;
static int hf_x11_window_value_mask_border_pixmap = -1;
static int hf_x11_window_value_mask_colormap = -1;
static int hf_x11_window_value_mask_cursor = -1;
static int hf_x11_window_value_mask_do_not_propagate_mask = -1;
static int hf_x11_window_value_mask_event_mask = -1;
static int hf_x11_window_value_mask_override_redirect = -1;
static int hf_x11_window_value_mask_save_under = -1;
static int hf_x11_window_value_mask_win_gravity = -1;
static int hf_x11_x = -1;
static int hf_x11_y = -1;
static int hf_x11_error_badvalue = -1;
static int hf_x11_error = -1;
static int hf_x11_success = -1;
static int hf_x11_release_number = -1;
static int hf_x11_resource_id_base = -1;
static int hf_x11_resource_id_mask = -1;
static int hf_x11_motion_buffer_size = -1;
static int hf_x11_length_of_vendor = -1;
static int hf_x11_maximum_request_length = -1;
static int hf_x11_number_of_screens_in_roots = -1;
static int hf_x11_number_of_formats_in_pixmap_formats = -1;
static int hf_x11_image_byte_order = -1;
static int hf_x11_bitmap_format_bit_order = -1;
static int hf_x11_bitmap_format_scanline_unit = -1;
static int hf_x11_bitmap_format_scanline_pad = -1;
static int hf_x11_min_keycode = -1;
static int hf_x11_max_keycode = -1;
static int hf_x11_vendor = -1;
{ &hf_x11_acceleration_denominator, { "acceleration-denominator", "x11.acceleration-denominator", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_acceleration_numerator, { "acceleration-numerator", "x11.acceleration-numerator", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_access_mode, { "access-mode", "x11.access-mode", FT_UINT8, BASE_DEC, VALS(access_mode_vals), 0, "", HFILL }},
{ &hf_x11_address, { "address", "x11.address", FT_BYTES, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_address_length, { "address-length", "x11.address-length", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_alloc, { "alloc", "x11.alloc", FT_UINT8, BASE_DEC, VALS(alloc_vals), 0, "", HFILL }},
{ &hf_x11_allow_events_mode, { "allow-events-mode", "x11.allow-events-mode", FT_UINT8, BASE_DEC, VALS(allow_events_mode_vals), 0, "", HFILL }},
{ &hf_x11_allow_exposures, { "allow-exposures", "x11.allow-exposures", FT_UINT8, BASE_DEC, VALS(yes_no_default_vals), 0, "", HFILL }},
{ &hf_x11_arc, { "arc", "x11.arc", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_arc_angle1, { "angle1", "x11.arc.angle1", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_arc_angle2, { "angle2", "x11.arc.angle2", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_arc_height, { "height", "x11.arc.height", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_arc_mode, { "arc-mode", "x11.arc-mode", FT_UINT8, BASE_DEC, VALS(arc_mode_vals), 0, "Tell us if we're drawing an arc or a pie", HFILL }},
{ &hf_x11_arc_width, { "width", "x11.arc.width", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_arc_x, { "x", "x11.arc.x", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_arc_y, { "y", "x11.arc.y", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_arcs, { "arcs", "x11.arcs", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_atom, { "atom", "x11.atom", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_authorization_protocol_data, { "authorization-protocol-data", "x11.authorization-protocol-data", FT_STRING, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_authorization_protocol_data_length, { "authorization-protocol-data-length", "x11.authorization-protocol-data-length", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_authorization_protocol_name, { "authorization-protocol-name", "x11.authorization-protocol-name", FT_STRING, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_authorization_protocol_name_length, { "authorization-protocol-name-length", "x11.authorization-protocol-name-length", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_auto_repeat_mode, { "auto-repeat-mode", "x11.auto-repeat-mode", FT_UINT8, BASE_DEC, VALS(auto_repeat_mode_vals), 0, "", HFILL }},
{ &hf_x11_back_blue, { "back-blue", "x11.back-blue", FT_UINT16, BASE_DEC, NULL, 0, "Background blue value for a cursor", HFILL }},
{ &hf_x11_back_green, { "back-green", "x11.back-green", FT_UINT16, BASE_DEC, NULL, 0, "Background green value for a cursor", HFILL }},
{ &hf_x11_back_red, { "back-red", "x11.back-red", FT_UINT16, BASE_DEC, NULL, 0, "Background red value for a cursor", HFILL }},
{ &hf_x11_background, { "background", "x11.background", FT_UINT32, BASE_HEX, NULL, 0, "Background color", HFILL }},
{ &hf_x11_background_pixel, { "background-pixel", "x11.background-pixel", FT_UINT32, BASE_HEX, NULL, 0, "Background color for a window", HFILL }},
{ &hf_x11_background_pixmap, { "background-pixmap", "x11.background-pixmap", FT_UINT32, BASE_HEX, VALS(background_pixmap_vals), 0, "Background pixmap for a window", HFILL }},
{ &hf_x11_backing_pixel, { "backing-pixel", "x11.backing-pixel", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_backing_planes, { "backing-planes", "x11.backing-planes", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_backing_store, { "backing-store", "x11.backing-store", FT_UINT8, BASE_DEC, VALS(backing_store_vals), 0, "", HFILL }},
{ &hf_x11_bell_duration, { "bell-duration", "x11.bell-duration", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_bell_percent, { "bell-percent", "x11.bell-percent", FT_INT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_bell_pitch, { "bell-pitch", "x11.bell-pitch", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_bit_gravity, { "bit-gravity", "x11.bit-gravity", FT_UINT8, BASE_DEC, VALS(gravity_vals), 0, "", HFILL }},
{ &hf_x11_bit_plane, { "bit-plane", "x11.bit-plane", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_bitmap_format_bit_order, { "bitmap_format_bit_order", "x11.bitmap_format_bit_order", FT_UINT8, BASE_HEX, VALS(image_byte_order_vals), 0, "", HFILL }},
{ &hf_x11_bitmap_format_scanline_pad, { "bitmap_format_scanline_pad", "x11.bitmap_format_scanline_pad", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_bitmap_format_scanline_unit, { "bitmap_format_scanline_unit", "x11.bitmap_format_scanline_unit", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_blue, { "blue", "x11.blue", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_blues, { "blues", "x11.blues", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_border_pixel, { "border-pixel", "x11.border-pixel", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_border_pixmap, { "border-pixmap", "x11.border-pixmap", FT_UINT32, BASE_HEX, VALS(border_pixmap_vals), 0, "", HFILL }},
{ &hf_x11_border_width, { "border-width", "x11.border-width", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_button, { "button", "x11.button", FT_UINT8, BASE_DEC, VALS(button_vals), 0, "", HFILL }},
{ &hf_x11_byte_order, { "byte-order", "x11.byte-order", FT_UINT8, BASE_HEX, VALS(byte_order_vals), 0, "", HFILL }},
{ &hf_x11_bytes_after, { "bytesafter", "x11.bytesafter", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_cap_style, { "cap-style", "x11.cap-style", FT_UINT8, BASE_DEC, VALS(cap_style_vals), 0, "", HFILL }},
{ &hf_x11_change_host_mode, { "change-host-mode", "x11.change-host-mode", FT_UINT8, BASE_DEC, VALS(insert_delete_vals), 0, "", HFILL }},
{ &hf_x11_childwindow, { "childwindow", "x11.event.childwindow", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_cid, { "cid", "x11.cid", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_class, { "class", "x11.class", FT_UINT8, BASE_DEC, VALS(class_vals), 0, "", HFILL }},
{ &hf_x11_clip_mask, { "clip-mask", "x11.clip-mask", FT_UINT32, BASE_HEX, VALS(zero_is_none_vals), 0, "", HFILL }},
{ &hf_x11_clip_x_origin, { "clip-x-origin", "x11.clip-x-origin", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_clip_y_origin, { "clip-y-origin", "x11.clip-y-origin", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_close_down_mode, { "close-down-mode", "x11.close-down-mode", FT_UINT8, BASE_DEC, VALS(close_down_mode_vals), 0, "", HFILL }},
{ &hf_x11_cmap, { "cmap", "x11.cmap", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_color_items, { "color-items", "x11.color-items", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_coloritem, { "coloritem", "x11.coloritem", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_coloritem_blue, { "blue", "x11.coloritem.blue", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_coloritem_flags, { "flags", "x11.coloritem.flags", FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_coloritem_flags_do_blue, { "do-blue", "x11.coloritem.flags.do-blue", FT_BOOLEAN, 8, NULL, 0x04, "", HFILL }},
{ &hf_x11_coloritem_flags_do_green, { "do-green", "x11.coloritem.flags.do-green", FT_BOOLEAN, 8, NULL, 0x02, "", HFILL }},
{ &hf_x11_coloritem_flags_do_red, { "do-red", "x11.coloritem.flags.do-red", FT_BOOLEAN, 8, NULL, 0x01, "", HFILL }},
{ &hf_x11_coloritem_flags_unused, { "unused", "x11.coloritem.flags.unused", FT_BOOLEAN, 8, NULL, 0xf8, "", HFILL }},
{ &hf_x11_coloritem_green, { "green", "x11.coloritem.green", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_coloritem_pixel, { "pixel", "x11.coloritem.pixel", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_coloritem_red, { "red", "x11.coloritem.red", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_coloritem_unused, { "unused", "x11.coloritem.unused", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_colormap, { "colormap", "x11.colormap", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_colors, { "colors", "x11.colors", FT_UINT16, BASE_DEC, NULL, 0, "The number of color cells to allocate", HFILL }},
{ &hf_x11_configure_window_mask, { "configure-window-mask", "x11.configure-window-mask", FT_UINT16, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_configure_window_mask_border_width, { "border-width", "x11.configure-window-mask.border-width", FT_BOOLEAN, 16, NULL, 0x0010, "", HFILL }},
{ &hf_x11_configure_window_mask_height, { "height", "x11.configure-window-mask.height", FT_BOOLEAN, 16, NULL, 0x0008, "", HFILL }},
{ &hf_x11_configure_window_mask_sibling, { "sibling", "x11.configure-window-mask.sibling", FT_BOOLEAN, 16, NULL, 0x0020, "", HFILL }},
{ &hf_x11_configure_window_mask_stack_mode, { "stack-mode", "x11.configure-window-mask.stack-mode", FT_BOOLEAN, 16, NULL, 0x0040, "", HFILL }},
{ &hf_x11_configure_window_mask_width, { "width", "x11.configure-window-mask.width", FT_BOOLEAN, 16, NULL, 0x0004, "", HFILL }},
{ &hf_x11_configure_window_mask_x, { "x", "x11.configure-window-mask.x", FT_BOOLEAN, 16, NULL, 0x0001, "", HFILL }},
{ &hf_x11_configure_window_mask_y, { "y", "x11.configure-window-mask.y", FT_BOOLEAN, 16, NULL, 0x0002, "", HFILL }},
{ &hf_x11_confine_to, { "confine-to", "x11.confine-to", FT_UINT32, BASE_HEX, VALS(zero_is_none_vals), 0, "", HFILL }},
{ &hf_x11_contiguous, { "contiguous", "x11.contiguous", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_coordinate_mode, { "coordinate-mode", "x11.coordinate-mode", FT_UINT8, BASE_DEC, VALS(coordinate_mode_vals), 0, "", HFILL }},
{ &hf_x11_count, { "count", "x11.count", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_cursor, { "cursor", "x11.cursor", FT_UINT32, BASE_HEX, VALS(zero_is_none_vals), 0, "", HFILL }},
{ &hf_x11_dash_offset, { "dash-offset", "x11.dash-offset", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_dashes, { "dashes", "x11.dashes", FT_BYTES, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_dashes_length, { "dashes-length", "x11.dashes-length", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_data, { "data", "x11.data", FT_BYTES, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_data_length, { "data-length", "x11.data-length", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_delete, { "delete", "x11.delete", FT_BOOLEAN, BASE_NONE, NULL, 0, "Delete this property after reading", HFILL }},
{ &hf_x11_delta, { "delta", "x11.delta", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_depth, { "depth", "x11.depth", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_detail, { "detail", "x11.event.detail", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_direction, { "direction", "x11.direction", FT_UINT8, BASE_DEC, VALS(direction_vals), 0, "", HFILL }},
{ &hf_x11_do_acceleration, { "do-acceleration", "x11.do-acceleration", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_do_not_propagate_mask, { "do-not-propagate-mask", "x11.do-not-propagate-mask", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_Button1Motion, { "Button1Motion", "x11.do-not-propagate-mask.Button1Motion", FT_BOOLEAN, 32, NULL, 0x00000100, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_Button2Motion, { "Button2Motion", "x11.do-not-propagate-mask.Button2Motion", FT_BOOLEAN, 32, NULL, 0x00000200, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_Button3Motion, { "Button3Motion", "x11.do-not-propagate-mask.Button3Motion", FT_BOOLEAN, 32, NULL, 0x00000400, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_Button4Motion, { "Button4Motion", "x11.do-not-propagate-mask.Button4Motion", FT_BOOLEAN, 32, NULL, 0x00000800, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_Button5Motion, { "Button5Motion", "x11.do-not-propagate-mask.Button5Motion", FT_BOOLEAN, 32, NULL, 0x00001000, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_ButtonMotion, { "ButtonMotion", "x11.do-not-propagate-mask.ButtonMotion", FT_BOOLEAN, 32, NULL, 0x00002000, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_ButtonPress, { "ButtonPress", "x11.do-not-propagate-mask.ButtonPress", FT_BOOLEAN, 32, NULL, 0x00000004, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_ButtonRelease, { "ButtonRelease", "x11.do-not-propagate-mask.ButtonRelease", FT_BOOLEAN, 32, NULL, 0x00000008, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_KeyPress, { "KeyPress", "x11.do-not-propagate-mask.KeyPress", FT_BOOLEAN, 32, NULL, 0x00000001, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_KeyRelease, { "KeyRelease", "x11.do-not-propagate-mask.KeyRelease", FT_BOOLEAN, 32, NULL, 0x00000002, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_PointerMotion, { "PointerMotion", "x11.do-not-propagate-mask.PointerMotion", FT_BOOLEAN, 32, NULL, 0x00000040, "", HFILL }},
{ &hf_x11_do_not_propagate_mask_erroneous_bits, { "erroneous-bits", "x11.do-not-propagate-mask.erroneous-bits", FT_BOOLEAN, 32, NULL, 0xffffc0b0, "", HFILL }},
{ &hf_x11_event_sequencenumber, { "sequencenumber", "x11.event.sequencenumber", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_do_threshold, { "do-threshold", "x11.do-threshold", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_drawable, { "drawable", "x11.drawable", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_dst_drawable, { "dst-drawable", "x11.dst-drawable", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_dst_gc, { "dst-gc", "x11.dst-gc", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_dst_window, { "dst-window", "x11.dst-window", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_dst_x, { "dst-x", "x11.dst-x", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_dst_y, { "dst-y", "x11.dst-y", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_error, { "error", "x11.error", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_error_badvalue, { "badvalue", "x11.error.badvalue", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_error_sequencenumber, { "sequencenumber", "x11.error.sequencenumber", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_errorcode, { "errorcode", "x11.errorcode", FT_UINT8, BASE_DEC, VALS(errorcode_vals), 0, "", HFILL }},
{ &hf_x11_event_mask, { "event-mask", "x11.event-mask", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_event_mask_Button1Motion, { "Button1Motion", "x11.event-mask.Button1Motion", FT_BOOLEAN, 32, NULL, 0x00000100, "", HFILL }},
{ &hf_x11_event_mask_Button2Motion, { "Button2Motion", "x11.event-mask.Button2Motion", FT_BOOLEAN, 32, NULL, 0x00000200, "", HFILL }},
{ &hf_x11_event_mask_Button3Motion, { "Button3Motion", "x11.event-mask.Button3Motion", FT_BOOLEAN, 32, NULL, 0x00000400, "", HFILL }},
{ &hf_x11_event_mask_Button4Motion, { "Button4Motion", "x11.event-mask.Button4Motion", FT_BOOLEAN, 32, NULL, 0x00000800, "", HFILL }},
{ &hf_x11_event_mask_Button5Motion, { "Button5Motion", "x11.event-mask.Button5Motion", FT_BOOLEAN, 32, NULL, 0x00001000, "", HFILL }},
{ &hf_x11_event_mask_ButtonMotion, { "ButtonMotion", "x11.event-mask.ButtonMotion", FT_BOOLEAN, 32, NULL, 0x00002000, "", HFILL }},
{ &hf_x11_event_mask_ButtonPress, { "ButtonPress", "x11.event-mask.ButtonPress", FT_BOOLEAN, 32, NULL, 0x00000004, "", HFILL }},
{ &hf_x11_event_mask_ButtonRelease, { "ButtonRelease", "x11.event-mask.ButtonRelease", FT_BOOLEAN, 32, NULL, 0x00000008, "", HFILL }},
{ &hf_x11_event_mask_ColormapChange, { "ColormapChange", "x11.event-mask.ColormapChange", FT_BOOLEAN, 32, NULL, 0x00800000, "", HFILL }},
{ &hf_x11_event_mask_EnterWindow, { "EnterWindow", "x11.event-mask.EnterWindow", FT_BOOLEAN, 32, NULL, 0x00000010, "", HFILL }},
{ &hf_x11_event_mask_Exposure, { "Exposure", "x11.event-mask.Exposure", FT_BOOLEAN, 32, NULL, 0x00008000, "", HFILL }},
{ &hf_x11_event_mask_FocusChange, { "FocusChange", "x11.event-mask.FocusChange", FT_BOOLEAN, 32, NULL, 0x00200000, "", HFILL }},
{ &hf_x11_event_mask_KeyPress, { "KeyPress", "x11.event-mask.KeyPress", FT_BOOLEAN, 32, NULL, 0x00000001, "", HFILL }},
{ &hf_x11_event_mask_KeyRelease, { "KeyRelease", "x11.event-mask.KeyRelease", FT_BOOLEAN, 32, NULL, 0x00000002, "", HFILL }},
{ &hf_x11_event_mask_KeymapState, { "KeymapState", "x11.event-mask.KeymapState", FT_BOOLEAN, 32, NULL, 0x00004000, "", HFILL }},
{ &hf_x11_event_mask_LeaveWindow, { "LeaveWindow", "x11.event-mask.LeaveWindow", FT_BOOLEAN, 32, NULL, 0x00000020, "", HFILL }},
{ &hf_x11_event_mask_OwnerGrabButton, { "OwnerGrabButton", "x11.event-mask.OwnerGrabButton", FT_BOOLEAN, 32, NULL, 0x01000000, "", HFILL }},
{ &hf_x11_event_mask_PointerMotion, { "PointerMotion", "x11.event-mask.PointerMotion", FT_BOOLEAN, 32, NULL, 0x00000040, "", HFILL }},
{ &hf_x11_event_mask_PointerMotionHint, { "PointerMotionHint", "x11.event-mask.PointerMotionHint", FT_BOOLEAN, 32, NULL, 0x00000080, "", HFILL }},
{ &hf_x11_event_mask_PropertyChange, { "PropertyChange", "x11.event-mask.PropertyChange", FT_BOOLEAN, 32, NULL, 0x00400000, "", HFILL }},
{ &hf_x11_event_mask_ResizeRedirect, { "ResizeRedirect", "x11.event-mask.ResizeRedirect", FT_BOOLEAN, 32, NULL, 0x00040000, "", HFILL }},
{ &hf_x11_event_mask_StructureNotify, { "StructureNotify", "x11.event-mask.StructureNotify", FT_BOOLEAN, 32, NULL, 0x00020000, "", HFILL }},
{ &hf_x11_event_mask_SubstructureNotify, { "SubstructureNotify", "x11.event-mask.SubstructureNotify", FT_BOOLEAN, 32, NULL, 0x00080000, "", HFILL }},
{ &hf_x11_event_mask_SubstructureRedirect, { "SubstructureRedirect", "x11.event-mask.SubstructureRedirect", FT_BOOLEAN, 32, NULL, 0x00100000, "", HFILL }},
{ &hf_x11_event_mask_VisibilityChange, { "VisibilityChange", "x11.event-mask.VisibilityChange", FT_BOOLEAN, 32, NULL, 0x00010000, "", HFILL }},
{ &hf_x11_event_mask_erroneous_bits, { "erroneous-bits", "x11.event-mask.erroneous-bits", FT_BOOLEAN, 32, NULL, 0xfe000000, "", HFILL }},
{ &hf_x11_event_x, { "event-x", "x11.event.event-x", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_event_y, { "event-y", "x11.event.event-y", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_eventbutton, { "button", "x11.button", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_eventcode, { "eventcode", "x11.eventcode", FT_UINT8, BASE_DEC, VALS(eventcode_vals), 0, "", HFILL }},
{ &hf_x11_eventwindow, { "eventwindow", "x11.event.window", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_exposures, { "exposures", "x11.exposures", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_family, { "family", "x11.family", FT_UINT8, BASE_DEC, VALS(family_vals), 0, "", HFILL }},
{ &hf_x11_fid, { "fid", "x11.fid", FT_UINT32, BASE_HEX, NULL, 0, "Font id", HFILL }},
{ &hf_x11_fill_rule, { "fill-rule", "x11.fill-rule", FT_UINT8, BASE_DEC, VALS(fill_rule_vals), 0, "", HFILL }},
{ &hf_x11_fill_style, { "fill-style", "x11.fill-style", FT_UINT8, BASE_DEC, VALS(fill_style_vals), 0, "", HFILL }},
{ &hf_x11_first_keycode, { "first-keycode", "x11.first-keycode", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_focus, { "focus", "x11.focus", FT_UINT8, BASE_DEC, VALS(focus_vals), 0, "", HFILL }},
{ &hf_x11_font, { "font", "x11.font", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_fore_blue, { "fore-blue", "x11.fore-blue", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_fore_green, { "fore-green", "x11.fore-green", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_fore_red, { "fore-red", "x11.fore-red", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_foreground, { "foreground", "x11.foreground", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_format, { "format", "x11.format", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_function, { "function", "x11.function", FT_UINT8, BASE_DEC, VALS(function_vals), 0, "", HFILL }},
{ &hf_x11_gc, { "gc", "x11.gc", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_gc_dashes, { "gc-dashes", "x11.gc-dashes", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_gc_value_mask, { "gc-value-mask", "x11.gc-value-mask", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_gc_value_mask_arc_mode, { "arc-mode", "x11.gc-value-mask.arc-mode", FT_BOOLEAN, 32, NULL, 0x00400000, "", HFILL }},
{ &hf_x11_gc_value_mask_background, { "background", "x11.gc-value-mask.background", FT_BOOLEAN, 32, NULL, 0x00000008, "", HFILL }},
{ &hf_x11_gc_value_mask_cap_style, { "cap-style", "x11.gc-value-mask.cap-style", FT_BOOLEAN, 32, NULL, 0x00000040, "", HFILL }},
{ &hf_x11_gc_value_mask_clip_mask, { "clip-mask", "x11.gc-value-mask.clip-mask", FT_BOOLEAN, 32, NULL, 0x00080000, "", HFILL }},
{ &hf_x11_gc_value_mask_clip_x_origin, { "clip-x-origin", "x11.gc-value-mask.clip-x-origin", FT_BOOLEAN, 32, NULL, 0x00020000, "", HFILL }},
{ &hf_x11_gc_value_mask_clip_y_origin, { "clip-y-origin", "x11.gc-value-mask.clip-y-origin", FT_BOOLEAN, 32, NULL, 0x00040000, "", HFILL }},
{ &hf_x11_gc_value_mask_dash_offset, { "dash-offset", "x11.gc-value-mask.dash-offset", FT_BOOLEAN, 32, NULL, 0x00100000, "", HFILL }},
{ &hf_x11_gc_value_mask_fill_rule, { "fill-rule", "x11.gc-value-mask.fill-rule", FT_BOOLEAN, 32, NULL, 0x00000200, "", HFILL }},
{ &hf_x11_gc_value_mask_fill_style, { "fill-style", "x11.gc-value-mask.fill-style", FT_BOOLEAN, 32, NULL, 0x00000100, "", HFILL }},
{ &hf_x11_gc_value_mask_font, { "font", "x11.gc-value-mask.font", FT_BOOLEAN, 32, NULL, 0x00004000, "", HFILL }},
{ &hf_x11_gc_value_mask_foreground, { "foreground", "x11.gc-value-mask.foreground", FT_BOOLEAN, 32, NULL, 0x00000004, "", HFILL }},
{ &hf_x11_gc_value_mask_function, { "function", "x11.gc-value-mask.function", FT_BOOLEAN, 32, NULL, 0x00000001, "", HFILL }},
{ &hf_x11_gc_value_mask_gc_dashes, { "gc-dashes", "x11.gc-value-mask.gc-dashes", FT_BOOLEAN, 32, NULL, 0x00200000, "", HFILL }},
{ &hf_x11_gc_value_mask_graphics_exposures, { "graphics-exposures", "x11.gc-value-mask.graphics-exposures", FT_BOOLEAN, 32, NULL, 0x00010000, "", HFILL }},
{ &hf_x11_gc_value_mask_join_style, { "join-style", "x11.gc-value-mask.join-style", FT_BOOLEAN, 32, NULL, 0x00000080, "", HFILL }},
{ &hf_x11_gc_value_mask_line_style, { "line-style", "x11.gc-value-mask.line-style", FT_BOOLEAN, 32, NULL, 0x00000020, "", HFILL }},
{ &hf_x11_gc_value_mask_line_width, { "line-width", "x11.gc-value-mask.line-width", FT_BOOLEAN, 32, NULL, 0x00000010, "", HFILL }},
{ &hf_x11_gc_value_mask_plane_mask, { "plane-mask", "x11.gc-value-mask.plane-mask", FT_BOOLEAN, 32, NULL, 0x00000002, "", HFILL }},
{ &hf_x11_gc_value_mask_stipple, { "stipple", "x11.gc-value-mask.stipple", FT_BOOLEAN, 32, NULL, 0x00000800, "", HFILL }},
{ &hf_x11_gc_value_mask_subwindow_mode, { "subwindow-mode", "x11.gc-value-mask.subwindow-mode", FT_BOOLEAN, 32, NULL, 0x00008000, "", HFILL }},
{ &hf_x11_gc_value_mask_tile, { "tile", "x11.gc-value-mask.tile", FT_BOOLEAN, 32, NULL, 0x00000400, "", HFILL }},
{ &hf_x11_gc_value_mask_tile_stipple_x_origin, { "tile-stipple-x-origin", "x11.gc-value-mask.tile-stipple-x-origin", FT_BOOLEAN, 32, NULL, 0x00001000, "", HFILL }},
{ &hf_x11_gc_value_mask_tile_stipple_y_origin, { "tile-stipple-y-origin", "x11.gc-value-mask.tile-stipple-y-origin", FT_BOOLEAN, 32, NULL, 0x00002000, "", HFILL }},
{ &hf_x11_get_property_type, { "get-property-type", "x11.get-property-type", FT_UINT32, BASE_HEX, VALS(zero_is_any_property_type_vals), 0, "", HFILL }},
{ &hf_x11_grab_window, { "grab_window", "x11.grab_window", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_graphics_exposures, { "graphics-exposures", "x11.graphics-exposures", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_green, { "green", "x11.green", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_greens, { "greens", "x11.greens", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_height, { "height", "x11.height", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_image_byte_order, { "image_byte_order", "x11.image_byte_order", FT_UINT8, BASE_HEX, VALS(image_byte_order_vals), 0, "", HFILL }},
{ &hf_x11_image_format, { "image-format", "x11.image-format", FT_UINT8, BASE_DEC, VALS(image_format_vals), 0, "", HFILL }},
{ &hf_x11_image_pixmap_format, { "image-pixmap-format", "x11.image-pixmap-format", FT_UINT8, BASE_DEC, VALS(image_pixmap_format_vals), 0, "", HFILL }},
{ &hf_x11_initial_connection, { "initial connection", "x11.inital_connection", FT_NONE, BASE_NONE, NULL, 0, "Yet undecoded by dissector", HFILL }},
{ &hf_x11_interval, { "interval", "x11.interval", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_ip_address, { "ip-address", "x11.ip-address", FT_IPv4, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_items, { "items", "x11.items", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_join_style, { "join-style", "x11.join-style", FT_UINT8, BASE_DEC, VALS(join_style_vals), 0, "", HFILL }},
{ &hf_x11_key, { "key", "x11.key", FT_UINT8, BASE_DEC, VALS(key_vals), 0, "", HFILL }},
{ &hf_x11_key_click_percent, { "key-click-percent", "x11.key-click-percent", FT_INT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_keyboard_key, { "keyboard-key", "x11.keyboard-key", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_keyboard_mode, { "keyboard-mode", "x11.keyboard-mode", FT_UINT8, BASE_DEC, VALS(pointer_keyboard_mode_vals), 0, "", HFILL }},
{ &hf_x11_keyboard_value_mask, { "keyboard-value-mask", "x11.keyboard-value-mask", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_keyboard_value_mask_auto_repeat_mode, { "auto-repeat-mode", "x11.keyboard-value-mask.auto-repeat-mode", FT_BOOLEAN, 32, NULL, 0x0080, "", HFILL }},
{ &hf_x11_keyboard_value_mask_bell_duration, { "bell-duration", "x11.keyboard-value-mask.bell-duration", FT_BOOLEAN, 32, NULL, 0x0008, "", HFILL }},
{ &hf_x11_keyboard_value_mask_bell_percent, { "bell-percent", "x11.keyboard-value-mask.bell-percent", FT_BOOLEAN, 32, NULL, 0x0002, "", HFILL }},
{ &hf_x11_keyboard_value_mask_bell_pitch, { "bell-pitch", "x11.keyboard-value-mask.bell-pitch", FT_BOOLEAN, 32, NULL, 0x0004, "", HFILL }},
{ &hf_x11_keyboard_value_mask_key_click_percent, { "key-click-percent", "x11.keyboard-value-mask.key-click-percent", FT_BOOLEAN, 32, NULL, 0x0001, "", HFILL }},
{ &hf_x11_keyboard_value_mask_keyboard_key, { "keyboard-key", "x11.keyboard-value-mask.keyboard-key", FT_BOOLEAN, 32, NULL, 0x0040, "", HFILL }},
{ &hf_x11_keyboard_value_mask_led, { "led", "x11.keyboard-value-mask.led", FT_BOOLEAN, 32, NULL, 0x0010, "", HFILL }},
{ &hf_x11_keyboard_value_mask_led_mode, { "led-mode", "x11.keyboard-value-mask.led-mode", FT_BOOLEAN, 32, NULL, 0x0020, "", HFILL }},
{ &hf_x11_keybut_mask_erroneous_bits, { "erroneous-bits", "x11.keybut-mask.erroneous-bits", FT_BOOLEAN, 16, NULL, 0xe000, "", HFILL }},
{ &hf_x11_keycode, { "keycode", "x11.event.keycode", FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_keycode_count, { "keycode-count", "x11.keycode-count", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_keycodes, { "keycodes", "x11.keycodes", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_keycodes_item, { "item", "x11.keycodes.item", FT_BYTES, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_keycodes_per_modifier, { "keycodes-per-modifier", "x11.keycodes-per-modifier", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_keysyms, { "keysyms", "x11.keysyms", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_keysyms_item, { "item", "x11.keysyms.item", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_keysyms_item_keysym, { "keysym", "x11.keysyms.item.keysym", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_keysyms_per_keycode, { "keysyms-per-keycode", "x11.keysyms-per-keycode", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_led, { "led", "x11.led", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_led_mode, { "led-mode", "x11.led-mode", FT_UINT8, BASE_DEC, VALS(on_off_vals), 0, "", HFILL }},
{ &hf_x11_left_pad, { "left-pad", "x11.left-pad", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_length_of_vendor, { "length_of_vendor", "x11.length_of_vendor", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_line_style, { "line-style", "x11.line-style", FT_UINT8, BASE_DEC, VALS(line_style_vals), 0, "", HFILL }},
{ &hf_x11_line_width, { "line-width", "x11.line-width", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_long_length, { "long-length", "x11.long-length", FT_UINT32, BASE_DEC, NULL, 0, "The maximum length of the property in bytes", HFILL }},
{ &hf_x11_long_offset, { "long-offset", "x11.long-offset", FT_UINT32, BASE_DEC, NULL, 0, "The starting position in the property bytes array", HFILL }},
{ &hf_x11_major_opcode, { "major-opcode", "x11.major-opcode", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_map, { "map", "x11.map", FT_BYTES, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_map_length, { "map-length", "x11.map-length", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_mask, { "mask", "x11.mask", FT_UINT32, BASE_HEX, VALS(zero_is_none_vals), 0, "", HFILL }},
{ &hf_x11_mask_char, { "mask-char", "x11.mask-char", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_mask_font, { "mask-font", "x11.mask-font", FT_UINT32, BASE_HEX, VALS(zero_is_none_vals), 0, "", HFILL }},
{ &hf_x11_max_keycode, { "max_keycode", "x11.max_keycode", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_max_names, { "max-names", "x11.max-names", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_maximum_request_length, { "maximum_request_length", "x11.maximum_request_length", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_mid, { "mid", "x11.mid", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_min_keycode, { "min_keycode", "x11.min_keycode", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_minor_opcode, { "minor-opcode", "x11.minor-opcode", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_mode, { "mode", "x11.mode", FT_UINT8, BASE_DEC, VALS(mode_vals), 0, "", HFILL }},
{ &hf_x11_modifiers_mask, { "modifiers-mask", "x11.modifiers-mask", FT_UINT16, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_modifiers_mask_AnyModifier, { "AnyModifier", "x11.modifiers-mask.AnyModifier", FT_UINT16, BASE_HEX, NULL, 0x8000, "", HFILL }},
{ &hf_x11_modifiers_mask_Button1, { "Button1", "x11.modifiers-mask.Button1", FT_BOOLEAN, 16, NULL, 0x0100, "", HFILL }},
{ &hf_x11_modifiers_mask_Button2, { "Button2", "x11.modifiers-mask.Button2", FT_BOOLEAN, 16, NULL, 0x0200, "", HFILL }},
{ &hf_x11_modifiers_mask_Button3, { "Button3", "x11.modifiers-mask.Button3", FT_BOOLEAN, 16, NULL, 0x0400, "", HFILL }},
{ &hf_x11_modifiers_mask_Button4, { "Button4", "x11.modifiers-mask.Button4", FT_BOOLEAN, 16, NULL, 0x0800, "", HFILL }},
{ &hf_x11_modifiers_mask_Button5, { "Button5", "x11.modifiers-mask.Button5", FT_BOOLEAN, 16, NULL, 0x1000, "", HFILL }},
{ &hf_x11_modifiers_mask_Control, { "Control", "x11.modifiers-mask.Control", FT_BOOLEAN, 16, NULL, 0x0004, "", HFILL }},
{ &hf_x11_modifiers_mask_Lock, { "Lock", "x11.modifiers-mask.Lock", FT_BOOLEAN, 16, NULL, 0x0002, "", HFILL }},
{ &hf_x11_modifiers_mask_Mod1, { "Mod1", "x11.modifiers-mask.Mod1", FT_BOOLEAN, 16, NULL, 0x0008, "", HFILL }},
{ &hf_x11_modifiers_mask_Mod2, { "Mod2", "x11.modifiers-mask.Mod2", FT_BOOLEAN, 16, NULL, 0x0010, "", HFILL }},
{ &hf_x11_modifiers_mask_Mod3, { "Mod3", "x11.modifiers-mask.Mod3", FT_BOOLEAN, 16, NULL, 0x0020, "", HFILL }},
{ &hf_x11_modifiers_mask_Mod4, { "Mod4", "x11.modifiers-mask.Mod4", FT_BOOLEAN, 16, NULL, 0x0040, "", HFILL }},
{ &hf_x11_modifiers_mask_Mod5, { "Mod5", "x11.modifiers-mask.Mod5", FT_BOOLEAN, 16, NULL, 0x0080, "", HFILL }},
{ &hf_x11_modifiers_mask_Shift, { "Shift", "x11.modifiers-mask.Shift", FT_BOOLEAN, 16, NULL, 0x0001, "", HFILL }},
{ &hf_x11_modifiers_mask_erroneous_bits, { "erroneous-bits", "x11.modifiers-mask.erroneous-bits", FT_BOOLEAN, 16, NULL, 0xff00, "", HFILL }},
{ &hf_x11_motion_buffer_size, { "motion_buffer_size", "x11.motion_buffer_size", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_name, { "name", "x11.name", FT_STRING, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_name_length, { "name-length", "x11.name-length", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_number_of_formats_in_pixmap_formats, { "number_of_formats_in_pixmap_formats", "x11.number_of_formats_in_pixmap_formats", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_number_of_screens_in_roots, { "number_of_screens_in_roots", "x11.number_of_screens_in_roots", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_odd_length, { "odd-length", "x11.odd-length", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_only_if_exists, { "only-if-exists", "x11.only-if-exists", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_opcode, { "opcode", "x11.opcode", FT_UINT8, BASE_DEC, VALS(opcode_vals), 0, "", HFILL }},
{ &hf_x11_ordering, { "ordering", "x11.ordering", FT_UINT8, BASE_DEC, VALS(ordering_vals), 0, "", HFILL }},
{ &hf_x11_override_redirect, { "override-redirect", "x11.override-redirect", FT_BOOLEAN, BASE_NONE, NULL, 0, "Window manager doesn't manage this window when true", HFILL }},
{ &hf_x11_owner, { "owner", "x11.owner", FT_UINT32, BASE_HEX, VALS(zero_is_none_vals), 0, "", HFILL }},
{ &hf_x11_owner_events, { "owner-events", "x11.owner-events", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_parent, { "parent", "x11.parent", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_path, { "path", "x11.path", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_path_string, { "string", "x11.path.string", FT_STRING, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_pattern, { "pattern", "x11.pattern", FT_STRING, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_pattern_length, { "pattern-length", "x11.pattern-length", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_percent, { "percent", "x11.percent", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_pid, { "pid", "x11.pid", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_pixel, { "pixel", "x11.pixel", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_pixels, { "pixels", "x11.pixels", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_pixels_item, { "pixels_item", "x11.pixels_item", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_pixmap, { "pixmap", "x11.pixmap", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_plane_mask, { "plane-mask", "x11.plane-mask", FT_UINT32, BASE_HEX, VALS(plane_mask_vals), 0, "", HFILL }},
{ &hf_x11_planes, { "planes", "x11.planes", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_point, { "point", "x11.point", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_point_x, { "point-x", "x11.point-x", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_point_y, { "point-y", "x11.point-y", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_pointer_event_mask, { "pointer-event-mask", "x11.pointer-event-mask", FT_UINT16, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_pointer_event_mask_Button1Motion, { "Button1Motion", "x11.pointer-event-mask.Button1Motion", FT_BOOLEAN, 16, NULL, 0x0100, "", HFILL }},
{ &hf_x11_pointer_event_mask_Button2Motion, { "Button2Motion", "x11.pointer-event-mask.Button2Motion", FT_BOOLEAN, 16, NULL, 0x0200, "", HFILL }},
{ &hf_x11_pointer_event_mask_Button3Motion, { "Button3Motion", "x11.pointer-event-mask.Button3Motion", FT_BOOLEAN, 16, NULL, 0x0400, "", HFILL }},
{ &hf_x11_pointer_event_mask_Button4Motion, { "Button4Motion", "x11.pointer-event-mask.Button4Motion", FT_BOOLEAN, 16, NULL, 0x0800, "", HFILL }},
{ &hf_x11_pointer_event_mask_Button5Motion, { "Button5Motion", "x11.pointer-event-mask.Button5Motion", FT_BOOLEAN, 16, NULL, 0x1000, "", HFILL }},
{ &hf_x11_pointer_event_mask_ButtonMotion, { "ButtonMotion", "x11.pointer-event-mask.ButtonMotion", FT_BOOLEAN, 16, NULL, 0x2000, "", HFILL }},
{ &hf_x11_pointer_event_mask_ButtonPress, { "ButtonPress", "x11.pointer-event-mask.ButtonPress", FT_BOOLEAN, 16, NULL, 0x0004, "", HFILL }},
{ &hf_x11_pointer_event_mask_ButtonRelease, { "ButtonRelease", "x11.pointer-event-mask.ButtonRelease", FT_BOOLEAN, 16, NULL, 0x0008, "", HFILL }},
{ &hf_x11_pointer_event_mask_EnterWindow, { "EnterWindow", "x11.pointer-event-mask.EnterWindow", FT_BOOLEAN, 16, NULL, 0x0010, "", HFILL }},
{ &hf_x11_pointer_event_mask_KeymapState, { "KeymapState", "x11.pointer-event-mask.KeymapState", FT_BOOLEAN, 16, NULL, 0x4000, "", HFILL }},
{ &hf_x11_pointer_event_mask_LeaveWindow, { "LeaveWindow", "x11.pointer-event-mask.LeaveWindow", FT_BOOLEAN, 16, NULL, 0x0020, "", HFILL }},
{ &hf_x11_pointer_event_mask_PointerMotion, { "PointerMotion", "x11.pointer-event-mask.PointerMotion", FT_BOOLEAN, 16, NULL, 0x0040, "", HFILL }},
{ &hf_x11_pointer_event_mask_PointerMotionHint, { "PointerMotionHint", "x11.pointer-event-mask.PointerMotionHint", FT_BOOLEAN, 16, NULL, 0x0080, "", HFILL }},
{ &hf_x11_pointer_event_mask_erroneous_bits, { "erroneous-bits", "x11.pointer-event-mask.erroneous-bits", FT_BOOLEAN, 16, NULL, 0x8003, "", HFILL }},
{ &hf_x11_pointer_mode, { "pointer-mode", "x11.pointer-mode", FT_UINT8, BASE_DEC, VALS(pointer_keyboard_mode_vals), 0, "", HFILL }},
{ &hf_x11_points, { "points", "x11.points", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_prefer_blanking, { "prefer-blanking", "x11.prefer-blanking", FT_UINT8, BASE_DEC, VALS(yes_no_default_vals), 0, "", HFILL }},
{ &hf_x11_properties, { "properties", "x11.properties", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_properties_item, { "item", "x11.properties.item", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_property, { "property", "x11.property", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_property_number, { "property-number", "x11.property-number", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_protocol_major_version, { "protocol-major-version", "x11.protocol-major-version", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_protocol_minor_version, { "protocol-minor-version", "x11.protocol-minor-version", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_rectangle, { "rectangle", "x11.rectangle", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_rectangle_height, { "rectangle-height", "x11.rectangle-height", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_rectangle_width, { "rectangle-width", "x11.rectangle-width", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_rectangle_x, { "rectangle-x", "x11.rectangle-x", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_rectangle_y, { "rectangle-y", "x11.rectangle-y", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_rectangles, { "rectangles", "x11.rectangles", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_red, { "red", "x11.red", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_reds, { "reds", "x11.reds", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_release_number, { "release_number", "x11.release_number", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_reply, { "reply", "x11.reply", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_reply_sequencenumber, { "sequencenumber", "x11.reply.sequencenumber", FT_UINT16, BASE_DEC, VALS(opcode_vals), 0, "", HFILL }},
{ &hf_x11_replylength, { "replylength", "x11.reply.length", FT_UINT32, BASE_DEC, NULL, 0, "Replylength", HFILL }},
{ &hf_x11_replyopcode, { "replyopcode", "x11.reply.opcode", FT_UINT8, BASE_DEC, VALS(opcode_vals), 0, "", HFILL }},
{ &hf_x11_request, { "request", "x11.request", FT_UINT8, BASE_DEC, VALS(opcode_vals), 0, "", HFILL }},
{ &hf_x11_request_length, { "request-length", "x11.request-length", FT_UINT16, BASE_DEC, NULL, 0, "Request length", HFILL }},
{ &hf_x11_requestor, { "requestor", "x11.requestor", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_resource, { "resource", "x11.resource", FT_UINT32, BASE_HEX, VALS(all_temporary_vals), 0, "", HFILL }},
{ &hf_x11_resource_id_base, { "resource_id_base", "x11.resource_id_base", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_resource_id_mask, { "resource_id_mask", "x11.resource_id_mask", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_revert_to, { "revert-to", "x11.revert-to", FT_UINT8, BASE_DEC, VALS(revert_to_vals), 0, "", HFILL }},
{ &hf_x11_root_x, { "root-x", "x11.event.root-x", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_root_y, { "root-y", "x11.event.root-y", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_rootwindow, { "rootwindow", "x11.event.rootwindow", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_same_screen, { "same-screen", "x11.event.same-screen", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_save_set_mode, { "save-set-mode", "x11.save-set-mode", FT_UINT8, BASE_DEC, VALS(insert_delete_vals), 0, "", HFILL }},
{ &hf_x11_save_under, { "save-under", "x11.save-under", FT_BOOLEAN, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_screen_saver_mode, { "screen-saver-mode", "x11.screen-saver-mode", FT_UINT8, BASE_DEC, VALS(screen_saver_mode_vals), 0, "", HFILL }},
{ &hf_x11_segment, { "segment", "x11.segment", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_segment_x1, { "segment_x1", "x11.segment_x1", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_segment_x2, { "segment_x2", "x11.segment_x2", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_segment_y1, { "segment_y1", "x11.segment_y1", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_segment_y2, { "segment_y2", "x11.segment_y2", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_segments, { "segments", "x11.segments", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_selection, { "selection", "x11.selection", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_shape, { "shape", "x11.shape", FT_UINT8, BASE_DEC, VALS(shape_vals), 0, "", HFILL }},
{ &hf_x11_sibling, { "sibling", "x11.sibling", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_source_char, { "source-char", "x11.source-char", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_source_font, { "source-font", "x11.source-font", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_source_pixmap, { "source-pixmap", "x11.source-pixmap", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_src_cmap, { "src-cmap", "x11.src-cmap", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_src_drawable, { "src-drawable", "x11.src-drawable", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_src_gc, { "src-gc", "x11.src-gc", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_src_height, { "src-height", "x11.src-height", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_src_width, { "src-width", "x11.src-width", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_src_window, { "src-window", "x11.src-window", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_src_x, { "src-x", "x11.src-x", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_src_y, { "src-y", "x11.src-y", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_stack_mode, { "stack-mode", "x11.stack-mode", FT_UINT8, BASE_DEC, VALS(stack_mode_vals), 0, "", HFILL }},
{ &hf_x11_start, { "start", "x11.start", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_stipple, { "stipple", "x11.stipple", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_stop, { "stop", "x11.stop", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_str_number_in_path, { "str-number-in-path", "x11.str-number-in-path", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_string, { "string", "x11.string", FT_STRING, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_string16, { "string16", "x11.string16", FT_STRING, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_string16_bytes, { "bytes", "x11.string16.bytes", FT_BYTES, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_string_length, { "string-length", "x11.string-length", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_subwindow_mode, { "subwindow-mode", "x11.subwindow-mode", FT_UINT8, BASE_DEC, VALS(subwindow_mode_vals), 0, "", HFILL }},
{ &hf_x11_success, { "success", "x11.success", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_target, { "target", "x11.target", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_textitem, { "textitem", "x11.textitem", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_textitem_font, { "font", "x11.textitem.font", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_textitem_string, { "string", "x11.textitem.string", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_textitem_string_delta, { "delta", "x11.textitem.string.delta", FT_INT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_textitem_string_string16, { "string16", "x11.textitem.string.string16", FT_STRING, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_textitem_string_string16_bytes, { "bytes", "x11.textitem.string.string16.bytes", FT_BYTES, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_textitem_string_string8, { "string8", "x11.textitem.string.string8", FT_STRING, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_threshold, { "threshold", "x11.threshold", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_tile, { "tile", "x11.tile", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_tile_stipple_x_origin, { "tile-stipple-x-origin", "x11.tile-stipple-x-origin", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_tile_stipple_y_origin, { "tile-stipple-y-origin", "x11.tile-stipple-y-origin", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_time, { "time", "x11.time", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_timeout, { "timeout", "x11.timeout", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_type, { "type", "x11.type", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_undecoded, { "undecoded", "x11.undecoded", FT_NONE, BASE_NONE, NULL, 0, "Yet undecoded by dissector", HFILL }},
{ &hf_x11_unused, { "unused", "x11.unused", FT_NONE, BASE_NONE, NULL, 0, "", HFILL }},
{ &hf_x11_value_length, { "valuelength", "x11.valuelength", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_vendor, { "vendor", "x11.vendor", FT_STRING, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_visual, { "visual", "x11.visual", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_visualid, { "visualid", "x11.visualid", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_warp_pointer_dst_window, { "warp-pointer-dst-window", "x11.warp-pointer-dst-window", FT_UINT32, BASE_HEX, VALS(zero_is_none_vals), 0, "", HFILL }},
{ &hf_x11_warp_pointer_src_window, { "warp-pointer-src-window", "x11.warp-pointer-src-window", FT_UINT32, BASE_HEX, VALS(zero_is_none_vals), 0, "", HFILL }},
{ &hf_x11_wid, { "wid", "x11.wid", FT_UINT32, BASE_HEX, NULL, 0, "Window id", HFILL }},
{ &hf_x11_width, { "width", "x11.width", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_win_gravity, { "win-gravity", "x11.win-gravity", FT_UINT8, BASE_DEC, VALS(gravity_vals), 0, "", HFILL }},
{ &hf_x11_window, { "window", "x11.window", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_window_class, { "window-class", "x11.window-class", FT_UINT16, BASE_DEC, VALS(window_class_vals), 0, "Window class", HFILL }},
{ &hf_x11_window_value_mask, { "window-value-mask", "x11.window-value-mask", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }},
{ &hf_x11_window_value_mask_background_pixel, { "background-pixel", "x11.window-value-mask.background-pixel", FT_BOOLEAN, 32, NULL, 0x00000002, "", HFILL }},
{ &hf_x11_window_value_mask_background_pixmap, { "background-pixmap", "x11.window-value-mask.background-pixmap", FT_BOOLEAN, 32, NULL, 0x00000001, "", HFILL }},
{ &hf_x11_window_value_mask_backing_pixel, { "backing-pixel", "x11.window-value-mask.backing-pixel", FT_BOOLEAN, 32, NULL, 0x00000100, "", HFILL }},
{ &hf_x11_window_value_mask_backing_planes, { "backing-planes", "x11.window-value-mask.backing-planes", FT_BOOLEAN, 32, NULL, 0x00000080, "", HFILL }},
{ &hf_x11_window_value_mask_backing_store, { "backing-store", "x11.window-value-mask.backing-store", FT_BOOLEAN, 32, NULL, 0x00000040, "", HFILL }},
{ &hf_x11_window_value_mask_bit_gravity, { "bit-gravity", "x11.window-value-mask.bit-gravity", FT_BOOLEAN, 32, NULL, 0x00000010, "", HFILL }},
{ &hf_x11_window_value_mask_border_pixel, { "border-pixel", "x11.window-value-mask.border-pixel", FT_BOOLEAN, 32, NULL, 0x00000008, "", HFILL }},
{ &hf_x11_window_value_mask_border_pixmap, { "border-pixmap", "x11.window-value-mask.border-pixmap", FT_BOOLEAN, 32, NULL, 0x00000004, "", HFILL }},
{ &hf_x11_window_value_mask_colormap, { "colormap", "x11.window-value-mask.colormap", FT_BOOLEAN, 32, NULL, 0x00002000, "", HFILL }},
{ &hf_x11_window_value_mask_cursor, { "cursor", "x11.window-value-mask.cursor", FT_BOOLEAN, 32, NULL, 0x00004000, "", HFILL }},
{ &hf_x11_window_value_mask_do_not_propagate_mask, { "do-not-propagate-mask", "x11.window-value-mask.do-not-propagate-mask", FT_BOOLEAN, 32, NULL, 0x00001000, "", HFILL }},
{ &hf_x11_window_value_mask_event_mask, { "event-mask", "x11.window-value-mask.event-mask", FT_BOOLEAN, 32, NULL, 0x00000800, "", HFILL }},
{ &hf_x11_window_value_mask_override_redirect, { "override-redirect", "x11.window-value-mask.override-redirect", FT_BOOLEAN, 32, NULL, 0x00000200, "", HFILL }},
{ &hf_x11_window_value_mask_save_under, { "save-under", "x11.window-value-mask.save-under", FT_BOOLEAN, 32, NULL, 0x00000400, "", HFILL }},
{ &hf_x11_window_value_mask_win_gravity, { "win-gravity", "x11.window-value-mask.win-gravity", FT_BOOLEAN, 32, NULL, 0x00000020, "", HFILL }},
{ &hf_x11_x, { "x", "x11.x", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_x11_y, { "y", "x11.y", FT_INT16, BASE_DEC, NULL, 0, "", HFILL }},
/* $TOG: keysymdef.h /main/28 1998/05/22 16:18:01 kaleb $ */

/***********************************************************
Copyright 1987, 1994, 1998  The Open Group

All Rights Reserved.

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.


Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.

DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

******************************************************************/
/* $XFree86: xc/include/keysymdef.h,v 1.10 2000/10/27 18:30:46 dawes Exp $ */

#define XK_VoidSymbol		0xFFFFFF	/* void symbol */

#define XK_MISCELLANY
#ifdef XK_MISCELLANY
/*
 * TTY Functions, cleverly chosen to map to ascii, for convenience of
 * programming, but could have been arbitrary (at the cost of lookup
 * tables in client code.
 */

#define XK_BackSpace		0xFF08	/* back space, back char */
#define XK_Tab			0xFF09
#define XK_Linefeed		0xFF0A	/* Linefeed, LF */
#define XK_Clear		0xFF0B
#define XK_Return		0xFF0D	/* Return, enter */
#define XK_Pause		0xFF13	/* Pause, hold */
#define XK_Scroll_Lock		0xFF14
#define XK_Sys_Req		0xFF15
#define XK_Escape		0xFF1B
#define XK_Delete		0xFFFF	/* Delete, rubout */



/* International & multi-key character composition */

#define XK_Multi_key		0xFF20  /* Multi-key character compose */
#define XK_Codeinput		0xFF37
#define XK_SingleCandidate	0xFF3C
#define XK_MultipleCandidate	0xFF3D
#define XK_PreviousCandidate	0xFF3E

/* Japanese keyboard support */

#define XK_Kanji		0xFF21	/* Kanji, Kanji convert */
#define XK_Muhenkan		0xFF22  /* Cancel Conversion */
#define XK_Henkan_Mode		0xFF23  /* Start/Stop Conversion */
#define XK_Henkan		0xFF23  /* Alias for Henkan_Mode */
#define XK_Romaji		0xFF24  /* to Romaji */
#define XK_Hiragana		0xFF25  /* to Hiragana */
#define XK_Katakana		0xFF26  /* to Katakana */
#define XK_Hiragana_Katakana	0xFF27  /* Hiragana/Katakana toggle */
#define XK_Zenkaku		0xFF28  /* to Zenkaku */
#define XK_Hankaku		0xFF29  /* to Hankaku */
#define XK_Zenkaku_Hankaku	0xFF2A  /* Zenkaku/Hankaku toggle */
#define XK_Touroku		0xFF2B  /* Add to Dictionary */
#define XK_Massyo		0xFF2C  /* Delete from Dictionary */
#define XK_Kana_Lock		0xFF2D  /* Kana Lock */
#define XK_Kana_Shift		0xFF2E  /* Kana Shift */
#define XK_Eisu_Shift		0xFF2F  /* Alphanumeric Shift */
#define XK_Eisu_toggle		0xFF30  /* Alphanumeric toggle */
#define XK_Kanji_Bangou		0xFF37  /* Codeinput */
#define XK_Zen_Koho		0xFF3D	/* Multiple/All Candidate(s) */
#define XK_Mae_Koho		0xFF3E	/* Previous Candidate */

/* 0xFF31 thru 0xFF3F are under XK_KOREAN */

/* Cursor control & motion */

#define XK_Home			0xFF50
#define XK_Left			0xFF51	/* Move left, left arrow */
#define XK_Up			0xFF52	/* Move up, up arrow */
#define XK_Right		0xFF53	/* Move right, right arrow */
#define XK_Down			0xFF54	/* Move down, down arrow */
#define XK_Prior		0xFF55	/* Prior, previous */
#define XK_Page_Up		0xFF55
#define XK_Next			0xFF56	/* Next */
#define XK_Page_Down		0xFF56
#define XK_End			0xFF57	/* EOL */
#define XK_Begin		0xFF58	/* BOL */


/* Misc Functions */

#define XK_Select		0xFF60	/* Select, mark */
#define XK_Print		0xFF61
#define XK_Execute		0xFF62	/* Execute, run, do */
#define XK_Insert		0xFF63	/* Insert, insert here */
#define XK_Undo			0xFF65	/* Undo, oops */
#define XK_Redo			0xFF66	/* redo, again */
#define XK_Menu			0xFF67
#define XK_Find			0xFF68	/* Find, search */
#define XK_Cancel		0xFF69	/* Cancel, stop, abort, exit */
#define XK_Help			0xFF6A	/* Help */
#define XK_Break		0xFF6B
#define XK_Mode_switch		0xFF7E	/* Character set switch */
#define XK_script_switch        0xFF7E  /* Alias for mode_switch */
#define XK_Num_Lock		0xFF7F

/* Keypad Functions, keypad numbers cleverly chosen to map to ascii */

#define XK_KP_Space		0xFF80	/* space */
#define XK_KP_Tab		0xFF89
#define XK_KP_Enter		0xFF8D	/* enter */
#define XK_KP_F1		0xFF91	/* PF1, KP_A, ... */
#define XK_KP_F2		0xFF92
#define XK_KP_F3		0xFF93
#define XK_KP_F4		0xFF94
#define XK_KP_Home		0xFF95
#define XK_KP_Left		0xFF96
#define XK_KP_Up		0xFF97
#define XK_KP_Right		0xFF98
#define XK_KP_Down		0xFF99
#define XK_KP_Prior		0xFF9A
#define XK_KP_Page_Up		0xFF9A
#define XK_KP_Next		0xFF9B
#define XK_KP_Page_Down		0xFF9B
#define XK_KP_End		0xFF9C
#define XK_KP_Begin		0xFF9D
#define XK_KP_Insert		0xFF9E
#define XK_KP_Delete		0xFF9F
#define XK_KP_Equal		0xFFBD	/* equals */
#define XK_KP_Multiply		0xFFAA
#define XK_KP_Add		0xFFAB
#define XK_KP_Separator		0xFFAC	/* separator, often comma */
#define XK_KP_Subtract		0xFFAD
#define XK_KP_Decimal		0xFFAE
#define XK_KP_Divide		0xFFAF

#define XK_KP_0			0xFFB0
#define XK_KP_1			0xFFB1
#define XK_KP_2			0xFFB2
#define XK_KP_3			0xFFB3
#define XK_KP_4			0xFFB4
#define XK_KP_5			0xFFB5
#define XK_KP_6			0xFFB6
#define XK_KP_7			0xFFB7
#define XK_KP_8			0xFFB8
#define XK_KP_9			0xFFB9



/*
 * Auxilliary Functions; note the duplicate definitions for left and right
 * function keys;  Sun keyboards and a few other manufactures have such
 * function key groups on the left and/or right sides of the keyboard.
 * We've not found a keyboard with more than 35 function keys total.
 */

#define XK_F1			0xFFBE
#define XK_F2			0xFFBF
#define XK_F3			0xFFC0
#define XK_F4			0xFFC1
#define XK_F5			0xFFC2
#define XK_F6			0xFFC3
#define XK_F7			0xFFC4
#define XK_F8			0xFFC5
#define XK_F9			0xFFC6
#define XK_F10			0xFFC7
#define XK_F11			0xFFC8
#define XK_L1			0xFFC8
#define XK_F12			0xFFC9
#define XK_L2			0xFFC9
#define XK_F13			0xFFCA
#define XK_L3			0xFFCA
#define XK_F14			0xFFCB
#define XK_L4			0xFFCB
#define XK_F15			0xFFCC
#define XK_L5			0xFFCC
#define XK_F16			0xFFCD
#define XK_L6			0xFFCD
#define XK_F17			0xFFCE
#define XK_L7			0xFFCE
#define XK_F18			0xFFCF
#define XK_L8			0xFFCF
#define XK_F19			0xFFD0
#define XK_L9			0xFFD0
#define XK_F20			0xFFD1
#define XK_L10			0xFFD1
#define XK_F21			0xFFD2
#define XK_R1			0xFFD2
#define XK_F22			0xFFD3
#define XK_R2			0xFFD3
#define XK_F23			0xFFD4
#define XK_R3			0xFFD4
#define XK_F24			0xFFD5
#define XK_R4			0xFFD5
#define XK_F25			0xFFD6
#define XK_R5			0xFFD6
#define XK_F26			0xFFD7
#define XK_R6			0xFFD7
#define XK_F27			0xFFD8
#define XK_R7			0xFFD8
#define XK_F28			0xFFD9
#define XK_R8			0xFFD9
#define XK_F29			0xFFDA
#define XK_R9			0xFFDA
#define XK_F30			0xFFDB
#define XK_R10			0xFFDB
#define XK_F31			0xFFDC
#define XK_R11			0xFFDC
#define XK_F32			0xFFDD
#define XK_R12			0xFFDD
#define XK_F33			0xFFDE
#define XK_R13			0xFFDE
#define XK_F34			0xFFDF
#define XK_R14			0xFFDF
#define XK_F35			0xFFE0
#define XK_R15			0xFFE0

/* Modifiers */

#define XK_Shift_L		0xFFE1	/* Left shift */
#define XK_Shift_R		0xFFE2	/* Right shift */
#define XK_Control_L		0xFFE3	/* Left control */
#define XK_Control_R		0xFFE4	/* Right control */
#define XK_Caps_Lock		0xFFE5	/* Caps lock */
#define XK_Shift_Lock		0xFFE6	/* Shift lock */

#define XK_Meta_L		0xFFE7	/* Left meta */
#define XK_Meta_R		0xFFE8	/* Right meta */
#define XK_Alt_L		0xFFE9	/* Left alt */
#define XK_Alt_R		0xFFEA	/* Right alt */
#define XK_Super_L		0xFFEB	/* Left super */
#define XK_Super_R		0xFFEC	/* Right super */
#define XK_Hyper_L		0xFFED	/* Left hyper */
#define XK_Hyper_R		0xFFEE	/* Right hyper */
#endif /* XK_MISCELLANY */

/*
 * ISO 9995 Function and Modifier Keys
 * Byte 3 = 0xFE
 */

#define XK_XKB_KEYS
#ifdef XK_XKB_KEYS
#define	XK_ISO_Lock					0xFE01
#define	XK_ISO_Level2_Latch				0xFE02
#define	XK_ISO_Level3_Shift				0xFE03
#define	XK_ISO_Level3_Latch				0xFE04
#define	XK_ISO_Level3_Lock				0xFE05
#define	XK_ISO_Group_Shift		0xFF7E	/* Alias for mode_switch */
#define	XK_ISO_Group_Latch				0xFE06
#define	XK_ISO_Group_Lock				0xFE07
#define	XK_ISO_Next_Group				0xFE08
#define	XK_ISO_Next_Group_Lock				0xFE09
#define	XK_ISO_Prev_Group				0xFE0A
#define	XK_ISO_Prev_Group_Lock				0xFE0B
#define	XK_ISO_First_Group				0xFE0C
#define	XK_ISO_First_Group_Lock				0xFE0D
#define	XK_ISO_Last_Group				0xFE0E
#define	XK_ISO_Last_Group_Lock				0xFE0F

#define	XK_ISO_Left_Tab					0xFE20
#define	XK_ISO_Move_Line_Up				0xFE21
#define	XK_ISO_Move_Line_Down				0xFE22
#define	XK_ISO_Partial_Line_Up				0xFE23
#define	XK_ISO_Partial_Line_Down			0xFE24
#define	XK_ISO_Partial_Space_Left			0xFE25
#define	XK_ISO_Partial_Space_Right			0xFE26
#define	XK_ISO_Set_Margin_Left				0xFE27
#define	XK_ISO_Set_Margin_Right				0xFE28
#define	XK_ISO_Release_Margin_Left			0xFE29
#define	XK_ISO_Release_Margin_Right			0xFE2A
#define	XK_ISO_Release_Both_Margins			0xFE2B
#define	XK_ISO_Fast_Cursor_Left				0xFE2C
#define	XK_ISO_Fast_Cursor_Right			0xFE2D
#define	XK_ISO_Fast_Cursor_Up				0xFE2E
#define	XK_ISO_Fast_Cursor_Down				0xFE2F
#define	XK_ISO_Continuous_Underline			0xFE30
#define	XK_ISO_Discontinuous_Underline			0xFE31
#define	XK_ISO_Emphasize				0xFE32
#define	XK_ISO_Center_Object				0xFE33
#define	XK_ISO_Enter					0xFE34

#define	XK_dead_grave					0xFE50
#define	XK_dead_acute					0xFE51
#define	XK_dead_circumflex				0xFE52
#define	XK_dead_tilde					0xFE53
#define	XK_dead_macron					0xFE54
#define	XK_dead_breve					0xFE55
#define	XK_dead_abovedot				0xFE56
#define	XK_dead_diaeresis				0xFE57
#define	XK_dead_abovering				0xFE58
#define	XK_dead_doubleacute				0xFE59
#define	XK_dead_caron					0xFE5A
#define	XK_dead_cedilla					0xFE5B
#define	XK_dead_ogonek					0xFE5C
#define	XK_dead_iota					0xFE5D
#define	XK_dead_voiced_sound				0xFE5E
#define	XK_dead_semivoiced_sound			0xFE5F
#define	XK_dead_belowdot				0xFE60
#define XK_dead_hook					0xFE61
#define XK_dead_horn					0xFE62

#define	XK_First_Virtual_Screen				0xFED0
#define	XK_Prev_Virtual_Screen				0xFED1
#define	XK_Next_Virtual_Screen				0xFED2
#define	XK_Last_Virtual_Screen				0xFED4
#define	XK_Terminate_Server				0xFED5

#define	XK_AccessX_Enable				0xFE70
#define	XK_AccessX_Feedback_Enable			0xFE71
#define	XK_RepeatKeys_Enable				0xFE72
#define	XK_SlowKeys_Enable				0xFE73
#define	XK_BounceKeys_Enable				0xFE74
#define	XK_StickyKeys_Enable				0xFE75
#define	XK_MouseKeys_Enable				0xFE76
#define	XK_MouseKeys_Accel_Enable			0xFE77
#define	XK_Overlay1_Enable				0xFE78
#define	XK_Overlay2_Enable				0xFE79
#define	XK_AudibleBell_Enable				0xFE7A

#define	XK_Pointer_Left					0xFEE0
#define	XK_Pointer_Right				0xFEE1
#define	XK_Pointer_Up					0xFEE2
#define	XK_Pointer_Down					0xFEE3
#define	XK_Pointer_UpLeft				0xFEE4
#define	XK_Pointer_UpRight				0xFEE5
#define	XK_Pointer_DownLeft				0xFEE6
#define	XK_Pointer_DownRight				0xFEE7
#define	XK_Pointer_Button_Dflt				0xFEE8
#define	XK_Pointer_Button1				0xFEE9
#define	XK_Pointer_Button2				0xFEEA
#define	XK_Pointer_Button3				0xFEEB
#define	XK_Pointer_Button4				0xFEEC
#define	XK_Pointer_Button5				0xFEED
#define	XK_Pointer_DblClick_Dflt			0xFEEE
#define	XK_Pointer_DblClick1				0xFEEF
#define	XK_Pointer_DblClick2				0xFEF0
#define	XK_Pointer_DblClick3				0xFEF1
#define	XK_Pointer_DblClick4				0xFEF2
#define	XK_Pointer_DblClick5				0xFEF3
#define	XK_Pointer_Drag_Dflt				0xFEF4
#define	XK_Pointer_Drag1				0xFEF5
#define	XK_Pointer_Drag2				0xFEF6
#define	XK_Pointer_Drag3				0xFEF7
#define	XK_Pointer_Drag4				0xFEF8
#define	XK_Pointer_Drag5				0xFEFD

#define	XK_Pointer_EnableKeys				0xFEF9
#define	XK_Pointer_Accelerate				0xFEFA
#define	XK_Pointer_DfltBtnNext				0xFEFB
#define	XK_Pointer_DfltBtnPrev				0xFEFC

#endif

/*
 * 3270 Terminal Keys
 * Byte 3 = 0xFD
 */

#define XK_3270
#ifdef XK_3270
#define XK_3270_Duplicate      0xFD01
#define XK_3270_FieldMark      0xFD02
#define XK_3270_Right2         0xFD03
#define XK_3270_Left2          0xFD04
#define XK_3270_BackTab        0xFD05
#define XK_3270_EraseEOF       0xFD06
#define XK_3270_EraseInput     0xFD07
#define XK_3270_Reset          0xFD08
#define XK_3270_Quit           0xFD09
#define XK_3270_PA1            0xFD0A
#define XK_3270_PA2            0xFD0B
#define XK_3270_PA3            0xFD0C
#define XK_3270_Test           0xFD0D
#define XK_3270_Attn           0xFD0E
#define XK_3270_CursorBlink    0xFD0F
#define XK_3270_AltCursor      0xFD10
#define XK_3270_KeyClick       0xFD11
#define XK_3270_Jump           0xFD12
#define XK_3270_Ident          0xFD13
#define XK_3270_Rule           0xFD14
#define XK_3270_Copy           0xFD15
#define XK_3270_Play           0xFD16
#define XK_3270_Setup          0xFD17
#define XK_3270_Record         0xFD18
#define XK_3270_ChangeScreen   0xFD19
#define XK_3270_DeleteWord     0xFD1A
#define XK_3270_ExSelect       0xFD1B
#define XK_3270_CursorSelect   0xFD1C
#define XK_3270_PrintScreen    0xFD1D
#define XK_3270_Enter          0xFD1E
#endif

/*
 *  Latin 1
 *  Byte 3 = 0
 */
#define XK_LATIN1
#ifdef XK_LATIN1
#define XK_space               0x020
#define XK_exclam              0x021
#define XK_quotedbl            0x022
#define XK_numbersign          0x023
#define XK_dollar              0x024
#define XK_percent             0x025
#define XK_ampersand           0x026
#define XK_apostrophe          0x027
#define XK_quoteright          0x027	/* deprecated */
#define XK_parenleft           0x028
#define XK_parenright          0x029
#define XK_asterisk            0x02a
#define XK_plus                0x02b
#define XK_comma               0x02c
#define XK_minus               0x02d
#define XK_period              0x02e
#define XK_slash               0x02f
#define XK_0                   0x030
#define XK_1                   0x031
#define XK_2                   0x032
#define XK_3                   0x033
#define XK_4                   0x034
#define XK_5                   0x035
#define XK_6                   0x036
#define XK_7                   0x037
#define XK_8                   0x038
#define XK_9                   0x039
#define XK_colon               0x03a
#define XK_semicolon           0x03b
#define XK_less                0x03c
#define XK_equal               0x03d
#define XK_greater             0x03e
#define XK_question            0x03f
#define XK_at                  0x040
#define XK_A                   0x041
#define XK_B                   0x042
#define XK_C                   0x043
#define XK_D                   0x044
#define XK_E                   0x045
#define XK_F                   0x046
#define XK_G                   0x047
#define XK_H                   0x048
#define XK_I                   0x049
#define XK_J                   0x04a
#define XK_K                   0x04b
#define XK_L                   0x04c
#define XK_M                   0x04d
#define XK_N                   0x04e
#define XK_O                   0x04f
#define XK_P                   0x050
#define XK_Q                   0x051
#define XK_R                   0x052
#define XK_S                   0x053
#define XK_T                   0x054
#define XK_U                   0x055
#define XK_V                   0x056
#define XK_W                   0x057
#define XK_X                   0x058
#define XK_Y                   0x059
#define XK_Z                   0x05a
#define XK_bracketleft         0x05b
#define XK_backslash           0x05c
#define XK_bracketright        0x05d
#define XK_asciicircum         0x05e
#define XK_underscore          0x05f
#define XK_grave               0x060
#define XK_quoteleft           0x060	/* deprecated */
#define XK_a                   0x061
#define XK_b                   0x062
#define XK_c                   0x063
#define XK_d                   0x064
#define XK_e                   0x065
#define XK_f                   0x066
#define XK_g                   0x067
#define XK_h                   0x068
#define XK_i                   0x069
#define XK_j                   0x06a
#define XK_k                   0x06b
#define XK_l                   0x06c
#define XK_m                   0x06d
#define XK_n                   0x06e
#define XK_o                   0x06f
#define XK_p                   0x070
#define XK_q                   0x071
#define XK_r                   0x072
#define XK_s                   0x073
#define XK_t                   0x074
#define XK_u                   0x075
#define XK_v                   0x076
#define XK_w                   0x077
#define XK_x                   0x078
#define XK_y                   0x079
#define XK_z                   0x07a
#define XK_braceleft           0x07b
#define XK_bar                 0x07c
#define XK_braceright          0x07d
#define XK_asciitilde          0x07e

#define XK_nobreakspace        0x0a0
#define XK_exclamdown          0x0a1
#define XK_cent        	       0x0a2
#define XK_sterling            0x0a3
#define XK_currency            0x0a4
#define XK_yen                 0x0a5
#define XK_brokenbar           0x0a6
#define XK_section             0x0a7
#define XK_diaeresis           0x0a8
#define XK_copyright           0x0a9
#define XK_ordfeminine         0x0aa
#define XK_guillemotleft       0x0ab	/* left angle quotation mark */
#define XK_notsign             0x0ac
#define XK_hyphen              0x0ad
#define XK_registered          0x0ae
#define XK_macron              0x0af
#define XK_degree              0x0b0
#define XK_plusminus           0x0b1
#define XK_twosuperior         0x0b2
#define XK_threesuperior       0x0b3
#define XK_acute               0x0b4
#define XK_mu                  0x0b5
#define XK_paragraph           0x0b6
#define XK_periodcentered      0x0b7
#define XK_cedilla             0x0b8
#define XK_onesuperior         0x0b9
#define XK_masculine           0x0ba
#define XK_guillemotright      0x0bb	/* right angle quotation mark */
#define XK_onequarter          0x0bc
#define XK_onehalf             0x0bd
#define XK_threequarters       0x0be
#define XK_questiondown        0x0bf
#define XK_Agrave              0x0c0
#define XK_Aacute              0x0c1
#define XK_Acircumflex         0x0c2
#define XK_Atilde              0x0c3
#define XK_Adiaeresis          0x0c4
#define XK_Aring               0x0c5
#define XK_AE                  0x0c6
#define XK_Ccedilla            0x0c7
#define XK_Egrave              0x0c8
#define XK_Eacute              0x0c9
#define XK_Ecircumflex         0x0ca
#define XK_Ediaeresis          0x0cb
#define XK_Igrave              0x0cc
#define XK_Iacute              0x0cd
#define XK_Icircumflex         0x0ce
#define XK_Idiaeresis          0x0cf
#define XK_ETH                 0x0d0
#define XK_Eth                 0x0d0	/* deprecated */
#define XK_Ntilde              0x0d1
#define XK_Ograve              0x0d2
#define XK_Oacute              0x0d3
#define XK_Ocircumflex         0x0d4
#define XK_Otilde              0x0d5
#define XK_Odiaeresis          0x0d6
#define XK_multiply            0x0d7
#define XK_Ooblique            0x0d8
#define XK_Oslash              XK_Ooblique
#define XK_Ugrave              0x0d9
#define XK_Uacute              0x0da
#define XK_Ucircumflex         0x0db
#define XK_Udiaeresis          0x0dc
#define XK_Yacute              0x0dd
#define XK_THORN               0x0de
#define XK_Thorn               0x0de	/* deprecated */
#define XK_ssharp              0x0df
#define XK_agrave              0x0e0
#define XK_aacute              0x0e1
#define XK_acircumflex         0x0e2
#define XK_atilde              0x0e3
#define XK_adiaeresis          0x0e4
#define XK_aring               0x0e5
#define XK_ae                  0x0e6
#define XK_ccedilla            0x0e7
#define XK_egrave              0x0e8
#define XK_eacute              0x0e9
#define XK_ecircumflex         0x0ea
#define XK_ediaeresis          0x0eb
#define XK_igrave              0x0ec
#define XK_iacute              0x0ed
#define XK_icircumflex         0x0ee
#define XK_idiaeresis          0x0ef
#define XK_eth                 0x0f0
#define XK_ntilde              0x0f1
#define XK_ograve              0x0f2
#define XK_oacute              0x0f3
#define XK_ocircumflex         0x0f4
#define XK_otilde              0x0f5
#define XK_odiaeresis          0x0f6
#define XK_division            0x0f7
#define XK_oslash              0x0f8
#define XK_ooblique            XK_oslash
#define XK_ugrave              0x0f9
#define XK_uacute              0x0fa
#define XK_ucircumflex         0x0fb
#define XK_udiaeresis          0x0fc
#define XK_yacute              0x0fd
#define XK_thorn               0x0fe
#define XK_ydiaeresis          0x0ff
#endif /* XK_LATIN1 */

/*
 *   Latin 2
 *   Byte 3 = 1
 */

#define XK_LATIN2
#ifdef XK_LATIN2
#define XK_Aogonek             0x1a1
#define XK_breve               0x1a2
#define XK_Lstroke             0x1a3
#define XK_Lcaron              0x1a5
#define XK_Sacute              0x1a6
#define XK_Scaron              0x1a9
#define XK_Scedilla            0x1aa
#define XK_Tcaron              0x1ab
#define XK_Zacute              0x1ac
#define XK_Zcaron              0x1ae
#define XK_Zabovedot           0x1af
#define XK_aogonek             0x1b1
#define XK_ogonek              0x1b2
#define XK_lstroke             0x1b3
#define XK_lcaron              0x1b5
#define XK_sacute              0x1b6
#define XK_caron               0x1b7
#define XK_scaron              0x1b9
#define XK_scedilla            0x1ba
#define XK_tcaron              0x1bb
#define XK_zacute              0x1bc
#define XK_doubleacute         0x1bd
#define XK_zcaron              0x1be
#define XK_zabovedot           0x1bf
#define XK_Racute              0x1c0
#define XK_Abreve              0x1c3
#define XK_Lacute              0x1c5
#define XK_Cacute              0x1c6
#define XK_Ccaron              0x1c8
#define XK_Eogonek             0x1ca
#define XK_Ecaron              0x1cc
#define XK_Dcaron              0x1cf
#define XK_Dstroke             0x1d0
#define XK_Nacute              0x1d1
#define XK_Ncaron              0x1d2
#define XK_Odoubleacute        0x1d5
#define XK_Rcaron              0x1d8
#define XK_Uring               0x1d9
#define XK_Udoubleacute        0x1db
#define XK_Tcedilla            0x1de
#define XK_racute              0x1e0
#define XK_abreve              0x1e3
#define XK_lacute              0x1e5
#define XK_cacute              0x1e6
#define XK_ccaron              0x1e8
#define XK_eogonek             0x1ea
#define XK_ecaron              0x1ec
#define XK_dcaron              0x1ef
#define XK_dstroke             0x1f0
#define XK_nacute              0x1f1
#define XK_ncaron              0x1f2
#define XK_odoubleacute        0x1f5
#define XK_udoubleacute        0x1fb
#define XK_rcaron              0x1f8
#define XK_uring               0x1f9
#define XK_tcedilla            0x1fe
#define XK_abovedot            0x1ff
#endif /* XK_LATIN2 */

/*
 *   Latin 3
 *   Byte 3 = 2
 */

#define XK_LATIN3
#ifdef XK_LATIN3
#define XK_Hstroke             0x2a1
#define XK_Hcircumflex         0x2a6
#define XK_Iabovedot           0x2a9
#define XK_Gbreve              0x2ab
#define XK_Jcircumflex         0x2ac
#define XK_hstroke             0x2b1
#define XK_hcircumflex         0x2b6
#define XK_idotless            0x2b9
#define XK_gbreve              0x2bb
#define XK_jcircumflex         0x2bc
#define XK_Cabovedot           0x2c5
#define XK_Ccircumflex         0x2c6
#define XK_Gabovedot           0x2d5
#define XK_Gcircumflex         0x2d8
#define XK_Ubreve              0x2dd
#define XK_Scircumflex         0x2de
#define XK_cabovedot           0x2e5
#define XK_ccircumflex         0x2e6
#define XK_gabovedot           0x2f5
#define XK_gcircumflex         0x2f8
#define XK_ubreve              0x2fd
#define XK_scircumflex         0x2fe
#endif /* XK_LATIN3 */


/*
 *   Latin 4
 *   Byte 3 = 3
 */

#define XK_LATIN4
#ifdef XK_LATIN4
#define XK_kra                 0x3a2
#define XK_kappa               0x3a2	/* deprecated */
#define XK_Rcedilla            0x3a3
#define XK_Itilde              0x3a5
#define XK_Lcedilla            0x3a6
#define XK_Emacron             0x3aa
#define XK_Gcedilla            0x3ab
#define XK_Tslash              0x3ac
#define XK_rcedilla            0x3b3
#define XK_itilde              0x3b5
#define XK_lcedilla            0x3b6
#define XK_emacron             0x3ba
#define XK_gcedilla            0x3bb
#define XK_tslash              0x3bc
#define XK_ENG                 0x3bd
#define XK_eng                 0x3bf
#define XK_Amacron             0x3c0
#define XK_Iogonek             0x3c7
#define XK_Eabovedot           0x3cc
#define XK_Imacron             0x3cf
#define XK_Ncedilla            0x3d1
#define XK_Omacron             0x3d2
#define XK_Kcedilla            0x3d3
#define XK_Uogonek             0x3d9
#define XK_Utilde              0x3dd
#define XK_Umacron             0x3de
#define XK_amacron             0x3e0
#define XK_iogonek             0x3e7
#define XK_eabovedot           0x3ec
#define XK_imacron             0x3ef
#define XK_ncedilla            0x3f1
#define XK_omacron             0x3f2
#define XK_kcedilla            0x3f3
#define XK_uogonek             0x3f9
#define XK_utilde              0x3fd
#define XK_umacron             0x3fe
#endif /* XK_LATIN4 */

/*
 * Latin-8
 * Byte 3 = 18
 */
#define XK_LATIN8
#ifdef XK_LATIN8
#define XK_Babovedot           0x12a1
#define XK_babovedot           0x12a2
#define XK_Dabovedot           0x12a6
#define XK_Wgrave              0x12a8
#define XK_Wacute              0x12aa
#define XK_dabovedot           0x12ab
#define XK_Ygrave              0x12ac
#define XK_Fabovedot           0x12b0
#define XK_fabovedot           0x12b1
#define XK_Mabovedot           0x12b4
#define XK_mabovedot           0x12b5
#define XK_Pabovedot           0x12b7
#define XK_wgrave              0x12b8
#define XK_pabovedot           0x12b9
#define XK_wacute              0x12ba
#define XK_Sabovedot           0x12bb
#define XK_ygrave              0x12bc
#define XK_Wdiaeresis          0x12bd
#define XK_wdiaeresis          0x12be
#define XK_sabovedot           0x12bf
#define XK_Wcircumflex         0x12d0
#define XK_Tabovedot           0x12d7
#define XK_Ycircumflex         0x12de
#define XK_wcircumflex         0x12f0
#define XK_tabovedot           0x12f7
#define XK_ycircumflex         0x12fe
#endif /* XK_LATIN8 */

/*
 * Latin-9 (a.k.a. Latin-0)
 * Byte 3 = 19
 */

#define XK_LATIN9
#ifdef XK_LATIN9
#define XK_OE                  0x13bc
#define XK_oe                  0x13bd
#define XK_Ydiaeresis          0x13be
#endif /* XK_LATIN9 */

/*
 * Katakana
 * Byte 3 = 4
 */

#define XK_KATAKANA
#ifdef XK_KATAKANA
#define XK_overline				       0x47e
#define XK_kana_fullstop                               0x4a1
#define XK_kana_openingbracket                         0x4a2
#define XK_kana_closingbracket                         0x4a3
#define XK_kana_comma                                  0x4a4
#define XK_kana_conjunctive                            0x4a5
#define XK_kana_middledot                              0x4a5  /* deprecated */
#define XK_kana_WO                                     0x4a6
#define XK_kana_a                                      0x4a7
#define XK_kana_i                                      0x4a8
#define XK_kana_u                                      0x4a9
#define XK_kana_e                                      0x4aa
#define XK_kana_o                                      0x4ab
#define XK_kana_ya                                     0x4ac
#define XK_kana_yu                                     0x4ad
#define XK_kana_yo                                     0x4ae
#define XK_kana_tsu                                    0x4af
#define XK_kana_tu                                     0x4af  /* deprecated */
#define XK_prolongedsound                              0x4b0
#define XK_kana_A                                      0x4b1
#define XK_kana_I                                      0x4b2
#define XK_kana_U                                      0x4b3
#define XK_kana_E                                      0x4b4
#define XK_kana_O                                      0x4b5
#define XK_kana_KA                                     0x4b6
#define XK_kana_KI                                     0x4b7
#define XK_kana_KU                                     0x4b8
#define XK_kana_KE                                     0x4b9
#define XK_kana_KO                                     0x4ba
#define XK_kana_SA                                     0x4bb
#define XK_kana_SHI                                    0x4bc
#define XK_kana_SU                                     0x4bd
#define XK_kana_SE                                     0x4be
#define XK_kana_SO                                     0x4bf
#define XK_kana_TA                                     0x4c0
#define XK_kana_CHI                                    0x4c1
#define XK_kana_TI                                     0x4c1  /* deprecated */
#define XK_kana_TSU                                    0x4c2
#define XK_kana_TU                                     0x4c2  /* deprecated */
#define XK_kana_TE                                     0x4c3
#define XK_kana_TO                                     0x4c4
#define XK_kana_NA                                     0x4c5
#define XK_kana_NI                                     0x4c6
#define XK_kana_NU                                     0x4c7
#define XK_kana_NE                                     0x4c8
#define XK_kana_NO                                     0x4c9
#define XK_kana_HA                                     0x4ca
#define XK_kana_HI                                     0x4cb
#define XK_kana_FU                                     0x4cc
#define XK_kana_HU                                     0x4cc  /* deprecated */
#define XK_kana_HE                                     0x4cd
#define XK_kana_HO                                     0x4ce
#define XK_kana_MA                                     0x4cf
#define XK_kana_MI                                     0x4d0
#define XK_kana_MU                                     0x4d1
#define XK_kana_ME                                     0x4d2
#define XK_kana_MO                                     0x4d3
#define XK_kana_YA                                     0x4d4
#define XK_kana_YU                                     0x4d5
#define XK_kana_YO                                     0x4d6
#define XK_kana_RA                                     0x4d7
#define XK_kana_RI                                     0x4d8
#define XK_kana_RU                                     0x4d9
#define XK_kana_RE                                     0x4da
#define XK_kana_RO                                     0x4db
#define XK_kana_WA                                     0x4dc
#define XK_kana_N                                      0x4dd
#define XK_voicedsound                                 0x4de
#define XK_semivoicedsound                             0x4df
#define XK_kana_switch          0xFF7E  /* Alias for mode_switch */
#endif /* XK_KATAKANA */

/*
 *  Arabic
 *  Byte 3 = 5
 */

#define XK_ARABIC
#ifdef XK_ARABIC
#define XK_Farsi_0                                     0x590
#define XK_Farsi_1                                     0x591
#define XK_Farsi_2                                     0x592
#define XK_Farsi_3                                     0x593
#define XK_Farsi_4                                     0x594
#define XK_Farsi_5                                     0x595
#define XK_Farsi_6                                     0x596
#define XK_Farsi_7                                     0x597
#define XK_Farsi_8                                     0x598
#define XK_Farsi_9                                     0x599
#define XK_Arabic_percent                              0x5a5
#define XK_Arabic_superscript_alef                     0x5a6
#define XK_Arabic_tteh                                 0x5a7
#define XK_Arabic_peh                                  0x5a8
#define XK_Arabic_tcheh                                0x5a9
#define XK_Arabic_ddal                                 0x5aa
#define XK_Arabic_rreh                                 0x5ab
#define XK_Arabic_comma                                0x5ac
#define XK_Arabic_fullstop                             0x5ae
#define XK_Arabic_0                                    0x5b0
#define XK_Arabic_1                                    0x5b1
#define XK_Arabic_2                                    0x5b2
#define XK_Arabic_3                                    0x5b3
#define XK_Arabic_4                                    0x5b4
#define XK_Arabic_5                                    0x5b5
#define XK_Arabic_6                                    0x5b6
#define XK_Arabic_7                                    0x5b7
#define XK_Arabic_8                                    0x5b8
#define XK_Arabic_9                                    0x5b9
#define XK_Arabic_semicolon                            0x5bb
#define XK_Arabic_question_mark                        0x5bf
#define XK_Arabic_hamza                                0x5c1
#define XK_Arabic_maddaonalef                          0x5c2
#define XK_Arabic_hamzaonalef                          0x5c3
#define XK_Arabic_hamzaonwaw                           0x5c4
#define XK_Arabic_hamzaunderalef                       0x5c5
#define XK_Arabic_hamzaonyeh                           0x5c6
#define XK_Arabic_alef                                 0x5c7
#define XK_Arabic_beh                                  0x5c8
#define XK_Arabic_tehmarbuta                           0x5c9
#define XK_Arabic_teh                                  0x5ca
#define XK_Arabic_theh                                 0x5cb
#define XK_Arabic_jeem                                 0x5cc
#define XK_Arabic_hah                                  0x5cd
#define XK_Arabic_khah                                 0x5ce
#define XK_Arabic_dal                                  0x5cf
#define XK_Arabic_thal                                 0x5d0
#define XK_Arabic_ra                                   0x5d1
#define XK_Arabic_zain                                 0x5d2
#define XK_Arabic_seen                                 0x5d3
#define XK_Arabic_sheen                                0x5d4
#define XK_Arabic_sad                                  0x5d5
#define XK_Arabic_dad                                  0x5d6
#define XK_Arabic_tah                                  0x5d7
#define XK_Arabic_zah                                  0x5d8
#define XK_Arabic_ain                                  0x5d9
#define XK_Arabic_ghain                                0x5da
#define XK_Arabic_tatweel                              0x5e0
#define XK_Arabic_feh                                  0x5e1
#define XK_Arabic_qaf                                  0x5e2
#define XK_Arabic_kaf                                  0x5e3
#define XK_Arabic_lam                                  0x5e4
#define XK_Arabic_meem                                 0x5e5
#define XK_Arabic_noon                                 0x5e6
#define XK_Arabic_ha                                   0x5e7
#define XK_Arabic_heh                                  0x5e7  /* deprecated */
#define XK_Arabic_waw                                  0x5e8
#define XK_Arabic_alefmaksura                          0x5e9
#define XK_Arabic_yeh                                  0x5ea
#define XK_Arabic_fathatan                             0x5eb
#define XK_Arabic_dammatan                             0x5ec
#define XK_Arabic_kasratan                             0x5ed
#define XK_Arabic_fatha                                0x5ee
#define XK_Arabic_damma                                0x5ef
#define XK_Arabic_kasra                                0x5f0
#define XK_Arabic_shadda                               0x5f1
#define XK_Arabic_sukun                                0x5f2
#define XK_Arabic_madda_above                          0x5f3
#define XK_Arabic_hamza_above                          0x5f4
#define XK_Arabic_hamza_below                          0x5f5
#define XK_Arabic_jeh                                  0x5f6
#define XK_Arabic_veh                                  0x5f7
#define XK_Arabic_keheh                                0x5f8
#define XK_Arabic_gaf                                  0x5f9
#define XK_Arabic_noon_ghunna                          0x5fa
#define XK_Arabic_heh_doachashmee                      0x5fb
#define XK_Farsi_yeh                                   0x5fc
#define XK_Arabic_farsi_yeh                     XK_Farsi_yeh
#define XK_Arabic_yeh_baree                            0x5fd
#define XK_Arabic_heh_goal                             0x5fe
#define XK_Arabic_switch        0xFF7E  /* Alias for mode_switch */
#endif /* XK_ARABIC */

/*
 * Cyrillic
 * Byte 3 = 6
 */
#define XK_CYRILLIC
#ifdef XK_CYRILLIC
#define XK_Cyrillic_GHE_bar	                           0x680
#define XK_Cyrillic_ghe_bar	                           0x690
#define XK_Cyrillic_ZHE_descender	                   0x681
#define XK_Cyrillic_zhe_descender	                   0x691
#define XK_Cyrillic_KA_descender	                   0x682
#define XK_Cyrillic_ka_descender	                   0x692
#define XK_Cyrillic_KA_vertstroke	                   0x683
#define XK_Cyrillic_ka_vertstroke	                   0x693
#define XK_Cyrillic_EN_descender	                   0x684
#define XK_Cyrillic_en_descender	                   0x694
#define XK_Cyrillic_U_straight	                       0x685
#define XK_Cyrillic_u_straight	                       0x695
#define XK_Cyrillic_U_straight_bar	                   0x686
#define XK_Cyrillic_u_straight_bar	                   0x696
#define XK_Cyrillic_HA_descender	                   0x687
#define XK_Cyrillic_ha_descender	                   0x697
#define XK_Cyrillic_CHE_descender	                   0x688
#define XK_Cyrillic_che_descender	                   0x698
#define XK_Cyrillic_CHE_vertstroke	                   0x689
#define XK_Cyrillic_che_vertstroke	                   0x699
#define XK_Cyrillic_SHHA	                           0x68a
#define XK_Cyrillic_shha	                           0x69a

#define XK_Cyrillic_SCHWA	                           0x68c
#define XK_Cyrillic_schwa	                           0x69c
#define XK_Cyrillic_I_macron		                   0x68d
#define XK_Cyrillic_i_macron		                   0x69d
#define XK_Cyrillic_O_bar	                           0x68e
#define XK_Cyrillic_o_bar	                           0x69e
#define XK_Cyrillic_U_macron		                   0x68f
#define XK_Cyrillic_u_macron		                   0x69f

#define XK_Serbian_dje                                 0x6a1
#define XK_Macedonia_gje                               0x6a2
#define XK_Cyrillic_io                                 0x6a3
#define XK_Ukrainian_ie                                0x6a4
#define XK_Ukranian_je                                 0x6a4  /* deprecated */
#define XK_Macedonia_dse                               0x6a5
#define XK_Ukrainian_i                                 0x6a6
#define XK_Ukranian_i                                  0x6a6  /* deprecated */
#define XK_Ukrainian_yi                                0x6a7
#define XK_Ukranian_yi                                 0x6a7  /* deprecated */
#define XK_Cyrillic_je                                 0x6a8
#define XK_Serbian_je                                  0x6a8  /* deprecated */
#define XK_Cyrillic_lje                                0x6a9
#define XK_Serbian_lje                                 0x6a9  /* deprecated */
#define XK_Cyrillic_nje                                0x6aa
#define XK_Serbian_nje                                 0x6aa  /* deprecated */
#define XK_Serbian_tshe                                0x6ab
#define XK_Macedonia_kje                               0x6ac
#define XK_Ukrainian_ghe_with_upturn                   0x6ad
#define XK_Byelorussian_shortu                         0x6ae
#define XK_Cyrillic_dzhe                               0x6af
#define XK_Serbian_dze                                 0x6af  /* deprecated */
#define XK_numerosign                                  0x6b0
#define XK_Serbian_DJE                                 0x6b1
#define XK_Macedonia_GJE                               0x6b2
#define XK_Cyrillic_IO                                 0x6b3
#define XK_Ukrainian_IE                                0x6b4
#define XK_Ukranian_JE                                 0x6b4  /* deprecated */
#define XK_Macedonia_DSE                               0x6b5
#define XK_Ukrainian_I                                 0x6b6
#define XK_Ukranian_I                                  0x6b6  /* deprecated */
#define XK_Ukrainian_YI                                0x6b7
#define XK_Ukranian_YI                                 0x6b7  /* deprecated */
#define XK_Cyrillic_JE                                 0x6b8
#define XK_Serbian_JE                                  0x6b8  /* deprecated */
#define XK_Cyrillic_LJE                                0x6b9
#define XK_Serbian_LJE                                 0x6b9  /* deprecated */
#define XK_Cyrillic_NJE                                0x6ba
#define XK_Serbian_NJE                                 0x6ba  /* deprecated */
#define XK_Serbian_TSHE                                0x6bb
#define XK_Macedonia_KJE                               0x6bc
#define XK_Ukrainian_GHE_WITH_UPTURN                   0x6bd
#define XK_Byelorussian_SHORTU                         0x6be
#define XK_Cyrillic_DZHE                               0x6bf
#define XK_Serbian_DZE                                 0x6bf  /* deprecated */
#define XK_Cyrillic_yu                                 0x6c0
#define XK_Cyrillic_a                                  0x6c1
#define XK_Cyrillic_be                                 0x6c2
#define XK_Cyrillic_tse                                0x6c3
#define XK_Cyrillic_de                                 0x6c4
#define XK_Cyrillic_ie                                 0x6c5
#define XK_Cyrillic_ef                                 0x6c6
#define XK_Cyrillic_ghe                                0x6c7
#define XK_Cyrillic_ha                                 0x6c8
#define XK_Cyrillic_i                                  0x6c9
#define XK_Cyrillic_shorti                             0x6ca
#define XK_Cyrillic_ka                                 0x6cb
#define XK_Cyrillic_el                                 0x6cc
#define XK_Cyrillic_em                                 0x6cd
#define XK_Cyrillic_en                                 0x6ce
#define XK_Cyrillic_o                                  0x6cf
#define XK_Cyrillic_pe                                 0x6d0
#define XK_Cyrillic_ya                                 0x6d1
#define XK_Cyrillic_er                                 0x6d2
#define XK_Cyrillic_es                                 0x6d3
#define XK_Cyrillic_te                                 0x6d4
#define XK_Cyrillic_u                                  0x6d5
#define XK_Cyrillic_zhe                                0x6d6
#define XK_Cyrillic_ve                                 0x6d7
#define XK_Cyrillic_softsign                           0x6d8
#define XK_Cyrillic_yeru                               0x6d9
#define XK_Cyrillic_ze                                 0x6da
#define XK_Cyrillic_sha                                0x6db
#define XK_Cyrillic_e                                  0x6dc
#define XK_Cyrillic_shcha                              0x6dd
#define XK_Cyrillic_che                                0x6de
#define XK_Cyrillic_hardsign                           0x6df
#define XK_Cyrillic_YU                                 0x6e0
#define XK_Cyrillic_A                                  0x6e1
#define XK_Cyrillic_BE                                 0x6e2
#define XK_Cyrillic_TSE                                0x6e3
#define XK_Cyrillic_DE                                 0x6e4
#define XK_Cyrillic_IE                                 0x6e5
#define XK_Cyrillic_EF                                 0x6e6
#define XK_Cyrillic_GHE                                0x6e7
#define XK_Cyrillic_HA                                 0x6e8
#define XK_Cyrillic_I                                  0x6e9
#define XK_Cyrillic_SHORTI                             0x6ea
#define XK_Cyrillic_KA                                 0x6eb
#define XK_Cyrillic_EL                                 0x6ec
#define XK_Cyrillic_EM                                 0x6ed
#define XK_Cyrillic_EN                                 0x6ee
#define XK_Cyrillic_O                                  0x6ef
#define XK_Cyrillic_PE                                 0x6f0
#define XK_Cyrillic_YA                                 0x6f1
#define XK_Cyrillic_ER                                 0x6f2
#define XK_Cyrillic_ES                                 0x6f3
#define XK_Cyrillic_TE                                 0x6f4
#define XK_Cyrillic_U                                  0x6f5
#define XK_Cyrillic_ZHE                                0x6f6
#define XK_Cyrillic_VE                                 0x6f7
#define XK_Cyrillic_SOFTSIGN                           0x6f8
#define XK_Cyrillic_YERU                               0x6f9
#define XK_Cyrillic_ZE                                 0x6fa
#define XK_Cyrillic_SHA                                0x6fb
#define XK_Cyrillic_E                                  0x6fc
#define XK_Cyrillic_SHCHA                              0x6fd
#define XK_Cyrillic_CHE                                0x6fe
#define XK_Cyrillic_HARDSIGN                           0x6ff
#endif /* XK_CYRILLIC */

/*
 * Greek
 * Byte 3 = 7
 */

#define XK_GREEK
#ifdef XK_GREEK
#define XK_Greek_ALPHAaccent                           0x7a1
#define XK_Greek_EPSILONaccent                         0x7a2
#define XK_Greek_ETAaccent                             0x7a3
#define XK_Greek_IOTAaccent                            0x7a4
#define XK_Greek_IOTAdieresis                          0x7a5
#define XK_Greek_IOTAdiaeresis         XK_Greek_IOTAdieresis /* old typo */
#define XK_Greek_OMICRONaccent                         0x7a7
#define XK_Greek_UPSILONaccent                         0x7a8
#define XK_Greek_UPSILONdieresis                       0x7a9
#define XK_Greek_OMEGAaccent                           0x7ab
#define XK_Greek_accentdieresis                        0x7ae
#define XK_Greek_horizbar                              0x7af
#define XK_Greek_alphaaccent                           0x7b1
#define XK_Greek_epsilonaccent                         0x7b2
#define XK_Greek_etaaccent                             0x7b3
#define XK_Greek_iotaaccent                            0x7b4
#define XK_Greek_iotadieresis                          0x7b5
#define XK_Greek_iotaaccentdieresis                    0x7b6
#define XK_Greek_omicronaccent                         0x7b7
#define XK_Greek_upsilonaccent                         0x7b8
#define XK_Greek_upsilondieresis                       0x7b9
#define XK_Greek_upsilonaccentdieresis                 0x7ba
#define XK_Greek_omegaaccent                           0x7bb
#define XK_Greek_ALPHA                                 0x7c1
#define XK_Greek_BETA                                  0x7c2
#define XK_Greek_GAMMA                                 0x7c3
#define XK_Greek_DELTA                                 0x7c4
#define XK_Greek_EPSILON                               0x7c5
#define XK_Greek_ZETA                                  0x7c6
#define XK_Greek_ETA                                   0x7c7
#define XK_Greek_THETA                                 0x7c8
#define XK_Greek_IOTA                                  0x7c9
#define XK_Greek_KAPPA                                 0x7ca
#define XK_Greek_LAMDA                                 0x7cb
#define XK_Greek_LAMBDA                                0x7cb
#define XK_Greek_MU                                    0x7cc
#define XK_Greek_NU                                    0x7cd
#define XK_Greek_XI                                    0x7ce
#define XK_Greek_OMICRON                               0x7cf
#define XK_Greek_PI                                    0x7d0
#define XK_Greek_RHO                                   0x7d1
#define XK_Greek_SIGMA                                 0x7d2
#define XK_Greek_TAU                                   0x7d4
#define XK_Greek_UPSILON                               0x7d5
#define XK_Greek_PHI                                   0x7d6
#define XK_Greek_CHI                                   0x7d7
#define XK_Greek_PSI                                   0x7d8
#define XK_Greek_OMEGA                                 0x7d9
#define XK_Greek_alpha                                 0x7e1
#define XK_Greek_beta                                  0x7e2
#define XK_Greek_gamma                                 0x7e3
#define XK_Greek_delta                                 0x7e4
#define XK_Greek_epsilon                               0x7e5
#define XK_Greek_zeta                                  0x7e6
#define XK_Greek_eta                                   0x7e7
#define XK_Greek_theta                                 0x7e8
#define XK_Greek_iota                                  0x7e9
#define XK_Greek_kappa                                 0x7ea
#define XK_Greek_lamda                                 0x7eb
#define XK_Greek_lambda                                0x7eb
#define XK_Greek_mu                                    0x7ec
#define XK_Greek_nu                                    0x7ed
#define XK_Greek_xi                                    0x7ee
#define XK_Greek_omicron                               0x7ef
#define XK_Greek_pi                                    0x7f0
#define XK_Greek_rho                                   0x7f1
#define XK_Greek_sigma                                 0x7f2
#define XK_Greek_finalsmallsigma                       0x7f3
#define XK_Greek_tau                                   0x7f4
#define XK_Greek_upsilon                               0x7f5
#define XK_Greek_phi                                   0x7f6
#define XK_Greek_chi                                   0x7f7
#define XK_Greek_psi                                   0x7f8
#define XK_Greek_omega                                 0x7f9
#define XK_Greek_switch         0xFF7E  /* Alias for mode_switch */
#endif /* XK_GREEK */

/*
 * Technical
 * Byte 3 = 8
 */

#define XK_TECHNICAL
#ifdef XK_TECHNICAL
#define XK_leftradical                                 0x8a1
#define XK_topleftradical                              0x8a2
#define XK_horizconnector                              0x8a3
#define XK_topintegral                                 0x8a4
#define XK_botintegral                                 0x8a5
#define XK_vertconnector                               0x8a6
#define XK_topleftsqbracket                            0x8a7
#define XK_botleftsqbracket                            0x8a8
#define XK_toprightsqbracket                           0x8a9
#define XK_botrightsqbracket                           0x8aa
#define XK_topleftparens                               0x8ab
#define XK_botleftparens                               0x8ac
#define XK_toprightparens                              0x8ad
#define XK_botrightparens                              0x8ae
#define XK_leftmiddlecurlybrace                        0x8af
#define XK_rightmiddlecurlybrace                       0x8b0
#define XK_topleftsummation                            0x8b1
#define XK_botleftsummation                            0x8b2
#define XK_topvertsummationconnector                   0x8b3
#define XK_botvertsummationconnector                   0x8b4
#define XK_toprightsummation                           0x8b5
#define XK_botrightsummation                           0x8b6
#define XK_rightmiddlesummation                        0x8b7
#define XK_lessthanequal                               0x8bc
#define XK_notequal                                    0x8bd
#define XK_greaterthanequal                            0x8be
#define XK_integral                                    0x8bf
#define XK_therefore                                   0x8c0
#define XK_variation                                   0x8c1
#define XK_infinity                                    0x8c2
#define XK_nabla                                       0x8c5
#define XK_approximate                                 0x8c8
#define XK_similarequal                                0x8c9
#define XK_ifonlyif                                    0x8cd
#define XK_implies                                     0x8ce
#define XK_identical                                   0x8cf
#define XK_radical                                     0x8d6
#define XK_includedin                                  0x8da
#define XK_includes                                    0x8db
#define XK_intersection                                0x8dc
#define XK_union                                       0x8dd
#define XK_logicaland                                  0x8de
#define XK_logicalor                                   0x8df
#define XK_partialderivative                           0x8ef
#define XK_function                                    0x8f6
#define XK_leftarrow                                   0x8fb
#define XK_uparrow                                     0x8fc
#define XK_rightarrow                                  0x8fd
#define XK_downarrow                                   0x8fe
#endif /* XK_TECHNICAL */

/*
 *  Special
 *  Byte 3 = 9
 */

#define XK_SPECIAL
#ifdef XK_SPECIAL
#define XK_blank                                       0x9df
#define XK_soliddiamond                                0x9e0
#define XK_checkerboard                                0x9e1
#define XK_ht                                          0x9e2
#define XK_ff                                          0x9e3
#define XK_cr                                          0x9e4
#define XK_lf                                          0x9e5
#define XK_nl                                          0x9e8
#define XK_vt                                          0x9e9
#define XK_lowrightcorner                              0x9ea
#define XK_uprightcorner                               0x9eb
#define XK_upleftcorner                                0x9ec
#define XK_lowleftcorner                               0x9ed
#define XK_crossinglines                               0x9ee
#define XK_horizlinescan1                              0x9ef
#define XK_horizlinescan3                              0x9f0
#define XK_horizlinescan5                              0x9f1
#define XK_horizlinescan7                              0x9f2
#define XK_horizlinescan9                              0x9f3
#define XK_leftt                                       0x9f4
#define XK_rightt                                      0x9f5
#define XK_bott                                        0x9f6
#define XK_topt                                        0x9f7
#define XK_vertbar                                     0x9f8
#endif /* XK_SPECIAL */

/*
 *  Publishing
 *  Byte 3 = a
 */

#define XK_PUBLISHING
#ifdef XK_PUBLISHING
#define XK_emspace                                     0xaa1
#define XK_enspace                                     0xaa2
#define XK_em3space                                    0xaa3
#define XK_em4space                                    0xaa4
#define XK_digitspace                                  0xaa5
#define XK_punctspace                                  0xaa6
#define XK_thinspace                                   0xaa7
#define XK_hairspace                                   0xaa8
#define XK_emdash                                      0xaa9
#define XK_endash                                      0xaaa
#define XK_signifblank                                 0xaac
#define XK_ellipsis                                    0xaae
#define XK_doubbaselinedot                             0xaaf
#define XK_onethird                                    0xab0
#define XK_twothirds                                   0xab1
#define XK_onefifth                                    0xab2
#define XK_twofifths                                   0xab3
#define XK_threefifths                                 0xab4
#define XK_fourfifths                                  0xab5
#define XK_onesixth                                    0xab6
#define XK_fivesixths                                  0xab7
#define XK_careof                                      0xab8
#define XK_figdash                                     0xabb
#define XK_leftanglebracket                            0xabc
#define XK_decimalpoint                                0xabd
#define XK_rightanglebracket                           0xabe
#define XK_marker                                      0xabf
#define XK_oneeighth                                   0xac3
#define XK_threeeighths                                0xac4
#define XK_fiveeighths                                 0xac5
#define XK_seveneighths                                0xac6
#define XK_trademark                                   0xac9
#define XK_signaturemark                               0xaca
#define XK_trademarkincircle                           0xacb
#define XK_leftopentriangle                            0xacc
#define XK_rightopentriangle                           0xacd
#define XK_emopencircle                                0xace
#define XK_emopenrectangle                             0xacf
#define XK_leftsinglequotemark                         0xad0
#define XK_rightsinglequotemark                        0xad1
#define XK_leftdoublequotemark                         0xad2
#define XK_rightdoublequotemark                        0xad3
#define XK_prescription                                0xad4
#define XK_minutes                                     0xad6
#define XK_seconds                                     0xad7
#define XK_latincross                                  0xad9
#define XK_hexagram                                    0xada
#define XK_filledrectbullet                            0xadb
#define XK_filledlefttribullet                         0xadc
#define XK_filledrighttribullet                        0xadd
#define XK_emfilledcircle                              0xade
#define XK_emfilledrect                                0xadf
#define XK_enopencircbullet                            0xae0
#define XK_enopensquarebullet                          0xae1
#define XK_openrectbullet                              0xae2
#define XK_opentribulletup                             0xae3
#define XK_opentribulletdown                           0xae4
#define XK_openstar                                    0xae5
#define XK_enfilledcircbullet                          0xae6
#define XK_enfilledsqbullet                            0xae7
#define XK_filledtribulletup                           0xae8
#define XK_filledtribulletdown                         0xae9
#define XK_leftpointer                                 0xaea
#define XK_rightpointer                                0xaeb
#define XK_club                                        0xaec
#define XK_diamond                                     0xaed
#define XK_heart                                       0xaee
#define XK_maltesecross                                0xaf0
#define XK_dagger                                      0xaf1
#define XK_doubledagger                                0xaf2
#define XK_checkmark                                   0xaf3
#define XK_ballotcross                                 0xaf4
#define XK_musicalsharp                                0xaf5
#define XK_musicalflat                                 0xaf6
#define XK_malesymbol                                  0xaf7
#define XK_femalesymbol                                0xaf8
#define XK_telephone                                   0xaf9
#define XK_telephonerecorder                           0xafa
#define XK_phonographcopyright                         0xafb
#define XK_caret                                       0xafc
#define XK_singlelowquotemark                          0xafd
#define XK_doublelowquotemark                          0xafe
#define XK_cursor                                      0xaff
#endif /* XK_PUBLISHING */

/*
 *  APL
 *  Byte 3 = b
 */

#define XK_APL
#ifdef XK_APL
#define XK_leftcaret                                   0xba3
#define XK_rightcaret                                  0xba6
#define XK_downcaret                                   0xba8
#define XK_upcaret                                     0xba9
#define XK_overbar                                     0xbc0
#define XK_downtack                                    0xbc2
#define XK_upshoe                                      0xbc3
#define XK_downstile                                   0xbc4
#define XK_underbar                                    0xbc6
#define XK_jot                                         0xbca
#define XK_quad                                        0xbcc
#define XK_uptack                                      0xbce
#define XK_circle                                      0xbcf
#define XK_upstile                                     0xbd3
#define XK_downshoe                                    0xbd6
#define XK_rightshoe                                   0xbd8
#define XK_leftshoe                                    0xbda
#define XK_lefttack                                    0xbdc
#define XK_righttack                                   0xbfc
#endif /* XK_APL */

/*
 * Hebrew
 * Byte 3 = c
 */

#define XK_HEBREW
#ifdef XK_HEBREW
#define XK_hebrew_doublelowline                        0xcdf
#define XK_hebrew_aleph                                0xce0
#define XK_hebrew_bet                                  0xce1
#define XK_hebrew_beth                                 0xce1  /* deprecated */
#define XK_hebrew_gimel                                0xce2
#define XK_hebrew_gimmel                               0xce2  /* deprecated */
#define XK_hebrew_dalet                                0xce3
#define XK_hebrew_daleth                               0xce3  /* deprecated */
#define XK_hebrew_he                                   0xce4
#define XK_hebrew_waw                                  0xce5
#define XK_hebrew_zain                                 0xce6
#define XK_hebrew_zayin                                0xce6  /* deprecated */
#define XK_hebrew_chet                                 0xce7
#define XK_hebrew_het                                  0xce7  /* deprecated */
#define XK_hebrew_tet                                  0xce8
#define XK_hebrew_teth                                 0xce8  /* deprecated */
#define XK_hebrew_yod                                  0xce9
#define XK_hebrew_finalkaph                            0xcea
#define XK_hebrew_kaph                                 0xceb
#define XK_hebrew_lamed                                0xcec
#define XK_hebrew_finalmem                             0xced
#define XK_hebrew_mem                                  0xcee
#define XK_hebrew_finalnun                             0xcef
#define XK_hebrew_nun                                  0xcf0
#define XK_hebrew_samech                               0xcf1
#define XK_hebrew_samekh                               0xcf1  /* deprecated */
#define XK_hebrew_ayin                                 0xcf2
#define XK_hebrew_finalpe                              0xcf3
#define XK_hebrew_pe                                   0xcf4
#define XK_hebrew_finalzade                            0xcf5
#define XK_hebrew_finalzadi                            0xcf5  /* deprecated */
#define XK_hebrew_zade                                 0xcf6
#define XK_hebrew_zadi                                 0xcf6  /* deprecated */
#define XK_hebrew_qoph                                 0xcf7
#define XK_hebrew_kuf                                  0xcf7  /* deprecated */
#define XK_hebrew_resh                                 0xcf8
#define XK_hebrew_shin                                 0xcf9
#define XK_hebrew_taw                                  0xcfa
#define XK_hebrew_taf                                  0xcfa  /* deprecated */
#define XK_Hebrew_switch        0xFF7E  /* Alias for mode_switch */
#endif /* XK_HEBREW */

/*
 * Thai
 * Byte 3 = d
 */

#define XK_THAI
#ifdef XK_THAI
#define XK_Thai_kokai					0xda1
#define XK_Thai_khokhai					0xda2
#define XK_Thai_khokhuat				0xda3
#define XK_Thai_khokhwai				0xda4
#define XK_Thai_khokhon					0xda5
#define XK_Thai_khorakhang			        0xda6  
#define XK_Thai_ngongu					0xda7  
#define XK_Thai_chochan					0xda8  
#define XK_Thai_choching				0xda9   
#define XK_Thai_chochang				0xdaa  
#define XK_Thai_soso					0xdab
#define XK_Thai_chochoe					0xdac
#define XK_Thai_yoying					0xdad
#define XK_Thai_dochada					0xdae
#define XK_Thai_topatak					0xdaf
#define XK_Thai_thothan					0xdb0
#define XK_Thai_thonangmontho			        0xdb1
#define XK_Thai_thophuthao			        0xdb2
#define XK_Thai_nonen					0xdb3
#define XK_Thai_dodek					0xdb4
#define XK_Thai_totao					0xdb5
#define XK_Thai_thothung				0xdb6
#define XK_Thai_thothahan				0xdb7
#define XK_Thai_thothong	 			0xdb8
#define XK_Thai_nonu					0xdb9
#define XK_Thai_bobaimai				0xdba
#define XK_Thai_popla					0xdbb
#define XK_Thai_phophung				0xdbc
#define XK_Thai_fofa					0xdbd
#define XK_Thai_phophan					0xdbe
#define XK_Thai_fofan					0xdbf
#define XK_Thai_phosamphao			        0xdc0
#define XK_Thai_moma					0xdc1
#define XK_Thai_yoyak					0xdc2
#define XK_Thai_rorua					0xdc3
#define XK_Thai_ru					0xdc4
#define XK_Thai_loling					0xdc5
#define XK_Thai_lu					0xdc6
#define XK_Thai_wowaen					0xdc7
#define XK_Thai_sosala					0xdc8
#define XK_Thai_sorusi					0xdc9
#define XK_Thai_sosua					0xdca
#define XK_Thai_hohip					0xdcb
#define XK_Thai_lochula					0xdcc
#define XK_Thai_oang					0xdcd
#define XK_Thai_honokhuk				0xdce
#define XK_Thai_paiyannoi				0xdcf
#define XK_Thai_saraa					0xdd0
#define XK_Thai_maihanakat				0xdd1
#define XK_Thai_saraaa					0xdd2
#define XK_Thai_saraam					0xdd3
#define XK_Thai_sarai					0xdd4   
#define XK_Thai_saraii					0xdd5   
#define XK_Thai_saraue					0xdd6    
#define XK_Thai_sarauee					0xdd7    
#define XK_Thai_sarau					0xdd8    
#define XK_Thai_sarauu					0xdd9   
#define XK_Thai_phinthu					0xdda
#define XK_Thai_maihanakat_maitho   			0xdde
#define XK_Thai_baht					0xddf
#define XK_Thai_sarae					0xde0    
#define XK_Thai_saraae					0xde1
#define XK_Thai_sarao					0xde2
#define XK_Thai_saraaimaimuan				0xde3   
#define XK_Thai_saraaimaimalai				0xde4  
#define XK_Thai_lakkhangyao				0xde5
#define XK_Thai_maiyamok				0xde6
#define XK_Thai_maitaikhu				0xde7
#define XK_Thai_maiek					0xde8   
#define XK_Thai_maitho					0xde9
#define XK_Thai_maitri					0xdea
#define XK_Thai_maichattawa				0xdeb
#define XK_Thai_thanthakhat				0xdec
#define XK_Thai_nikhahit				0xded
#define XK_Thai_leksun					0xdf0 
#define XK_Thai_leknung					0xdf1  
#define XK_Thai_leksong					0xdf2 
#define XK_Thai_leksam					0xdf3
#define XK_Thai_leksi					0xdf4  
#define XK_Thai_lekha					0xdf5  
#define XK_Thai_lekhok					0xdf6  
#define XK_Thai_lekchet					0xdf7  
#define XK_Thai_lekpaet					0xdf8  
#define XK_Thai_lekkao					0xdf9 
#endif /* XK_THAI */

/*
 *   Korean
 *   Byte 3 = e
 */

#define XK_KOREAN
#ifdef XK_KOREAN

#define XK_Hangul		0xff31    /* Hangul start/stop(toggle) */
#define XK_Hangul_Start		0xff32    /* Hangul start */
#define XK_Hangul_End		0xff33    /* Hangul end, English start */
#define XK_Hangul_Hanja		0xff34    /* Start Hangul->Hanja Conversion */
#define XK_Hangul_Jamo		0xff35    /* Hangul Jamo mode */
#define XK_Hangul_Romaja	0xff36    /* Hangul Romaja mode */
#define XK_Hangul_Codeinput	0xff37    /* Hangul code input mode */
#define XK_Hangul_Jeonja	0xff38    /* Jeonja mode */
#define XK_Hangul_Banja		0xff39    /* Banja mode */
#define XK_Hangul_PreHanja	0xff3a    /* Pre Hanja conversion */
#define XK_Hangul_PostHanja	0xff3b    /* Post Hanja conversion */
#define XK_Hangul_SingleCandidate	0xff3c    /* Single candidate */
#define XK_Hangul_MultipleCandidate	0xff3d    /* Multiple candidate */
#define XK_Hangul_PreviousCandidate	0xff3e    /* Previous candidate */
#define XK_Hangul_Special	0xff3f    /* Special symbols */
#define XK_Hangul_switch	0xFF7E    /* Alias for mode_switch */

/* Hangul Consonant Characters */
#define XK_Hangul_Kiyeog				0xea1
#define XK_Hangul_SsangKiyeog				0xea2
#define XK_Hangul_KiyeogSios				0xea3
#define XK_Hangul_Nieun					0xea4
#define XK_Hangul_NieunJieuj				0xea5
#define XK_Hangul_NieunHieuh				0xea6
#define XK_Hangul_Dikeud				0xea7
#define XK_Hangul_SsangDikeud				0xea8
#define XK_Hangul_Rieul					0xea9
#define XK_Hangul_RieulKiyeog				0xeaa
#define XK_Hangul_RieulMieum				0xeab
#define XK_Hangul_RieulPieub				0xeac
#define XK_Hangul_RieulSios				0xead
#define XK_Hangul_RieulTieut				0xeae
#define XK_Hangul_RieulPhieuf				0xeaf
#define XK_Hangul_RieulHieuh				0xeb0
#define XK_Hangul_Mieum					0xeb1
#define XK_Hangul_Pieub					0xeb2
#define XK_Hangul_SsangPieub				0xeb3
#define XK_Hangul_PieubSios				0xeb4
#define XK_Hangul_Sios					0xeb5
#define XK_Hangul_SsangSios				0xeb6
#define XK_Hangul_Ieung					0xeb7
#define XK_Hangul_Jieuj					0xeb8
#define XK_Hangul_SsangJieuj				0xeb9
#define XK_Hangul_Cieuc					0xeba
#define XK_Hangul_Khieuq				0xebb
#define XK_Hangul_Tieut					0xebc
#define XK_Hangul_Phieuf				0xebd
#define XK_Hangul_Hieuh					0xebe

/* Hangul Vowel Characters */
#define XK_Hangul_A					0xebf
#define XK_Hangul_AE					0xec0
#define XK_Hangul_YA					0xec1
#define XK_Hangul_YAE					0xec2
#define XK_Hangul_EO					0xec3
#define XK_Hangul_E					0xec4
#define XK_Hangul_YEO					0xec5
#define XK_Hangul_YE					0xec6
#define XK_Hangul_O					0xec7
#define XK_Hangul_WA					0xec8
#define XK_Hangul_WAE					0xec9
#define XK_Hangul_OE					0xeca
#define XK_Hangul_YO					0xecb
#define XK_Hangul_U					0xecc
#define XK_Hangul_WEO					0xecd
#define XK_Hangul_WE					0xece
#define XK_Hangul_WI					0xecf
#define XK_Hangul_YU					0xed0
#define XK_Hangul_EU					0xed1
#define XK_Hangul_YI					0xed2
#define XK_Hangul_I					0xed3

/* Hangul syllable-final (JongSeong) Characters */
#define XK_Hangul_J_Kiyeog				0xed4
#define XK_Hangul_J_SsangKiyeog				0xed5
#define XK_Hangul_J_KiyeogSios				0xed6
#define XK_Hangul_J_Nieun				0xed7
#define XK_Hangul_J_NieunJieuj				0xed8
#define XK_Hangul_J_NieunHieuh				0xed9
#define XK_Hangul_J_Dikeud				0xeda
#define XK_Hangul_J_Rieul				0xedb
#define XK_Hangul_J_RieulKiyeog				0xedc
#define XK_Hangul_J_RieulMieum				0xedd
#define XK_Hangul_J_RieulPieub				0xede
#define XK_Hangul_J_RieulSios				0xedf
#define XK_Hangul_J_RieulTieut				0xee0
#define XK_Hangul_J_RieulPhieuf				0xee1
#define XK_Hangul_J_RieulHieuh				0xee2
#define XK_Hangul_J_Mieum				0xee3
#define XK_Hangul_J_Pieub				0xee4
#define XK_Hangul_J_PieubSios				0xee5
#define XK_Hangul_J_Sios				0xee6
#define XK_Hangul_J_SsangSios				0xee7
#define XK_Hangul_J_Ieung				0xee8
#define XK_Hangul_J_Jieuj				0xee9
#define XK_Hangul_J_Cieuc				0xeea
#define XK_Hangul_J_Khieuq				0xeeb
#define XK_Hangul_J_Tieut				0xeec
#define XK_Hangul_J_Phieuf				0xeed
#define XK_Hangul_J_Hieuh				0xeee

/* Ancient Hangul Consonant Characters */
#define XK_Hangul_RieulYeorinHieuh			0xeef
#define XK_Hangul_SunkyeongeumMieum			0xef0
#define XK_Hangul_SunkyeongeumPieub			0xef1
#define XK_Hangul_PanSios				0xef2
#define XK_Hangul_KkogjiDalrinIeung			0xef3
#define XK_Hangul_SunkyeongeumPhieuf			0xef4
#define XK_Hangul_YeorinHieuh				0xef5

/* Ancient Hangul Vowel Characters */
#define XK_Hangul_AraeA					0xef6
#define XK_Hangul_AraeAE				0xef7

/* Ancient Hangul syllable-final (JongSeong) Characters */
#define XK_Hangul_J_PanSios				0xef8
#define XK_Hangul_J_KkogjiDalrinIeung			0xef9
#define XK_Hangul_J_YeorinHieuh				0xefa

/* Korean currency symbol */
#define XK_Korean_Won					0xeff

#endif /* XK_KOREAN */

/*
 *   Armenian
 *   Byte 3 = 0x14
 */

#define XK_ARMENIAN
#ifdef XK_ARMENIAN
#define XK_Armenian_eternity				0x14a1
#define XK_Armenian_ligature_ew				0x14a2
#define XK_Armenian_full_stop				0x14a3
#define XK_Armenian_verjaket				0x14a3
#define XK_Armenian_parenright				0x14a4
#define XK_Armenian_parenleft				0x14a5
#define XK_Armenian_guillemotright			0x14a6
#define XK_Armenian_guillemotleft			0x14a7
#define XK_Armenian_em_dash				0x14a8
#define XK_Armenian_dot					0x14a9
#define XK_Armenian_mijaket				0x14a9
#define XK_Armenian_separation_mark			0x14aa
#define XK_Armenian_but					0x14aa
#define XK_Armenian_comma				0x14ab
#define XK_Armenian_en_dash				0x14ac
#define XK_Armenian_hyphen				0x14ad
#define XK_Armenian_yentamna				0x14ad
#define XK_Armenian_ellipsis				0x14ae
#define XK_Armenian_exclam				0x14af
#define XK_Armenian_amanak				0x14af
#define XK_Armenian_accent				0x14b0
#define XK_Armenian_shesht				0x14b0
#define XK_Armenian_question				0x14b1
#define XK_Armenian_paruyk				0x14b1
#define XK_Armenian_AYB					0x14b2
#define XK_Armenian_ayb					0x14b3
#define XK_Armenian_BEN					0x14b4
#define XK_Armenian_ben					0x14b5
#define XK_Armenian_GIM					0x14b6
#define XK_Armenian_gim					0x14b7
#define XK_Armenian_DA					0x14b8
#define XK_Armenian_da					0x14b9
#define XK_Armenian_YECH				0x14ba
#define XK_Armenian_yech				0x14bb
#define XK_Armenian_ZA					0x14bc
#define XK_Armenian_za					0x14bd
#define XK_Armenian_E					0x14be
#define XK_Armenian_e					0x14bf
#define XK_Armenian_AT					0x14c0
#define XK_Armenian_at					0x14c1
#define XK_Armenian_TO					0x14c2
#define XK_Armenian_to					0x14c3
#define XK_Armenian_ZHE					0x14c4
#define XK_Armenian_zhe					0x14c5
#define XK_Armenian_INI					0x14c6
#define XK_Armenian_ini					0x14c7
#define XK_Armenian_LYUN				0x14c8
#define XK_Armenian_lyun				0x14c9
#define XK_Armenian_KHE					0x14ca
#define XK_Armenian_khe					0x14cb
#define XK_Armenian_TSA					0x14cc
#define XK_Armenian_tsa					0x14cd
#define XK_Armenian_KEN					0x14ce
#define XK_Armenian_ken					0x14cf
#define XK_Armenian_HO					0x14d0
#define XK_Armenian_ho					0x14d1
#define XK_Armenian_DZA					0x14d2
#define XK_Armenian_dza					0x14d3
#define XK_Armenian_GHAT				0x14d4
#define XK_Armenian_ghat				0x14d5
#define XK_Armenian_TCHE				0x14d6
#define XK_Armenian_tche				0x14d7
#define XK_Armenian_MEN					0x14d8
#define XK_Armenian_men					0x14d9
#define XK_Armenian_HI					0x14da
#define XK_Armenian_hi					0x14db
#define XK_Armenian_NU					0x14dc
#define XK_Armenian_nu					0x14dd
#define XK_Armenian_SHA					0x14de
#define XK_Armenian_sha					0x14df
#define XK_Armenian_VO					0x14e0
#define XK_Armenian_vo					0x14e1
#define XK_Armenian_CHA					0x14e2
#define XK_Armenian_cha					0x14e3
#define XK_Armenian_PE					0x14e4
#define XK_Armenian_pe					0x14e5
#define XK_Armenian_JE					0x14e6
#define XK_Armenian_je					0x14e7
#define XK_Armenian_RA					0x14e8
#define XK_Armenian_ra					0x14e9
#define XK_Armenian_SE					0x14ea
#define XK_Armenian_se					0x14eb
#define XK_Armenian_VEV					0x14ec
#define XK_Armenian_vev					0x14ed
#define XK_Armenian_TYUN				0x14ee
#define XK_Armenian_tyun				0x14ef
#define XK_Armenian_RE					0x14f0
#define XK_Armenian_re					0x14f1
#define XK_Armenian_TSO					0x14f2
#define XK_Armenian_tso					0x14f3
#define XK_Armenian_VYUN				0x14f4
#define XK_Armenian_vyun				0x14f5
#define XK_Armenian_PYUR				0x14f6
#define XK_Armenian_pyur				0x14f7
#define XK_Armenian_KE					0x14f8
#define XK_Armenian_ke					0x14f9
#define XK_Armenian_O					0x14fa
#define XK_Armenian_o					0x14fb
#define XK_Armenian_FE					0x14fc
#define XK_Armenian_fe					0x14fd
#define XK_Armenian_apostrophe				0x14fe
#define XK_Armenian_section_sign			0x14ff
#endif /* XK_ARMENIAN */

/*
 *   Georgian
 *   Byte 3 = 0x15
 */

#define XK_GEORGIAN
#ifdef XK_GEORGIAN
#define XK_Georgian_an					0x15d0
#define XK_Georgian_ban					0x15d1
#define XK_Georgian_gan					0x15d2
#define XK_Georgian_don					0x15d3
#define XK_Georgian_en					0x15d4
#define XK_Georgian_vin					0x15d5
#define XK_Georgian_zen					0x15d6
#define XK_Georgian_tan					0x15d7
#define XK_Georgian_in					0x15d8
#define XK_Georgian_kan					0x15d9
#define XK_Georgian_las					0x15da
#define XK_Georgian_man					0x15db
#define XK_Georgian_nar					0x15dc
#define XK_Georgian_on					0x15dd
#define XK_Georgian_par					0x15de
#define XK_Georgian_zhar				0x15df
#define XK_Georgian_rae					0x15e0
#define XK_Georgian_san					0x15e1
#define XK_Georgian_tar					0x15e2
#define XK_Georgian_un					0x15e3
#define XK_Georgian_phar				0x15e4
#define XK_Georgian_khar				0x15e5
#define XK_Georgian_ghan				0x15e6
#define XK_Georgian_qar					0x15e7
#define XK_Georgian_shin				0x15e8
#define XK_Georgian_chin				0x15e9
#define XK_Georgian_can					0x15ea
#define XK_Georgian_jil					0x15eb
#define XK_Georgian_cil					0x15ec
#define XK_Georgian_char				0x15ed
#define XK_Georgian_xan					0x15ee
#define XK_Georgian_jhan				0x15ef
#define XK_Georgian_hae					0x15f0
#define XK_Georgian_he					0x15f1
#define XK_Georgian_hie					0x15f2
#define XK_Georgian_we					0x15f3
#define XK_Georgian_har					0x15f4
#define XK_Georgian_hoe					0x15f5
#define XK_Georgian_fi					0x15f6
#endif /* XK_GEORGIAN */

/*
 * Azeri (and other Turkic or Caucasian languages of ex-USSR)
 * Byte 3 = 0x16
 */

#define XK_CAUCASUS
#ifdef XK_CAUCASUS
/* latin */
#define XK_Ccedillaabovedot	0x16a2
#define XK_Xabovedot		0x16a3
#define XK_Qabovedot		0x16a5
#define	XK_Ibreve		0x16a6
#define XK_IE			0x16a7
#define XK_UO			0x16a8
#define XK_Zstroke		0x16a9
#define	XK_Gcaron		0x16aa
#define	XK_Obarred		0x16af
#define XK_ccedillaabovedot	0x16b2
#define XK_xabovedot		0x16b3
#define	XK_Ocaron		0x16b4
#define XK_qabovedot		0x16b5
#define	XK_ibreve		0x16b6
#define XK_ie			0x16b7
#define XK_uo			0x16b8
#define XK_zstroke		0x16b9
#define	XK_gcaron		0x16ba
#define	XK_ocaron		0x16bd
#define	XK_obarred		0x16bf
#define XK_SCHWA		0x16c6
#define XK_schwa		0x16f6
/* those are not really Caucasus, but I put them here for now */
/* For Inupiak */
#define XK_Lbelowdot		0x16d1
#define XK_Lstrokebelowdot	0x16d2
#define XK_lbelowdot		0x16e1
#define XK_lstrokebelowdot	0x16e2
/* For Guarani */
#define XK_Gtilde		0x16d3
#define XK_gtilde		0x16e3
#endif /* XK_CAUCASUS */

/*
 *   Vietnamese
 *   Byte 3 = 0x1e
 */
 
#define XK_VIETNAMESE
#ifdef XK_VIETNAMESE
#define XK_Abelowdot					0x1ea0
#define XK_abelowdot					0x1ea1
#define XK_Ahook					0x1ea2
#define XK_ahook					0x1ea3
#define XK_Acircumflexacute				0x1ea4
#define XK_acircumflexacute				0x1ea5
#define XK_Acircumflexgrave				0x1ea6
#define XK_acircumflexgrave				0x1ea7
#define XK_Acircumflexhook				0x1ea8
#define XK_acircumflexhook				0x1ea9
#define XK_Acircumflextilde				0x1eaa
#define XK_acircumflextilde				0x1eab
#define XK_Acircumflexbelowdot				0x1eac
#define XK_acircumflexbelowdot				0x1ead
#define XK_Abreveacute					0x1eae
#define XK_abreveacute					0x1eaf
#define XK_Abrevegrave					0x1eb0
#define XK_abrevegrave					0x1eb1
#define XK_Abrevehook					0x1eb2
#define XK_abrevehook					0x1eb3
#define XK_Abrevetilde					0x1eb4
#define XK_abrevetilde					0x1eb5
#define XK_Abrevebelowdot				0x1eb6
#define XK_abrevebelowdot				0x1eb7
#define XK_Ebelowdot					0x1eb8
#define XK_ebelowdot					0x1eb9
#define XK_Ehook					0x1eba
#define XK_ehook					0x1ebb
#define XK_Etilde					0x1ebc
#define XK_etilde					0x1ebd
#define XK_Ecircumflexacute				0x1ebe
#define XK_ecircumflexacute				0x1ebf
#define XK_Ecircumflexgrave				0x1ec0
#define XK_ecircumflexgrave				0x1ec1
#define XK_Ecircumflexhook				0x1ec2
#define XK_ecircumflexhook				0x1ec3
#define XK_Ecircumflextilde				0x1ec4
#define XK_ecircumflextilde				0x1ec5
#define XK_Ecircumflexbelowdot				0x1ec6
#define XK_ecircumflexbelowdot				0x1ec7
#define XK_Ihook					0x1ec8
#define XK_ihook					0x1ec9
#define XK_Ibelowdot					0x1eca
#define XK_ibelowdot					0x1ecb
#define XK_Obelowdot					0x1ecc
#define XK_obelowdot					0x1ecd
#define XK_Ohook					0x1ece
#define XK_ohook					0x1ecf
#define XK_Ocircumflexacute				0x1ed0
#define XK_ocircumflexacute				0x1ed1
#define XK_Ocircumflexgrave				0x1ed2
#define XK_ocircumflexgrave				0x1ed3
#define XK_Ocircumflexhook				0x1ed4
#define XK_ocircumflexhook				0x1ed5
#define XK_Ocircumflextilde				0x1ed6
#define XK_ocircumflextilde				0x1ed7
#define XK_Ocircumflexbelowdot				0x1ed8
#define XK_ocircumflexbelowdot				0x1ed9
#define XK_Ohornacute					0x1eda
#define XK_ohornacute					0x1edb
#define XK_Ohorngrave					0x1edc
#define XK_ohorngrave					0x1edd
#define XK_Ohornhook					0x1ede
#define XK_ohornhook					0x1edf
#define XK_Ohorntilde					0x1ee0
#define XK_ohorntilde					0x1ee1
#define XK_Ohornbelowdot				0x1ee2
#define XK_ohornbelowdot				0x1ee3
#define XK_Ubelowdot					0x1ee4
#define XK_ubelowdot					0x1ee5
#define XK_Uhook					0x1ee6
#define XK_uhook					0x1ee7
#define XK_Uhornacute					0x1ee8
#define XK_uhornacute					0x1ee9
#define XK_Uhorngrave					0x1eea
#define XK_uhorngrave					0x1eeb
#define XK_Uhornhook					0x1eec
#define XK_uhornhook					0x1eed
#define XK_Uhorntilde					0x1eee
#define XK_uhorntilde					0x1eef
#define XK_Uhornbelowdot				0x1ef0
#define XK_uhornbelowdot				0x1ef1
#define XK_Ybelowdot					0x1ef4
#define XK_ybelowdot					0x1ef5
#define XK_Yhook					0x1ef6
#define XK_yhook					0x1ef7
#define XK_Ytilde					0x1ef8
#define XK_ytilde					0x1ef9
#define XK_Ohorn					0x1efa /* U+01a0 */
#define XK_ohorn					0x1efb /* U+01a1 */
#define XK_Uhorn					0x1efc /* U+01af */
#define XK_uhorn					0x1efd /* U+01b0 */

#define XK_combining_tilde				0x1e9f /* U+0303 */
#define XK_combining_grave				0x1ef2 /* U+0300 */
#define XK_combining_acute				0x1ef3 /* U+0301 */
#define XK_combining_hook				0x1efe /* U+0309 */
#define XK_combining_belowdot				0x1eff /* U+0323 */
#endif /* XK_VIETNAMESE */

#define XK_CURRENCY
#ifdef XK_CURRENCY
#define XK_EcuSign					0x20a0
#define XK_ColonSign					0x20a1
#define XK_CruzeiroSign					0x20a2
#define XK_FFrancSign					0x20a3
#define XK_LiraSign					0x20a4
#define XK_MillSign					0x20a5
#define XK_NairaSign					0x20a6
#define XK_PesetaSign					0x20a7
#define XK_RupeeSign					0x20a8
#define XK_WonSign					0x20a9
#define XK_NewSheqelSign				0x20aa
#define XK_DongSign					0x20ab
#define XK_EuroSign					0x20ac
#endif

void
XConvertCase(sym, lower, upper)
    register int sym;
    int *lower;
    int *upper;
{
    *lower = sym;
    *upper = sym;
    switch(sym >> 8) {
    case 0: /* Latin 1 */
	if ((sym >= XK_A) && (sym <= XK_Z))
	    *lower += (XK_a - XK_A);
	else if ((sym >= XK_a) && (sym <= XK_z))
	    *upper -= (XK_a - XK_A);
	else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
	    *lower += (XK_agrave - XK_Agrave);
	else if ((sym >= XK_agrave) && (sym <= XK_odiaeresis))
	    *upper -= (XK_agrave - XK_Agrave);
	else if ((sym >= XK_Ooblique) && (sym <= XK_Thorn))
	    *lower += (XK_oslash - XK_Ooblique);
	else if ((sym >= XK_oslash) && (sym <= XK_thorn))
	    *upper -= (XK_oslash - XK_Ooblique);
	break;
    case 1: /* Latin 2 */
	/* Assume the KeySym is a legal value (ignore discontinuities) */
	if (sym == XK_Aogonek)
	    *lower = XK_aogonek;
	else if (sym >= XK_Lstroke && sym <= XK_Sacute)
	    *lower += (XK_lstroke - XK_Lstroke);
	else if (sym >= XK_Scaron && sym <= XK_Zacute)
	    *lower += (XK_scaron - XK_Scaron);
	else if (sym >= XK_Zcaron && sym <= XK_Zabovedot)
	    *lower += (XK_zcaron - XK_Zcaron);
	else if (sym == XK_aogonek)
	    *upper = XK_Aogonek;
	else if (sym >= XK_lstroke && sym <= XK_sacute)
	    *upper -= (XK_lstroke - XK_Lstroke);
	else if (sym >= XK_scaron && sym <= XK_zacute)
	    *upper -= (XK_scaron - XK_Scaron);
	else if (sym >= XK_zcaron && sym <= XK_zabovedot)
	    *upper -= (XK_zcaron - XK_Zcaron);
	else if (sym >= XK_Racute && sym <= XK_Tcedilla)
	    *lower += (XK_racute - XK_Racute);
	else if (sym >= XK_racute && sym <= XK_tcedilla)
	    *upper -= (XK_racute - XK_Racute);
	break;
    case 2: /* Latin 3 */
	/* Assume the KeySym is a legal value (ignore discontinuities) */
	if (sym >= XK_Hstroke && sym <= XK_Hcircumflex)
	    *lower += (XK_hstroke - XK_Hstroke);
	else if (sym >= XK_Gbreve && sym <= XK_Jcircumflex)
	    *lower += (XK_gbreve - XK_Gbreve);
	else if (sym >= XK_hstroke && sym <= XK_hcircumflex)
	    *upper -= (XK_hstroke - XK_Hstroke);
	else if (sym >= XK_gbreve && sym <= XK_jcircumflex)
	    *upper -= (XK_gbreve - XK_Gbreve);
	else if (sym >= XK_Cabovedot && sym <= XK_Scircumflex)
	    *lower += (XK_cabovedot - XK_Cabovedot);
	else if (sym >= XK_cabovedot && sym <= XK_scircumflex)
	    *upper -= (XK_cabovedot - XK_Cabovedot);
	break;
    case 3: /* Latin 4 */
	/* Assume the KeySym is a legal value (ignore discontinuities) */
	if (sym >= XK_Rcedilla && sym <= XK_Tslash)
	    *lower += (XK_rcedilla - XK_Rcedilla);
	else if (sym >= XK_rcedilla && sym <= XK_tslash)
	    *upper -= (XK_rcedilla - XK_Rcedilla);
	else if (sym == XK_ENG)
	    *lower = XK_eng;
	else if (sym == XK_eng)
	    *upper = XK_ENG;
	else if (sym >= XK_Amacron && sym <= XK_Umacron)
	    *lower += (XK_amacron - XK_Amacron);
	else if (sym >= XK_amacron && sym <= XK_umacron)
	    *upper -= (XK_amacron - XK_Amacron);
	break;
    case 6: /* Cyrillic */
	/* Assume the KeySym is a legal value (ignore discontinuities) */
	if (sym >= XK_Serbian_DJE && sym <= XK_Serbian_DZE)
	    *lower -= (XK_Serbian_DJE - XK_Serbian_dje);
	else if (sym >= XK_Serbian_dje && sym <= XK_Serbian_dze)
	    *upper += (XK_Serbian_DJE - XK_Serbian_dje);
	else if (sym >= XK_Cyrillic_YU && sym <= XK_Cyrillic_HARDSIGN)
	    *lower -= (XK_Cyrillic_YU - XK_Cyrillic_yu);
	else if (sym >= XK_Cyrillic_yu && sym <= XK_Cyrillic_hardsign)
	    *upper += (XK_Cyrillic_YU - XK_Cyrillic_yu);
        break;
    case 7: /* Greek */
	/* Assume the KeySym is a legal value (ignore discontinuities) */
	if (sym >= XK_Greek_ALPHAaccent && sym <= XK_Greek_OMEGAaccent)
	    *lower += (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
	else if (sym >= XK_Greek_alphaaccent && sym <= XK_Greek_omegaaccent &&
		 sym != XK_Greek_iotaaccentdieresis &&
		 sym != XK_Greek_upsilonaccentdieresis)
	    *upper -= (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
	else if (sym >= XK_Greek_ALPHA && sym <= XK_Greek_OMEGA)
	    *lower += (XK_Greek_alpha - XK_Greek_ALPHA);
	else if (sym >= XK_Greek_alpha && sym <= XK_Greek_omega &&
		 sym != XK_Greek_finalsmallsigma)
	    *upper -= (XK_Greek_alpha - XK_Greek_ALPHA);
        break;
    }
}

diff -ru ../ethereal-0.9.7/doc/ethereal.pod doc/ethereal.pod
--- ../ethereal-0.9.7/doc/ethereal.pod	Thu Mar 27 20:07:33 2003
+++ doc/ethereal.pod	Tue Jul 29 12:33:02 2003
@@ -36297,6 +36297,9 @@
     x11.byte-order  byte-order
         Unsigned 8-bit integer
 
+    x11.bytesafter  bytesafter
+        Unsigned 32-bit integer
+
     x11.cap-style  cap-style
         Unsigned 8-bit integer
 
@@ -36497,6 +36500,18 @@
     x11.dst-y  dst-y
         Signed 16-bit integer
 
+    x11.error  error
+        Unsigned 8-bit integer
+
+    x11.error.badvalue  badvalue
+        Unsigned 32-bit integer
+
+    x11.error.sequencenumber  sequencenumber
+        Unsigned 16-bit integer
+
+    x11.errorcode  errorcode
+        Unsigned 8-bit integer
+
     x11.event-mask  event-mask
         Unsigned 32-bit integer
 
@@ -36759,7 +36774,7 @@
     x11.image-pixmap-format  image-pixmap-format
         Unsigned 8-bit integer
 
-    x11.inital_connection  inital connection
+    x11.inital_connection  initial connection
         No value
         Yet undecoded by dissector
 
@@ -36864,6 +36879,9 @@
         Unsigned 32-bit integer
         The starting position in the property bytes array
 
+    x11.major-opcode  major-opcode
+        Unsigned 16-bit integer
+
     x11.map  map
         Byte array
 
@@ -36885,6 +36903,9 @@
     x11.mid  mid
         Unsigned 32-bit integer
 
+    x11.minor-opcode  minor-opcode
+        Unsigned 16-bit integer
+
     x11.mode  mode
         Unsigned 8-bit integer
 
@@ -37287,6 +37308,9 @@
 
     x11.unused  unused
         No value
+
+    x11.valuelength  valuelength
+        Unsigned 32-bit integer
 
     x11.visual  visual
         Unsigned 32-bit integer
diff -ru ../ethereal-0.9.7/doc/tethereal.pod doc/tethereal.pod
--- ../ethereal-0.9.7/doc/tethereal.pod	Thu Mar 27 20:08:00 2003
+++ doc/tethereal.pod	Tue Jul 29 12:33:23 2003
@@ -35649,6 +35649,9 @@
     x11.byte-order  byte-order
         Unsigned 8-bit integer
 
+    x11.bytesafter  bytesafter
+        Unsigned 32-bit integer
+
     x11.cap-style  cap-style
         Unsigned 8-bit integer
 
@@ -35849,6 +35852,18 @@
     x11.dst-y  dst-y
         Signed 16-bit integer
 
+    x11.error  error
+        Unsigned 8-bit integer
+
+    x11.error.badvalue  badvalue
+        Unsigned 32-bit integer
+
+    x11.error.sequencenumber  sequencenumber
+        Unsigned 16-bit integer
+
+    x11.errorcode  errorcode
+        Unsigned 8-bit integer
+
     x11.event-mask  event-mask
         Unsigned 32-bit integer
 
@@ -36111,7 +36126,7 @@
     x11.image-pixmap-format  image-pixmap-format
         Unsigned 8-bit integer
 
-    x11.inital_connection  inital connection
+    x11.inital_connection  initial connection
         No value
         Yet undecoded by dissector
 
@@ -36216,6 +36231,9 @@
         Unsigned 32-bit integer
         The starting position in the property bytes array
 
+    x11.major-opcode  major-opcode
+        Unsigned 16-bit integer
+
     x11.map  map
         Byte array
 
@@ -36237,6 +36255,9 @@
     x11.mid  mid
         Unsigned 32-bit integer
 
+    x11.minor-opcode  minor-opcode
+        Unsigned 16-bit integer
+
     x11.mode  mode
         Unsigned 8-bit integer
 
@@ -36639,6 +36660,9 @@
 
     x11.unused  unused
         No value
+
+    x11.valuelength  valuelength
+        Unsigned 32-bit integer
 
     x11.visual  visual
         Unsigned 32-bit integer
Only in doc/: tethereal.pod_