]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ascii.c
add a short option '#', same as long option '--number' (print a packet number)
[tcpdump] / print-ascii.c
index 55e0ae72589eca09f89dd974b51255ed7423e423..96410da8faf65b5026dc63347a2b292f134b94c3 100644 (file)
@@ -36,6 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -43,7 +44,6 @@
 #include <tcpdump-stdinc.h>
 #include <stdio.h>
 
-#include "netdissect.h"
 #include "interface.h"
 
 #define ASCII_LINELENGTH 300
                (HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
 
 void
-ascii_print(register const u_char *cp, register u_int length)
+ascii_print(netdissect_options *ndo,
+            const u_char *cp, u_int length)
 {
-       register int s;
+       register u_char s;
 
-       putchar('\n');
+       ND_PRINT((ndo, "\n"));
        while (length > 0) {
                s = *cp++;
                length--;
@@ -73,13 +74,13 @@ ascii_print(register const u_char *cp, register u_int length)
                         * In the middle of a line, just print a '.'.
                         */
                        if (length > 1 && *cp != '\n')
-                               putchar('.');
+                               ND_PRINT((ndo, "."));
                } else {
                        if (!ND_ISGRAPH(s) &&
                            (s != '\t' && s != ' ' && s != '\n'))
-                               putchar('.');
+                               ND_PRINT((ndo, "."));
                        else
-                               putchar(s);
+                               ND_PRINT((ndo, "%c", s));
                }
        }
 }
@@ -153,16 +154,16 @@ hex_print_with_offset(netdissect_options *ndo,
        i = 0;
        while (--nshorts >= 0) {
                if ((i++ % 8) == 0) {
-                  (void)ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
-                  oset += HEXDUMP_BYTES_PER_LINE;
+                       ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
+                       oset += HEXDUMP_BYTES_PER_LINE;
                }
                s = *cp++;
-               (void)ND_PRINT((ndo," %02x%02x", s, *cp++));
+               ND_PRINT((ndo," %02x%02x", s, *cp++));
        }
        if (length & 1) {
                if ((i % 8) == 0)
-                  (void)ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
-               (void)ND_PRINT((ndo," %02x", *cp));
+                       ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
+               ND_PRINT((ndo," %02x", *cp));
        }
 }