diff smpp-send/hexdump.c @ 223:f11c3e40c87a

new program smpp-send
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 05 Aug 2023 12:24:31 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/smpp-send/hexdump.c	Sat Aug 05 12:24:31 2023 -0800
@@ -0,0 +1,39 @@
+/*
+ * This module implements debug hex dump output of SMPP submit_sm PDUs
+ * constructed by our smpp-send program.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+
+void
+hex_dump_output(pdu, pdulen)
+	u_char *pdu;
+	unsigned pdulen;
+{
+	unsigned off, chunk;
+	int i, c;
+
+	printf("Constructed PDU of %u bytes:\n", pdulen);
+	for (off = 0; off < pdulen; off += chunk) {
+		printf("%04X:  ", off);
+		chunk = pdulen - off;
+		if (chunk > 16)
+			chunk = 16;
+		for (i = 0; i < 16; i++) {
+			if (i < chunk)
+				printf("%02X ", pdu[off + i]);
+			else
+				fputs("   ", stdout);
+			if (i == 7 || i == 15)
+				putchar(' ');
+		}
+		for (i = 0; i < chunk; i++) {
+			c = pdu[off + i];
+			if (c < ' ' || c > '~')
+				c = '.';
+			putchar(c);
+		}
+		putchar('\n');
+	}
+}