]> granicus.if.org Git - strace/commitdiff
v4l2: quote pixelformat
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 25 Jan 2015 00:27:00 +0000 (00:27 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 26 Jan 2015 19:08:37 +0000 (19:08 +0000)
* v4l2.c (print_pixelformat): Output in quoted v4l2_fourcc() format.

v4l2.c

diff --git a/v4l2.c b/v4l2.c
index e3c607cffc7a0b226967bad42392c7c87b699a1d..c4541d9fc3b25aabf8df097e851cdb4c17f7eb34 100644 (file)
--- a/v4l2.c
+++ b/v4l2.c
 
 static void print_pixelformat(uint32_t fourcc)
 {
+       union {
+               uint32_t pixelformat;
+               unsigned char cc[sizeof(uint32_t)];
+       } u = {
+               .pixelformat =
 #if WORDS_BIGENDIAN
-       fourcc = htole32(fourcc);
+                       htole32(fourcc)
+#else
+                       fourcc
 #endif
-       tprintf("%.4s", (char*)&fourcc);
+       };
+       unsigned int i;
+
+       tprints("v4l2_fourcc(");
+       for (i = 0; i < sizeof(u.cc); ++i) {
+               unsigned int c = u.cc[i];
+
+               if (i)
+                       tprints(", ");
+               if (c == ' ' ||
+                   (c >= '0' && c <= '9') ||
+                   (c >= 'A' && c <= 'Z') ||
+                   (c >= 'a' && c <= 'z')) {
+                       char sym[] = {
+                               '\'',
+                               u.cc[i],
+                               '\''
+                       };
+                       tprints(sym);
+               } else {
+                       char hex[] = {
+                               '\'',
+                               '\\',
+                               'x',
+                               "0123456789abcdef"[c >> 4],
+                               "0123456789abcdef"[c & 0xf],
+                               '\'',
+                               '\0'
+                       };
+                       tprints(hex);
+               }
+       }
+       tprints(")");
 }
 
 static void print_v4l2_format_fmt(const struct v4l2_format *f)