+static const char *
+message_summary (const void *buf, size_t n, char *workspace)
+{
+ const unsigned char *cbuf = buf;
+ size_t i = 0;
+ char *p = workspace;
+ int truncate = 0;
+
+ /* Print only up to 5 x 32 bits of the message. That is enough to
+ * cover the message length, and the first four fields of the
+ * message header (prog, vers, proc, direction).
+ */
+ if (n > 5 * 4) {
+ n = 5 * 4;
+ truncate = 1;
+ }
+
+ while (n > 0) {
+ sprintf (p, "%02x ", cbuf[i]);
+ p += 3;
+ n--;
+ i++;
+
+ if ((i & 3) == 0) {
+ strcpy (p, "| ");
+ p += 2;
+ }
+ }
+
+ if (truncate)
+ strcpy (p, "...");
+
+ return workspace;
+}
+