From 95a96dbdc483d9dc6371f52a9e41771a64d23aed Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 15 Jul 2012 01:32:49 -0700 Subject: Create PrintPropertyValues function for property requests Currently used for core protocol window properties, but will be used for extensions that have similar property handling requests in the future. Signed-off-by: Alan Coopersmith --- print11.c | 16 +++++----------- proto.h | 3 +++ prtype.c | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/print11.c b/print11.c index a84de9e..b2b61fb 100644 --- a/print11.c +++ b/print11.c @@ -1402,9 +1402,9 @@ GetAtomNameReply(const unsigned char *buf) void ChangeProperty(FD fd, const unsigned char *buf) { - long n; - short unit; - long type; + uint32_t n; + uint8_t unit; + uint32_t type; /* Request ChangeProperty is opcode 18 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ChangeProperty */ @@ -1423,10 +1423,7 @@ ChangeProperty(FD fd, const unsigned char *buf) unit = IByte(&buf[16]) / 8; printfield(buf, 20, 4, CARD32, "length of data"); n = ILong(&buf[20]); - if (type == 31 /* string */ ) - PrintString8(&buf[24], n * unit, "data"); - else - PrintBytes(&buf[24], n * unit, "data"); + PrintPropertyValues(&buf[24], type, unit, n, "data"); } void @@ -1482,10 +1479,7 @@ GetPropertyReply(const unsigned char *buf) PrintField(buf, 12, 4, CARD32, "bytes-after"); printfield(buf, 16, 4, CARD32, "length of value"); n = ILong(&buf[16]); - if (type == 31 /* string */ ) - PrintString8(&buf[32], n * unit, "value"); - else - PrintBytes(&buf[32], n * unit, "value"); + PrintPropertyValues(&buf[32], type, unit, n, "value"); } void diff --git a/proto.h b/proto.h index 14ab41e..733ced1 100644 --- a/proto.h +++ b/proto.h @@ -257,6 +257,9 @@ extern void PrintTextList8(const unsigned char *buf, int length, const char *name); extern void PrintTextList16(const unsigned char *buf, int length, const char *name); +extern int PrintPropertyValues(const unsigned char *buf, + uint32_t type /* atom */, uint8_t unit, + uint32_t num, const char *name); /* scope.c */ extern void TestBreakPoints(const unsigned char *buf, long n); diff --git a/prtype.c b/prtype.c index 9abdd3b..9117ae0 100644 --- a/prtype.c +++ b/prtype.c @@ -1046,6 +1046,24 @@ PrintTextList16(const unsigned char *buf, int length, const char *name) /* */ /* ************************************************************ */ +/* Several extensions have grown property requests mimicing the + core protocol Window properties, and share this code for printing + lists of property values */ +int +PrintPropertyValues(const unsigned char *buf, uint32_t type /* atom */, + uint8_t unit, uint32_t num, const char *name) +{ + if (type == 31 /* string */) + PrintString8(buf, num * unit, name); + else + PrintBytes(buf, num * unit, name); +} + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + #define MAXline 78 void -- cgit v1.2.1