#include #include #include #include "sets.h" #include "atoms.h" #include "structs.h" #include "fmt-util.h" #include "fmt-core.h" #define MODGROUPS 8 static const char *modgroups[MODGROUPS] = { "Shift", "Lock", "Control", "Mod1", "Mod2", "Mod3", "Mod4", "Mod5" }; static void print_bitgravity(FILE *o, unsigned int g) { print_choice(o,g,11, 0, "Forget", 1, "NorthWest", 2, "North", 3, "NorthEast", 4, "West", 5, "Center", 6, "East", 7, "SouthWest", 8, "South", 9, "SouthEast", 10, "Opposite" ); } static void print_wingravity(FILE *o, unsigned int g) { print_choice(o,g,11, 0, "Unmap", 1, "NorthWest", 2, "North", 3, "NorthEast", 4, "West", 5, "Center", 6, "East", 7, "SouthWest", 8, "South", 9, "SouthEast", 10, "Static" ); } static void print_backingstore(FILE *o, unsigned int bs) { print_choice(o,bs,3,0,"NotUseful",1,"WhenMapped",2,"Always"); } void print_bool(FILE *o, unsigned int bv) { print_choice(o,bv,2,0,"False",1,"True"); } void print_vclass(FILE *o, unsigned int c) { print_choice(o,c,6, 0, "StaticGray", 1, "GrayScale", 2, "StaticColor", 3, "PseudoColor", 4, "TrueColor", 5, "DirectColor" ); } static void print_stackmode(FILE *o, unsigned int m) { print_choice(o,m,5, 0, "Above", 1, "Below", 2, "TopIf", 3, "BottomIf", 4, "Opposite" ); } static void print_grabmode(FILE *o, unsigned int gm) { print_choice(o,gm,2,0,"Synchronous",1,"Asynchronous"); } static void print_grabstatus(FILE *o, unsigned int stat) { print_choice(o,stat,5, 0, "Success", 1, "AlreadyGrabbed", 2, "InvalidTime", 3, "NotViewable", 4, "Frozen" ); } static void print_grabbutton(FILE *o, unsigned int b) { switch (b) { case 0: fprintf(o,"AnyButton"); break; default: fprintf(o,"%d",b); break; } } static void print_grabkey(FILE *o, unsigned int k) { switch (k) { case 0: fprintf(o,"AnyKey"); break; default: fprintf(o,"%d",k); break; } } static void print_revertto(FILE *o, unsigned int rto) { print_choice(o,rto,3,0,"None",1,"PointerRoot",2,"Parent"); } static void print_drawdir(FILE *o, unsigned int d) { print_choice(o,d,2,0,"LeftToRight",1,"RightToLeft"); } static void print_coordmode(FILE *o, unsigned int cm) { print_choice(o,cm,2,0,"Origin",1,"Previous"); } static void print_cwalist(FLOW *f, FILE *o, unsigned int bits, unsigned int off) { fprintf(o," Value bitmask: %08x\n",bits); if (bits & 0x00000001) { fprintf(o," Background pixmap: "); print_xid_alt(o,get4u(f,off),2,0U,"None",1U,"ParentRelative"); fprintf(o,"\n"); off += 4; } if (bits & 0x00000002) { fprintf(o," Background pixel: %u\n",get4u(f,off)); off += 4; } if (bits & 0x00000004) { fprintf(o," Border pixmap: "); print_xid_z(o,get4u(f,off),"CopyFromParent"); fprintf(o,"\n"); off += 4; } if (bits & 0x00000008) { fprintf(o," Border pixel: %u\n",get4u(f,off)); off += 4; } if (bits & 0x00000010) { fprintf(o," Bit gravity: "); print_bitgravity(o,ltob_u(get4u(f,off))); fprintf(o,"\n"); off += 4; } if (bits & 0x00000020) { fprintf(o," Window gravity: "); print_wingravity(o,ltob_u(get4u(f,off))); fprintf(o,"\n"); off += 4; } if (bits & 0x00000040) { fprintf(o," Backing store: "); print_backingstore(o,ltob_u(get4u(f,off))); fprintf(o,"\n"); off += 4; } if (bits & 0x00000080) { fprintf(o," Backing planes: %08x\n",get4u(f,off)); off += 4; } if (bits & 0x00000100) { fprintf(o," Backing pixel: %u\n",get4u(f,off)); off += 4; } if (bits & 0x00000200) { fprintf(o," Override-redirect: "); print_bool(o,ltob_u(get4u(f,off))); fprintf(o,"\n"); off += 4; } if (bits & 0x00000400) { fprintf(o," Save-under: "); print_bool(o,ltob_u(get4u(f,off))); fprintf(o,"\n"); off += 4; } if (bits & 0x00000800) { print_set(o," Event mask: "," ",get4u(f,off),SETofEVENT); off += 4; } if (bits & 0x00001000) { print_set(o," Do-not-propagate mask: "," ",get4u(f,off),SETofDEVICEEVENT); off += 4; } if (bits & 0x00002000) { fprintf(o," Colourmap: "); print_xid_z(o,get4u(f,off),"CopyFromParent"); fprintf(o,"\n"); off += 4; } if (bits & 0x00004000) { fprintf(o," Cursor: "); print_xid_z(o,get4u(f,off),"None"); fprintf(o,"\n"); off += 4; } if (bits & 0xffff8000) { fprintf(o," Unrecognized bits: %08x\n",bits&0xffff8000); } } static void print_cgclist(FLOW *f, FILE *o, unsigned int bits, unsigned int off) { fprintf(o," Value bitmask: %08x\n",bits); if (bits & 0x00000001) { fprintf(o," Function: "); print_choice(o,ltob_u(get4u(f,off)),16, 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" ); fprintf(o,"\n"); off += 4; } if (bits & 0x00000002) { fprintf(o," Plane mask: 0x%x\n",get4u(f,off)); off += 4; } if (bits & 0x00000004) { fprintf(o," Foreground: %u\n",get4u(f,off)); off += 4; } if (bits & 0x00000008) { fprintf(o," Background: %u\n",get4u(f,off)); off += 4; } if (bits & 0x00000010) { fprintf(o," Line width: %u\n",ltos_u(get4u(f,off))); off += 4; } if (bits & 0x00000020) { fprintf(o," Line style: "); print_choice(o,ltob_u(get4u(f,off)),3, 0, "Solid", 1, "OnOffDash", 2, "DoubleDash" ); fprintf(o,"\n"); off += 4; } if (bits & 0x00000040) { fprintf(o," Cap style: "); print_choice(o,ltob_u(get4u(f,off)),4, 0, "NotLast", 1, "Butt", 2, "Round", 3, "Projecting" ); fprintf(o,"\n"); off += 4; } if (bits & 0x00000080) { fprintf(o," Join style: "); print_choice(o,ltob_u(get4u(f,off)),3, 0, "Miter", 1, "Round", 2, "Bevel" ); fprintf(o,"\n"); off += 4; } if (bits & 0x00000100) { fprintf(o," Fill style: "); print_choice(o,ltob_u(get4u(f,off)),4, 0, "Solid", 1, "Tiled", 2, "Stippled", 3, "OpaqueStippled" ); fprintf(o,"\n"); off += 4; } if (bits & 0x00000200) { fprintf(o," Fill rule: "); print_choice(o,ltob_u(get4u(f,off)),2,0,"EvenOdd",1,"Winding"); fprintf(o,"\n"); off += 4; } if (bits & 0x00000400) { fprintf(o," Tile: "XID_FMT"\n",get4u(f,off)); off += 4; } if (bits & 0x00000800) { fprintf(o," Stipple: "XID_FMT"\n",get4u(f,off)); off += 4; } if (bits & 0x00001000) { fprintf(o," Tile/stipple X origin: %d\n",ltos_s(get4u(f,off))); off += 4; } if (bits & 0x00002000) { fprintf(o," Tile/stipple Y origin: %d\n",ltos_s(get4u(f,off))); off += 4; } if (bits & 0x00004000) { fprintf(o," Font: "XID_FMT"\n",get4u(f,off)); off += 4; } if (bits & 0x00008000) { fprintf(o," Subwindow mode: "); print_choice(o,ltob_u(get4u(f,off)),2,0,"ClipByChildren",1,"IncludeInferiors"); fprintf(o,"\n"); off += 4; } if (bits & 0x00010000) { fprintf(o," Graphics exposures: "); print_bool(o,ltob_u(get4u(f,off))); fprintf(o,"\n"); off += 4; } if (bits & 0x00020000) { fprintf(o," Clip X origin: %d\n",ltos_s(get4s(f,off))); off += 4; } if (bits & 0x00040000) { fprintf(o," Clip Y origin: %d\n",ltos_s(get4s(f,off))); off += 4; } if (bits & 0x00080000) { fprintf(o," Clip mask: "); print_xid_z(o,get4u(f,off),"None"); fprintf(o,"\n"); off += 4; } if (bits & 0x00100000) { fprintf(o," Dash offset: %u\n",ltos_u(get4u(f,off))); off += 4; } if (bits & 0x00200000) { fprintf(o," Dashes: %u\n",ltob_u(get4u(f,off))); off += 4; } if (bits & 0x00400000) { fprintf(o," Arc mode: "); print_choice(o,ltob_u(get4u(f,off)),2,0,"Chord",1,"PieSlice"); fprintf(o,"\n"); off += 4; } if (bits & 0xff800000) { fprintf(o," Unrecognized bits: %08x\n",bits&0xff800000); } } static void print_charinfo(FILE *o, FLOW *f, unsigned int off) { fprintf(o,"lb=%d,rb=%d,w=%d,a=%d,d=%d,attr=%04x", get2s(f,off), get2s(f,off+2), get2s(f,off+4), get2s(f,off+6), get2s(f,off+8), get2u(f,off+10) ); } static void print_do_rgb(FILE *o, unsigned int m) { fprintf(o,"%c%c%c",(m&1)?'R':'-',(m&2)?'G':'-',(m&4)?'B':'-'); } static int print_host(FILE *o, FLOW *f, const char *pref, unsigned int off, unsigned int maxlen) { int al; char *p; if (maxlen < 4) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } al = get2u(f,off+2); if (maxlen < 4+padded(al)) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } fprintf(o,"%s",pref); print_choice(o,get1u(f,0),3,0,"Internet",1,"DECnet",2,"Chaos"); fprintf(o,":\n"); asprintf(&p,"%s ",pref); print_bin_blk(f,o,off+4,al,p,0); free(p); return(4+padded(al)); } static void canthappen(FLOW *f __attribute__((__unused__)), FILE *o __attribute__((__unused__))) { abort(); } static void ctox_CreateWindow(FLOW *f, FILE *o) { unsigned int mask; req_hdr_min(f,o,"CreateWindow",32); fprintf(o," Depth: %u\n",get1u(f,1)); fprintf(o," New window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Parent: "XID_FMT"\n",get4u(f,8)); fprintf(o," Shape: %ux%u at (%d,%d)\n",get2u(f,16),get2u(f,18),get2s(f,12),get2s(f,14)); fprintf(o," Border width: %u\n",get2u(f,20)); fprintf(o," Class: "); print_choice(o,get2u(f,22),3,0,"CopyFromParent",1,"InputOutput",2,"InputOnly"); fprintf(o,"\n"); fprintf(o," Visual: "); print_xid_z(o,get4u(f,24),"CopyFromParent"); fprintf(o,"\n"); mask = get4u(f,28); EXACTLENGTH(32+(4*bitcount(mask))); print_cwalist(f,o,mask,32); } static void ctox_ChangeWindowAttributes(FLOW *f, FILE *o) { unsigned int mask; req_hdr_min(f,o,"ChangeWindowAttributes",12); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); mask = get4u(f,8); EXACTLENGTH(12+(4*bitcount(mask))); print_cwalist(f,o,mask,12); } static void xtoc_GetWindowAttributes(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"GetWindowAttributes"); EXACTLENGTH(44); fprintf(o," Backing-store: "); print_backingstore(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Visual: "XID_FMT"\n",get4u(f,8)); fprintf(o," Class: "); print_choice(o,get2u(f,12),2,1,"InputOutput",2,"InputOnly"); fprintf(o,"\n"); fprintf(o," Bit gravity: "); print_bitgravity(o,get1u(f,14)); fprintf(o,"\n"); fprintf(o," Window gravity: "); print_wingravity(o,get1u(f,15)); fprintf(o,"\n"); fprintf(o," Backing planes: %08x\n",get4u(f,16)); fprintf(o," Backing pixel: %d",get4u(f,20)); fprintf(o," Save under: "); print_bool(o,get1u(f,24)); fprintf(o,"\n"); fprintf(o," Colourmap installed: "); print_bool(o,get1u(f,25)); fprintf(o,"\n"); fprintf(o," Map state: "); print_choice(o,get1u(f,26),3,0,"Unmapped",1,"Unviewable",2,"Viewable"); fprintf(o,"\n"); fprintf(o," Override-redirect: "); print_bool(o,get1u(f,27)); fprintf(o,"\n"); fprintf(o," Colourmap: "); print_xid_z(o,get4u(f,28),"None"); fprintf(o,"\n"); print_set(o," All event masks: "," ",get4u(f,32),SETofEVENT); print_set(o," This client's event masks: "," ",get4u(f,36),SETofEVENT); print_set(o," Do-not-propagate mask: "," ",get2u(f,40),SETofDEVICEEVENT); get_pad(f,42,2); } static void ctox_GetWindowAttributes(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetWindowAttributes",8); get_pad(f,1,1); expect_reply(f->conn,&xtoc_GetWindowAttributes,0); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void ctox_DestroyWindow(FLOW *f, FILE *o) { req_hdr_exact(f,o,"DestroyWindow",8); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void ctox_DestroySubwindows(FLOW *f, FILE *o) { req_hdr_exact(f,o,"DestroySubwindows",8); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void ctox_ChangeSaveSet(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ChangeSaveSet",8); fprintf(o," Mode: "); print_choice(o,get1u(f,1),2,0,"Insert",1,"Delete"); fprintf(o,"\n"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void ctox_ReparentWindow(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ReparentWindow",16); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," New parent: "XID_FMT"\n",get4u(f,8)); fprintf(o," New position: (%d,%d)\n",get2s(f,12),get2s(f,14)); } static void ctox_MapWindow(FLOW *f, FILE *o) { req_hdr_exact(f,o,"MapWindow",8); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void ctox_MapSubwindows(FLOW *f, FILE *o) { req_hdr_exact(f,o,"MapSubwindows",8); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void ctox_UnmapWindow(FLOW *f, FILE *o) { req_hdr_exact(f,o,"UnmapWindow",8); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void ctox_UnmapSubwindows(FLOW *f, FILE *o) { req_hdr_exact(f,o,"UnmapSubwindows",8); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void ctox_ConfigureWindow(FLOW *f, FILE *o) { unsigned int mask; int off; req_hdr_min(f,o,"ConfigureWindow",12); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); mask = get2u(f,8); get_pad(f,10,2); EXACTLENGTH(12+(4*bitcount(mask))); off = 12; fprintf(o," Value bitmask: %04x\n",mask); if (mask & 0x0001) { fprintf(o," X position: %d\n",ltos_s(get4s(f,off))); off += 4; } if (mask & 0x0002) { fprintf(o," Y position: %d\n",ltos_s(get4s(f,off))); off += 4; } if (mask & 0x0004) { fprintf(o," Width: %u\n",ltos_u(get4u(f,off))); off += 4; } if (mask & 0x0008) { fprintf(o," Height: %u\n",ltos_u(get4u(f,off))); off += 4; } if (mask & 0x0010) { fprintf(o," Border width: %u\n",ltos_u(get4u(f,off))); off += 4; } if (mask & 0x0020) { fprintf(o," Sibling: "XID_FMT"\n",get4u(f,off)); off += 4; } if (mask & 0x0040) { fprintf(o," Stack mode: "); print_stackmode(o,ltob_u(get4u(f,off))); fprintf(o,"\n"); off += 4; } if (mask & 0xff80) { fprintf(o," Unrecognized bits: %04x\n",mask&0xff80); } } static void ctox_CirculateWindow(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CirculateWindow",8); fprintf(o," Direction: "); print_choice(o,get1u(f,1),2,0,"RaiseLowest",1,"LowerHighest"); fprintf(o,"\n"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void xtoc_GetGeometry(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"GetGeometry"); EXACTLENGTH(32); fprintf(o," Depth: %u\n",get1u(f,1)); fprintf(o," Root: "XID_FMT"\n",get4u(f,8)); fprintf(o," Shape: %ux%u at (%d,%d)\n",get2u(f,16),get2u(f,18),get2s(f,12),get2s(f,14)); fprintf(o," Border width: %u\n",get2u(f,20)); get_pad(f,22,10); } static void ctox_GetGeometry(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetGeometry",8); get_pad(f,1,1); expect_reply(f->conn,&xtoc_GetGeometry,0); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); } static void xtoc_QueryTree(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; int off; int x; if (! f) return; rep_hdr(f,o,"QueryTree"); n = get2u(f,16); EXACTLENGTH(32+(4*n)); fprintf(o," Root: "XID_FMT"\n",get4u(f,8)); fprintf(o," Parent: "); print_xid_z(o,get4u(f,12),"None"); fprintf(o,"\n"); fprintf(o," Child count: %u\n",n); off = 32; x = 0; for (;n>0;n--) { if (x == 0) fprintf(o," "); fprintf(o," "XID_FMT,get4u(f,off)); x ++; if (x >= 7) { fprintf(o,"\n"); x = 0; } } if (x) fprintf(o,"\n"); } static void ctox_QueryTree(FLOW *f, FILE *o) { req_hdr_exact(f,o,"QueryTree",8); expect_reply(f->conn,&xtoc_QueryTree,0); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } typedef struct priv_InternAtom PRIV_InternAtom; struct priv_InternAtom { int nl; char *name; } ; static void xtoc_InternAtom(FLOW *f, FILE *o, void *pv) { unsigned int a; PRIV_InternAtom *p; p = pv; if (f) { rep_hdr(f,o,"InternAtom"); EXACTLENGTH(32); get_pad(f,1,1); a = get4u(f,8); fprintf(o," Atom: "); print_xid_z(o,a,"None"); fprintf(o,"\n"); get_pad(f,12,20); if (a) atoms_register(f->conn->atoms,p->name,p->nl,a); } free(p->name); free(p); } static void ctox_InternAtom(FLOW *f, FILE *o) { int n; PRIV_InternAtom *p; req_hdr_min(f,o,"InternAtom",8); n = get2u(f,4); EXACTLENGTH(8+padded(n)); p = malloc(sizeof(*p)); p->nl = n; p->name = copy_block(f->ibuf+8,n); expect_reply(f->conn,&xtoc_InternAtom,p); fprintf(o," Only-if-exists: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); get_pad(f,6,2); print_padded_text_blk(f,o,8,n," Name: ",0); } typedef struct priv_GetAtomName PRIV_GetAtomName; struct priv_GetAtomName { unsigned int a; } ; static void xtoc_GetAtomName(FLOW *f, FILE *o, void *pv) { int n; PRIV_GetAtomName *p; p = pv; if (f) { rep_hdr(f,o,"GetAtomName"); MINLENGTH(32); get_pad(f,1,1); n = get2u(f,8); EXACTLENGTH(32+padded(n)); get_pad(f,10,22); print_padded_text_blk(f,o,32,n," Name: ",0); atoms_register(f->conn->atoms,f->ibuf+32,n,p->a); } free(p); } static void ctox_GetAtomName(FLOW *f, FILE *o) { PRIV_GetAtomName *p; req_hdr_exact(f,o,"GetAtomName",8); get_pad(f,1,1); p = malloc(sizeof(*p)); p->a = get4u(f,4); expect_reply(f->conn,&xtoc_GetAtomName,p); fprintf(o," Atom: "XID_FMT"\n",get4u(f,4)); } static void ctox_ChangeProperty(FLOW *f, FILE *o) { int fmt; unsigned int len; static const char *unitname[] = { "?0", "byte", "short", "?3", "long" }; req_hdr_min(f,o,"ChangeProperty",24); fprintf(o," Mode: "); print_choice(o,get1u(f,1),3,0,"Replace",1,"Prepend",2,"Append"); fprintf(o,"\n"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Property: "); print_atom(o,f->conn,get4u(f,8)); fprintf(o,"\n"); fprintf(o," Type: "); print_atom(o,f->conn,get4u(f,12)); fprintf(o,"\n"); fmt = get1u(f,16); get_pad(f,17,3); len = get4u(f,20); switch (fmt) { case 8: case 16: case 32: fprintf(o," Format: %d\n",fmt); fprintf(o," Length in %ss: %u\n",unitname[fmt>>3],len); len *= fmt >> 3; EXACTLENGTH(24+padded(len)); print_bin_blk(f,o,24,len," Data: ",0); get_pad(f,24+len,pad(len)); break; default: fprintf(o," Format: %d (INVALID)\n",fmt); fprintf(o," Length in format units: %u\n",len); get_pad(f,24,f->ibfill-24); break; } } static void ctox_DeleteProperty(FLOW *f, FILE *o) { req_hdr_exact(f,o,"DeleteProperty",12); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Property: "); print_atom(o,f->conn,get4u(f,8)); fprintf(o,"\n"); } static void xtoc_GetProperty(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { int fmt; int len; int nb; static const char *unitname[] = { "?0", "byte", "short", "?3", "long" }; if (! f) return; rep_hdr(f,o,"GetProperty"); fmt = get1u(f,1); len = get4u(f,16); get_pad(f,20,12); switch (fmt) { case 0: fprintf(o," Format: 0\n"); get_pad(f,8,8); break; case 8: case 16: case 32: fprintf(o," Format: %d\n",fmt); fprintf(o," Type: "); print_atom_z(o,f->conn,get4u(f,8),"None"); fprintf(o,"\n"); fprintf(o," Bytes-after: %u\n",get4u(f,12)); fprintf(o," Length in %ss: %u\n",unitname[fmt>>3],len); nb = len * (fmt >> 3); EXACTLENGTH(32+padded(nb)); print_bin_blk(f,o,32,nb," Value: ",0); get_pad(f,32+nb,pad(nb)); break; default: fprintf(o," Format: %d (INVALID)\n",fmt); fprintf(o," Type: "); print_atom_z(o,f->conn,get4u(f,8),"None"); fprintf(o,"\n"); fprintf(o," Bytes-after: %u\n",get4u(f,12)); fprintf(o," Length in format units: %u\n",len); get_pad(f,32,f->ibfill-32); break; } } static void ctox_GetProperty(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetProperty",24); expect_reply(f->conn,&xtoc_GetProperty,0); fprintf(o," Delete: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Property: "); print_atom(o,f->conn,get4u(f,8)); fprintf(o,"\n"); fprintf(o," Type: "); print_atom_z(o,f->conn,get4u(f,12),"AnyPropertyType"); fprintf(o,"\n"); fprintf(o," Offset: %u\n",get4u(f,16)); fprintf(o," Length: %u\n",get4u(f,20)); } static void xtoc_ListProperties(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; int off; if (! f) return; rep_hdr(f,o,"ListProperites"); n = get2u(f,8); EXACTLENGTH(32+(4*n)); fprintf(o," Property count: %u\n",n); off = 32; for (;n>0;n--) { fprintf(o," "); print_atom(o,f->conn,get4u(f,off)); fprintf(o,"\n"); off += 4; } } static void ctox_ListProperties(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ListProperties",8); expect_reply(f->conn,&xtoc_ListProperties,0); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); } static void ctox_SetSelectionOwner(FLOW *f, FILE *o) { req_hdr_exact(f,o,"SetSelectionOwner",16); fprintf(o," Window: "); print_xid_z(o,get4u(f,4),"None"); fprintf(o,"\n"); fprintf(o," Selection: "); print_atom(o,f->conn,get4u(f,8)); fprintf(o,"\n"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,12)); fprintf(o,"\n"); } static void xtoc_GetSelectionOwner(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"GetSelectionOwner"); EXACTLENGTH(32); fprintf(o," Owner: "); print_xid_z(o,get4u(f,8),"None"); fprintf(o,"\n"); } static void ctox_GetSelectionOwner(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetSelectionOwner",8); fprintf(o," Selection: "); print_atom(o,f->conn,get4u(f,4)); fprintf(o,"\n"); expect_reply(f->conn,&xtoc_GetSelectionOwner,0); } static void ctox_ConvertSelection(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ConvertSelection",24); fprintf(o," Requestor: "XID_FMT"\n",get4u(f,4)); fprintf(o," Selection: "); print_atom(o,f->conn,get4u(f,8)); fprintf(o,"\n"); fprintf(o," Target: "); print_atom(o,f->conn,get4u(f,12)); fprintf(o,"\n"); fprintf(o," Property: "); print_atom_z(o,f->conn,get4u(f,16),"None"); fprintf(o,"\n"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,20)); fprintf(o,"\n"); } static void ctox_SendEvent(FLOW *f, FILE *o) { unsigned char *ibsave; int ibfsave; FILE *osub; int atbol; int ow(void *cookie __attribute__((__unused__)), const char *buf, int len) { int i; for (i=0;iibfill != f->ibfull) abort(); ibsave = f->ibuf; ibfsave = f->ibfill; f->ibuf += 12; f->ibfill = 32; f->ibfull = 32; atbol = 1; osub = funopen(0,0,&ow,0,&oc); format_event(f,osub); fclose(osub); f->ibuf = ibsave; f->ibfill = ibfsave; f->ibfull = ibfsave; } static void xtoc_GrabPointer(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"GrabPointer"); EXACTLENGTH(32); fprintf(o," Status: "); print_grabstatus(o,get1u(f,1)); fprintf(o,"\n"); } static void ctox_GrabPointer(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GrabPointer",24); fprintf(o," Owner events: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Grab window: "XID_FMT"\n",get4u(f,4)); print_set(o," Event mask: "," ",get2u(f,8),SETofPOINTEREVENT); fprintf(o," Pointer mode: "); print_grabmode(o,get1u(f,10)); fprintf(o,"\n"); fprintf(o," Keyboard mode: "); print_grabmode(o,get1u(f,11)); fprintf(o,"\n"); fprintf(o," Confine to: "); print_xid_z(o,get4u(f,12),"None"); fprintf(o,"\n"); fprintf(o," Cursor: "); print_xid_z(o,get4u(f,16),"None"); fprintf(o,"\n"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,20)); fprintf(o,"\n"); expect_reply(f->conn,&xtoc_GrabPointer,0); } static void ctox_UngrabPointer(FLOW *f, FILE *o) { req_hdr_exact(f,o,"UngrabPointer",8); get_pad(f,1,1); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,4)); fprintf(o,"\n"); } static void ctox_GrabButton(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GrabButton",24); fprintf(o," Owner events: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Grab window: "XID_FMT"\n",get4u(f,4)); print_set(o," Event mask: "," ",get2u(f,8),SETofPOINTEREVENT); fprintf(o," Pointer mode: "); print_grabmode(o,get1u(f,10)); fprintf(o,"\n"); fprintf(o," Keyboard mode: "); print_grabmode(o,get1u(f,11)); fprintf(o,"\n"); fprintf(o," Confine to: "); print_xid_z(o,get4u(f,12),"None"); fprintf(o,"\n"); fprintf(o," Cursor: "); print_xid_z(o,get4u(f,16),"None"); fprintf(o,"\n"); fprintf(o," Button: "); print_grabbutton(o,get1u(f,20)); fprintf(o,"\n"); print_set_alt(o," Modifiers: "," ",get2u(f,22),SETofKEYMASK,1,0x8000U,"AnyModifier"); } static void ctox_UngrabButton(FLOW *f, FILE *o) { req_hdr_exact(f,o,"UngrabButton",12); fprintf(o," Button: "); print_grabbutton(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Grab window: "XID_FMT"\n",get4u(f,4)); print_set_alt(o," Modifiers: "," ",get2u(f,8),SETofKEYMASK,1,0x8000U,"AnyModifier"); } static void ctox_ChangeActivePointerGrab(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ChangeActivePointerGrab",16); fprintf(o," Cursor: "); print_xid_z(o,get4u(f,4),"None"); fprintf(o,"\n"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,8)); fprintf(o,"\n"); print_set(o," Event mask: "," ",get2u(f,12),SETofPOINTEREVENT); } static void xtoc_GrabKeyboard(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"GrabKeyboard"); EXACTLENGTH(32); fprintf(o," Status: "); print_grabstatus(o,get1u(f,1)); fprintf(o,"\n"); get_pad(f,8,24); } static void ctox_GrabKeyboard(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GrabKeyboard",16); fprintf(o," Owner events: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Grab window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,8)); fprintf(o,"\n"); fprintf(o," Pointer mode: "); print_grabmode(o,get1u(f,12)); fprintf(o,"\n"); fprintf(o," Keyboard mode: "); print_grabmode(o,get1u(f,13)); fprintf(o,"\n"); get_pad(f,14,2); expect_reply(f->conn,&xtoc_GrabKeyboard,0); } static void ctox_UngrabKeyboard(FLOW *f, FILE *o) { req_hdr_exact(f,o,"UngrabKeyboard",8); get_pad(f,1,1); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,4)); fprintf(o,"\n"); } static void ctox_GrabKey(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GrabKey",16); fprintf(o," Owner events: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Grab window: "XID_FMT"\n",get4u(f,4)); print_set_alt(o," Modifiers: "," ",get2u(f,8),SETofKEYMASK,1,0x8000U,"AnyModifier"); fprintf(o," Key: "); print_grabkey(o,get1u(f,10)); fprintf(o,"\n"); fprintf(o," Pointer mode: "); print_grabmode(o,get1u(f,11)); fprintf(o,"\n"); fprintf(o," Keyboard mode: "); print_grabmode(o,get1u(f,12)); fprintf(o,"\n"); get_pad(f,13,3); } static void ctox_UngrabKey(FLOW *f, FILE *o) { req_hdr_exact(f,o,"UngrabKey",12); fprintf(o," Key: "); print_grabkey(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Grab window: "XID_FMT"\n",get4u(f,4)); print_set_alt(o," Modifiers: "," ",get2u(f,8),SETofKEYMASK,1,0x8000U,"AnyModifier"); } static void ctox_AllowEvents(FLOW *f, FILE *o) { req_hdr_exact(f,o,"AllowEvents",8); fprintf(o," Mode: "); print_choice(o,get1u(f,1),8, 0, "AsyncPointer", 1, "SyncPointer", 2, "ReplayPointer", 3, "AsyncKeyboard", 4, "SyncKeyboard", 5, "ReplayKeyboard", 6, "AsyncBoth", 7, "SyncBoth" ); fprintf(o,"\n"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,4)); fprintf(o,"\n"); } static void ctox_GrabServer(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GrabServer",4); } static void ctox_UngrabServer(FLOW *f, FILE *o) { req_hdr_exact(f,o,"UngrabServer",4); } static void xtoc_QueryPointer(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"QueryPointer"); EXACTLENGTH(32); fprintf(o," Same screen: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Root: "XID_FMT"\n",get4u(f,8)); fprintf(o," Child: "); print_xid_z(o,get4u(f,12),"None"); fprintf(o,"\n"); fprintf(o," Location: root (%d,%d) window (%d,%d)\n",get2s(f,16),get2s(f,18),get2s(f,20),get2s(f,22)); print_set(o," Mask: "," ",get2u(f,24),SETofKEYBUTMASK); get_pad(f,26,6); } static void ctox_QueryPointer(FLOW *f, FILE *o) { req_hdr_exact(f,o,"QueryPointer",8); get_pad(f,1,1); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); expect_reply(f->conn,&xtoc_QueryPointer,0); } static void xtoc_GetMotionEvents(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; if (! f) return; rep_hdr(f,o,"GetMotionEvents"); n = get4u(f,8); EXACTLENGTH(32+(8*n)); fprintf(o," Count: %u\n",n); off = 32; for (;n>0;n--) { fprintf(o," "); print_timestamp(o,get4u(f,off)); fprintf(o," (%u,%d)\n",get2u(f,off+4),get2u(f,off+6)); off += 8; } } static void ctox_GetMotionEvents(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetMotionEvents",16); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Start time: "); print_timestamp(o,get4u(f,8)); fprintf(o,"\n"); fprintf(o," Stop time: "); print_timestamp(o,get4u(f,12)); fprintf(o,"\n"); expect_reply(f->conn,&xtoc_GetMotionEvents,0); } static void xtoc_TranslateCoordinates(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"TranslateCoordinates"); EXACTLENGTH(32); fprintf(o," Same screen: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Child: "); print_xid_z(o,get4u(f,8),"None"); fprintf(o,"\n"); fprintf(o," Location: (%d,%d)\n",get2s(f,12),get2s(f,14)); } static void ctox_TranslateCoordinates(FLOW *f, FILE *o) { req_hdr_exact(f,o,"TranslateCoordinates",16); fprintf(o," Source window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Destination window: "XID_FMT"\n",get4u(f,8)); fprintf(o," Location: (%d,%d)\n",get2s(f,12),get2s(f,14)); expect_reply(f->conn,&xtoc_TranslateCoordinates,0); } static void ctox_WarpPointer(FLOW *f, FILE *o) { req_hdr_exact(f,o,"WarpPointer",24); get_pad(f,1,1); fprintf(o," Source window: "); print_xid_z(o,get4u(f,4),"None"); fprintf(o,"\n"); fprintf(o," Destination window: "); print_xid_z(o,get4u(f,8),"None"); fprintf(o,"\n"); fprintf(o," Source rect: %ux%u+%d+%d\n",get2u(f,16),get2u(f,18),get2s(f,12),get2s(f,14)); fprintf(o," Destination location: (%d,%d)\n",get2s(f,20),get2s(f,22)); } static void ctox_SetInputFocus(FLOW *f, FILE *o) { req_hdr_exact(f,o,"SetInputFocus",12); fprintf(o," Revert to: "); print_revertto(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Focus window: "); print_xid_alt(o,get4u(f,4),2,0U,"None",1U,"PointerRoot"); fprintf(o,"\n"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,8)); fprintf(o,"\n"); } static void xtoc_GetInputFocus(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"GetInputFocus"); EXACTLENGTH(32); fprintf(o," Revert to: "); print_revertto(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Focus: "); print_xid_alt(o,get4u(f,8),2,0U,"None",1U,"PointerRoot"); fprintf(o,"\n"); get_pad(f,12,20); } static void ctox_GetInputFocus(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetInputFocus",4); get_pad(f,1,1); expect_reply(f->conn,&xtoc_GetInputFocus,0); } static void xtoc_QueryKeymap(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { int i; int n; int j; unsigned char m; if (! f) return; rep_hdr(f,o,"QueryKeymap"); EXACTLENGTH(40); n = 0; for (i=0;i<32;i++) n += bitcount(get1u(f,8+i)); if (n == 0) { fprintf(o," Keys down: none\n"); } else if (n < 10) { fprintf(o," Keys down:"); for (i=0;i<32;i++) { m = get1u(f,8+i); for (j=0;j<8;j++,m>>=1) { if (m & 1) { fprintf(o," %d",(i*8)+j); } } } fprintf(o,"\n"); } else { fprintf(o,"\n"); for (i=0;i<256;i++) { if (! (i & 7)) m = get1u(f,8+(i>>3)); if (! (i & 63)) fprintf(o," "); putc( (m & (1 << (i & 7))) ? (i < 8) ? '?' : '*' : (i < 8) ? ' ' : '-', o); switch (i & 63) { case 15: case 31: case 47: putc(' ',o); break; case 63: putc('\n',o); break; } } } } static void ctox_QueryKeymap(FLOW *f, FILE *o) { req_hdr_exact(f,o,"QueryKeymap",4); expect_reply(f->conn,&xtoc_QueryKeymap,0); } static void ctox_OpenFont(FLOW *f, FILE *o) { int n; req_hdr_min(f,o,"OpenFont",12); get_pad(f,1,1); n = get2u(f,8); EXACTLENGTH(12+padded(n)); fprintf(o," ID: "XID_FMT"\n",get4u(f,4)); get_pad(f,10,2); print_padded_text_blk(f,o,12,n," Name: ",0); } static void ctox_CloseFont(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CloseFont",8); get_pad(f,1,1); fprintf(o," ID: "XID_FMT"\n",get4u(f,4)); } /* XXX Think about factoring common code out of xtoc_QueryFont and xtoc_ListFontsWithInfo */ static void xtoc_QueryFont(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int m; unsigned int min_char_or_byte2; unsigned int max_char_or_byte2; unsigned char min_byte1; unsigned char max_byte1; unsigned int off; if (! f) return; rep_hdr(f,o,"QueryFont"); MINLENGTH(60); get_pad(f,1,1); n = get2u(f,46); m = get4u(f,56); EXACTLENGTH(60+(8*n)+(12*m)); min_byte1 = get1u(f,49); max_byte1 = get1u(f,50); min_char_or_byte2 = get2u(f,40); max_char_or_byte2 = get2u(f,42); fprintf(o," Draw direction: "); print_drawdir(o,get1u(f,48)); fprintf(o,"\n"); if ((min_byte1 == 0) && (max_byte1 == 0)) { fprintf(o," Linear chars: %d..%d\n",min_char_or_byte2,max_char_or_byte2); } else if ((min_char_or_byte2 < 256) && (max_char_or_byte2 < 256)) { fprintf(o," Chars [%u..%u] [%u..%u]\n",min_byte1,max_byte1,min_char_or_byte2,max_char_or_byte2); } else { fprintf(o," INVALID: min byte1 %u, max byte1 %u, min char-or-byte2 %u, max char-or-byte2 %u\n",min_byte1,max_byte1,min_char_or_byte2,max_char_or_byte2); } if (m == 0) { if (bcmp(f->ibuf+8,f->ibuf+24,12)) { fprintf(o," INVALID: no charinfos, but min and max bounds differ\n"); fprintf(o," Min bounds: "); print_charinfo(o,f,8); fprintf(o,"\n"); get_pad(f,20,4); fprintf(o," Max bounds: "); print_charinfo(o,f,24); fprintf(o,"\n"); get_pad(f,36,4); } else { fprintf(o," Bounds: "); print_charinfo(o,f,8); fprintf(o,"\n"); get_pad(f,20,20); } } else { fprintf(o," Min bounds: "); print_charinfo(o,f,8); fprintf(o,"\n"); get_pad(f,20,4); fprintf(o," Max bounds: "); print_charinfo(o,f,24); fprintf(o,"\n"); get_pad(f,36,4); } fprintf(o," All chars exist: "); print_bool(o,get1u(f,51)); fprintf(o,"\n"); fprintf(o," Default char: 0x%x\n",get2u(f,44)); fprintf(o," Font ascent: %d\n",get2s(f,52)); fprintf(o," Font descent: %d\n",get2s(f,54)); fprintf(o," Properties: %u\n",n); off = 60; for (;n>0;n--) { fprintf(o," "); print_atom(o,f->conn,get4u(f,off)); fprintf(o," = 0x%x\n",get4u(f,off+4)); off += 8; } fprintf(o," Per-character info count: %u\n",m); for (;m>0;m--) { fprintf(o," "); print_charinfo(o,f,off); fprintf(o,"\n"); off += 12; } } static void ctox_QueryFont(FLOW *f, FILE *o) { req_hdr_exact(f,o,"QueryFont",8); get_pad(f,1,1); fprintf(o," ID: "XID_FMT"\n",get4u(f,4)); expect_reply(f->conn,&xtoc_QueryFont,0); } static void xtoc_QueryTextExtents(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"QueryTextExtents"); EXACTLENGTH(32); fprintf(o," Draw direction: "); print_drawdir(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Font ascent: %d\n",get2s(f,8)); fprintf(o," Font descent: %d\n",get2s(f,10)); fprintf(o," Ascent: %d\n",get2s(f,12)); fprintf(o," Descent: %d\n",get2s(f,14)); fprintf(o," Width: %d\n",get4s(f,16)); fprintf(o," Left bearing: %d\n",get4s(f,20)); fprintf(o," Right bearing: %d\n",get4s(f,24)); } static void ctox_QueryTextExtents(FLOW *f, FILE *o) { unsigned int n; req_hdr_min(f,o,"QueryTextExtents",8); n = (f->ibfill - 8) / 2; EXACTLENGTH(8+(2*n)); fprintf(o," Odd length: "); print_bool(o,get1u(f,1)); if (get1u(f,1)) { if (n == 0) { fprintf(o," (INVALID - length is 0)"); } else { n --; } } fprintf(o,"\n"); fprintf(o," Font: "XID_FMT"\n",get4u(f,4)); print_bin_blk(f,o,8,n*2," Data: ",0); expect_reply(f->conn,&xtoc_QueryTextExtents,0); } /* XXX Think about factoring common code out of xtoc_ListFonts and xtoc_GetFontPath */ static void xtoc_ListFonts(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; unsigned int l; if (! f) return; rep_hdr(f,o,"ListFonts"); MINLENGTH(32); n = get2u(f,8); fprintf(o," Name count: %u\n",n); off = 32; for (;n>0;n--) { if (off >= f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } l = get1u(f,off); if (off+1+l > f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } print_text_blk(f,o,off+1,l," Name: ",0); off += 1 + l; } if (off > f->ibfill) abort(); if (f->ibfill-off > 3) { fprintf(o,"*** Packet underrun (bytes left: %d)\n",f->ibfill-off); print_raw_data(o,f); abort_packet_print(); } } static void ctox_ListFonts(FLOW *f, FILE *o) { unsigned int n; req_hdr_min(f,o,"ListFonts",8); n = get2u(f,6); EXACTLENGTH(8+padded(n)); fprintf(o," Max names: %u\n",get2u(f,4)); print_text_blk(f,o,8,n," Pattern: ",0); expect_reply(f->conn,&xtoc_ListFonts,0); } /* XXX Think about factoring common code out of xtoc_QueryFont and xtoc_ListFontsWithInfo */ static void xtoc_ListFontsWithInfo(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int m; unsigned int min_char_or_byte2; unsigned int max_char_or_byte2; unsigned char min_byte1; unsigned char max_byte1; unsigned int off; if (! f) return; rep_hdr(f,o,"ListFontsWithInfo"); MINLENGTH(60); n = get1u(f,1); if (n == 0) { EXACTLENGTH(60); fprintf(o," Terminator entry\n"); return; } m = get2u(f,46); EXACTLENGTH(60+(8*m)+padded(n)); min_byte1 = get1u(f,49); max_byte1 = get1u(f,50); min_char_or_byte2 = get2u(f,40); max_char_or_byte2 = get2u(f,42); fprintf(o," Draw direction: "); print_drawdir(o,get1u(f,48)); fprintf(o,"\n"); if ((min_byte1 == 0) && (max_byte1 == 0)) { fprintf(o," Linear chars: %d..%d\n",min_char_or_byte2,max_char_or_byte2); } else if ((min_char_or_byte2 < 256) && (max_char_or_byte2 < 256)) { fprintf(o," Chars [%u..%u] [%u..%u]\n",min_byte1,max_byte1,min_char_or_byte2,max_char_or_byte2); } else { fprintf(o," INVALID: min byte1 %u, max byte1 %u, min char-or-byte2 %u, max char-or-byte2 %u\n",min_byte1,max_byte1,min_char_or_byte2,max_char_or_byte2); } fprintf(o," Min bounds: "); print_charinfo(o,f,8); fprintf(o,"\n"); fprintf(o," Max bounds: "); print_charinfo(o,f,24); fprintf(o,"\n"); fprintf(o," All chars exist: "); print_bool(o,get1u(f,51)); fprintf(o,"\n"); fprintf(o," Default char: 0x%x\n",get2u(f,44)); fprintf(o," Font ascent: %d\n",get2s(f,52)); fprintf(o," Font descent: %d\n",get2s(f,54)); fprintf(o," Replies hint: %u\n",get4u(f,56)); fprintf(o," Properties: %u\n",n); off = 60; for (;m>0;m--) { fprintf(o," "); print_atom(o,f->conn,get4u(f,off)); fprintf(o," = 0x%x\n",get4u(f,off+4)); off += 8; } print_text_blk(f,o,off,n," Name: ",0); expect_another_reply(f->conn,get2u(f,2),&xtoc_ListFontsWithInfo,0); } static void ctox_ListFontsWithInfo(FLOW *f, FILE *o) { unsigned int n; req_hdr_min(f,o,"ListFontsWithInfo",8); n = get2u(f,6); EXACTLENGTH(8+padded(n)); fprintf(o," Max names: %u\n",get2u(f,4)); print_text_blk(f,o,8,n," Pattern: ",0); expect_reply(f->conn,&xtoc_ListFontsWithInfo,0); } static void ctox_SetFontPath(FLOW *f, FILE *o) { unsigned int n; unsigned int off; unsigned int l; req_hdr_min(f,o,"SetFontPath",8); n = get2u(f,4); fprintf(o," Path count: %u\n",n); off = 8; for (;n>0;n--) { if (off >= f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } l = get1u(f,off); if (off+1+l > f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } print_text_blk(f,o,off+1,l," Path: ",0); off += 1 + l; } if (off > f->ibfill) abort(); if (f->ibfill-off > 3) { fprintf(o,"*** Packet underrun (bytes left: %d)\n",f->ibfill-off); print_raw_data(o,f); abort_packet_print(); } } /* XXX Think about factoring common code out of xtoc_ListFonts and xtoc_GetFontPath */ static void xtoc_GetFontPath(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; unsigned int l; if (! f) return; rep_hdr(f,o,"GetFontPath"); MINLENGTH(32); n = get2u(f,8); fprintf(o," Path count: %u\n",n); off = 32; for (;n>0;n--) { if (off >= f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } l = get1u(f,off); if (off+1+l > f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } print_text_blk(f,o,off+1,l," Path: ",0); off += 1 + l; } if (off > f->ibfill) abort(); if (f->ibfill-off > 3) { fprintf(o,"*** Packet underrun (bytes left: %d)\n",f->ibfill-off); print_raw_data(o,f); abort_packet_print(); } } static void ctox_GetFontPath(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetFontPath",4); expect_reply(f->conn,&xtoc_GetFontPath,0); } static void ctox_CreatePixmap(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CreatePixmap",16); fprintf(o," Depth: %u\n",get1u(f,1)); fprintf(o," New pixmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,8)); fprintf(o," Size: %ux%u\n",get2u(f,12),get2u(f,14)); } static void ctox_FreePixmap(FLOW *f, FILE *o) { req_hdr_exact(f,o,"FreePixmap",8); get_pad(f,1,1); fprintf(o," Pixmap: "XID_FMT"\n",get4u(f,4)); } static void ctox_CreateGC(FLOW *f, FILE *o) { unsigned int mask; req_hdr_min(f,o,"CreateGC",16); get_pad(f,1,1); fprintf(o," New GC: "XID_FMT"\n",get4u(f,4)); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,8)); mask = get4u(f,12); EXACTLENGTH(16+(4*bitcount(mask))); print_cgclist(f,o,mask,16); } static void ctox_ChangeGC(FLOW *f, FILE *o) { unsigned int mask; req_hdr_min(f,o,"ChangeGC",12); get_pad(f,1,1); fprintf(o," GC: "XID_FMT"\n",get4u(f,4)); mask = get4u(f,8); EXACTLENGTH(12+(4*bitcount(mask))); print_cgclist(f,o,mask,12); } static void ctox_CopyGC(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CopyGC",16); fprintf(o," Source GC: "XID_FMT"\n",get4u(f,4)); fprintf(o," Destination GC: "XID_FMT"\n",get4u(f,8)); print_set(o," Values: "," ",get4u(f,12),COPYGC); } static void ctox_SetDashes(FLOW *f, FILE *o) { unsigned int n; int col; unsigned int off; req_hdr_min(f,o,"SetDashes",12); n = get2u(f,10); EXACTLENGTH(12+padded(n)); fprintf(o," GC: "XID_FMT"\n",get4u(f,4)); fprintf(o," Dash offset: %u\n",get2u(f,8)); col = fprintf(o," Dashes:"); for (;n>0;n--) { if (col > 64) { fprintf(o,"\n"); col = fprintf(o," "); } col += fprintf(o," %d",get1u(f,off)); off ++; } fprintf(o,"\n"); } static void ctox_SetClipRectangles(FLOW *f, FILE *o) { unsigned int n; unsigned int off; req_hdr_min(f,o,"SetClipRectangles",12); n = (f->ibfull - 12) / 8; EXACTLENGTH(12+(8*n)); fprintf(o," GC: "XID_FMT"\n",get4u(f,4)); fprintf(o," Clip origin: (%d,%d)\n",get2s(f,8),get2s(f,10)); fprintf(o," Rectangle count: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," %ux%u+%d+%d\n",get2u(f,off+4),get2u(f,off+6),get2s(f,off),get2s(f,off+2)); off += 12; } } static void ctox_FreeGC(FLOW *f, FILE *o) { req_hdr_exact(f,o,"FreeGC",8); get_pad(f,1,1); fprintf(o," GC: "XID_FMT"\n",get4u(f,4)); } static void ctox_ClearArea(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ClearArea",16); fprintf(o," Exposures: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Area: %ux%u+%d+%d\n",get2u(f,12),get2u(f,14),get2s(f,8),get2s(f,10)); } static void ctox_CopyArea(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CopyArea",28); fprintf(o," Source: "XID_FMT"\n",get4u(f,4)); fprintf(o," Destination: "XID_FMT"\n",get4u(f,8)); fprintf(o," GC: "XID_FMT"\n",get4u(f,12)); fprintf(o," Copy: %ux%u from (%d,%d) to (%d,%d)\n", get2u(f,24), get2u(f,26), get2s(f,16), get2s(f,18), get2s(f,20), get2s(f,22) ); } static void ctox_CopyPlane(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CopyPlane",32); fprintf(o," Source: "XID_FMT"\n",get4u(f,4)); fprintf(o," Destination: "XID_FMT"\n",get4u(f,8)); fprintf(o," GC: "XID_FMT"\n",get4u(f,12)); fprintf(o," Copy: %ux%u from (%d,%d) to (%d,%d)\n", get2u(f,24), get2u(f,26), get2s(f,16), get2s(f,18), get2s(f,20), get2s(f,22) ); fprintf(o," Plane: 0x%08x\n",get4u(f,28)); } static void ctox_PolyPoint(FLOW *f, FILE *o) { int n; unsigned int off; req_hdr_min(f,o,"PolyPoint",12); n = (f->ibfill - 12) / 4; EXACTLENGTH(12+(4*n)); fprintf(o," Mode: "); print_coordmode(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Points: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," (%d,%d)\n",get2s(f,off),get2s(f,off+2)); off += 4; } } static void ctox_PolyLine(FLOW *f, FILE *o) { int n; unsigned int off; req_hdr_min(f,o,"PolyLine",12); n = (f->ibfill - 12) / 4; EXACTLENGTH(12+(4*n)); fprintf(o," Mode: "); print_coordmode(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Points: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," (%d,%d)\n",get2s(f,off),get2s(f,off+2)); off += 4; } } static void ctox_PolySegment(FLOW *f, FILE *o) { int n; unsigned int off; req_hdr_min(f,o,"PolySegment",12); n = (f->ibfill - 12) / 8; EXACTLENGTH(12+(8*n)); get_pad(f,1,1); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Segments: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," (%d,%d)-(%d,%d)\n",get2s(f,off),get2s(f,off+2),get2s(f,off+4),get2s(f,off+6)); off += 8; } } static void ctox_PolyRectangle(FLOW *f, FILE *o) { int n; unsigned int off; req_hdr_min(f,o,"PolyRectangle",12); n = (f->ibfill - 12) / 8; EXACTLENGTH(12+(8*n)); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Rectangles: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," %ux%u+%d+%d\n",get2s(f,off+4),get2s(f,off+6),get2s(f,off),get2s(f,off+2)); off += 8; } } static void ctox_PolyArc(FLOW *f, FILE *o) { int n; unsigned int off; req_hdr_min(f,o,"PolyArc",12); n = (f->ibfill - 12) / 12; EXACTLENGTH(12+(12*n)); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Arcs: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," %ux%u+%d+%d %g..%g\n", get2s(f,off+4), get2s(f,off+6), get2s(f,off), get2s(f,off+2), get2s(f,off+8)/64.0, get2s(f,off+10)/64.0 ); off += 12; } } static void ctox_FillPoly(FLOW *f, FILE *o) { int n; unsigned int off; req_hdr_min(f,o,"FillPoly",16); n = (f->ibfill - 16) / 4; EXACTLENGTH(16+(4*n)); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Shape: "); print_choice(o,get1u(f,12),3, 0, "Complex", 1, "Nonconvex", 2, "Convex" ); fprintf(o,"\n"); fprintf(o," Mode: "); print_coordmode(o,get1u(f,13)); fprintf(o,"\n"); fprintf(o," Points: %u\n",n); off = 16; for (;n>0;n--) { fprintf(o," (%d,%d)\n",get2s(f,off),get2s(f,off+2)); off += 4; } } static void ctox_PolyFillRectangle(FLOW *f, FILE *o) { int n; unsigned int off; req_hdr_min(f,o,"PolyFillRectangle",12); n = (f->ibfill - 12) / 8; EXACTLENGTH(12+(8*n)); get_pad(f,1,1); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Rectangles: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," %ux%u+%d+%d\n",get2s(f,off+4),get2s(f,off+6),get2s(f,off),get2s(f,off+2)); off += 8; } } static void ctox_PolyFillArc(FLOW *f, FILE *o) { int n; unsigned int off; req_hdr_min(f,o,"PolyFillArc",12); n = (f->ibfill - 12) / 12; EXACTLENGTH(12+(12*n)); get_pad(f,1,1); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Arcs: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," %ux%u+%d+%d %g..%g\n", get2s(f,off+4), get2s(f,off+6), get2s(f,off), get2s(f,off+2), get2s(f,off+8)/64.0, get2s(f,off+10)/64.0 ); off += 12; } } static void ctox_PutImage(FLOW *f, FILE *o) { req_hdr_min(f,o,"PutImage",24); fprintf(o," Format: "); print_choice(o,get1u(f,1),3,0,"Bitmap",1,"XYPixmap",2,"ZPixmap"); fprintf(o,"\n"); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Size: %ux%u\n",get2u(f,12),get2u(f,14)); fprintf(o," Location: (%d,%d)\n",get2u(f,16),get2u(f,18)); fprintf(o," Left pad: %u\n",get1u(f,20)); fprintf(o," Depth: %u\n",get1u(f,21)); get_pad(f,22,2); print_bin_blk(f,o,24,f->ibfill-24," Data: ",0); } static void xtoc_GetImage(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"GetImage"); MINLENGTH(32); fprintf(o," Depth: %u\n",get1u(f,1)); fprintf(o," Visual: "); print_xid_z(o,get4u(f,8),"None"); get_pad(f,12,20); print_bin_blk(f,o,32,f->ibfill-32," Data: ",0); } static void ctox_GetImage(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetImage",20); fprintf(o," Format: "); print_choice(o,get1u(f,1),2,1,"XYPixmap",2,"ZPixmap"); fprintf(o,"\n"); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," Shape: %ux%u+%d+%d\n",get2u(f,12),get2u(f,14),get2s(f,8),get2s(f,10)); fprintf(o," Plane mask: 0x%x\n",get4u(f,16)); expect_reply(f->conn,&xtoc_GetImage,0); } static void ctox_PolyText8(FLOW *f, FILE *o) { unsigned int off; unsigned int m; req_hdr_min(f,o,"PolyText8",16); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Location: (%d,%d)\n",get2u(f,12),get2u(f,14)); off = 16; while (1) { if (off+1 >= f->ibfill) break; m = get1u(f,off); if (m == 255) { if (off+5 > f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } fprintf(o," - Change to font "XID_FMT"\n", (get1u(f,off+1)*0x01000000) + (get1u(f,off+2)*0x00010000) + (get1u(f,off+3)*0x00000100) + (get1u(f,off+4)*0x00000001) ); off += 5; } else { if (off+2+m > f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } fprintf(o," - Delta %d\n",get1s(f,off+1)); print_text_blk(f,o,off+2,m," Text: ",0); off += 2 + m; } } } static void ctox_PolyText16(FLOW *f, FILE *o) { unsigned int off; unsigned int m; req_hdr_min(f,o,"PolyText16",16); get_pad(f,1,1); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Location: (%d,%d)\n",get2u(f,12),get2u(f,14)); off = 16; while (1) { if (off > f->ibfill) abort(); if (off == f->ibfill) break; if (off+1 == f->ibfill) { get_pad(f,off,1); break; } m = get1u(f,off); if (m == 255) { if (off+5 > f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } fprintf(o," - Change to font "XID_FMT"\n", (get1u(f,off+1)*0x01000000) + (get1u(f,off+2)*0x00010000) + (get1u(f,off+3)*0x00000100) + (get1u(f,off+4)*0x00000001) ); off += 5; } else { if (off+2+(2*m) > f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } fprintf(o," - Delta %d\n",get1s(f,off+1)); print_bin_blk(f,o,off+2,2*m," Text: ",0); off += 2 + (2 * m); } } } static void ctox_ImageText8(FLOW *f, FILE *o) { unsigned int n; req_hdr_min(f,o,"ImageText8",16); n = get1u(f,1); EXACTLENGTH(16+padded(n)); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Location: (%d,%d)\n",get2u(f,12),get2u(f,14)); print_padded_text_blk(f,o,16,n," Text: ",0); } static void ctox_ImageText16(FLOW *f, FILE *o) { unsigned int n; req_hdr_min(f,o,"ImageText16",16); n = get1u(f,1); EXACTLENGTH(16+padded(2*n)); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," GC: "XID_FMT"\n",get4u(f,8)); fprintf(o," Location: (%d,%d)\n",get2u(f,12),get2u(f,14)); print_bin_blk(f,o,16,2*n," Text: ",0); } static void ctox_CreateColormap(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CreateColormap",16); fprintf(o," Alloc: "); print_choice(o,get1u(f,1),2,0,"None",1,"All"); fprintf(o,"\n"); fprintf(o," New colourmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," Visual: "XID_FMT"\n",get4u(f,12)); } static void ctox_FreeColormap(FLOW *f, FILE *o) { req_hdr_exact(f,o,"FreeColormap",8); get_pad(f,1,1); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); } static void ctox_CopyColormapAndFree(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CopyColormapAndFree",12); get_pad(f,1,1); fprintf(o," New colourmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Source colourmap: "XID_FMT"\n",get4u(f,8)); } static void ctox_InstallColormap(FLOW *f, FILE *o) { req_hdr_exact(f,o,"InstallColormap",8); get_pad(f,1,1); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); } static void ctox_UninstallColormap(FLOW *f, FILE *o) { req_hdr_exact(f,o,"UninstallColormap",8); get_pad(f,1,1); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); } static void xtoc_ListInstalledColormaps(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; if (! f) return; rep_hdr(f,o,"ListInstalledColormaps"); MINLENGTH(32); n = get2u(f,8); EXACTLENGTH(32+(4*n)); fprintf(o," Colourmaps: %u\n",n); off = 32; for (;n>0;n--) { fprintf(o," "XID_FMT"\n",get4u(f,off)); off += 4; } } static void ctox_ListInstalledColormaps(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ListInstalledColormaps",8); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); expect_reply(f->conn,&xtoc_ListInstalledColormaps,0); } static void xtoc_AllocColor(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"AllocColor"); EXACTLENGTH(32); get_pad(f,1,1); fprintf(o," Colour: (%u,%u,%u)\n",get2u(f,8),get2u(f,10),get2u(f,12)); get_pad(f,14,2); fprintf(o," Pixel: %u\n",get4u(f,16)); get_pad(f,20,12); } static void ctox_AllocColor(FLOW *f, FILE *o) { req_hdr_exact(f,o,"AllocColor",16); get_pad(f,1,1); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Colour: (%u,%u,%u)\n",get2u(f,8),get2u(f,10),get2u(f,12)); get_pad(f,14,2); expect_reply(f->conn,&xtoc_AllocColor,0); } static void xtoc_AllocNamedColor(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"AllocNamedColor"); EXACTLENGTH(32); fprintf(o," Pixel: %u\n",get4u(f,8)); fprintf(o," Exact: (%u,%u,%u)\n",get2u(f,12),get2u(f,14),get2u(f,16)); fprintf(o," Visual: (%u,%u,%u)\n",get2u(f,18),get2u(f,20),get2u(f,22)); } static void ctox_AllocNamedColor(FLOW *f, FILE *o) { int n; req_hdr_min(f,o,"AllocNamedColor",12); n = get2u(f,8); EXACTLENGTH(12+padded(n)); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); print_text_blk(f,o,12,n," Name: ",0); expect_reply(f->conn,&xtoc_AllocNamedColor,0); } static void xtoc_AllocColorCells(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int m; unsigned int off; if (! f) return; rep_hdr(f,o,"AllocColorCells"); n = get2u(f,8); m = get2u(f,10); EXACTLENGTH(32+(4*(n+m))); off = 32; fprintf(o," Pixels: %u\n",n); for (;n>0;n--) { fprintf(o," %u\n",get4u(f,off)); off += 4; } fprintf(o," Masks: %u\n",m); for (;m>0;m--) { fprintf(o," %u\n",get4u(f,off)); off += 4; } } static void ctox_AllocColorCells(FLOW *f, FILE *o) { req_hdr_exact(f,o,"AllocColorCells",12); fprintf(o," Contiguous: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Colours: %u\n",get2u(f,8)); fprintf(o," Planes: %u\n",get2u(f,10)); expect_reply(f->conn,&xtoc_AllocColorCells,0); } static void xtoc_AllocColorPlanes(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; if (! f) return; rep_hdr(f,o,"AllocColorPlanes"); n = get2u(f,8); EXACTLENGTH(32+(4*n)); fprintf(o," Red mask: 0x%x\n",get4u(f,12)); fprintf(o," Green mask: 0x%x\n",get4u(f,16)); fprintf(o," Blue mask: 0x%x\n",get4u(f,20)); off = 32; fprintf(o," Pixels: %u\n",n); for (;n>0;n--) { fprintf(o," %u\n",get4u(f,off)); off += 4; } } static void ctox_AllocColorPlanes(FLOW *f, FILE *o) { req_hdr_exact(f,o,"AllocColorPlanes",16); fprintf(o," Contiguous: "); print_bool(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Colours: %u\n",get2u(f,8)); fprintf(o," Reds: %u\n",get2u(f,10)); fprintf(o," Greens: %u\n",get2u(f,12)); fprintf(o," Blues: %u\n",get2u(f,14)); expect_reply(f->conn,&xtoc_AllocColorPlanes,0); } static void ctox_FreeColors(FLOW *f, FILE *o) { unsigned int n; unsigned int off; req_hdr_min(f,o,"FreeColors",12); n = (f->ibfill - 12) / 4; EXACTLENGTH(12+(4*n)); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Plane mask: 0x%x\n",get2u(f,8)); fprintf(o," Pixels: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," %u\n",get4u(f,off)); off += 4; } } static void ctox_StoreColors(FLOW *f, FILE *o) { unsigned int n; unsigned int off; req_hdr_min(f,o,"StoreColors",8); n = (f->ibfill - 8) / 12; EXACTLENGTH(8+(12*n)); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Items: %u\n",n); off = 8; for (;n>0;n--) { fprintf(o," %u <- (%u,%u,%u) do ",get4u(f,off),get2u(f,off+4),get2u(f,off+6),get2u(f,off+8)); print_do_rgb(o,get1u(f,10)); fprintf(o,"\n"); off += 12; } } static void ctox_StoreNamedColor(FLOW *f, FILE *o) { unsigned int n; req_hdr_min(f,o,"StoreNamedColor",16); n = get2u(f,12); EXACTLENGTH(16+padded(n)); fprintf(o," Do: "); print_do_rgb(o,get1u(f,1)); fprintf(o,"\n"); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Pixel: %u\n",get4u(f,8)); print_text_blk(f,o,16,n," Name: ",0); } static void xtoc_QueryColors(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; if (! f) return; rep_hdr(f,o,"QueryColors"); get_pad(f,1,1); n = get2u(f,8); get_pad(f,10,22); EXACTLENGTH(32+(8*n)); off = 32; fprintf(o," Colours: %u\n",n); for (;n>0;n--) { fprintf(o," (%u,%u,%u)\n",get2u(f,off),get2u(f,off+2),get2u(f,off+4)); get_pad(f,off+6,2); off += 8; } } static void ctox_QueryColors(FLOW *f, FILE *o) { unsigned int n; unsigned int off; req_hdr_min(f,o,"QueryColors",8); n = (f->ibfill - 8) / 4; EXACTLENGTH(8+(4*n)); get_pad(f,1,1); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); fprintf(o," Pixels: %u\n",n); off = 8; for (;n>0;n--) { fprintf(o," %u\n",get4u(f,off)); off += 4; } expect_reply(f->conn,&xtoc_QueryColors,0); } static void xtoc_LookupColor(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"LookupColor"); get_pad(f,1,1); get_pad(f,20,12); EXACTLENGTH(32); fprintf(o," Exact: (%u,%u,%u)\n",get2u(f,8),get2u(f,10),get2u(f,12)); fprintf(o," Visual: (%u,%u,%u)\n",get2u(f,14),get2u(f,16),get2u(f,18)); } static void ctox_LookupColor(FLOW *f, FILE *o) { unsigned int n; req_hdr_min(f,o,"LookupColor",12); get_pad(f,1,1); n = get2u(f,8); get_pad(f,10,2); EXACTLENGTH(12+padded(n)); fprintf(o," Colourmap: "XID_FMT"\n",get4u(f,4)); print_padded_text_blk(f,o,12,n," Name: ",0); expect_reply(f->conn,&xtoc_LookupColor,0); } static void ctox_CreateCursor(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CreateCursor",32); get_pad(f,1,1); fprintf(o," Cursor: "XID_FMT"\n",get4u(f,4)); fprintf(o," Source: "XID_FMT"\n",get4u(f,8)); fprintf(o," Mask: "); print_xid_z(o,get4u(f,12),"None"); fprintf(o,"\n"); fprintf(o," Foreground: (%u,%u,%u)\n",get2u(f,16),get2u(f,18),get2u(f,20)); fprintf(o," Background: (%u,%u,%u)\n",get2u(f,22),get2u(f,24),get2u(f,26)); fprintf(o," Hot spot: (%u,%u)\n",get2u(f,28),get2u(f,30)); } static void ctox_CreateGlyphCursor(FLOW *f, FILE *o) { req_hdr_exact(f,o,"CreateGlyphCursor",32); fprintf(o," Cursor: "XID_FMT"\n",get4u(f,4)); fprintf(o," Source: font "XID_FMT", char 0x%04x\n",get4u(f,8),get2u(f,16)); fprintf(o," Mask: font "); print_xid_z(o,get4u(f,12),"None"); fprintf(o," , char 0x%04x\n",get2u(f,18)); fprintf(o," Foreground: (%u,%u,%u)\n",get2u(f,20),get2u(f,22),get2u(f,24)); fprintf(o," Background: (%u,%u,%u)\n",get2u(f,26),get2u(f,28),get2u(f,30)); } static void ctox_FreeCursor(FLOW *f, FILE *o) { req_hdr_exact(f,o,"FreeCursor",8); get_pad(f,1,1); fprintf(o," Cursor: "XID_FMT"\n",get4u(f,4)); } static void ctox_RecolorCursor(FLOW *f, FILE *o) { req_hdr_exact(f,o,"RecolorCursor",20); get_pad(f,1,1); fprintf(o," Cursor: "XID_FMT"\n",get4u(f,4)); fprintf(o," Foreground: (%u,%u,%u)\n",get2u(f,8),get2u(f,10),get2u(f,12)); fprintf(o," Background: (%u,%u,%u)\n",get2u(f,14),get2u(f,16),get2u(f,18)); } static void xtoc_QueryBestSize(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"QueryBestSize"); EXACTLENGTH(32); get_pad(f,1,1); fprintf(o," Size: %ux%u\n",get2u(f,8),get2u(f,10)); get_pad(f,12,20); } static void ctox_QueryBestSize(FLOW *f, FILE *o) { req_hdr_exact(f,o,"QueryBestSize",12); fprintf(o," What: "); print_choice(o,get1u(f,1),3,0,"Cursor",1,"Tile",2,"Stipple"); fprintf(o,"\n"); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," Size: %ux%u\n",get2u(f,8),get2u(f,10)); expect_reply(f->conn,&xtoc_QueryBestSize,0); } typedef struct priv_QueryExtension PRIV_QueryExtension; struct priv_QueryExtension { int nl; char *name; } ; static void xtoc_QueryExtension(FLOW *f, FILE *o, void *pv) { PRIV_QueryExtension *p; unsigned int v; int inv; p = pv; if (f) { rep_hdr(f,o,"QueryExtension"); get_pad(f,1,1); fprintf(o," Present: "); print_bool(o,get1u(f,8)); fprintf(o,"\n"); inv = 0; v = get1u(f,9); fprintf(o," Major opcode: %u",v); if ((v != 0) && (v < 128)) { fprintf(o," (INVALID)"); inv = 1; } fprintf(o,"\n"); v = get1u(f,10); fprintf(o," First event: %u",v); if ((v != 0) && ((v < 64) || (v > 127))) { fprintf(o," (INVALID)"); inv = 1; } fprintf(o,"\n"); v = get1u(f,11); fprintf(o," First error: %u",v); if ((v != 0) && (v < 128)) { fprintf(o," (INVALID)"); inv = 1; } fprintf(o,"\n"); get_pad(f,12,20); } if (! inv) ext_values(f,o,p->name,p->nl,get1u(f,8),get1u(f,9),get1u(f,10),get1u(f,11)); free(p->name); free(p); } static void ctox_QueryExtension(FLOW *f, FILE *o) { int nl; PRIV_QueryExtension *p; req_hdr_min(f,o,"QueryExtension",8); get_pad(f,1,1); get_pad(f,6,2); nl = get2u(f,4); EXACTLENGTH(8+padded(nl)); p = malloc(sizeof(*p)); p->nl = nl; p->name = copy_block(f->ibuf+8,nl); expect_reply(f->conn,&xtoc_QueryExtension,p); print_padded_text_blk(f,o,8,nl," Name: ",0); } static void xtoc_ListExtensions(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; unsigned int l; if (! f) return; rep_hdr(f,o,"ListExtensions"); MINLENGTH(32); n = get1u(f,1); fprintf(o," Extension count: %u\n",n); get_pad(f,8,24); off = 32; for (;n>0;n--) { if (off >= f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } l = get1u(f,off); if (off+1+l > f->ibfill) { fprintf(o,"*** Packet overrun\n"); print_raw_data(o,f); abort_packet_print(); } print_text_blk(f,o,off+1,l," Extension: ",0); off += 1 + l; } if (off > f->ibfill) abort(); if (f->ibfill-off > 3) { fprintf(o,"*** Packet underrun (bytes left: %d)\n",f->ibfill-off); print_raw_data(o,f); abort_packet_print(); } get_pad(f,off,f->ibfill-off); } static void ctox_ListExtensions(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ListExtensions",4); get_pad(f,1,1); expect_reply(f->conn,&xtoc_ListExtensions,0); } static void ctox_ChangeKeyboardMapping(FLOW *f, FILE *o) { unsigned int n; unsigned int m; unsigned int off; unsigned int i; unsigned int kc; req_hdr_min(f,o,"ChangeKeyboardMapping",8); n = get1u(f,1); m = get1u(f,5); EXACTLENGTH(8+(4*n*m)); kc = get1u(f,4); fprintf(o," First keycode: %u\n",kc); off = 8; for (;n>0;n--) { fprintf(o," %u:",kc); for (i=m;i>0;i--) { fprintf(o," 0x%x",get4u(f,off)); off += 4; } fprintf(o,"\n"); kc ++; } } typedef struct priv_GetKeyboardMapping PRIV_GetKeyboardMapping; struct priv_GetKeyboardMapping { unsigned int kc; unsigned int m; } ; static void xtoc_GetKeyboardMapping(FLOW *f, FILE *o, void *pv) { PRIV_GetKeyboardMapping *p; unsigned int n; unsigned int i; unsigned int m; unsigned int off; unsigned int kc; p = pv; if (f) { rep_hdr(f,o,"GetKeyboardMapping"); n = get1u(f,1); EXACTLENGTH(32+(4*n*p->m)); fprintf(o," Keysyms per keycode: %u\n",n); kc = p->kc; m = p->m; get_pad(f,8,24); off = 32; for (;m>0;m--) { fprintf(o," %u:",kc); for (i=n;i>0;i--) { fprintf(o," 0x%x",get4u(f,off)); off += 4; } fprintf(o,"\n"); kc ++; } } free(p); } static void ctox_GetKeyboardMapping(FLOW *f, FILE *o) { PRIV_GetKeyboardMapping *p; req_hdr_exact(f,o,"GetKeyboardMapping",8); get_pad(f,1,1); p = malloc(sizeof(*p)); p->kc = get1u(f,4); p->m = get1u(f,5); get_pad(f,6,2); fprintf(o," First keycode; %u\n",p->kc); fprintf(o," Count; %u\n",p->m); expect_reply(f->conn,&xtoc_GetKeyboardMapping,p); } static void ctox_ChangeKeyboardControl(FLOW *f, FILE *o) { unsigned int mask; unsigned int off; req_hdr_min(f,o,"ChangeKeyboardControl",8); get_pad(f,1,1); mask = get4u(f,4); EXACTLENGTH(8+(4*bitcount(mask))); fprintf(o," Value mask: 0x%x\n",mask); off = 8; if (mask & 0x00000001) { fprintf(o," Keyclick percent: %d\n",ltob_s(get4s(f,off))); off += 4; } if (mask & 0x00000002) { fprintf(o," Bell percent: %d\n",ltob_s(get4s(f,off))); off += 4; } if (mask & 0x00000004) { fprintf(o," Bell pitch: %d\n",ltos_s(get4s(f,off))); off += 4; } if (mask & 0x00000008) { fprintf(o," Bell duration: %d\n",ltos_s(get4s(f,off))); off += 4; } if (mask & 0x00000010) { fprintf(o," LED: %u\n",ltob_u(get4u(f,off))); off += 4; } if (mask & 0x00000020) { fprintf(o," LED mode: "); print_choice(o,ltob_u(get4u(f,off)),2,0,"Off",1,"On"); fprintf(o,"\n"); off += 4; } if (mask & 0x00000040) { fprintf(o," Key: %u\n",ltob_u(get4u(f,off))); off += 4; } if (mask & 0x00000080) { fprintf(o," Autorepeat mode: "); print_choice(o,ltob_u(get4u(f,off)),3,0,"Off",1,"On",2,"Default"); fprintf(o,"\n"); off += 4; } if (mask & 0xffffff00) { fprintf(o," Unrecognized bits: %08x\n",mask&0xffffff00); } } static void xtoc_GetKeyboardControl(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int v; int i; if (! f) return; rep_hdr(f,o,"GetKeyboardControl"); EXACTLENGTH(52); fprintf(o," Global autorepeat: "); print_choice(o,get1u(f,1),2,0,"Off",1,"On"); fprintf(o,"\n"); fprintf(o," LED mask: 0x%08x\n",get4u(f,8)); fprintf(o," Keyclick percent: %u\n",get1u(f,12)); fprintf(o," Bell percent: %u\n",get1u(f,13)); fprintf(o," Bell pitch: %u\n",get2u(f,14)); fprintf(o," Bell duration: %u\n",get2u(f,16)); get_pad(f,18,2); fprintf(o," Autorepeats:\n"); for (i=0;i<256;i++) { if (! (i & 7)) v = get1u(f,20+(i>>3)); if (! (i & 63)) fprintf(o," "); putc( (v & (1 << (i & 7))) ? (i < 8) ? '?' : '*' : (i < 8) ? ' ' : '-', o); switch (i & 63) { case 15: case 31: case 47: putc(' ',o); break; case 63: putc('\n',o); break; } } } static void ctox_GetKeyboardControl(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetKeyboardControl",4); get_pad(f,1,1); expect_reply(f->conn,&xtoc_GetKeyboardControl,0); } static void ctox_Bell(FLOW *f, FILE *o) { req_hdr_exact(f,o,"Bell",4); } static void ctox_ChangePointerControl(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ChangePointerControl",12); get_pad(f,1,1); fprintf(o," Acceleration fraction: %d / %d\n",get2s(f,4),get2s(f,6)); fprintf(o," Acceleration threshold: %d\n",get2s(f,8)); fprintf(o," Do acceleration: "); print_bool(o,get1u(f,10)); fprintf(o,"\n"); fprintf(o," Do threshold: "); print_bool(o,get1u(f,11)); fprintf(o,"\n"); } static void xtoc_GetPointerControl(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"GetPointerControl"); EXACTLENGTH(32); fprintf(o," Acceleration fraction: %d / %d\n",get2u(f,8),get2u(f,10)); fprintf(o," Acceleration threshold: %d\n",get2s(f,12)); } static void ctox_GetPointerControl(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetPointerControl",4); expect_reply(f->conn,&xtoc_GetPointerControl,0); } static void ctox_SetScreenSaver(FLOW *f, FILE *o) { req_hdr_exact(f,o,"SetScreenSaver",12); fprintf(o," Timeout: %d\n",get2s(f,4)); fprintf(o," Interval: %d\n",get2s(f,6)); fprintf(o," Prefer blanking: "); print_choice(o,get1u(f,8),3,0,"No",1,"Yes",2,"Default"); fprintf(o,"\n"); fprintf(o," Allow exposures: "); print_choice(o,get1u(f,9),3,0,"No",1,"Yes",2,"Default"); fprintf(o,"\n"); } static void xtoc_GetScreenSaver(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"GetScreenSaver"); EXACTLENGTH(32); fprintf(o," Timeout: %d\n",get2u(f,8)); fprintf(o," Interval: %d\n",get2u(f,10)); fprintf(o," Prefer blanking: "); print_choice(o,get1u(f,12),2,0,"No",1,"Yes"); fprintf(o,"\n"); fprintf(o," Allow exposures: "); print_choice(o,get1u(f,13),2,0,"No",1,"Yes"); fprintf(o,"\n"); } static void ctox_GetScreenSaver(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetScreenSaver",4); expect_reply(f->conn,&xtoc_GetScreenSaver,0); } static void ctox_ChangeHosts(FLOW *f, FILE *o) { unsigned int n; req_hdr_min(f,o,"ChangeHosts",8); n = get2u(f,6); EXACTLENGTH(8+padded(n)); fprintf(o," Mode: "); print_choice(o,get1u(f,1),2,0,"Insert",1,"Delete"); fprintf(o,"\n"); fprintf(o," Family: "); print_choice(o,get1u(f,4),3,0,"Internet",1,"DECnet",2,"Chaos"); fprintf(o,"\n"); print_bin_blk(f,o,8,n," Address: ",0); } static void xtoc_ListHosts(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; int adv; if (! f) return; rep_hdr(f,o,"ListHosts"); EXACTLENGTH(32); fprintf(o," Mode: "); print_choice(o,get1u(f,1),2,0,"Disabled",1,"Enabled"); fprintf(o,"\n"); n = get2u(f,8); fprintf(o," Hosts: %u\n",n); off = 32; for (;n>0;n--) { adv = print_host(o,f," ",off,f->ibfill-off); if (adv < 0) break; off += adv; } } static void ctox_ListHosts(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ListHosts",4); expect_reply(f->conn,&xtoc_ListHosts,0); } static void ctox_SetAccessControl(FLOW *f, FILE *o) { req_hdr_exact(f,o,"SetAccessControl",4); fprintf(o," Mode: "); print_choice(o,get1u(f,1),2,0,"Disable",1,"Enable"); fprintf(o,"\n"); } static void ctox_SetCloseDownMode(FLOW *f, FILE *o) { req_hdr_exact(f,o,"SetCloseDownMode",4); fprintf(o," Mode: "); print_choice(o,get1u(f,1),3,0,"Destroy",1,"RetainPermanent",2,"RetainTemporary"); fprintf(o,"\n"); } static void ctox_KillClient(FLOW *f, FILE *o) { req_hdr_exact(f,o,"KillClient",8); fprintf(o," Resource: "); print_xid_z(o,get4u(f,4),"AllTemporary"); fprintf(o,"\n"); } static void ctox_RotateProperties(FLOW *f, FILE *o) { unsigned int n; unsigned int off; req_hdr_min(f,o,"RotateProperties",12); n = get2u(f,8); EXACTLENGTH(12+(4*n)); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Delta: %d\n",get2s(f,10)); fprintf(o," Properties: %u\n",n); off = 12; for (;n>0;n--) { fprintf(o," "); print_atom(o,f->conn,get4u(f,off)); off += 4; } } static void ctox_ForceScreenSaver(FLOW *f, FILE *o) { req_hdr_exact(f,o,"ForceScreenSaver",4); fprintf(o," Mode: "); print_choice(o,get1u(f,1),2,0,"Reset",1,"Activate"); fprintf(o,"\n"); } static void xtoc_SetPointerMapping(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"SetPointerMapping"); EXACTLENGTH(32); fprintf(o," Status: "); print_choice(o,get1u(f,1),2,0,"Success",1,"Busy"); fprintf(o,"\n"); } static void ctox_SetPointerMapping(FLOW *f, FILE *o) { unsigned int n; unsigned int off; req_hdr_min(f,o,"SetPointerMapping",4); n = get1u(f,1); EXACTLENGTH(4+padded(n)); fprintf(o," Map:"); off = 4; for (;n>0;n--) { fprintf(o," %u",get1u(f,off)); off ++; } expect_reply(f->conn,&xtoc_SetPointerMapping,0); } static void xtoc_GetPointerMapping(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; if (! f) return; rep_hdr(f,o,"GetPointerMapping"); n = get1u(f,1); EXACTLENGTH(32+padded(n)); get_pad(f,8,24); fprintf(o," Map:"); off = 32; get_pad(f,off+n,pad(n)); for (;n>0;n--) { fprintf(o," %u",get1u(f,off)); off ++; } fprintf(o,"\n"); } static void ctox_GetPointerMapping(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetPointerMapping",4); get_pad(f,1,1); expect_reply(f->conn,&xtoc_GetPointerMapping,0); } static void xtoc_SetModifierMapping(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { if (! f) return; rep_hdr(f,o,"SetModifierMapping"); EXACTLENGTH(32); fprintf(o," Status: "); print_choice(o,get1u(f,1),3,0,"Success",1,"Busy",2,"Failed"); fprintf(o,"\n"); } static void ctox_SetModifierMapping(FLOW *f, FILE *o) { unsigned int n; unsigned int off; int i; unsigned int j; req_hdr_min(f,o,"SetModifierMapping",4); n = get1u(f,1); EXACTLENGTH(4+(8*n)); off = 4; for (i=0;i0;j--) { fprintf(o," %u",get1u(f,off)); off ++; } fprintf(o,"\n"); } expect_reply(f->conn,&xtoc_SetModifierMapping,0); } static void xtoc_GetModifierMapping(FLOW *f, FILE *o, void *pv __attribute__((__unused__))) { unsigned int n; unsigned int off; int i; unsigned int j; if (! f) return; rep_hdr(f,o,"GetModifierMapping"); n = get1u(f,1); EXACTLENGTH(32+(8*n)); get_pad(f,8,24); off = 32; for (i=0;i0;j--) { fprintf(o," %u",get1u(f,off)); off ++; } fprintf(o,"\n"); } } static void ctox_GetModifierMapping(FLOW *f, FILE *o) { req_hdr_exact(f,o,"GetModifierMapping",4); get_pad(f,1,1); expect_reply(f->conn,&xtoc_GetModifierMapping,0); } static void ctox_NoOperation(FLOW *f, FILE *o) { req_hdr_exact(f,o,"NoOperation",4); } static void ctox_nosuch(FLOW *f, FILE *o) { fprintf(o,"Undefined core request %u",get1u(f,0)); print_raw_data(o,f); set_eof(f); abort_packet_print(); } static void (*core_req[128])(FLOW *, FILE *) = { /* 0 */ &canthappen, /* 1 */ &ctox_CreateWindow, /* 2 */ &ctox_ChangeWindowAttributes, /* 3 */ &ctox_GetWindowAttributes, /* 4 */ &ctox_DestroyWindow, /* 5 */ &ctox_DestroySubwindows, /* 6 */ &ctox_ChangeSaveSet, /* 7 */ &ctox_ReparentWindow, /* 8 */ &ctox_MapWindow, /* 9 */ &ctox_MapSubwindows, /* 10 */ &ctox_UnmapWindow, /* 11 */ &ctox_UnmapSubwindows, /* 12 */ &ctox_ConfigureWindow, /* 13 */ &ctox_CirculateWindow, /* 14 */ &ctox_GetGeometry, /* 15 */ &ctox_QueryTree, /* 16 */ &ctox_InternAtom, /* 17 */ &ctox_GetAtomName, /* 18 */ &ctox_ChangeProperty, /* 19 */ &ctox_DeleteProperty, /* 20 */ &ctox_GetProperty, /* 21 */ &ctox_ListProperties, /* 22 */ &ctox_SetSelectionOwner, /* 23 */ &ctox_GetSelectionOwner, /* 24 */ &ctox_ConvertSelection, /* 25 */ &ctox_SendEvent, /* 26 */ &ctox_GrabPointer, /* 27 */ &ctox_UngrabPointer, /* 28 */ &ctox_GrabButton, /* 29 */ &ctox_UngrabButton, /* 30 */ &ctox_ChangeActivePointerGrab, /* 31 */ &ctox_GrabKeyboard, /* 32 */ &ctox_UngrabKeyboard, /* 33 */ &ctox_GrabKey, /* 34 */ &ctox_UngrabKey, /* 35 */ &ctox_AllowEvents, /* 36 */ &ctox_GrabServer, /* 37 */ &ctox_UngrabServer, /* 38 */ &ctox_QueryPointer, /* 39 */ &ctox_GetMotionEvents, /* 40 */ &ctox_TranslateCoordinates, /* 41 */ &ctox_WarpPointer, /* 42 */ &ctox_SetInputFocus, /* 43 */ &ctox_GetInputFocus, /* 44 */ &ctox_QueryKeymap, /* 45 */ &ctox_OpenFont, /* 46 */ &ctox_CloseFont, /* 47 */ &ctox_QueryFont, /* 48 */ &ctox_QueryTextExtents, /* 49 */ &ctox_ListFonts, /* 50 */ &ctox_ListFontsWithInfo, /* 51 */ &ctox_SetFontPath, /* 52 */ &ctox_GetFontPath, /* 53 */ &ctox_CreatePixmap, /* 54 */ &ctox_FreePixmap, /* 55 */ &ctox_CreateGC, /* 56 */ &ctox_ChangeGC, /* 57 */ &ctox_CopyGC, /* 58 */ &ctox_SetDashes, /* 59 */ &ctox_SetClipRectangles, /* 60 */ &ctox_FreeGC, /* 61 */ &ctox_ClearArea, /* 62 */ &ctox_CopyArea, /* 63 */ &ctox_CopyPlane, /* 64 */ &ctox_PolyPoint, /* 65 */ &ctox_PolyLine, /* 66 */ &ctox_PolySegment, /* 67 */ &ctox_PolyRectangle, /* 68 */ &ctox_PolyArc, /* 69 */ &ctox_FillPoly, /* 70 */ &ctox_PolyFillRectangle, /* 71 */ &ctox_PolyFillArc, /* 72 */ &ctox_PutImage, /* 73 */ &ctox_GetImage, /* 74 */ &ctox_PolyText8, /* 75 */ &ctox_PolyText16, /* 76 */ &ctox_ImageText8, /* 77 */ &ctox_ImageText16, /* 78 */ &ctox_CreateColormap, /* 79 */ &ctox_FreeColormap, /* 80 */ &ctox_CopyColormapAndFree, /* 81 */ &ctox_InstallColormap, /* 82 */ &ctox_UninstallColormap, /* 83 */ &ctox_ListInstalledColormaps, /* 84 */ &ctox_AllocColor, /* 85 */ &ctox_AllocNamedColor, /* 86 */ &ctox_AllocColorCells, /* 87 */ &ctox_AllocColorPlanes, /* 88 */ &ctox_FreeColors, /* 89 */ &ctox_StoreColors, /* 90 */ &ctox_StoreNamedColor, /* 91 */ &ctox_QueryColors, /* 92 */ &ctox_LookupColor, /* 93 */ &ctox_CreateCursor, /* 94 */ &ctox_CreateGlyphCursor, /* 95 */ &ctox_FreeCursor, /* 96 */ &ctox_RecolorCursor, /* 97 */ &ctox_QueryBestSize, /* 98 */ &ctox_QueryExtension, /* 99 */ &ctox_ListExtensions, /* 100 */ &ctox_ChangeKeyboardMapping, /* 101 */ &ctox_GetKeyboardMapping, /* 102 */ &ctox_ChangeKeyboardControl, /* 103 */ &ctox_GetKeyboardControl, /* 104 */ &ctox_Bell, /* 105 */ &ctox_ChangePointerControl, /* 106 */ &ctox_GetPointerControl, /* 107 */ &ctox_SetScreenSaver, /* 108 */ &ctox_GetScreenSaver, /* 109 */ &ctox_ChangeHosts, /* 110 */ &ctox_ListHosts, /* 111 */ &ctox_SetAccessControl, /* 112 */ &ctox_SetCloseDownMode, /* 113 */ &ctox_KillClient, /* 114 */ &ctox_RotateProperties, /* 115 */ &ctox_ForceScreenSaver, /* 116 */ &ctox_SetPointerMapping, /* 117 */ &ctox_GetPointerMapping, /* 118 */ &ctox_SetModifierMapping, /* 119 */ &ctox_GetModifierMapping, /* 120 */ &ctox_nosuch, /* 121 */ &ctox_nosuch, /* 122 */ &ctox_nosuch, /* 123 */ &ctox_nosuch, /* 124 */ &ctox_nosuch, /* 125 */ &ctox_nosuch, /* 126 */ &ctox_nosuch, /* 127 */ &ctox_NoOperation }; void ctox_core(FLOW *f, FILE *o) { if (get1u(f,0) > sizeof(core_req)/sizeof(core_req[0])) abort(); if (f->ibfill < 4) { fprintf(o,"*** Packet far too short (length %d < 4)\n",f->ibfill); print_raw_data(o,f); abort_packet_print(); } if (f->ibfill != 4*get2u(f,2)) { fprintf(o,"*** Packet length wrong (length %d, claims %d)\n",f->ibfill,4*get2u(f,2)); print_raw_data(o,f); abort_packet_print(); } (*core_req[get1u(f,0)])(f,o); } static void device_event_body(FLOW *f, FILE *o) { fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,4)); fprintf(o,"\n"); fprintf(o," Root: "XID_FMT"\n",get4u(f,8)); fprintf(o," Event window: "XID_FMT"\n",get4u(f,12)); fprintf(o," Child window: "); print_xid_z(o,get4u(f,16),"None"); fprintf(o,"\n"); fprintf(o," Location: root (%d,%d), event (%d,%d)\n",get2s(f,20),get2s(f,22),get2s(f,24),get2s(f,26)); print_set(o," State: "," ",get2u(f,28),SETofKEYBUTMASK); } static void device_up_down(FLOW *f, FILE *o, const char *evname, const char *detailname) { event_hdr(f,o,evname); fprintf(o," %s: %u\n",detailname,get1u(f,1)); device_event_body(f,o); fprintf(o," Same screen: "); print_bool(o,get1u(f,30)); fprintf(o,"\n"); get_pad(f,31,1); } static void event_KeyPress(FLOW *f, FILE *o) { device_up_down(f,o,"KeyPress","Keycode"); } static void event_KeyRelease(FLOW *f, FILE *o) { device_up_down(f,o,"KeyRelease","Keycode"); } static void event_ButtonPress(FLOW *f, FILE *o) { device_up_down(f,o,"ButtonPress","Button"); } static void event_ButtonRelease(FLOW *f, FILE *o) { device_up_down(f,o,"ButtonRelease","Button"); } static void event_MotionNotify(FLOW *f, FILE *o) { event_hdr(f,o,"MotionNotify"); fprintf(o," Detail: "); print_choice(o,get1u(f,1),2,0,"Normal",1,"Hint"); fprintf(o,"\n"); device_event_body(f,o); fprintf(o," Same screen: "); print_bool(o,get1u(f,30)); fprintf(o,"\n"); get_pad(f,31,1); } static void enterleave(FLOW *f, FILE *o, const char *evname) { event_hdr(f,o,evname); fprintf(o," Detail: "); print_choice(o,get1u(f,1),5, 0, "Ancestor", 1, "Virtual", 2, "Inferior", 3, "Nonlinear", 4, "NonlinearVirtual" ); fprintf(o,"\n"); device_event_body(f,o); fprintf(o," Mode: "); print_choice(o,get1u(f,30),3, 0, "Normal", 1, "Grab", 2, "Ungrab" ); fprintf(o,"\n"); fprintf(o," Same screen: "); print_bool(o,(get1u(f,31)&2)?1:0); fprintf(o,"\n"); fprintf(o," Focus: "); print_bool(o,get1u(f,31)&1); fprintf(o,"\n"); } static void event_EnterNotify(FLOW *f, FILE *o) { enterleave(f,o,"EnterNotify"); } static void event_LeaveNotify(FLOW *f, FILE *o) { enterleave(f,o,"LeaveNotify"); } static void focus_in_out(FLOW *f, FILE *o, const char *evname) { event_hdr(f,o,evname); fprintf(o," Detail: "); print_choice(o,get1u(f,1),8, 0, "Ancestor", 1, "Virtual", 2, "Inferior", 3, "Nonlinear", 4, "NonlinearVirtual", 5, "Pointer", 6, "PointerRoot", 7, "None" ); fprintf(o,"\n"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Mode: "); print_choice(o,get1u(f,8),4, 0, "Normal", 1, "Grab", 2, "Ungrab", 3, "WhileGrabbed" ); fprintf(o,"\n"); get_pad(f,9,23); } static void event_FocusIn(FLOW *f, FILE *o) { focus_in_out(f,o,"FocusIn"); } static void event_FocusOut(FLOW *f, FILE *o) { focus_in_out(f,o,"FocusOut"); } static void event_KeymapNotify(FLOW *f, FILE *o) { int i; unsigned int m; fprintf(o,"KeymapNotify event\n"); EXACTLENGTH(32); fprintf(o," ........"); for (i=8;i<256;i++) { if (! (i & 7)) m = get1u(f,i>>3); if (! (i & 63)) fprintf(o," "); putc( (m & (1 << (i & 7))) ? '*' : '-', o); switch (i & 63) { case 15: case 31: case 47: putc(' ',o); break; case 63: putc('\n',o); break; } } } static void exposure_event(FLOW *f, FILE *o, const char *evname, const char *drwname) { event_hdr(f,o,evname); fprintf(o," %s: "XID_FMT"\n",drwname,get4u(f,4)); fprintf(o," Area: %ux%u+%u+%u\n",get2u(f,12),get2u(f,14),get2u(f,8),get2u(f,10)); } static void event_Expose(FLOW *f, FILE *o) { exposure_event(f,o,"Expose","Window"); get_pad(f,1,1); fprintf(o," Count: %u\n",get2u(f,16)); get_pad(f,18,14); } static void event_GraphicsExposure(FLOW *f, FILE *o) { exposure_event(f,o,"GraphicsExposure","Drawable"); fprintf(o," Minor opcode: %u\n",get2u(f,16)); fprintf(o," Count: %u\n",get2u(f,18)); fprintf(o," Major opcode: %u\n",get1u(f,20)); } static void event_NoExposure(FLOW *f, FILE *o) { event_hdr(f,o,"NoExposure"); fprintf(o," Drawable: "XID_FMT"\n",get4u(f,4)); fprintf(o," Minor opcode: %u\n",get2u(f,8)); fprintf(o," Major opcode: %u\n",get1u(f,10)); } static void event_VisibilityNotify(FLOW *f, FILE *o) { event_hdr(f,o,"VisibilityNotify"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," State: "); print_choice(o,get1u(f,8),3, 0, "Unobscured", 1, "PartiallyObscured", 2, "FullyObscured" ); fprintf(o,"\n"); } static void event_CreateNotify(FLOW *f, FILE *o) { event_hdr(f,o,"CreateNotify"); fprintf(o," Parent: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," Area: %ux%u+%d+%d\n",get2u(f,16),get2u(f,18),get2s(f,12),get2s(f,14)); fprintf(o," Border width: %u\n",get2u(f,20)); fprintf(o," Override redirect: "); print_bool(o,get1u(f,22)); fprintf(o,"\n"); } static void event_DestroyNotify(FLOW *f, FILE *o) { event_hdr(f,o,"DestroyNotify"); fprintf(o," Event: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); } static void event_UnmapNotify(FLOW *f, FILE *o) { event_hdr(f,o,"UnmapNotify"); fprintf(o," Event: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," From configure: "); print_bool(o,get1u(f,12)); fprintf(o,"\n"); } static void event_MapNotify(FLOW *f, FILE *o) { event_hdr(f,o,"MapNotify"); get_pad(f,1,1); fprintf(o," Event: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," Override redirect: "); print_bool(o,get1u(f,12)); fprintf(o,"\n"); get_pad(f,13,19); } static void event_MapRequest(FLOW *f, FILE *o) { event_hdr(f,o,"MapRequest"); fprintf(o," Parent: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); } static void event_ReparentNotify(FLOW *f, FILE *o) { event_hdr(f,o,"ReparentNotify"); fprintf(o," Event: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," Parent: "XID_FMT"\n",get4u(f,12)); fprintf(o," Position: (%d,%d)",get2s(f,16),get2s(f,18)); fprintf(o," Override redirect: "); print_bool(o,get1u(f,20)); fprintf(o,"\n"); } static void event_ConfigureNotify(FLOW *f, FILE *o) { event_hdr(f,o,"ConfigureNotify"); get_pad(f,1,1); fprintf(o," Event: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," Above sibling: "); print_xid_z(o,get4u(f,12),"None"); fprintf(o,"\n"); fprintf(o," Shape: %ux%u+%d+%d\n",get2u(f,20),get2u(f,22),get2s(f,16),get2s(f,18)); fprintf(o," Border width: %u\n",get2u(f,24)); fprintf(o," Override redirect: "); print_bool(o,get1u(f,26)); fprintf(o,"\n"); get_pad(f,27,5); } static void event_ConfigureRequest(FLOW *f, FILE *o) { unsigned int mask; event_hdr(f,o,"ConfigureRequest"); mask = get2u(f,26); #define OPEN(bit) ((mask&(bit))?"":"(") #define CLOSE(bit) ((mask&(bit))?"":")") fprintf(o," %sStack mode: ",OPEN(0x0040)); print_choice(o,get1u(f,1),5, 0, "Above", 1, "Below", 2, "TopIf", 3, "BottomIf", 4, "Opposite" ); fprintf(o,"%s\n",CLOSE(0x0040)); fprintf(o," Parent: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," %sSibling: ",OPEN(0x0020)); print_xid_z(o,get4u(f,12),"None"); fprintf(o,"%s\n",CLOSE(0x0020)); switch (mask & 0x000f) { case 0: fprintf(o," (Shape: %ux%u+%d+%d)\n",get2u(f,20),get2u(f,22),get2s(f,16),get2s(f,18)); break; case 3: fprintf(o," Shape: (%ux%u)+%d+%d\n",get2u(f,20),get2u(f,22),get2s(f,16),get2s(f,18)); break; case 12: fprintf(o," Shape: %ux%u(+%d+%d)\n",get2u(f,20),get2u(f,22),get2s(f,16),get2s(f,18)); break; case 15: fprintf(o," Shape: %ux%u+%d+%d\n",get2u(f,20),get2u(f,22),get2s(f,16),get2s(f,18)); break; default: fprintf(o," %sX: %d%s\n",OPEN(0x0001),get2s(f,16),CLOSE(0x0001)); fprintf(o," %sY: %d%s\n",OPEN(0x0002),get2s(f,18),CLOSE(0x0002)); fprintf(o," %sWidth: %u%s\n",OPEN(0x0004),get2u(f,20),CLOSE(0x0004)); fprintf(o," %sHeight: %u%s\n",OPEN(0x0008),get2u(f,22),CLOSE(0x0008)); break; } fprintf(o," %sBorder width: %u%s\n",OPEN(0x0010),get2u(f,24),CLOSE(0x0010)); #undef OPEN #undef CLOSE } static void event_GravityNotify(FLOW *f, FILE *o) { event_hdr(f,o,"GravityNotify"); fprintf(o," Event: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," Position: (%d,%d)\n",get2s(f,12),get2s(f,14)); } static void event_ResizeRequest(FLOW *f, FILE *o) { event_hdr(f,o,"ResizeRequest"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Size: %ux%u\n",get2u(f,8),get2u(f,10)); } static void event_CirculateNotify(FLOW *f, FILE *o) { event_hdr(f,o,"CirculateNotify"); fprintf(o," Event: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," Place: "); print_choice(o,get1u(f,16),2,0,"Top",1,"Bottom"); fprintf(o,"\n"); } static void event_CirculateRequest(FLOW *f, FILE *o) { event_hdr(f,o,"CirculateRequest"); fprintf(o," Parent: "XID_FMT"\n",get4u(f,4)); fprintf(o," Window: "XID_FMT"\n",get4u(f,8)); fprintf(o," Place: "); print_choice(o,get1u(f,16),2,0,"Top",1,"Bottom"); fprintf(o,"\n"); } static void event_PropertyNotify(FLOW *f, FILE *o) { event_hdr(f,o,"PropertyNotify"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Property: "); print_atom(o,f->conn,get4u(f,8)); fprintf(o,"\n"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,12)); fprintf(o,"\n"); fprintf(o," State: "); print_choice(o,get1u(f,16),2,0,"NewValue",1,"Deleted"); fprintf(o,"\n"); } static void event_SelectionClear(FLOW *f, FILE *o) { event_hdr(f,o,"SelectionClear"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,4)); fprintf(o,"\n"); fprintf(o," Owner: "XID_FMT"\n",get4u(f,8)); fprintf(o," Selection: "); print_atom(o,f->conn,get4u(f,12)); fprintf(o,"\n"); } static void event_SelectionRequest(FLOW *f, FILE *o) { event_hdr(f,o,"SelectionRequest"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,4)); fprintf(o,"\n"); fprintf(o," Owner: "XID_FMT"\n",get4u(f,8)); fprintf(o," Requestor: "XID_FMT"\n",get4u(f,12)); fprintf(o," Selection: "); print_atom(o,f->conn,get4u(f,16)); fprintf(o,"\n"); fprintf(o," Target: "); print_atom(o,f->conn,get4u(f,20)); fprintf(o,"\n"); fprintf(o," Property: "); print_atom_z(o,f->conn,get4u(f,24),"None"); fprintf(o,"\n"); } static void event_SelectionNotify(FLOW *f, FILE *o) { event_hdr(f,o,"SelectionNotify"); fprintf(o," Timestamp: "); print_timestamp(o,get4u(f,4)); fprintf(o,"\n"); fprintf(o," Requestor: "XID_FMT"\n",get4u(f,8)); fprintf(o," Selection: "); print_atom(o,f->conn,get4u(f,12)); fprintf(o,"\n"); fprintf(o," Target: "); print_atom(o,f->conn,get4u(f,16)); fprintf(o,"\n"); fprintf(o," Property: "); print_atom_z(o,f->conn,get4u(f,20),"None"); fprintf(o,"\n"); } static void event_ColormapNotify(FLOW *f, FILE *o) { event_hdr(f,o,"ColormapNotify"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Colourmap: "); print_xid_z(o,get4u(f,8),"None"); fprintf(o,"\n"); fprintf(o," New: "); print_bool(o,get1u(f,12)); fprintf(o,"\n"); fprintf(o," State: "); print_choice(o,get1u(f,13),2,0,"Uninstalled",1,"Installed"); fprintf(o,"\n"); } static void event_ClientMessage(FLOW *f, FILE *o) { unsigned int fmt; int i; event_hdr(f,o,"ClientMessage"); fmt = get1u(f,1); fprintf(o," Format: %u",fmt); switch (fmt) { case 8: case 16: case 32: break; default: fprintf(o," (INVALID)"); break; } fprintf(o,"\n"); fprintf(o," Window: "XID_FMT"\n",get4u(f,4)); fprintf(o," Type: "); print_atom(o,f->conn,get4u(f,8)); fprintf(o,"\n"); fprintf(o," Data:"); switch (fmt) { case 8: for (i=0;i<20;i++) fprintf(o," %02x",get1u(f,12+i)); break; case 16: for (i=0;i<10;i++) fprintf(o," %04x",get2u(f,12+i+i)); break; case 32: for (i=0;i<5;i++) fprintf(o," %08x",get4u(f,12+(4*i))); break; default: fprintf(o," "); for (i=0;i<20;i++) fprintf(o,"%02x",get1u(f,12+i)); break; } fprintf(o,"\n"); } static void event_MappingNotify(FLOW *f, FILE *o) { unsigned int req; event_hdr(f,o,"MappingNotify"); fprintf(o," Request: "); req = get1u(f,4); print_choice(o,req,3,0,"Modifier",1,"Keyboard",2,"Pointer"); fprintf(o,"\n"); fprintf(o," %sKeycodes: start %u, count %u%s\n", (req==1)?"":"(",get1u(f,5),get1u(f,6),(req==1)?"":")"); } static void event_nosuch(FLOW *f, FILE *o) { fprintf(o,"Undefined core event %u",get1u(f,0)); print_raw_data(o,f); set_eof(f); abort_packet_print(); } static void (*core_ev[64])(FLOW *, FILE *) = { /* 0 */ &canthappen, /* 1 */ &canthappen, /* 2 */ &event_KeyPress, /* 3 */ &event_KeyRelease, /* 4 */ &event_ButtonPress, /* 5 */ &event_ButtonRelease, /* 6 */ &event_MotionNotify, /* 7 */ &event_EnterNotify, /* 8 */ &event_LeaveNotify, /* 9 */ &event_FocusIn, /* 10 */ &event_FocusOut, /* 11 */ &event_KeymapNotify, /* 12 */ &event_Expose, /* 13 */ &event_GraphicsExposure, /* 14 */ &event_NoExposure, /* 15 */ &event_VisibilityNotify, /* 16 */ &event_CreateNotify, /* 17 */ &event_DestroyNotify, /* 18 */ &event_UnmapNotify, /* 19 */ &event_MapNotify, /* 20 */ &event_MapRequest, /* 21 */ &event_ReparentNotify, /* 22 */ &event_ConfigureNotify, /* 23 */ &event_ConfigureRequest, /* 24 */ &event_GravityNotify, /* 25 */ &event_ResizeRequest, /* 26 */ &event_CirculateNotify, /* 27 */ &event_CirculateRequest, /* 28 */ &event_PropertyNotify, /* 29 */ &event_SelectionClear, /* 30 */ &event_SelectionRequest, /* 31 */ &event_SelectionNotify, /* 32 */ &event_ColormapNotify, /* 33 */ &event_ClientMessage, /* 34 */ &event_MappingNotify, /* 35 */ &event_nosuch, /* 36 */ &event_nosuch, /* 37 */ &event_nosuch, /* 38 */ &event_nosuch, /* 39 */ &event_nosuch, /* 40 */ &event_nosuch, /* 41 */ &event_nosuch, /* 42 */ &event_nosuch, /* 43 */ &event_nosuch, /* 44 */ &event_nosuch, /* 45 */ &event_nosuch, /* 46 */ &event_nosuch, /* 47 */ &event_nosuch, /* 48 */ &event_nosuch, /* 49 */ &event_nosuch, /* 50 */ &event_nosuch, /* 51 */ &event_nosuch, /* 52 */ &event_nosuch, /* 53 */ &event_nosuch, /* 54 */ &event_nosuch, /* 55 */ &event_nosuch, /* 56 */ &event_nosuch, /* 57 */ &event_nosuch, /* 58 */ &event_nosuch, /* 59 */ &event_nosuch, /* 60 */ &event_nosuch, /* 61 */ &event_nosuch, /* 62 */ &event_nosuch, /* 63 */ &event_nosuch }; void event_core(FLOW *f, FILE *o) { if ((get1u(f,0) & 0x7f) > sizeof(core_ev)/sizeof(core_ev[0])) abort(); (*core_ev[get1u(f,0)])(f,o); } static void error_with_value(FLOW *f, FILE *o, const char *errname, const char *what) { error_hdr(f,o,errname); fprintf(o," Bad %s: 0x%08x\n",what,get4u(f,4)); } static void error_Request(FLOW *f, FILE *o) { error_hdr(f,o,"Request"); } static void error_Value(FLOW *f, FILE *o) { error_with_value(f,o,"Value","value"); } static void error_Window(FLOW *f, FILE *o) { error_with_value(f,o,"Window","window"); get_pad(f,11,21); } static void error_Pixmap(FLOW *f, FILE *o) { error_with_value(f,o,"Pixmap","pixmap"); } static void error_Atom(FLOW *f, FILE *o) { error_with_value(f,o,"Atom","atom"); } static void error_Cursor(FLOW *f, FILE *o) { error_with_value(f,o,"Cursor","cursor"); } static void error_Font(FLOW *f, FILE *o) { error_with_value(f,o,"Font","font"); get_pad(f,11,21); } static void error_Match(FLOW *f, FILE *o) { error_hdr(f,o,"Match"); get_pad(f,4,4); get_pad(f,11,21); } static void error_Drawable(FLOW *f, FILE *o) { error_with_value(f,o,"Drawable","drawable"); } static void error_Access(FLOW *f, FILE *o) { error_hdr(f,o,"Access"); } static void error_Alloc(FLOW *f, FILE *o) { error_hdr(f,o,"Alloc"); } static void error_Colormap(FLOW *f, FILE *o) { error_with_value(f,o,"Colormap","colourmap"); } static void error_GContext(FLOW *f, FILE *o) { error_with_value(f,o,"GContext","GC"); } static void error_IDChoice(FLOW *f, FILE *o) { error_with_value(f,o,"IDChoice","ID"); } static void error_Name(FLOW *f, FILE *o) { error_hdr(f,o,"Name"); get_pad(f,4,4); get_pad(f,11,21); } static void error_Length(FLOW *f, FILE *o) { error_hdr(f,o,"Length"); } static void error_Implementation(FLOW *f, FILE *o) { error_hdr(f,o,"Implementation"); } static void error_nosuch(FLOW *f, FILE *o) { fprintf(o,"Undefined core error %u",get1u(f,1)); print_raw_data(o,f); set_eof(f); abort_packet_print(); } static void (*core_err[128])(FLOW *, FILE *) = { /* 0 */ &error_nosuch, /* 1 */ &error_Request, /* 2 */ &error_Value, /* 3 */ &error_Window, /* 4 */ &error_Pixmap, /* 5 */ &error_Atom, /* 6 */ &error_Cursor, /* 7 */ &error_Font, /* 8 */ &error_Match, /* 9 */ &error_Drawable, /* 10 */ &error_Access, /* 11 */ &error_Alloc, /* 12 */ &error_Colormap, /* 13 */ &error_GContext, /* 14 */ &error_IDChoice, /* 15 */ &error_Name, /* 16 */ &error_Length, /* 17 */ &error_Implementation, /* 18 */ &error_nosuch, /* 19 */ &error_nosuch, #define NS4 &error_nosuch, &error_nosuch, &error_nosuch, &error_nosuch #define NS16 NS4, NS4, NS4, NS4 /* 20 - 31 */ NS4, NS4, NS4, /* 32 - 63 */ NS16, NS16, /* 64 - 127 */ NS16, NS16, NS16, NS16 }; #undef NS4 #undef NS16 void error_core(FLOW *f, FILE *o) { if (get1u(f,0) || (get1u(f,1) > sizeof(core_err)/sizeof(core_err[0]))) abort(); (*core_err[get1u(f,1)])(f,o); }