1 /* 2 * Copyright (c) 2001 by Sun Microsystems, Inc. 3 * All rights reserved. 4 */ 5 6 #include <stdlib.h> 7 #include <string.h> 8 #include <ctype.h> 9 10 static char hexdig[] = "0123456789abcdef"; 11 12 char* hexa_print(char *aString, int aLen) 13 { 14 char *res; 15 int i =0; 16 17 if ((res = (char *)calloc (aLen*2 + 1, 1 )) == NULL){ 18 return (NULL); 19 } 20 for (;;){ 21 if (aLen < 1) 22 break; 23 res[i] = hexdig[ ( *aString & 0xf0 ) >> 4 ]; 24 res[i + 1] = hexdig[ *aString & 0x0f ]; 25 i+= 2; 26 aLen--; 27 aString++; 28 } 29 return (res); 30 } 31