Deleted Added
full compact
print-ascii.c (276788) print-ascii.c (285275)
1/* $NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $ */
2
3/*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Alan Barrett and Simon J. Gerraty.

--- 43 unchanged lines hidden (view full) ---

52#define HEXDUMP_HEXSTUFF_PER_SHORT 5 /* 4 hex digits and a space */
53#define HEXDUMP_HEXSTUFF_PER_LINE \
54 (HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
55
56void
57ascii_print(netdissect_options *ndo,
58 const u_char *cp, u_int length)
59{
1/* $NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $ */
2
3/*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Alan Barrett and Simon J. Gerraty.

--- 43 unchanged lines hidden (view full) ---

52#define HEXDUMP_HEXSTUFF_PER_SHORT 5 /* 4 hex digits and a space */
53#define HEXDUMP_HEXSTUFF_PER_LINE \
54 (HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
55
56void
57ascii_print(netdissect_options *ndo,
58 const u_char *cp, u_int length)
59{
60 u_int caplength;
60 register u_char s;
61
61 register u_char s;
62
63 caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
64 if (length > caplength)
65 length = caplength;
62 ND_PRINT((ndo, "\n"));
63 while (length > 0) {
64 s = *cp++;
65 length--;
66 if (s == '\r') {
67 /*
68 * Don't print CRs at the end of the line; they
69 * don't belong at the ends of lines on UN*X,

--- 14 unchanged lines hidden (view full) ---

84 }
85 }
86}
87
88void
89hex_and_ascii_print_with_offset(netdissect_options *ndo, register const char *ident,
90 register const u_char *cp, register u_int length, register u_int oset)
91{
66 ND_PRINT((ndo, "\n"));
67 while (length > 0) {
68 s = *cp++;
69 length--;
70 if (s == '\r') {
71 /*
72 * Don't print CRs at the end of the line; they
73 * don't belong at the ends of lines on UN*X,

--- 14 unchanged lines hidden (view full) ---

88 }
89 }
90}
91
92void
93hex_and_ascii_print_with_offset(netdissect_options *ndo, register const char *ident,
94 register const u_char *cp, register u_int length, register u_int oset)
95{
96 u_int caplength;
92 register u_int i;
93 register int s1, s2;
94 register int nshorts;
95 char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
96 char asciistuff[ASCII_LINELENGTH+1], *asp;
97
97 register u_int i;
98 register int s1, s2;
99 register int nshorts;
100 char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
101 char asciistuff[ASCII_LINELENGTH+1], *asp;
102
103 caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
104 if (length > caplength)
105 length = caplength;
98 nshorts = length / sizeof(u_short);
99 i = 0;
100 hsp = hexstuff; asp = asciistuff;
101 while (--nshorts >= 0) {
102 s1 = *cp++;
103 s2 = *cp++;
104 (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
105 " %02x%02x", s1, s2);

--- 36 unchanged lines hidden (view full) ---

142/*
143 * telnet_print() wants this. It is essentially default_print_unaligned()
144 */
145void
146hex_print_with_offset(netdissect_options *ndo,
147 const char *ident, const u_char *cp, u_int length,
148 u_int oset)
149{
106 nshorts = length / sizeof(u_short);
107 i = 0;
108 hsp = hexstuff; asp = asciistuff;
109 while (--nshorts >= 0) {
110 s1 = *cp++;
111 s2 = *cp++;
112 (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
113 " %02x%02x", s1, s2);

--- 36 unchanged lines hidden (view full) ---

150/*
151 * telnet_print() wants this. It is essentially default_print_unaligned()
152 */
153void
154hex_print_with_offset(netdissect_options *ndo,
155 const char *ident, const u_char *cp, u_int length,
156 u_int oset)
157{
158 u_int caplength;
150 register u_int i, s;
151 register int nshorts;
152
159 register u_int i, s;
160 register int nshorts;
161
162 caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
163 if (length > caplength)
164 length = caplength;
153 nshorts = (u_int) length / sizeof(u_short);
154 i = 0;
155 while (--nshorts >= 0) {
156 if ((i++ % 8) == 0) {
157 ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
158 oset += HEXDUMP_BYTES_PER_LINE;
159 }
160 s = *cp++;

--- 36 unchanged lines hidden ---
165 nshorts = (u_int) length / sizeof(u_short);
166 i = 0;
167 while (--nshorts >= 0) {
168 if ((i++ % 8) == 0) {
169 ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
170 oset += HEXDUMP_BYTES_PER_LINE;
171 }
172 s = *cp++;

--- 36 unchanged lines hidden ---