library/src/utility/BP-StringUtilities.cc
// string conforms to a path semantic
string conforms to a path semantic
string conforms to a path semantic
BP_ERROR_T BP_StringIsPathURL(char * str_value)
{
	if(!str_value)
		return ERR_FAILURE;
	if(!strnlen(str_value, 1))
		return ERR_FAILURE;
	size_t len = bpstrlen(str_value);
	char * parsed = BP_ParseURLToPathPCRE(str_value);
	if(!parsed)
		return ERR_FAILURE;
	if(bpstrlen(parsed) != len)
	{
		free(parsed);
		return ERR_FAILURE;
	}
	if(memcmp(parsed, str_value, len) != 0)
	{
		free(parsed);
		return ERR_FAILURE;
	}
	free(parsed);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_StringIsPathURL ( char * str_value ) { if ( ! str_value ) return ERR_FAILURE ; if ( ! strnlen ( str_value , 1 ) ) return ERR_FAILURE ; size_t len = bpstrlen ( str_value ) ; char * parsed = BP_ParseURLToPathPCRE ( str_value ) ; if ( ! parsed ) return ERR_FAILURE ; if ( bpstrlen ( parsed ) != len ) { free ( parsed ) ; return ERR_FAILURE ; } if ( memcmp ( parsed , str_value , len ) != 0 ) { free ( parsed ) ; return ERR_FAILURE ; } free ( parsed ) ; return ERR_SUCCESS ; }
string conforms to a path semantic
string conforms to a path semantic
// ensure we have a string value // ensure the value has length // determine string length // attempt to parse the value to a script // ensure that value was parsed // if the parsed length is not matched to length, we know we // have unmatched data. // if memcmp fails, exit with failure status // destroy parsed string // return indicating success