]> The Tcpdump Group git mirrors - tcpdump/blobdiff - util.c
NDOize safeputs() and safeputchar()
[tcpdump] / util.c
diff --git a/util.c b/util.c
index ff406025c9929c87b3d104eb1318e548ee727883..822b60e5e557d90b1681fe7dcd91a44b3b7f955b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -578,27 +578,23 @@ read_infile(char *fname)
 }
 
 void
-safeputs(const char *s, int maxlen)
+safeputs(netdissect_options *ndo,
+         const u_char *s, const u_int maxlen)
 {
-       int idx = 0;
+       u_int idx = 0;
 
        while (*s && idx < maxlen) {
-               safeputchar(*s);
-                idx++;
+               safeputchar(ndo, *s);
+               idx++;
                s++;
        }
 }
 
 void
-safeputchar(int c)
+safeputchar(netdissect_options *ndo,
+            const u_char c)
 {
-       unsigned char ch;
-
-       ch = (unsigned char)(c & 0xff);
-       if (ch < 0x80 && ND_ISPRINT(ch))
-               printf("%c", ch);
-       else
-               printf("\\0x%02x", ch);
+       ND_PRINT((ndo, (c < 0x80 && ND_ISPRINT(c)) ? "%c" : "\\0x%02x", c));
 }
 
 #ifdef LBL_ALIGN