library/src/utility/BP-StringUtilities.cc
// USES PCRE: This function takes a blacklist, an item, and an item count and checks
// to see that the item exists as a regexp in the blacklist.  If so it returns
// the position (first, second, third) of the index which matched. If there
// is no match, it returns 0.  Note: The 0 index, is the first position.
USES PCRE: This function takes a blacklist, an item, and an item count and checks
to see that the item exists as a regexp in the blacklist.  If so it returns
the position (first, second, third) of the index which matched. If there
is no match, it returns 0.  Note: The 0 index, is the first position.
USES PCRE : This function takes a blacklist an item and an item count and checks to see that the item exists as a regexp in the blacklist . If so it returns the position ( first second third ) of the index which matched . If there is no match it returns 0 . Note : The 0 index is the first position .
int BP_StringMatchesBlacklistREGEXP(char ** blacklist, size_t blacklist_cnt, char *item)
{
	if(!blacklist || !blacklist_cnt || !item)
		return ERR_FAILURE;
	size_t i = 0;
	for(i = 0; i < blacklist_cnt; i++)
	{
		if(!blacklist[i])
			break;
		if(!strnlen(blacklist[i], 1))
			continue;
		BP_REGEX_MATCH_INFO match_info = {0};
		BP_ERROR_T match_code = BP_MatchRegularExpressionPCRE
				(
						item,
						bpstrlen(item),
						(char *)&blacklist[i][0],
						0,
						1,
						(P_BP_REGEX_MATCH_INFO) &match_info,
						true
				);
		BP_DestroyRegexpMatchInfo(&match_info);
		if(match_code == ERR_SUCCESS)
			return i+1;
	}
	return ERR_FAILURE;
}
int BP_StringMatchesBlacklistREGEXP ( char * * blacklist , size_t blacklist_cnt , char * item ) { if ( ! blacklist || ! blacklist_cnt || ! item ) return ERR_FAILURE ; size_t i = 0 ; for ( i = 0 ; i < blacklist_cnt ; i ++ ) { if ( ! blacklist [ i ] ) break ; if ( ! strnlen ( blacklist [ i ] , 1 ) ) continue ; BP_REGEX_MATCH_INFO match_info = { 0 } ; BP_ERROR_T match_code = BP_MatchRegularExpressionPCRE ( item , bpstrlen ( item ) , ( char * ) & blacklist [ i ] [ 0 ] , 0 , 1 , ( P_BP_REGEX_MATCH_INFO ) & match_info , true ) ; BP_DestroyRegexpMatchInfo ( & match_info ) ; if ( match_code == ERR_SUCCESS ) return i + 1 ; } return ERR_FAILURE ; }
USES PCRE: This function takes a blacklist, an item, and an item count and checks
to see that the item exists as a regexp in the blacklist.
USES PCRE : This function takes a blacklist an item and an item count and checks to see that the item exists as a regexp in the blacklist .
// run initial checks // loop index for blacklist iteration loop // walk every entry in the blacklist array, and compare it with the anchor href // check for empty/no length entries // store match information //	printf("\n Trying to match: %s in \n this: %s", item, &blacklist[i][0]); // match regular expression // destroy match info where necessary // check for a successful match and return success (item is blacklisted) // return indicating that the item isn't in the blacklist