library/src/buffer_analysis/ASCII/BP-BufferAnalysisASCII.cc
// display the buffer analysis ascii portion.
display the buffer analysis ascii portion.
display the buffer analysis ascii portion .
BP_ERROR_T BP_DisplayBufferAnalysisASCII(P_BP_BUFFER_ANALYSIS buff_analysis)
{
	if(!buff_analysis)
		return ERR_FAILURE;
	if(!buff_analysis->ascii)
		return ERR_FAILURE;
	printf("\n\t [-] ASCII Analysis Structure (%p)", buff_analysis->ascii);
	printf("\n");
	printf("\n\t\t char_map: %p", buff_analysis->ascii->char_map);
	printf("\n");
	P_BP_BUFFER_ANALYSIS_ASCII_FLAG_COUNTS flag_counts = &buff_analysis->ascii->ascii_char_flag_counts;
	BP_BUFFER_ANALYSIS_ASCII_FLAG_COUNTS empty_flags;
	BP_ZERO_STACK(empty_flags);
	if(memcmp(&empty_flags, flag_counts, sizeof(BP_BUFFER_ANALYSIS_ASCII_FLAG_COUNTS)) != 0)
	{
		printf("\n\t\t [-] Flag Counts: ");
		if(flag_counts->control_n)
		{
			printf("\n\t\t    control_n: ................%u", flag_counts->control_n);
		}
		if(flag_counts->alphalower_n)
		{
			printf("\n\t\t    alphalower_n: .............%u", flag_counts->alphalower_n);
		}
		if(flag_counts->alphacaps_n)
		{
			printf("\n\t\t    alphacaps_n: ..............%u", flag_counts->alphacaps_n);
		}
		if(flag_counts->number_n)
		{
			printf("\n\t\t    number_n: .................%u", flag_counts->number_n);
		}
		if(flag_counts->printable_n)
		{
			printf("\n\t\t    printable_n: ..............%u", flag_counts->printable_n);
		}
		if(flag_counts->nonprintable_n)
		{
			printf("\n\t\t    nonprintable_n: ...........%u", flag_counts->nonprintable_n);
		}
		if(flag_counts->extended_n)
		{
			printf("\n\t\t    extended_n: ...............%u", flag_counts->extended_n);
		}
		if(flag_counts->math_n)
		{
			printf("\n\t\t    math_n: ...................%u", flag_counts->math_n);
		}
		if(flag_counts->superscript_n)
		{
			printf("\n\t\t    superscript_n: ............%u", flag_counts->superscript_n);
		}
		if(flag_counts->currency_n)
		{
			printf("\n\t\t    currency_n: ...............%u", flag_counts->currency_n);
		}
		if(flag_counts->fraction_n)
		{
			printf("\n\t\t    fraction_n: ...............%u", flag_counts->fraction_n);
		}
		if(flag_counts->acute_n)
		{
			printf("\n\t\t    acute_n: ..................%u", flag_counts->acute_n);
		}
		if(flag_counts->grave_n)
		{
			printf("\n\t\t    grave_n: ..................%u", flag_counts->grave_n);
		}
		if(flag_counts->diaeresis_n)
		{
			printf("\n\t\t    diaeresis_n: ..............%u", flag_counts->diaeresis_n);
		}
		if(flag_counts->slash_n)
		{
			printf("\n\t\t    slash_n: ..................%u", flag_counts->slash_n);
		}
		if(flag_counts->circumflex_n)
		{
			printf("\n\t\t    circumflex_n: .............%u", flag_counts->circumflex_n);
		}
		if(flag_counts->caron_n)
		{
			printf("\n\t\t    caron_n: ..................%u", flag_counts->caron_n);
		}
		if(flag_counts->macron_n)
		{
			printf("\n\t\t    macron_n: .................%u", flag_counts->macron_n);
		}
		if(flag_counts->punctuation_n)
		{
			printf("\n\t\t    punctuation_n: ............%u", flag_counts->punctuation_n);
		}
		if(flag_counts->symbol_n)
		{
			printf("\n\t\t    symbol_n: .................%u", flag_counts->symbol_n);
		}
		if(flag_counts->latin_n)
		{
			printf("\n\t\t    latin_n: ..................%u", flag_counts->latin_n);
		}
		if(flag_counts->latin_nonstandard_caps_n)
		{
			printf("\n\t\t    latin_nonstandard_caps_n:  %u", flag_counts->latin_nonstandard_caps_n);
		}
		if(flag_counts->latin_nonstandard_lower_n)
		{
			printf("\n\t\t    latin_nonstandard_lower_n: %u", flag_counts->latin_nonstandard_lower_n);
		}
		if(flag_counts->quotation_n)
		{
			printf("\n\t\t    quotation_n: ..............%u", flag_counts->quotation_n);
		}
		if(flag_counts->whitespace_n)
		{
			printf("\n\t\t    whitespace_n: .............%u", flag_counts->whitespace_n);
		}
		if(flag_counts->undefined_n)
		{
			printf("\n\t\t    undefined_n: ..............%u", flag_counts->undefined_n);
		}
		printf("\n");
	}
	printf("\n\t\t [-] Char Counts:");
	size_t n = 0;
	for(; n <= 0xff; n++)
	{
		if(!buff_analysis->ascii->char_counts[n])
			continue;
		printf("\n\t\t     char: 0x%.02x - %u - %s", n, buff_analysis->ascii->char_counts[n], buff_analysis->ascii->char_map->ascii_chart[n].symbol_description);
	}
	printf("\n");
	n = 0;
	for(; n < buff_analysis->ascii->string_n; n++)
	{
		if(buff_analysis->ascii->strings[n].marked_as_restricted == BP_TRUE)
			continue;
		printf("\n\t [x] String Index in String Stack: %zu", n);
		BP_DisplayBufferAnalysisASCIIString(&buff_analysis->ascii->strings[n], BP_TRUE);
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DisplayBufferAnalysisASCII ( P_BP_BUFFER_ANALYSIS buff_analysis ) { if ( ! buff_analysis ) return ERR_FAILURE ; if ( ! buff_analysis -> ascii ) return ERR_FAILURE ; printf ( " \n \t " , buff_analysis -> ascii ) ; printf ( " \n " ) ; printf ( " \n \t \t " , buff_analysis -> ascii -> char_map ) ; printf ( " \n " ) ; P_BP_BUFFER_ANALYSIS_ASCII_FLAG_COUNTS flag_counts = & buff_analysis -> ascii -> ascii_char_flag_counts ; BP_BUFFER_ANALYSIS_ASCII_FLAG_COUNTS empty_flags ; BP_ZERO_STACK ( empty_flags ) ; if ( memcmp ( & empty_flags , flag_counts , sizeof ( BP_BUFFER_ANALYSIS_ASCII_FLAG_COUNTS ) ) != 0 ) { printf ( " \n \t \t " ) ; if ( flag_counts -> control_n ) { printf ( " \n \t \t " , flag_counts -> control_n ) ; } if ( flag_counts -> alphalower_n ) { printf ( " \n \t \t " , flag_counts -> alphalower_n ) ; } if ( flag_counts -> alphacaps_n ) { printf ( " \n \t \t " , flag_counts -> alphacaps_n ) ; } if ( flag_counts -> number_n ) { printf ( " \n \t \t " , flag_counts -> number_n ) ; } if ( flag_counts -> printable_n ) { printf ( " \n \t \t " , flag_counts -> printable_n ) ; } if ( flag_counts -> nonprintable_n ) { printf ( " \n \t \t " , flag_counts -> nonprintable_n ) ; } if ( flag_counts -> extended_n ) { printf ( " \n \t \t " , flag_counts -> extended_n ) ; } if ( flag_counts -> math_n ) { printf ( " \n \t \t " , flag_counts -> math_n ) ; } if ( flag_counts -> superscript_n ) { printf ( " \n \t \t " , flag_counts -> superscript_n ) ; } if ( flag_counts -> currency_n ) { printf ( " \n \t \t " , flag_counts -> currency_n ) ; } if ( flag_counts -> fraction_n ) { printf ( " \n \t \t " , flag_counts -> fraction_n ) ; } if ( flag_counts -> acute_n ) { printf ( " \n \t \t " , flag_counts -> acute_n ) ; } if ( flag_counts -> grave_n ) { printf ( " \n \t \t " , flag_counts -> grave_n ) ; } if ( flag_counts -> diaeresis_n ) { printf ( " \n \t \t " , flag_counts -> diaeresis_n ) ; } if ( flag_counts -> slash_n ) { printf ( " \n \t \t " , flag_counts -> slash_n ) ; } if ( flag_counts -> circumflex_n ) { printf ( " \n \t \t " , flag_counts -> circumflex_n ) ; } if ( flag_counts -> caron_n ) { printf ( " \n \t \t " , flag_counts -> caron_n ) ; } if ( flag_counts -> macron_n ) { printf ( " \n \t \t " , flag_counts -> macron_n ) ; } if ( flag_counts -> punctuation_n ) { printf ( " \n \t \t " , flag_counts -> punctuation_n ) ; } if ( flag_counts -> symbol_n ) { printf ( " \n \t \t " , flag_counts -> symbol_n ) ; } if ( flag_counts -> latin_n ) { printf ( " \n \t \t " , flag_counts -> latin_n ) ; } if ( flag_counts -> latin_nonstandard_caps_n ) { printf ( " \n \t \t " , flag_counts -> latin_nonstandard_caps_n ) ; } if ( flag_counts -> latin_nonstandard_lower_n ) { printf ( " \n \t \t " , flag_counts -> latin_nonstandard_lower_n ) ; } if ( flag_counts -> quotation_n ) { printf ( " \n \t \t " , flag_counts -> quotation_n ) ; } if ( flag_counts -> whitespace_n ) { printf ( " \n \t \t " , flag_counts -> whitespace_n ) ; } if ( flag_counts -> undefined_n ) { printf ( " \n \t \t " , flag_counts -> undefined_n ) ; } printf ( " \n " ) ; } printf ( " \n \t \t " ) ; size_t n = 0 ; for ( ; n <= 0xff ; n ++ ) { if ( ! buff_analysis -> ascii -> char_counts [ n ] ) continue ; printf ( " \n \t \t " , n , buff_analysis -> ascii -> char_counts [ n ] , buff_analysis -> ascii -> char_map -> ascii_chart [ n ] . symbol_description ) ; } printf ( " \n " ) ; n = 0 ; for ( ; n < buff_analysis -> ascii -> string_n ; n ++ ) { if ( buff_analysis -> ascii -> strings [ n ] . marked_as_restricted == BP_TRUE ) continue ; printf ( " \n \t " , n ) ; BP_DisplayBufferAnalysisASCIIString ( & buff_analysis -> ascii -> strings [ n ] , BP_TRUE ) ; } return ERR_SUCCESS ; }
display the buffer analysis ascii portion.
display the buffer analysis ascii portion .
// ensure we have an analysis pointer // ensure we have an ascii analysis pointer // character map // create a reference // create and zero out an empty flags structure (used for // comparisson) // if we have flags set, display them // display flag count // add trailing newline // display character count header // iterate through individual characters // only display characters with existing counts // display the character // now iterate through strings // don't display restricted strings // return indicating success