library/src/utility/BP-StringUtilities.cc
// Attempts to parse out a csv file from a buffer.  This is primarily
// used with the sqlmap subsystem which generates a csv file directly.
Attempts to parse out a csv file from a buffer.  This is primarily
used with the sqlmap subsystem which generates a csv file directly.
Attempts to parse out a csv file from a buffer . This is primarily used with the sqlmap subsystem which generates a csv file directly .
char * BP_ParseBufferToUNIXFilesystemPathCSVPCRE(char *buffer, size_t buffer_size)
{
	char * regexp = "(?:\\/\.?[\\w-]{4,})+(?:[\\/~\\w\\-0-9]+)\\.csv";
	BP_REGEX_MATCH_INFO match_info = {0};
	size_t matched = BP_MatchRegularExpressionPCRE(buffer, buffer_size, regexp, 0, 1024, &match_info, true);
	char *ret_string = NULL;
	if(matched == ERR_SUCCESS)
	{
		size_t n = 0;
		for(; n < match_info.pcre_num_matched; n++)
		{
			ret_string = bpstrdup(match_info.preg_matches->matched_string);
			break;
		}
	}
	BP_DestroyRegexpMatchInfo(&match_info);
	return ret_string;
}
char * BP_ParseBufferToUNIXFilesystemPathCSVPCRE ( char * buffer , size_t buffer_size ) { char * regexp = " \\ \. \\ \\ \\ \\ \\ " ; BP_REGEX_MATCH_INFO match_info = { 0 } ; size_t matched = BP_MatchRegularExpressionPCRE ( buffer , buffer_size , regexp , 0 , 1024 , & match_info , true ) ; char * ret_string = NULL ; if ( matched == ERR_SUCCESS ) { size_t n = 0 ; for ( ; n < match_info . pcre_num_matched ; n ++ ) { ret_string = bpstrdup ( match_info . preg_matches -> matched_string ) ; break ; } } BP_DestroyRegexpMatchInfo ( & match_info ) ; return ret_string ; }
Attempts to parse out a csv file from a buffer.
Attempts to parse out a csv file from a buffer .
// path matching regexp // create zeroed out inout structure // get matches // set the return string default to null // set matched // check for the matches // display matched string // destroy the match info // return null for failure