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