view smpp-send/hexdump.c @ 270:6f28a4377a99

doc/Local-short-numbers: first draft written
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 26 Nov 2023 17:08:10 -0800
parents f11c3e40c87a
children
line wrap: on
line source

/*
 * 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');
	}
}