library/src/utility/BP-StringUtilities.cc
// Converts a string to a unsigned long (base10).  Stores result in value_length.
Converts a string to a unsigned long (base10).  Stores result in value_length.
Converts a string to a unsigned long ( base10 ) . Stores result in value_length .
BP_ERROR_T BP_StringToUnsignedLongBase10(char * str, size_t len, unsigned long * store_value)
{
	if(!str || !len)
		return ERR_FAILURE;
	if(!store_value)
		return ERR_FAILURE;
	if(!store_value)
		return ERR_FAILURE;
	if(!BP_StringContainsOnlyNumericASCIIDigits(str, len))
		return ERR_FAILURE;
	if(str[0] == '0' && (bpstrlen(str) > 1))
	   return ERR_FAILURE;
	unsigned long tmp_val = 0;
	errno = 0;
	tmp_val = strtoul(str, NULL, 10);
	if(errno)
		return ERR_FAILURE;
	*store_value = tmp_val;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_StringToUnsignedLongBase10 ( char * str , size_t len , unsigned long * store_value ) { if ( ! str || ! len ) return ERR_FAILURE ; if ( ! store_value ) return ERR_FAILURE ; if ( ! store_value ) return ERR_FAILURE ; if ( ! BP_StringContainsOnlyNumericASCIIDigits ( str , len ) ) return ERR_FAILURE ; if ( str [ 0 ] == ' ' && ( bpstrlen ( str ) > 1 ) ) return ERR_FAILURE ; unsigned long tmp_val = 0 ; errno = 0 ; tmp_val = strtoul ( str , NULL , 10 ) ; if ( errno ) return ERR_FAILURE ; * store_value = tmp_val ; return ERR_SUCCESS ; }
Converts a string to a unsigned long (base10).
Converts a string to a unsigned long ( base10 ) .
// run basic checks // if there is no where to put a result, exit failure // check that string contains only numeric ascii digits // Check to ensure that the string doesn't start with zero.  This check // is only valid for strings longer than 1 byte, since 0 itself is // a valid value. // set tmp storage // attempt to convert // return if errno has been set // set the storage var from the tmp value if conversion was successful // return indicating success