From 7ede207f9064fd88427026e38818819c2c8422bb Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Fri, 3 Jan 2014 05:48:17 -0800 Subject: Special-case printing of the GUID property Rather than printing GUIDs as 16 signed decimal integers, print them in {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} format. Signed-off-by: Aaron Plattner Reviewed-by: Alex Deucher --- xrandr.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/xrandr.c b/xrandr.c index ddc6c64..0a182c3 100644 --- a/xrandr.c +++ b/xrandr.c @@ -2425,6 +2425,25 @@ print_edid(int nitems, const unsigned char *prop) printf("\n"); } +static void +print_guid(const unsigned char *prop) +{ + int k; + + printf("{"); + + for (k = 0; k < 16; k++) + { + printf("%02" PRIX8, prop[k]); + if (k == 3 || k == 5 || k == 7 || k == 9) + { + printf("-"); + } + } + + printf("}\n"); +} + static void print_output_property(const char *atom_name, int value_format, @@ -2444,6 +2463,12 @@ print_output_property(const char *atom_name, print_edid (nitems, prop); return; } + else if (strcmp (atom_name, "GUID") == 0 && value_format == 8 && + value_type == XA_INTEGER && nitems == 16) + { + print_guid (prop); + return; + } for (k = 0; k < nitems; k++) { -- cgit v1.2.3