diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-06-01 10:09:54 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-06-01 16:00:33 +0200 |
commit | 181ae787f8a65beb6ba1fc29178acd18676772f1 (patch) | |
tree | 34791f6d132356b0331c32a0981030bb0d56877e /tests/utils.c | |
parent | 2ec2d70980a5a200c234a16d305cb4c34e5a09ea (diff) | |
download | gnutls-181ae787f8a65beb6ba1fc29178acd18676772f1.tar.gz |
tests: utils: added c_print()
Diffstat (limited to 'tests/utils.c')
-rw-r--r-- | tests/utils.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/utils.c b/tests/utils.c index 2a0b944e07..83ec426de8 100644 --- a/tests/utils.c +++ b/tests/utils.c @@ -152,7 +152,7 @@ void escapeprint(const char *str, size_t len) { size_t i; - printf(" (length %d bytes):\n\t", (int)len); + printf(" (length %d bytes):\n\t'", (int)len); for (i = 0; i < len; i++) { if (((str[i] & 0xFF) >= 'A' && (str[i] & 0xFF) <= 'Z') || ((str[i] & 0xFF) >= 'a' && (str[i] & 0xFF) <= 'z') || @@ -167,6 +167,19 @@ void escapeprint(const char *str, size_t len) printf("\n"); } +void c_print(const unsigned char *str, size_t len) +{ + size_t i; + + printf(" (length %d bytes):\n\t\"", (int)len); + for (i = 0; i < len; i++) { + printf("\\x%02X", (str[i] & 0xFF)); + if ((i + 1) % 16 == 0 && (i + 1) < len) + printf("\"\n\t\""); + } + printf("\"\n"); +} + void hexprint(const void *_str, size_t len) { size_t i; |