library/src/buffer_analysis/ASCII/BP-BufferAnalysisASCII.cc
// Returns a BP_FLAGS_T value set with any combination of BP_ASCII_CHARACTER_SEARCH_FLAG_VALUES enumerated
// values.
Returns a BP_FLAGS_T value set with any combination of BP_ASCII_CHARACTER_SEARCH_FLAG_VALUES enumerated
values.
Returns a BP_FLAGS_T value set with any combination of BP_ASCII_CHARACTER_SEARCH_FLAG_VALUES enumerated values .
BP_FLAGS_T BP_CompareASCIIStringFlags(P_BP_BUFFER_ANALYSIS_ASCII_STRING_FLAGS flags_compare_this, P_BP_BUFFER_ANALYSIS_ASCII_STRING_FLAGS flags_compare_with_this)
{
	if(!flags_compare_this || !flags_compare_with_this)
		return BP_ASCII_STRING_SEARCH_NONE;
	size_t compare_flag_count = BP_CountNumberASCIIStringFlagsSet(flags_compare_this);
	size_t match_flag_count = 0;
	size_t match_flag_negative_count = 0;
	BP_FLAGS_T match_flags = 0;
	if(memcmp(flags_compare_this, flags_compare_with_this, sizeof(BP_BUFFER_ANALYSIS_ASCII_STRING_FLAGS)) == 0)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_POSITIVE_MATCH);
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_ALL_SEARCH_FLAG_CONDITIONS_MET);
		return match_flags;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_NEGATIVE_MATCH);
	}
	if(flags_compare_this->is_unix_file_path == 1)
	if(flags_compare_this->is_unix_file_path == flags_compare_with_this->is_unix_file_path)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(flags_compare_this->is_url == 1)
	if(flags_compare_this->is_url == flags_compare_with_this->is_url)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(flags_compare_this->is_host_url == 1)
	if(flags_compare_this->is_host_url == flags_compare_with_this->is_host_url)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(flags_compare_this->is_base_url == 1)
	if(flags_compare_this->is_base_url == flags_compare_with_this->is_base_url)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(flags_compare_this->is_script_url == 1)
	if(flags_compare_this->is_script_url == flags_compare_with_this->is_script_url)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(flags_compare_this->is_path_url == 1)
	if(flags_compare_this->is_path_url == flags_compare_with_this->is_path_url)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(flags_compare_this->is_dynamic_so == 1)
	if(flags_compare_this->is_dynamic_so == flags_compare_with_this->is_dynamic_so)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(flags_compare_this->exists_as_file_on_filesystem == 1)
	if(flags_compare_this->exists_as_file_on_filesystem == flags_compare_with_this->exists_as_file_on_filesystem)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(flags_compare_this->exists_as_file_on_filesystem_and_is_readable == 1)
	if(flags_compare_this->exists_as_file_on_filesystem_and_is_readable == flags_compare_with_this->exists_as_file_on_filesystem_and_is_readable)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(flags_compare_this->exists_as_file_on_filesystem_and_is_writable == 1)
	if(flags_compare_this->exists_as_file_on_filesystem_and_is_writable == flags_compare_with_this->exists_as_file_on_filesystem_and_is_writable)
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH);
		match_flag_count++;
	}
	else
	{
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH);
		match_flag_negative_count++;
	}
	if(compare_flag_count == match_flag_count)
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_ALL_SEARCH_FLAG_CONDITIONS_MET);
	if(compare_flag_count == match_flag_negative_count)
		BP_SET_FLAG(match_flags, BP_ASCII_STRING_SEARCH_ALL_SEARCH_FLAG_CONDITIONS_MET_NEGATIVELY);
	return match_flags;
}
BP_FLAGS_T BP_CompareASCIIStringFlags ( P_BP_BUFFER_ANALYSIS_ASCII_STRING_FLAGS flags_compare_this , P_BP_BUFFER_ANALYSIS_ASCII_STRING_FLAGS flags_compare_with_this ) { if ( ! flags_compare_this || ! flags_compare_with_this ) return BP_ASCII_STRING_SEARCH_NONE ; size_t compare_flag_count = BP_CountNumberASCIIStringFlagsSet ( flags_compare_this ) ; size_t match_flag_count = 0 ; size_t match_flag_negative_count = 0 ; BP_FLAGS_T match_flags = 0 ; if ( memcmp ( flags_compare_this , flags_compare_with_this , sizeof ( BP_BUFFER_ANALYSIS_ASCII_STRING_FLAGS ) ) == 0 ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_POSITIVE_MATCH ) ; BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_ALL_SEARCH_FLAG_CONDITIONS_MET ) ; return match_flags ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_NEGATIVE_MATCH ) ; } if ( flags_compare_this -> is_unix_file_path == 1 ) if ( flags_compare_this -> is_unix_file_path == flags_compare_with_this -> is_unix_file_path ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( flags_compare_this -> is_url == 1 ) if ( flags_compare_this -> is_url == flags_compare_with_this -> is_url ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( flags_compare_this -> is_host_url == 1 ) if ( flags_compare_this -> is_host_url == flags_compare_with_this -> is_host_url ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( flags_compare_this -> is_base_url == 1 ) if ( flags_compare_this -> is_base_url == flags_compare_with_this -> is_base_url ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( flags_compare_this -> is_script_url == 1 ) if ( flags_compare_this -> is_script_url == flags_compare_with_this -> is_script_url ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( flags_compare_this -> is_path_url == 1 ) if ( flags_compare_this -> is_path_url == flags_compare_with_this -> is_path_url ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( flags_compare_this -> is_dynamic_so == 1 ) if ( flags_compare_this -> is_dynamic_so == flags_compare_with_this -> is_dynamic_so ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( flags_compare_this -> exists_as_file_on_filesystem == 1 ) if ( flags_compare_this -> exists_as_file_on_filesystem == flags_compare_with_this -> exists_as_file_on_filesystem ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( flags_compare_this -> exists_as_file_on_filesystem_and_is_readable == 1 ) if ( flags_compare_this -> exists_as_file_on_filesystem_and_is_readable == flags_compare_with_this -> exists_as_file_on_filesystem_and_is_readable ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( flags_compare_this -> exists_as_file_on_filesystem_and_is_writable == 1 ) if ( flags_compare_this -> exists_as_file_on_filesystem_and_is_writable == flags_compare_with_this -> exists_as_file_on_filesystem_and_is_writable ) { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_POSITIVE_MATCH ) ; match_flag_count ++ ; } else { BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_PARTIAL_NEGATIVE_MATCH ) ; match_flag_negative_count ++ ; } if ( compare_flag_count == match_flag_count ) BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_ALL_SEARCH_FLAG_CONDITIONS_MET ) ; if ( compare_flag_count == match_flag_negative_count ) BP_SET_FLAG ( match_flags , BP_ASCII_STRING_SEARCH_ALL_SEARCH_FLAG_CONDITIONS_MET_NEGATIVELY ) ; return match_flags ; }
Returns a BP_FLAGS_T value set with any combination of BP_ASCII_CHARACTER_SEARCH_FLAG_VALUES enumerated
values.
Returns a BP_FLAGS_T value set with any combination of BP_ASCII_CHARACTER_SEARCH_FLAG_VALUES enumerated values .
// ensure we have two sets of flags to compare // count for matches (used to determine if we have an inbound search perfect partial match) // match flag count // match negative count // declare and initialize flags (this is a bitfield flag-set which // is the eventual return value for this routine) // set based on pure positive/negative match // set indicator showing we have a perfect match // since we have a perfect match, we know all flag values were set ok // return the flags // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched as unix file path %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched as generic URL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched is_host_url %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched is_base_url %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched is_script_url %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched is_path_url %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched is_path_url %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched exists_as_file_on_filesystem %%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched exists_as_file_on_filesystem_and_is_readable %%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% is matched exists_as_file_on_filesystem_and_is_writable %%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // if we have matched the correct number of flags, we can safely consider // all conditions met. // return the matched flags