mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2025-04-21 12:27:27 +03:00
qi-add-hex-sprintf-type-functions.patch
We need to print hex into string buffers now, only in phase 2 Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
@@ -109,3 +109,26 @@ void hexdump(unsigned char *start, int len)
|
||||
len -= 16;
|
||||
}
|
||||
}
|
||||
|
||||
void setnybble(char *p, unsigned char n)
|
||||
{
|
||||
if (n < 10)
|
||||
*p = '0' + n;
|
||||
else
|
||||
*p = 'a' + n - 10;
|
||||
}
|
||||
|
||||
void set8(char *p, unsigned char n)
|
||||
{
|
||||
setnybble(p, (n >> 4) & 15);
|
||||
setnybble(p + 1, n & 15);
|
||||
}
|
||||
|
||||
void set32(char *p, unsigned int u)
|
||||
{
|
||||
set8(p, u >> 24);
|
||||
set8(p + 2, u >> 16);
|
||||
set8(p + 4, u >> 8);
|
||||
set8(p + 6, u);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user