comparison 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
comparison
equal deleted inserted replaced
222:9d6e8d99d2b1 223:f11c3e40c87a
1 /*
2 * This module implements debug hex dump output of SMPP submit_sm PDUs
3 * constructed by our smpp-send program.
4 */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8
9 void
10 hex_dump_output(pdu, pdulen)
11 u_char *pdu;
12 unsigned pdulen;
13 {
14 unsigned off, chunk;
15 int i, c;
16
17 printf("Constructed PDU of %u bytes:\n", pdulen);
18 for (off = 0; off < pdulen; off += chunk) {
19 printf("%04X: ", off);
20 chunk = pdulen - off;
21 if (chunk > 16)
22 chunk = 16;
23 for (i = 0; i < 16; i++) {
24 if (i < chunk)
25 printf("%02X ", pdu[off + i]);
26 else
27 fputs(" ", stdout);
28 if (i == 7 || i == 15)
29 putchar(' ');
30 }
31 for (i = 0; i < chunk; i++) {
32 c = pdu[off + i];
33 if (c < ' ' || c > '~')
34 c = '.';
35 putchar(c);
36 }
37 putchar('\n');
38 }
39 }