[libpri-commits] rmudgett: branch 1.4 r848 - /branches/1.4/asn1_primitive.c
SVN commits to the libpri project
libpri-commits at lists.digium.com
Wed Jun 3 17:51:45 CDT 2009
Author: rmudgett
Date: Wed Jun 3 17:51:42 2009
New Revision: 848
URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=848
Log:
Made ASN.1 memory dump also display printable characters.
Modified:
branches/1.4/asn1_primitive.c
Modified: branches/1.4/asn1_primitive.c
URL: http://svn.asterisk.org/svn-view/libpri/branches/1.4/asn1_primitive.c?view=diff&rev=848&r1=847&r2=848
==============================================================================
--- branches/1.4/asn1_primitive.c (original)
+++ branches/1.4/asn1_primitive.c Wed Jun 3 17:51:42 2009
@@ -33,6 +33,7 @@
#include <stdio.h>
+#include <ctype.h>
#include "compat.h"
#include "libpri.h"
@@ -43,6 +44,26 @@
/*!
* \internal
+ * \brief Dump the memory contents indicated in printable characters. (Helper function.)
+ *
+ * \param ctrl D channel controller for any diagnostic messages.
+ * \param start Dump memory starting position.
+ * \param end Dump memory ending position. (Not included in dump.)
+ *
+ * \return Nothing
+ */
+static void asn1_dump_mem_helper(struct pri *ctrl, const unsigned char *start,
+ const unsigned char *end)
+{
+ pri_message(ctrl, " - \"");
+ for (; start < end; ++start) {
+ pri_message(ctrl, "%c", (isprint(*start)) ? *start : '~');
+ }
+ pri_message(ctrl, "\"\n");
+}
+
+/*!
+ * \internal
* \brief Dump the memory contents indicated.
*
* \param ctrl D channel controller for any diagnostic messages.
@@ -55,10 +76,12 @@
static void asn1_dump_mem(struct pri *ctrl, unsigned indent, const unsigned char *pos,
unsigned length)
{
+ const unsigned char *seg_start;
const unsigned char *end;
unsigned delimiter;
unsigned count;
+ seg_start = pos;
end = pos + length;
if (pos < end) {
delimiter = '<';
@@ -71,12 +94,14 @@
if (end <= pos) {
break;
}
- pri_message(ctrl, "\n");
+ asn1_dump_mem_helper(ctrl, seg_start, pos);
+ seg_start = pos;
}
} else {
pri_message(ctrl, "%*s<", indent, "");
}
- pri_message(ctrl, ">\n");
+ pri_message(ctrl, ">");
+ asn1_dump_mem_helper(ctrl, seg_start, end);
}
/*!
More information about the libpri-commits
mailing list