summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-15 12:54:38 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-10-02 22:16:08 -0700
commit519488decdfe224c79e7f2f18e36d2ecae2166a2 (patch)
tree7ff235483462eac1d0f4424c914282ce9f2f0cd8
parentd678ab80b2987ddd696519a27dad5571c379b511 (diff)
downloadxscope-519488decdfe224c79e7f2f18e36d2ecae2166a2.tar.gz
Add support for printing more types of property value
Prints atoms, cardinals, integers, and windows as formatted values instead of lists of bytes. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--prtype.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/prtype.c b/prtype.c
index 8a16bfb..b1ba8ce 100644
--- a/prtype.c
+++ b/prtype.c
@@ -1053,8 +1053,48 @@ int
PrintPropertyValues(const unsigned char *buf, uint32_t type /* atom */,
uint8_t unit, uint32_t num, const char *name)
{
- if (type == 31 /* string */)
+ short fieldType = 0;
+
+ switch (type) {
+ case 4: /* XA_ATOM */
+ fieldType = ATOM;
+ break;
+ case 6: /* XA_CARDINAL */
+ switch (unit) {
+ case 4: fieldType = CARD32; break;
+ case 2: fieldType = CARD16; break;
+ case 1: fieldType = CARD8; break;
+ default:
+ goto rawbytes;
+ }
+ break;
+ case 19: /* XA_INTEGER */
+ switch (unit) {
+ case 4: fieldType = INT32; break;
+ case 2: fieldType = INT16; break;
+ case 1: fieldType = INT8; break;
+ default:
+ goto rawbytes;
+ }
+ break;
+ case 31: /* XA_STRING */
return PrintString8(buf, num * unit, name);
+ case 33: /* XA_WINDOW */
+ fieldType = WINDOW;
+ break;
+ default:
+ /* Fall through to check for known non-builtin types below */
+ break;
+ }
+
+ if (fieldType != 0) {
+ if (num == 1) {
+ PrintField(buf, 0, unit, fieldType, name);
+ return unit;
+ }
+ else
+ return PrintList(buf, num, fieldType, name);
+ }
else {
const char *typename = FindAtomName(type);
@@ -1063,11 +1103,12 @@ PrintPropertyValues(const unsigned char *buf, uint32_t type /* atom */,
if (IsUTF8locale)
return PrintString8(buf, num * unit, name);
else
- return PrintBytes(buf, num * unit, name);
+ goto rawbytes;
}
}
}
+ rawbytes:
/* When all else fails, print raw bytes */
return PrintBytes(buf, num * unit, name);
}