Files
open62541/plugins/ua_debug_dump_pkgs.c
Stefan Profanter c2305461a3 Copyright holders at beginning of file (#1514)
* New script to add copyright names (see #1456)

* Use file history instead of git blame

* Order authors by first commit and modify displayed names

* fixup

* Add generated copyright holders
2018-01-26 14:14:25 +01:00

40 lines
1.1 KiB
C

/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
* See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
*
* Copyright 2017 (c) Stefan Profanter, fortiss GmbH
*/
#include "ua_util.h"
#include <ctype.h>
#include <stdio.h>
void UA_dump_hex_pkg(UA_Byte* buffer, size_t bufferLen) {
printf("--------------- HEX Package Start ---------------\n");
char ascii[17];
memset(ascii,0,17);
for (size_t i = 0; i < bufferLen; i++)
{
if (i == 0)
printf("%08zx ", i);
else if (i%16 == 0)
printf(" |%s|\n%08zx ", ascii, i);
if (isprint((int)(buffer[i])))
ascii[i%16] = (char)buffer[i];
else
ascii[i%16] = '.';
if (i%8==0)
printf(" ");
printf("%02X ", (unsigned char)buffer[i]);
}
size_t fillPos = bufferLen %16;
ascii[fillPos] = 0;
for (size_t i=fillPos; i<16; i++) {
if (i%8==0)
printf(" ");
printf(" ");
}
printf(" |%s|\n%08zx\n", ascii, bufferLen);
printf("--------------- HEX Package END ---------------\n");
}