library/src/buffer_analysis/ASCII/BP-BufferAnalysisASCII.cc
// adds a string to a ascii portion of buffer analyis.  This is a utility routine used by BP_ExtractASCIIStringsFromAnalyzedBuffer
// and probably shouldn't be used directly, although it can be, depending on the current predicament.  The strings added here
// are automatically freed() when BP_DestroyBufferAnalysis is called.
adds a string to a ascii portion of buffer analyis.  This is a utility routine used by BP_ExtractASCIIStringsFromAnalyzedBuffer
and probably shouldn't be used directly, although it can be, depending on the current predicament.  The strings added here
are automatically freed() when BP_DestroyBufferAnalysis is called.
adds a string to a ascii portion of buffer analyis . This is a utility routine used by BP_ExtractASCIIStringsFromAnalyzedBuffer and probably shouldn ' t be used directly although it can be depending on the current predicament . The strings added here are automatically freed () when BP_DestroyBufferAnalysis is called .
BP_ERROR_T BP_AddASCIIStringToBufferAnalysis
(
		P_BP_BUFFER_ANALYSIS                  buff_analysis,
		size_t                                position_in_analyzed_buffer,
		size_t                                string_len,
		unsigned char *                       address_of_string_in_buffer,
		P_BP_ASCII_CHAR_FLAGS                 match_flags,
		BP_ASCII_CHARACTER_SEARCH_FLAG_VALUES match_flags_how,
		P_BP_ASCII_CHAR_FLAGS                 negative_match_flags,
		BP_ASCII_CHARACTER_SEARCH_FLAG_VALUES negative_match_flags_how
)
{
	if(!buff_analysis)
		return ERR_FAILURE;
	if(!buff_analysis->tq)
		return ERR_FAILURE;
	if(!buff_analysis->ascii)
		return ERR_FAILURE;
	if(!buff_analysis->buffer)
		return ERR_FAILURE;
	if(!buff_analysis->buffer_n)
		return ERR_FAILURE;
	buff_analysis->ascii->strings = (P_BP_BUFFER_ANALYSIS_ASCII_STRINGS) tq_realloc
	(
			buff_analysis->tq,
			buff_analysis->ascii->strings,
			sizeof(BP_BUFFER_ANALYSIS_ASCII_STRINGS) * (buff_analysis->ascii->string_n+1),
			BPLN
	);
	if(!buff_analysis->ascii->strings)
		return ERR_FAILURE;
	buff_analysis->ascii->string_n++;
	P_BP_BUFFER_ANALYSIS_ASCII_STRINGS new_string = &buff_analysis->ascii->strings[buff_analysis->ascii->string_n-1];
	new_string->position_in_analyzed_buffer = position_in_analyzed_buffer;
	new_string->string_length = string_len;
	new_string->address_of_string_in_buffer = address_of_string_in_buffer;
	if(match_flags)
	{
		 enabled here
		new_string->match_flags_enabled = BP_TRUE;
		memcpy(&new_string->match_flags, match_flags, sizeof(BP_ASCII_CHAR_FLAGS));
		new_string->match_flags_how = match_flags_how;
	}
	if(negative_match_flags)
	{
		 enabled here
		new_string->match_flags_enabled = BP_TRUE;
		memcpy(&new_string->negative_match_flags, negative_match_flags, sizeof(BP_ASCII_CHAR_FLAGS));
		new_string->negative_match_flags_how = negative_match_flags_how;
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_AddASCIIStringToBufferAnalysis ( P_BP_BUFFER_ANALYSIS buff_analysis , size_t position_in_analyzed_buffer , size_t string_len , unsigned char * address_of_string_in_buffer , P_BP_ASCII_CHAR_FLAGS match_flags , BP_ASCII_CHARACTER_SEARCH_FLAG_VALUES match_flags_how , P_BP_ASCII_CHAR_FLAGS negative_match_flags , BP_ASCII_CHARACTER_SEARCH_FLAG_VALUES negative_match_flags_how ) { if ( ! buff_analysis ) return ERR_FAILURE ; if ( ! buff_analysis -> tq ) return ERR_FAILURE ; if ( ! buff_analysis -> ascii ) return ERR_FAILURE ; if ( ! buff_analysis -> buffer ) return ERR_FAILURE ; if ( ! buff_analysis -> buffer_n ) return ERR_FAILURE ; buff_analysis -> ascii -> strings = ( P_BP_BUFFER_ANALYSIS_ASCII_STRINGS ) tq_realloc ( buff_analysis -> tq , buff_analysis -> ascii -> strings , sizeof ( BP_BUFFER_ANALYSIS_ASCII_STRINGS ) * ( buff_analysis -> ascii -> string_n + 1 ) , BPLN ) ; if ( ! buff_analysis -> ascii -> strings ) return ERR_FAILURE ; buff_analysis -> ascii -> string_n ++ ; P_BP_BUFFER_ANALYSIS_ASCII_STRINGS new_string = & buff_analysis -> ascii -> strings [ buff_analysis -> ascii -> string_n - 1 ] ; new_string -> position_in_analyzed_buffer = position_in_analyzed_buffer ; new_string -> string_length = string_len ; new_string -> address_of_string_in_buffer = address_of_string_in_buffer ; if ( match_flags ) { new_string -> match_flags_enabled = BP_TRUE ; memcpy ( & new_string -> match_flags , match_flags , sizeof ( BP_ASCII_CHAR_FLAGS ) ) ; new_string -> match_flags_how = match_flags_how ; } if ( negative_match_flags ) { new_string -> match_flags_enabled = BP_TRUE ; memcpy ( & new_string -> negative_match_flags , negative_match_flags , sizeof ( BP_ASCII_CHAR_FLAGS ) ) ; new_string -> negative_match_flags_how = negative_match_flags_how ; } return ERR_SUCCESS ; }
adds a string to a ascii portion of buffer analyis.
adds a string to a ascii portion of buffer analyis .
// ensure we've created an analysis // ensure we have a tail queue allocator // ensure analysis structure has an ascii substructure4 // ensure we have a buffer // ensure we have a length // attempt to allocate data // return failure if we could not allocate memory for strings // increase the string count here // create a reference for readability purposes // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %% Set Members Here %%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set the position in the analyzed buffer // set the string length // set the address of the string in the buffer // set match flags // set match flags enabled here // copy in the positive match flags // set the match how // check to see if we were provided with negative match flags // set match flags enabled here // copy in negative flags // set the negative "match how" // return indicating success