diff --git a/epan/print.c b/epan/print.c index 05010cce82..b39a9b8bfb 100644 --- a/epan/print.c +++ b/epan/print.c @@ -90,7 +90,7 @@ static gchar *get_field_hex_value(GSList *src_list, field_info *fi); static void proto_tree_print_node(proto_node *node, gpointer data); static void proto_tree_write_node_pdml(proto_node *node, gpointer data); static const guint8 *get_field_data(GSList *src_list, field_info *fi); -static void write_pdml_field_hex_value(write_pdml_data *pdata, field_info *fi); +static void pdml_write_field_hex_value(write_pdml_data *pdata, field_info *fi); static gboolean print_hex_data_buffer(print_stream_t *stream, const guchar *cp, guint length, packet_char_enc encoding); static void print_escaped_xml(FILE *fh, const char *unescaped_string); @@ -230,7 +230,7 @@ write_pdml_preamble(FILE *fh, const gchar *filename) } void -proto_tree_write_pdml(epan_dissect_t *edt, FILE *fh) +write_pdml_proto_tree(epan_dissect_t *edt, FILE *fh) { write_pdml_data data; @@ -313,7 +313,7 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data) if (fi->length > 0) { fputs("\" value=\"", pdata->fh); - write_pdml_field_hex_value(pdata, fi); + pdml_write_field_hex_value(pdata, fi); } if (node->first_child != NULL) { @@ -330,7 +330,7 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data) /* Write out field with data */ fputs("fh); - write_pdml_field_hex_value(pdata, fi); + pdml_write_field_hex_value(pdata, fi); fputs("\">\n", pdata->fh); } /* Normal protocols and fields */ @@ -434,10 +434,10 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data) g_assert_not_reached(); } fputs("\" unmaskedvalue=\"", pdata->fh); - write_pdml_field_hex_value(pdata, fi); + pdml_write_field_hex_value(pdata, fi); } else { - write_pdml_field_hex_value(pdata, fi); + pdml_write_field_hex_value(pdata, fi); } } } @@ -585,7 +585,7 @@ write_pdml_finale(FILE *fh) } void -write_psml_preamble(capture_file *cf, FILE *fh) +write_psml_preamble(column_info *cinfo, FILE *fh) { gint i; @@ -594,9 +594,9 @@ write_psml_preamble(capture_file *cf, FILE *fh) fprintf(fh, "creator=\"%s/%s\">\n", PACKAGE, VERSION); fprintf(fh, "\n"); - for (i = 0; i < cf->cinfo.num_cols; i++) { + for (i = 0; i < cinfo->num_cols; i++) { fprintf(fh, "
"); - print_escaped_xml(fh, cf->cinfo.col_title[i]); + print_escaped_xml(fh, cinfo->col_title[i]); fprintf(fh, "
\n"); } @@ -604,7 +604,7 @@ write_psml_preamble(capture_file *cf, FILE *fh) } void -proto_tree_write_psml(epan_dissect_t *edt, FILE *fh) +write_psml_columns(epan_dissect_t *edt, FILE *fh) { gint i; @@ -658,17 +658,17 @@ static void csv_write_str(const char *str, char sep, FILE *fh) } void -write_csv_preamble(capture_file *cf, FILE *fh) +write_csv_column_titles(column_info *cinfo, FILE *fh) { gint i; - for (i = 0; i < cf->cinfo.num_cols - 1; i++) - csv_write_str(cf->cinfo.col_title[i], ',', fh); - csv_write_str(cf->cinfo.col_title[i], '\n', fh); + for (i = 0; i < cinfo->num_cols - 1; i++) + csv_write_str(cinfo->col_title[i], ',', fh); + csv_write_str(cinfo->col_title[i], '\n', fh); } void -proto_tree_write_csv(epan_dissect_t *edt, FILE *fh) +write_csv_columns(epan_dissect_t *edt, FILE *fh) { gint i; @@ -678,19 +678,7 @@ proto_tree_write_csv(epan_dissect_t *edt, FILE *fh) } void -write_csv_finale(FILE *fh _U_) -{ - -} - -void -write_carrays_preamble(FILE *fh _U_) -{ - -} - -void -proto_tree_write_carrays(guint32 num, FILE *fh, epan_dissect_t *edt) +write_carrays_hex_data(guint32 num, FILE *fh, epan_dissect_t *edt) { guint32 i = 0, src_num = 0; GSList *src_le; @@ -750,12 +738,6 @@ proto_tree_write_carrays(guint32 num, FILE *fh, epan_dissect_t *edt) } } -void -write_carrays_finale(FILE *fh _U_) -{ - -} - /* * Find the data source for a specified field, and return a pointer * to the data in it. Returns NULL if the data is out of bounds. @@ -840,7 +822,7 @@ print_escaped_xml(FILE *fh, const char *unescaped_string) } static void -write_pdml_field_hex_value(write_pdml_data *pdata, field_info *fi) +pdml_write_field_hex_value(write_pdml_data *pdata, field_info *fi) { int i; const guint8 *pd; @@ -1316,7 +1298,7 @@ static void proto_tree_get_node_field_values(proto_node *node, gpointer data) } } -void proto_tree_write_fields(output_fields_t *fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh) +void write_fields_proto_tree(output_fields_t *fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh) { gsize i; gint col; diff --git a/epan/print.h b/epan/print.h index 37a4a08204..95bc6a9da2 100644 --- a/epan/print.h +++ b/epan/print.h @@ -105,23 +105,20 @@ WS_DLL_PUBLIC gboolean proto_tree_print(print_args_t *print_args, WS_DLL_PUBLIC gboolean print_hex_data(print_stream_t *stream, epan_dissect_t *edt); WS_DLL_PUBLIC void write_pdml_preamble(FILE *fh, const gchar* filename); -WS_DLL_PUBLIC void proto_tree_write_pdml(epan_dissect_t *edt, FILE *fh); +WS_DLL_PUBLIC void write_pdml_proto_tree(epan_dissect_t *edt, FILE *fh); WS_DLL_PUBLIC void write_pdml_finale(FILE *fh); -WS_DLL_PUBLIC void write_psml_preamble(capture_file *cf, FILE *fh); -WS_DLL_PUBLIC void proto_tree_write_psml(epan_dissect_t *edt, FILE *fh); +WS_DLL_PUBLIC void write_psml_preamble(column_info *cinfo, FILE *fh); +WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh); WS_DLL_PUBLIC void write_psml_finale(FILE *fh); -WS_DLL_PUBLIC void write_csv_preamble(capture_file *cf, FILE *fh); -WS_DLL_PUBLIC void proto_tree_write_csv(epan_dissect_t *edt, FILE *fh); -WS_DLL_PUBLIC void write_csv_finale(FILE *fh); +WS_DLL_PUBLIC void write_csv_column_titles(column_info *cinfo, FILE *fh); +WS_DLL_PUBLIC void write_csv_columns(epan_dissect_t *edt, FILE *fh); -WS_DLL_PUBLIC void write_carrays_preamble(FILE *fh); -WS_DLL_PUBLIC void proto_tree_write_carrays(guint32 num, FILE *fh, epan_dissect_t *edt); -WS_DLL_PUBLIC void write_carrays_finale(FILE *fh); +WS_DLL_PUBLIC void write_carrays_hex_data(guint32 num, FILE *fh, epan_dissect_t *edt); WS_DLL_PUBLIC void write_fields_preamble(output_fields_t* fields, FILE *fh); -WS_DLL_PUBLIC void proto_tree_write_fields(output_fields_t* fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh); +WS_DLL_PUBLIC void write_fields_proto_tree(output_fields_t* fields, epan_dissect_t *edt, column_info *cinfo, FILE *fh); WS_DLL_PUBLIC void write_fields_finale(output_fields_t* fields, FILE *fh); WS_DLL_PUBLIC gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt); diff --git a/file.c b/file.c index d586090c3c..ba0660efb2 100644 --- a/file.c +++ b/file.c @@ -2726,7 +2726,7 @@ write_pdml_packet(capture_file *cf, frame_data *fdata, epan_dissect_run(&args->edt, cf->cd_t, phdr, frame_tvbuff_new(fdata, pd), fdata, NULL); /* Write out the information in that tree. */ - proto_tree_write_pdml(&args->edt, args->fh); + write_pdml_proto_tree(&args->edt, args->fh); epan_dissect_reset(&args->edt); @@ -2796,12 +2796,13 @@ write_psml_packet(capture_file *cf, frame_data *fdata, { write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp; + /* Fill in the column information */ col_custom_prime_edt(&args->edt, &cf->cinfo); epan_dissect_run(&args->edt, cf->cd_t, phdr, frame_tvbuff_new(fdata, pd), fdata, &cf->cinfo); epan_dissect_fill_in_columns(&args->edt, FALSE, TRUE); - /* Write out the information in that tree. */ - proto_tree_write_psml(&args->edt, args->fh); + /* Write out the column information. */ + write_psml_columns(&args->edt, args->fh); epan_dissect_reset(&args->edt); @@ -2821,7 +2822,7 @@ cf_write_psml_packets(capture_file *cf, print_args_t *print_args) if (fh == NULL) return CF_PRINT_OPEN_ERROR; /* attempt to open destination failed */ - write_psml_preamble(cf, fh); + write_psml_preamble(&cf->cinfo, fh); if (ferror(fh)) { fclose(fh); return CF_PRINT_WRITE_ERROR; @@ -2882,8 +2883,8 @@ write_csv_packet(capture_file *cf, frame_data *fdata, epan_dissect_run(&args->edt, cf->cd_t, phdr, frame_tvbuff_new(fdata, pd), fdata, &cf->cinfo); epan_dissect_fill_in_columns(&args->edt, FALSE, TRUE); - /* Write out the information in that tree. */ - proto_tree_write_csv(&args->edt, args->fh); + /* Write out the column information. */ + write_csv_columns(&args->edt, args->fh); epan_dissect_reset(&args->edt); @@ -2902,7 +2903,7 @@ cf_write_csv_packets(capture_file *cf, print_args_t *print_args) if (fh == NULL) return CF_PRINT_OPEN_ERROR; /* attempt to open destination failed */ - write_csv_preamble(cf, fh); + write_csv_column_titles(&cf->cinfo, fh); if (ferror(fh)) { fclose(fh); return CF_PRINT_WRITE_ERROR; @@ -2938,12 +2939,6 @@ cf_write_csv_packets(capture_file *cf, print_args_t *print_args) return CF_PRINT_WRITE_ERROR; } - write_csv_finale(fh); - if (ferror(fh)) { - fclose(fh); - return CF_PRINT_WRITE_ERROR; - } - /* XXX - check for an error */ fclose(fh); @@ -2951,14 +2946,14 @@ cf_write_csv_packets(capture_file *cf, print_args_t *print_args) } static gboolean -write_carrays_packet(capture_file *cf, frame_data *fdata, +carrays_write_packet(capture_file *cf, frame_data *fdata, struct wtap_pkthdr *phdr, const guint8 *pd, void *argsp) { write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp; epan_dissect_run(&args->edt, cf->cd_t, phdr, frame_tvbuff_new(fdata, pd), fdata, NULL); - proto_tree_write_carrays(fdata->num, args->fh, &args->edt); + write_carrays_hex_data(fdata->num, args->fh, &args->edt); epan_dissect_reset(&args->edt); return !ferror(args->fh); @@ -2976,8 +2971,6 @@ cf_write_carrays_packets(capture_file *cf, print_args_t *print_args) if (fh == NULL) return CF_PRINT_OPEN_ERROR; /* attempt to open destination failed */ - write_carrays_preamble(fh); - if (ferror(fh)) { fclose(fh); return CF_PRINT_WRITE_ERROR; @@ -2991,7 +2984,7 @@ cf_write_carrays_packets(capture_file *cf, print_args_t *print_args) ret = process_specified_records(cf, &print_args->range, "Writing C Arrays", "selected packets", TRUE, - write_carrays_packet, &callback_args); + carrays_write_packet, &callback_args); epan_dissect_cleanup(&callback_args.edt); @@ -3008,13 +3001,6 @@ cf_write_carrays_packets(capture_file *cf, print_args_t *print_args) return CF_PRINT_WRITE_ERROR; } - write_carrays_finale(fh); - - if (ferror(fh)) { - fclose(fh); - return CF_PRINT_WRITE_ERROR; - } - fclose(fh); return CF_PRINT_OK; } diff --git a/tshark.c b/tshark.c index b217b2f14d..c3218244a8 100644 --- a/tshark.c +++ b/tshark.c @@ -2182,7 +2182,7 @@ main(int argc, char *argv[]) print_packet_counts = TRUE; if (print_packet_info) { - if (!write_preamble(NULL)) { + if (!write_preamble(&cfile)) { show_print_file_io_error(errno); return 2; } @@ -3592,13 +3592,13 @@ write_preamble(capture_file *cf) switch (output_action) { case WRITE_TEXT: - return print_preamble(print_stream, cf ? cf->filename : NULL, get_ws_vcs_version_info()); + return print_preamble(print_stream, cf->filename, get_ws_vcs_version_info()); case WRITE_XML: if (print_details) - write_pdml_preamble(stdout, cf ? cf->filename : NULL); + write_pdml_preamble(stdout, cf->filename); else - write_psml_preamble(cf, stdout); + write_psml_preamble(&cf->cinfo, stdout); return !ferror(stdout); case WRITE_FIELDS: @@ -3903,7 +3903,7 @@ print_packet(capture_file *cf, epan_dissect_t *edt) break; case WRITE_XML: - proto_tree_write_psml(edt, stdout); + write_psml_columns(edt, stdout); return !ferror(stdout); case WRITE_FIELDS: /*No non-verbose "fields" format */ g_assert_not_reached(); @@ -3937,11 +3937,11 @@ print_packet(capture_file *cf, epan_dissect_t *edt) break; case WRITE_XML: - proto_tree_write_pdml(edt, stdout); + write_pdml_proto_tree(edt, stdout); printf("\n"); return !ferror(stdout); case WRITE_FIELDS: - proto_tree_write_fields(output_fields, edt, &cf->cinfo, stdout); + write_fields_proto_tree(output_fields, edt, &cf->cinfo, stdout); printf("\n"); return !ferror(stdout); }