From 3aafeef2154546283b5f7b0c4061d6843d4f8a24 Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Wed, 13 Apr 2016 12:38:53 +0000 Subject: [PATCH] res_query_dump: added comment with printable symbols --- tests/res_query_dump.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tests/res_query_dump.c b/tests/res_query_dump.c index c9965fb..cb4bdb6 100644 --- a/tests/res_query_dump.c +++ b/tests/res_query_dump.c @@ -1,14 +1,41 @@ -/* Simple program to dump res_query(3) response. */ +/* res_query_dump.c + * Simple program to dump res_query(3) response + * + * Copyright (C) 2014 Dmitry Podgorny + * + * This software is provided AS-IS with no warranty, either express + * or implied. + * + * This program is dual licensed under the MIT and GPLv3 licenses. + */ + +/* Linux and OSX: + * gcc -o res_query_dump tests/res_query_dump.c -lresolv + * *BSD: + * gcc -o res_query_dump tests/res_query_dump.c + * QNX: + * gcc -o res_query_dump tests/res_query_dump.c -lsocket + * Solaris: + * gcc -o res_query_dump tests/res_query_dump.c -lresolv -lsocket -lnsl + */ #include #include #include +#include #include #include #include -#define STEP 8 +#ifndef T_SRV +#define T_SRV 33 +#endif /* T_SRV */ +#ifndef C_IN +#define C_IN 1 +#endif /* C_IN */ + +#define STEP 10 int main(int argc, char **argv) { @@ -47,6 +74,13 @@ int main(int argc, char **argv) for (j = i; j < len && j < i + STEP; ++j) { printf(" 0x%02x,", buf[j]); } + for (j = len; j < i + STEP; ++j) { + printf(" "); + } + printf(" // "); + for (j = i; j < len && j < i + STEP; ++j) { + printf("%c", isprint(buf[j]) ? buf[j] : '.'); + } printf("\n"); } printf("};\n");