library/src/utility/BP-StringUtilities.cc
// same as the non-escaped version, except this version escapes the string as if it were
// \xNN encoded (aka \x00\x01\x02)
same as the non-escaped version, except this version escapes the string as if it were
\xNN encoded (aka \x00\x01\x02)
same as the non - escaped version except this version escapes the string as if it were \ xNN encoded ( aka \ x00 \ x01 \ x02 )
char * BP_GenEscapedHexStringFromBuffer(unsigned char * buff, size_t size, P_BP_LINKL tq)
{
	if(!buff || !size)
		return NULL;
	size_t buff_size = (size * 4) + 1;
	char *out_buff = (char *) NULL;
	if(tq)
		out_buff = (char *) tq_calloc(tq, buff_size, 1, BPLN);
	else
		out_buff = (char *) bpcalloc(buff_size, 1);
	size_t n = 0;
	size_t j = 0;
	for(; n < size; n++)
	{
		sprintf(&out_buff[n*4], "\\x%.02x", buff[n]);
	}
	if(out_buff && tq)
	{
		P_BP_LINKL_DATA linkl_data = BP_BackwardLookupDataItemFromPointer(tq, out_buff);
		linkl_data->data_type = BP_MEMPROF_ALLOC_TYPE_USER_DEFINED_ASCII;
	}
	return out_buff;
}
char * BP_GenEscapedHexStringFromBuffer ( unsigned char * buff , size_t size , P_BP_LINKL tq ) { if ( ! buff || ! size ) return NULL ; size_t buff_size = ( size * 4 ) + 1 ; char * out_buff = ( char * ) NULL ; if ( tq ) out_buff = ( char * ) tq_calloc ( tq , buff_size , 1 , BPLN ) ; else out_buff = ( char * ) bpcalloc ( buff_size , 1 ) ; size_t n = 0 ; size_t j = 0 ; for ( ; n < size ; n ++ ) { sprintf ( & out_buff [ n * 4 ] , " \\ " , buff [ n ] ) ; } if ( out_buff && tq ) { P_BP_LINKL_DATA linkl_data = BP_BackwardLookupDataItemFromPointer ( tq , out_buff ) ; linkl_data -> data_type = BP_MEMPROF_ALLOC_TYPE_USER_DEFINED_ASCII ; } return out_buff ; }
same as the non-escaped version, except this version escapes the string as if it were
\xNN encoded (aka \x00\x01\x02)
same as the non - escaped version except this version escapes the string as if it were \ xNN encoded ( aka \ x00 \ x01 \ x02 )
// check to ensure we have a buffer and a buffer size // since we're expanding the buffer from one byte per char to // four bytes per hex char, we can just multiply size to get // the correct buffer size. // now allocate the out buffer // now fill the buffer with escaped hex data // set data type via manual means since we're creating a string // set the data type here // return the allocated buffer