library/src/buffer_analysis/ASCII/BP-BufferAnalysisASCII.cc
// creates an ascii buffer analysis based around the configuration provided.  The analysis which is generated is
// stored as a pointer within the P_BP_BUFFER_ANALYSIS pointer provided as first function parameter.
creates an ascii buffer analysis based around the configuration provided.  The analysis which is generated is
stored as a pointer within the P_BP_BUFFER_ANALYSIS pointer provided as first function parameter.
creates an ascii buffer analysis based around the configuration provided . The analysis which is generated is stored as a pointer within the P_BP_BUFFER_ANALYSIS pointer provided as first function parameter .
BP_ERROR_T BP_CreateBufferAnalysisASCII(P_BP_BUFFER_ANALYSIS buff_analysis, P_BP_BUFFER_ANALYSIS_ASCII_CONFIGURATION analysis_config)
{
	if(!buff_analysis || !analysis_config)
		return ERR_FAILURE;
	if(!buff_analysis->tq)
		return ERR_FAILURE;
	buff_analysis->ascii = (P_BP_BUFFER_ANALYSIS_ASCII) tq_calloc
	(
		buff_analysis->tq,
		sizeof(BP_BUFFER_ANALYSIS_ASCII),
		1,
		BPLN
	);
	if(!buff_analysis->ascii)
		return ERR_FAILURE;
	P_BP_BUFFER_ANALYSIS_ASCII ascii_analysis = buff_analysis->ascii;
	ascii_analysis->char_map = BP_CreateASCIICharacterMap();
	if(!ascii_analysis->char_map)
		return ERR_FAILURE;
	P_BP_ASCII_CHART current_char_index = NULL;
	unsigned char curr_character = 0;
	size_t n = 0;
	for(; n < buff_analysis->buffer_n; n++)
	{
		curr_character = buff_analysis->buffer[n];
		current_char_index = &ascii_analysis->char_map->ascii_chart[curr_character];
		ascii_analysis->char_counts[curr_character]++;
		ascii_analysis->ascii_char_flag_counts.control_n                 += current_char_index->flags.is_control;
		ascii_analysis->ascii_char_flag_counts.alphalower_n              += current_char_index->flags.is_alphalower;
		ascii_analysis->ascii_char_flag_counts.alphacaps_n               += current_char_index->flags.is_alphacaps;
		ascii_analysis->ascii_char_flag_counts.number_n                  += current_char_index->flags.is_number;
		ascii_analysis->ascii_char_flag_counts.printable_n               += current_char_index->flags.is_printable;
		ascii_analysis->ascii_char_flag_counts.nonprintable_n            += current_char_index->flags.is_nonprintable;
		ascii_analysis->ascii_char_flag_counts.extended_n                += current_char_index->flags.is_extended;
		ascii_analysis->ascii_char_flag_counts.math_n                    += current_char_index->flags.is_math;
		ascii_analysis->ascii_char_flag_counts.superscript_n             += current_char_index->flags.is_superscript;
		ascii_analysis->ascii_char_flag_counts.currency_n                += current_char_index->flags.is_currency;
		ascii_analysis->ascii_char_flag_counts.fraction_n                += current_char_index->flags.is_fraction;
		ascii_analysis->ascii_char_flag_counts.acute_n                   += current_char_index->flags.is_acute;
		ascii_analysis->ascii_char_flag_counts.grave_n                   += current_char_index->flags.is_grave;
		ascii_analysis->ascii_char_flag_counts.diaeresis_n               += current_char_index->flags.is_diaeresis;
		ascii_analysis->ascii_char_flag_counts.slash_n                   += current_char_index->flags.is_slash;
		ascii_analysis->ascii_char_flag_counts.circumflex_n              += current_char_index->flags.is_circumflex;
		ascii_analysis->ascii_char_flag_counts.caron_n                   += current_char_index->flags.is_caron;
		ascii_analysis->ascii_char_flag_counts.macron_n                  += current_char_index->flags.is_macron;
		ascii_analysis->ascii_char_flag_counts.punctuation_n             += current_char_index->flags.is_punctuation;
		ascii_analysis->ascii_char_flag_counts.symbol_n                  += current_char_index->flags.is_symbol;
		ascii_analysis->ascii_char_flag_counts.latin_n                   += current_char_index->flags.is_latin;
		ascii_analysis->ascii_char_flag_counts.latin_nonstandard_caps_n  += current_char_index->flags.is_latin_nonstandard_caps;
		ascii_analysis->ascii_char_flag_counts.latin_nonstandard_lower_n += current_char_index->flags.is_latin_nonstandard_lower;
		ascii_analysis->ascii_char_flag_counts.quotation_n               += current_char_index->flags.is_quotation;
		ascii_analysis->ascii_char_flag_counts.whitespace_n              += current_char_index->flags.is_whitespace;
		ascii_analysis->ascii_char_flag_counts.undefined_n               += current_char_index->flags.is_undefined;
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_CreateBufferAnalysisASCII ( P_BP_BUFFER_ANALYSIS buff_analysis , P_BP_BUFFER_ANALYSIS_ASCII_CONFIGURATION analysis_config ) { if ( ! buff_analysis || ! analysis_config ) return ERR_FAILURE ; if ( ! buff_analysis -> tq ) return ERR_FAILURE ; buff_analysis -> ascii = ( P_BP_BUFFER_ANALYSIS_ASCII ) tq_calloc ( buff_analysis -> tq , sizeof ( BP_BUFFER_ANALYSIS_ASCII ) , 1 , BPLN ) ; if ( ! buff_analysis -> ascii ) return ERR_FAILURE ; P_BP_BUFFER_ANALYSIS_ASCII ascii_analysis = buff_analysis -> ascii ; ascii_analysis -> char_map = BP_CreateASCIICharacterMap ( ) ; if ( ! ascii_analysis -> char_map ) return ERR_FAILURE ; P_BP_ASCII_CHART current_char_index = NULL ; unsigned char curr_character = 0 ; size_t n = 0 ; for ( ; n < buff_analysis -> buffer_n ; n ++ ) { curr_character = buff_analysis -> buffer [ n ] ; current_char_index = & ascii_analysis -> char_map -> ascii_chart [ curr_character ] ; ascii_analysis -> char_counts [ curr_character ] ++ ; ascii_analysis -> ascii_char_flag_counts . control_n += current_char_index -> flags . is_control ; ascii_analysis -> ascii_char_flag_counts . alphalower_n += current_char_index -> flags . is_alphalower ; ascii_analysis -> ascii_char_flag_counts . alphacaps_n += current_char_index -> flags . is_alphacaps ; ascii_analysis -> ascii_char_flag_counts . number_n += current_char_index -> flags . is_number ; ascii_analysis -> ascii_char_flag_counts . printable_n += current_char_index -> flags . is_printable ; ascii_analysis -> ascii_char_flag_counts . nonprintable_n += current_char_index -> flags . is_nonprintable ; ascii_analysis -> ascii_char_flag_counts . extended_n += current_char_index -> flags . is_extended ; ascii_analysis -> ascii_char_flag_counts . math_n += current_char_index -> flags . is_math ; ascii_analysis -> ascii_char_flag_counts . superscript_n += current_char_index -> flags . is_superscript ; ascii_analysis -> ascii_char_flag_counts . currency_n += current_char_index -> flags . is_currency ; ascii_analysis -> ascii_char_flag_counts . fraction_n += current_char_index -> flags . is_fraction ; ascii_analysis -> ascii_char_flag_counts . acute_n += current_char_index -> flags . is_acute ; ascii_analysis -> ascii_char_flag_counts . grave_n += current_char_index -> flags . is_grave ; ascii_analysis -> ascii_char_flag_counts . diaeresis_n += current_char_index -> flags . is_diaeresis ; ascii_analysis -> ascii_char_flag_counts . slash_n += current_char_index -> flags . is_slash ; ascii_analysis -> ascii_char_flag_counts . circumflex_n += current_char_index -> flags . is_circumflex ; ascii_analysis -> ascii_char_flag_counts . caron_n += current_char_index -> flags . is_caron ; ascii_analysis -> ascii_char_flag_counts . macron_n += current_char_index -> flags . is_macron ; ascii_analysis -> ascii_char_flag_counts . punctuation_n += current_char_index -> flags . is_punctuation ; ascii_analysis -> ascii_char_flag_counts . symbol_n += current_char_index -> flags . is_symbol ; ascii_analysis -> ascii_char_flag_counts . latin_n += current_char_index -> flags . is_latin ; ascii_analysis -> ascii_char_flag_counts . latin_nonstandard_caps_n += current_char_index -> flags . is_latin_nonstandard_caps ; ascii_analysis -> ascii_char_flag_counts . latin_nonstandard_lower_n += current_char_index -> flags . is_latin_nonstandard_lower ; ascii_analysis -> ascii_char_flag_counts . quotation_n += current_char_index -> flags . is_quotation ; ascii_analysis -> ascii_char_flag_counts . whitespace_n += current_char_index -> flags . is_whitespace ; ascii_analysis -> ascii_char_flag_counts . undefined_n += current_char_index -> flags . is_undefined ; } return ERR_SUCCESS ; }
creates an ascii buffer analysis based around the configuration provided.
creates an ascii buffer analysis based around the configuration provided .
// ensure we have valid pointers, if not return null // ensure we have a tail queue allocator to work with // create pointer within the buffer analysis structure, using the analysis structure // tailqueue allocator. // ensure we created the ascii structure ok, if not return // localized reference for code clarity purposes // now create a character map which we can use for analysis purposes // if we couldn't create the map, exit here // current byte index (for readability) // reference to current character // now walk each position in the buffer provided within the analysis // structure, and update ascii analysis appropriately // set character reference // current character index // increment the character counter at the current index // debugging print statement: // printf("\n Current Char: %.02x - %.02x ", current_char_index->ascii_char, buff_analysis->buffer[n]); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Now Update Flag Counts %%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Since all the flags in the current character index are either 1 or 0, we can // simply add all values directly to the analysis flag count structure.  Simple // as could be. // return indicating success (analysis created successfully)