[svn-commits] mattf: trunk r87 - /trunk/ss7.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jun 18 14:47:37 CDT 2007
Author: mattf
Date: Mon Jun 18 14:47:36 2007
New Revision: 87
URL: http://svn.digium.com/view/libss7?view=rev&rev=87
Log:
Make debug output not quite as ugly (#9903)
Modified:
trunk/ss7.c
Modified: trunk/ss7.c
URL: http://svn.digium.com/view/libss7/trunk/ss7.c?view=diff&rev=87&r1=86&r2=87
==============================================================================
--- trunk/ss7.c (original)
+++ trunk/ss7.c Mon Jun 18 14:47:36 2007
@@ -72,26 +72,28 @@
void ss7_dump_buf(struct ss7 *ss7, int tabs, unsigned char *buf, int len)
{
+ int i, j = 0;
+ char tmp[1024];
+
+ for (i = 0; i < tabs; i++)
+ snprintf(&tmp[i], sizeof(tmp)-i, "\t");
+ snprintf(&tmp[i], sizeof(tmp)-i, "[ ");
+ j = i + 2; /* some TAB + "[ " */
+ for (i = 0; i < len; i++) {
+ snprintf(&tmp[3*i]+j, sizeof(tmp)-3*i-j, "%02x ", buf[i]); /* &tmp[3*i]+j - for speed optimization, don't change format! */
+ }
+ ss7_message(ss7, "%s]\n", tmp);
+}
+
+void ss7_dump_msg(struct ss7 *ss7, unsigned char *buf, int len)
+{
int i;
-
- for (i = 0; i < tabs; i++)
- ss7_message(ss7, "\t");
- ss7_message(ss7, "[ ");
+ char tmp[1024];
+
for (i = 0; i < len; i++) {
- ss7_message(ss7, "%02x ", buf[i]);
- }
- ss7_message(ss7, "]\n");
-}
-
-void ss7_dump_msg(struct ss7 *ss7, unsigned char *buf, int len)
-{
- int i;
-
- ss7_message(ss7, "Len = %d [ ", len);
- for (i = 0; i < len; i++) {
- ss7_message(ss7, "%02x ", buf[i]);
- }
- ss7_message(ss7, "]\n");
+ snprintf(&tmp[3*i], sizeof(tmp)-3*i, "%02x ", buf[i]); /* &tmp[3*i] - for speed optimization, don't change format! */
+ }
+ ss7_message(ss7, "Len = %d [ %s]\n", len, tmp);
}
void ss7_msg_free(struct ss7_msg *m)
More information about the svn-commits
mailing list