93{
94 uint8_t *buf = NULL;
95 register uint8_t h1, h2;
96 uint32_t i;
97
98 if( hexsize % 2 )
99 lwerror(
"Invalid hex string, length (%zu) has to be a multiple of two!", hexsize);
100
102
103 if( ! buf )
104 lwerror(
"Unable to allocate memory buffer.");
105
106 for( i = 0; i < hexsize/2; i++ )
107 {
110 if( h1 > 15 )
111 lwerror(
"Invalid hex character (%c) encountered", hexbuf[2*i]);
112 if( h2 > 15 )
113 lwerror(
"Invalid hex character (%c) encountered", hexbuf[2*i+1]);
114
115 buf[i] = ((h1 & 0x0F) << 4) | (h2 & 0x0F);
116 }
117 return buf;
118}
void * lwalloc(size_t size)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static uint8_t hex2char[256]