1
0
mirror of https://github.com/DxWnd/DxWnd.reloaded synced 2024-12-30 09:25:35 +01:00
DxWnd.reloaded/dll/hexdump.cpp
gho tik f43aa4930c v2_03_23_src
Former-commit-id: cecbfca59b1066f5c3b745a7e8bdda9510acd68b
2017-03-06 11:40:51 -05:00

23 lines
488 B
C++

#define _CRT_SECURE_NO_WARNINGS
#include "stdio.h"
#include "string.h"
#define MAX_HEXDUMP 512
char *hexdump(unsigned char *Buffer, int len)
{
static char sHexBuffer[3*MAX_HEXDUMP+12];
char *s;
int iMaxI;
if(!Buffer) return "(NULL)";
s=sHexBuffer;
iMaxI = len;
if(iMaxI > MAX_HEXDUMP) iMaxI = MAX_HEXDUMP;
for (int i=0; i<iMaxI; i++){
sprintf(s, "%02.2X,", Buffer[i]);
s += 3;
}
*(--s)=0; // eliminate last comma
if(len > iMaxI) strcpy(s, ",...");
return sHexBuffer;
}