Add the configure parameter --enable-packet-dump so that this
code can be enabled without editing the source.
This code is normally commented out, because it is too verbose
unless you happen to be debugging the underlying protocol. Because
it is normally commented out, I found it had bit-rotted slightly.
This commit also fixes the obvious problems.
+dnl Enable packet dumps when in verbose mode. This generates lots
+dnl of debug info, only useful for people debugging the RPC mechanism.
+AC_ARG_ENABLE([packet-dump],
+ [AS_HELP_STRING([--enable-packet-dump],
+ [enable packet dumps in verbose mode @<:@default=no@:>@])],
+ [AC_DEFINE([ENABLE_PACKET_DUMP],[1],[Enable packet dumps in verbose mode.])],
+ [])
+
dnl Readline.
AC_ARG_WITH([readline],
[AS_HELP_STRING([--with-readline],
dnl Readline.
AC_ARG_WITH([readline],
[AS_HELP_STRING([--with-readline],
[AC_DEFINE_UNQUOTED([ENABLE_DEBUG_COMMAND],[1],[Enable the 'debug' command])],
[])
[AC_DEFINE_UNQUOTED([ENABLE_DEBUG_COMMAND],[1],[Enable the 'debug' command])],
[])
+dnl Enable packet dumps when in verbose mode. This generates lots
+dnl of debug info, only useful for people debugging the RPC mechanism.
+AC_ARG_ENABLE([packet-dump],
+ [AS_HELP_STRING([--enable-packet-dump],
+ [enable packet dumps in verbose mode @<:@default=no@:>@])],
+ [AC_DEFINE([ENABLE_PACKET_DUMP],[1],[Enable packet dumps in verbose mode.])],
+ [])
+
dnl For strchrnul(3), asprintf(3), futimens(2) and getline(3).
AC_GNU_SOURCE
dnl For strchrnul(3), asprintf(3), futimens(2) and getline(3).
AC_GNU_SOURCE
+#ifdef ENABLE_PACKET_DUMP
for (i = 0; i < len; i += 16) {
for (i = 0; i < len; i += 16) {
for (j = i; j < MIN (i+16, len); ++j)
printf ("%02x ", (unsigned char) buf[j]);
for (; j < i+16; ++j)
for (j = i; j < MIN (i+16, len); ++j)
printf ("%02x ", (unsigned char) buf[j]);
for (; j < i+16; ++j)
}
/* Got the full message, caller can start processing it. */
}
/* Got the full message, caller can start processing it. */
+#ifdef ENABLE_PACKET_DUMP
for (i = 0; i < nr; i += 16) {
for (i = 0; i < nr; i += 16) {
for (j = i; j < MIN (i+16, nr); ++j)
for (j = i; j < MIN (i+16, nr); ++j)
- printf ("%02x ", (unsigned char) (*buf_rtn)[j]);
+ printf ("%02x ", (*(unsigned char **)buf_rtn)[j]);
for (; j < i+16; ++j)
printf (" ");
printf ("|");
for (; j < i+16; ++j)
printf (" ");
printf ("|");
- for (j = i; j < MIN (i+16, g->nr); ++j)
- if (isprint ((*buf_rtn)[j]))
- printf ("%c", (*buf_rtn)[j]);
+ for (j = i; j < MIN (i+16, nr); ++j)
+ if (isprint ((*(char **)buf_rtn)[j]))
+ printf ("%c", (*(char **)buf_rtn)[j]);
else
printf (".");
for (; j < i+16; ++j)
else
printf (".");
for (; j < i+16; ++j)