library/src/utility/BP-StringUtilities.cc
// Generates a SHA1 provided given input of a null ptr terminated string array.  Returned string must be bpfreed.  This function
// is obviously not length safe, and should be used with caution.  Max string length for this
// function is 2048.
Generates a SHA1 provided given input of a null ptr terminated string array.  Returned string must be bpfreed.  This function
is obviously not length safe, and should be used with caution.  Max string length for this
function is 2048.
Generates a SHA1 provided given input of a null ptr terminated string array . Returned string must be bpfreed . This function is obviously not length safe and should be used with caution . Max string length for this function is 2048 .
char * BP_GenSHA1FromStringArray(char **in)
{
	if(!in)
		return NULL;
	size_t j = 0;
	size_t x = 0;
	char *loop_str     = NULL;
	char *md5_item_str = NULL;
	for(; in[j]; j++)
	{
		if(!bpstrlen(in[j]))
			continue;
		md5_item_str = (char *) BP_GenSHA1(in[j], strnlen(in[j], 2048));
		if(!md5_item_str)
			return NULL;
		loop_str = (char *) bprealloc(loop_str, (j*40) + 41);
		memset((char *) &loop_str[j*40], 0x00, 41);
		memcpy((char *) &loop_str[j*40], md5_item_str, 40);
		bpfree(md5_item_str);
		md5_item_str = NULL;
	}
	if(!loop_str)
		return NULL;
	char *ret_str = BP_GenSHA1(loop_str, strnlen(loop_str, 4096));
	bpfree(loop_str);
	return ret_str;
}
char * BP_GenSHA1FromStringArray ( char * * in ) { if ( ! in ) return NULL ; size_t j = 0 ; size_t x = 0 ; char * loop_str = NULL ; char * md5_item_str = NULL ; for ( ; in [ j ] ; j ++ ) { if ( ! bpstrlen ( in [ j ] ) ) continue ; md5_item_str = ( char * ) BP_GenSHA1 ( in [ j ] , strnlen ( in [ j ] , 2048 ) ) ; if ( ! md5_item_str ) return NULL ; loop_str = ( char * ) bprealloc ( loop_str , ( j * 40 ) + 41 ) ; memset ( ( char * ) & loop_str [ j * 40 ] , 0x00 , 41 ) ; memcpy ( ( char * ) & loop_str [ j * 40 ] , md5_item_str , 40 ) ; bpfree ( md5_item_str ) ; md5_item_str = NULL ; } if ( ! loop_str ) return NULL ; char * ret_str = BP_GenSHA1 ( loop_str , strnlen ( loop_str , 4096 ) ) ; bpfree ( loop_str ) ; return ret_str ; }
Generates a SHA1 provided given input of a null ptr terminated string array.
Generates a SHA1 provided given input of a null ptr terminated string array .
// loop iter // length counter // bprealloced loop string, used for mdfs // walk the strings // make sure the string has a length // generate the md5 for an item // increase length of string // zero out new position // copy in the buffer // bpfree string on loop // sha1 the final string // destroy the aggregate sum chunk // return the newly allocated md5