void appprint(struct layer *m) { printf("DATA: %d bytes\n",m->size); ascii_print(m->proto,m->size); puts(""); }
int main(int argc, char *argv[]) { hex_print("\n\t", "Hello, World!\n", 14); printf("\n"); hex_and_ascii_print("\n\t", "Hello, World!\n", 14); printf("\n"); ascii_print("Hello, World!\n", 14); printf("\n"); #define TMSG "Now is the winter of our discontent...\n" hex_print_with_offset("\n\t", TMSG, sizeof(TMSG) - 1, 0x100); printf("\n"); hex_and_ascii_print_with_offset("\n\t", TMSG, sizeof(TMSG) - 1, 0x100); printf("\n"); exit(0); }
ostream& Compound::ascii_write(ostream &os , const CompoundData *compound_histo , bool exhaustive , bool file_flag) const { os << STAT_word[STATW_COMPOUND] << endl; ascii_characteristic_print(os , exhaustive , file_flag); if (compound_histo) { double likelihood , information; Test test(CHI2); os << "\n"; if (file_flag) { os << "# "; } os << STAT_label[STATL_FREQUENCY_DISTRIBUTION] << " - "; compound_histo->ascii_characteristic_print(os , exhaustive , file_flag); likelihood = likelihood_computation(*compound_histo); information = compound_histo->information_computation(); os << "\n"; if (file_flag) { os << "# "; } os << STAT_label[STATL_LIKELIHOOD] << ": " << likelihood << " (" << STAT_label[STATL_NORMALIZED] << ": " << likelihood / compound_histo->nb_element << ")" << endl; if (file_flag) { os << "# "; } os << STAT_label[STATL_MAX_LIKELIHOOD] << ": " << information << " (" << STAT_label[STATL_INFORMATION] << ": " << information / compound_histo->nb_element << endl; if (file_flag) { os << "# "; } os << STAT_label[STATL_DEVIANCE] << ": " << 2 * (information - likelihood) << endl; chi2_fit(*compound_histo , test); os << "\n"; test.ascii_print(os , file_flag); } if (exhaustive) { os << "\n"; if (file_flag) { os << "# "; } os << " "; if (compound_histo) { os << " | " << STAT_label[STATL_FREQUENCY_DISTRIBUTION]; } os << " | " << STAT_label[STATL_COMPOUND] << " " << STAT_label[STATL_DISTRIBUTION]; if (compound_histo) { os << " | " << STAT_label[STATL_CUMULATIVE] << " " << STAT_label[STATL_FREQUENCY_DISTRIBUTION] << " " << STAT_label[STATL_FUNCTION]; } os << " | " << STAT_label[STATL_CUMULATIVE] << " " << STAT_label[STATL_COMPOUND] << " " << STAT_label[STATL_DISTRIBUTION] << " " << STAT_label[STATL_FUNCTION] << endl; ascii_print(os , file_flag , true , false , compound_histo); } os << "\n" << STAT_word[STATW_SUM] << endl; sum_distribution->ascii_print(os); sum_distribution->ascii_parametric_characteristic_print(os , exhaustive , file_flag); if (compound_histo) { os << "\n"; if (file_flag) { os << "# "; } os << STAT_label[STATL_SUM] << " " << STAT_label[STATL_FREQUENCY_DISTRIBUTION] << " - "; compound_histo->sum_frequency_distribution->ascii_characteristic_print(os , exhaustive , file_flag); } if (exhaustive) { os << "\n"; if (file_flag) { os << "# "; } os << " "; if (compound_histo) { os << " | " << STAT_label[STATL_SUM] << " " << STAT_label[STATL_FREQUENCY_DISTRIBUTION]; } os << " | " << STAT_label[STATL_SUM] << " " << STAT_label[STATL_DISTRIBUTION]; if (compound_histo) { os << " | " << STAT_label[STATL_CUMULATIVE] << " " << STAT_label[STATL_SUM] << " " << STAT_label[STATL_FREQUENCY_DISTRIBUTION] << " " << STAT_label[STATL_FUNCTION]; } os << " | " << STAT_label[STATL_CUMULATIVE] << " " << STAT_label[STATL_SUM] << " " << STAT_label[STATL_DISTRIBUTION] << " " << STAT_label[STATL_FUNCTION] << endl; sum_distribution->Distribution::ascii_print(os , file_flag , true , false , (compound_histo ? compound_histo->sum_frequency_distribution : NULL)); } os << "\n" << STAT_word[STATW_ELEMENTARY] << endl; distribution->ascii_print(os); distribution->ascii_parametric_characteristic_print(os , exhaustive , file_flag); if (compound_histo) { os << "\n"; if (file_flag) { os << "# "; } os << STAT_label[STATL_ELEMENTARY] << " " << STAT_label[STATL_FREQUENCY_DISTRIBUTION] << " - "; compound_histo->frequency_distribution->ascii_characteristic_print(os , exhaustive , file_flag); } if (exhaustive) { os << "\n"; if (file_flag) { os << "# "; } os << " "; if ((compound_histo) && (compound_histo->frequency_distribution->nb_element > 0)) { os << " | " << STAT_label[STATL_ELEMENTARY] << " " << STAT_label[STATL_FREQUENCY_DISTRIBUTION]; } os << " | " << STAT_label[STATL_ELEMENTARY] << " " << STAT_label[STATL_DISTRIBUTION]; if ((compound_histo) && (compound_histo->frequency_distribution->nb_element > 0)) { os << " | " << STAT_label[STATL_CUMULATIVE] << " " << STAT_label[STATL_ELEMENTARY] << " " << STAT_label[STATL_FREQUENCY_DISTRIBUTION] << " " << STAT_label[STATL_FUNCTION]; } os << " | " << STAT_label[STATL_CUMULATIVE] << " " << STAT_label[STATL_ELEMENTARY] << " " << STAT_label[STATL_DISTRIBUTION] << " " << STAT_label[STATL_FUNCTION] << endl; distribution->Distribution::ascii_print(os , file_flag , true , false , (((compound_histo) && (compound_histo->frequency_distribution->nb_element > 0)) ? compound_histo->frequency_distribution : NULL)); } return os; }
void raw_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *sp, u_int hdrlen) { if (ndo->ndo_Xflag) { /* * Print the raw packet data in hex and ASCII. */ if (ndo->ndo_Xflag > 1) { /* * Include the link-layer header. */ hex_and_ascii_print(ndo, "\n\t", sp, h->caplen); } else { /* * Don't include the link-layer header - and if * we have nothing past the link-layer header, * print nothing. */ if (h->caplen > hdrlen) hex_and_ascii_print(ndo, "\n\t", sp + hdrlen, h->caplen - hdrlen); } } else if (ndo->ndo_xflag) { /* * Print the raw packet data in hex. */ if (ndo->ndo_xflag > 1) { /* * Include the link-layer header. */ hex_print(ndo, "\n\t", sp, h->caplen); } else { /* * Don't include the link-layer header - and if * we have nothing past the link-layer header, * print nothing. */ if (h->caplen > hdrlen) hex_print(ndo, "\n\t", sp + hdrlen, h->caplen - hdrlen); } } else if (ndo->ndo_Aflag) { /* * Print the raw packet data in ASCII. */ if (ndo->ndo_Aflag > 1) { /* * Include the link-layer header. */ ascii_print(ndo, sp, h->caplen); } else { /* * Don't include the link-layer header - and if * we have nothing past the link-layer header, * print nothing. */ if (h->caplen > hdrlen) ascii_print(ndo, sp + hdrlen, h->caplen - hdrlen); } } }