library/src/utility/BP-StringUtilities.cc
char * BP_GenSHA1FromStringArray(char **in)
{

	if(!in)
		return NULL;

	// loop iter
	size_t j = 0;

	// length counter
	size_t x = 0;

	// bprealloced loop string, used for mdfs
	char *loop_str     = NULL;
	char *md5_item_str = NULL;

	// walk the strings
	for(; in[j]; j++)
	{

		// make sure the string has a length
		if(!bpstrlen(in[j]))
			continue;

		// generate the md5 for an item
		md5_item_str = (char *) BP_GenSHA1(in[j], strnlen(in[j], 2048));
		if(!md5_item_str)
			return NULL;

		// increase length of string
		loop_str = (char *) bprealloc(loop_str, (j*40) + 41);

		// zero out new position
		memset((char *) &loop_str[j*40], 0x00, 41);

		// copy in the buffer
		memcpy((char *) &loop_str[j*40], md5_item_str, 40);

		// bpfree string on loop
		bpfree(md5_item_str);
		md5_item_str = NULL;

	}

	if(!loop_str)
		return NULL;

	// sha1 the final string
	char *ret_str = BP_GenSHA1(loop_str, strnlen(loop_str, 4096));

	// destroy the aggregate sum chunk
	bpfree(loop_str);

	// return the newly allocated md5
	return ret_str;

}
// 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