#include "config.h"
#include <string.h>
-#include <time.h>
#include <gtk/gtk.h>
-#include <epan/strutil.h>
+#include <version_info.h>
-#include <wiretap/wtap.h>
-
-#include <wsutil/ws_version_info.h>
-
-#include "../globals.h"
-#include "../file.h"
-#include "../summary.h"
+#include "../../file.h"
+#include "../../summary.h"
#ifdef HAVE_LIBPCAP
#include "ui/capture.h"
#include "ui/gtk/help_dlg.h"
#include "ui/gtk/packet_list.h"
+#include "globals.h"
+
#define SUM_STR_MAX 1024
#define FILTER_SNIP_LEN 50
#define SHB_STR_SNIP_LEN 50
new_comment = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE /* whether to include invisible text */);
- cf_update_capture_comment(&cfile, new_comment);
+ cf_update_section_comment(&cfile, new_comment);
/* Update the main window */
main_update_for_unsaved_changes(&cfile);
GtkWidget *list, *treeview;
GtkWidget *comment_view = NULL, *comment_frame, *comment_vbox;
GtkTextBuffer *buffer = NULL;
- gchar *buf_str;
GtkListStore *store;
GtkTreeIter iter;
GtkCellRenderer *renderer;
unsigned int elapsed_time;
iface_options iface;
+ wtap_block_t shb_inf;
unsigned int i;
if (summary_dlg != NULL) {
g_snprintf(string_buff, SUM_STR_MAX, "%s", wtap_encap_string(summary.file_encap_type));
add_string_to_grid(grid, &row, "Encapsulation:", string_buff);
}
- if (summary.has_snap) {
+ if (summary.snap != 0) {
/* snapshot length */
g_snprintf(string_buff, SUM_STR_MAX, "%u bytes", summary.snap);
add_string_to_grid(grid, &row, "Packet size limit:", string_buff);
}
+ shb_inf = wtap_file_get_shb(cfile.provider.wth);
+
/* Capture file comment area */
if (wtap_dump_can_write(cfile.linktypes, WTAP_COMMENT_PER_SECTION)) {
comment_frame = gtk_frame_new("Capture file comments");
comment_view = gtk_text_view_new();
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(comment_view), GTK_WRAP_WORD);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (comment_view));
- if(summary.opt_comment == NULL) {
- gtk_text_buffer_set_text (buffer, "", -1);
- } else {
- buf_str = g_strdup_printf("%s", summary.opt_comment);
- gtk_text_buffer_set_text (buffer, buf_str, -1);
- g_free(buf_str);
+ gtk_text_buffer_set_text (buffer, "", -1);
+ if (shb_inf != NULL) {
+ char *opt_comment;
+
+ /* XXX - this only shows the last comment */
+ for (i = 0; wtap_block_get_nth_string_option_value(shb_inf, OPT_COMMENT, i, &opt_comment) == WTAP_OPTTYPE_SUCCESS; i++) {
+ if (opt_comment[0] != '\0')
+ gtk_text_buffer_set_text (buffer, opt_comment, -1);
+ }
}
gtk_box_pack_start(GTK_BOX(comment_vbox), comment_view, TRUE, TRUE, 0);
gtk_widget_show (comment_view);
/* Capture */
add_string_to_grid(grid, &row, "", "");
add_string_to_grid_sensitive(grid, &row, "Capture", "", (summary.ifaces->len > 0));
- if(summary.shb_hardware){
- /* truncate the string to a reasonable length */
- g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s",summary.shb_hardware);
- add_string_to_grid(grid, &row, "Capture HW:",string_buff);
- }
- if(summary.shb_os){
- /* truncate the strings to a reasonable length */
- g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s",summary.shb_os);
- add_string_to_grid(grid, &row, "OS:", string_buff);
- }
- if(summary.shb_user_appl){
- /* truncate the string to a reasonable length */
- g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s",summary.shb_user_appl);
- add_string_to_grid(grid, &row, "Capture application:", string_buff);
+ if (shb_inf != NULL) {
+ char *str;
+
+ if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS &&
+ str[0] != '\0') {
+ g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s", str);
+ add_string_to_grid(grid, &row, "Capture HW:",string_buff);
+ }
+
+ if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS &&
+ str[0] != '\0') {
+ /* truncate the strings to a reasonable length */
+ g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s", str);
+ add_string_to_grid(grid, &row, "OS:", string_buff);
+ }
+
+ if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS &&
+ str[0] != '\0') {
+ /* truncate the strings to a reasonable length */
+ g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s", str);
+ add_string_to_grid(grid, &row, "Capture application:", string_buff);
+ }
}
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 5);
summary_tally summary;
gchar string_buff[SUM_STR_MAX];
gchar tmp_buff[SUM_STR_MAX];
- gchar *buf_str;
+ wtap_block_t shb_inf;
unsigned int i;
unsigned int elapsed_time;
iface_options iface;
- double seconds;
+ double seconds;
/* initial computations */
summary_fill_in(&cfile, &summary);
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Encapsulation: %s\n", wtap_encap_string(summary.file_encap_type));
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
}
- if (summary.has_snap) {
+ if (summary.snap != 0) {
/* snapshot length */
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Packet size limit: %u bytes\n", summary.snap);
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
g_snprintf(string_buff, SUM_STR_MAX, "Capture:\n");
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- if(summary.shb_hardware){
- /* truncate the string to a reasonable length */
- g_snprintf(string_buff, SUM_STR_MAX, INDENT "Capture HW: %s\n",summary.shb_hardware);
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- }
- if(summary.shb_os){
- /* truncate the strings to a reasonable length */
- g_snprintf(string_buff, SUM_STR_MAX, INDENT "OS: %s\n",summary.shb_os);
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
- }
- if(summary.shb_user_appl){
- /* truncate the string to a reasonable length */
- g_snprintf(string_buff, SUM_STR_MAX, INDENT "Capture application: %s\n",summary.shb_user_appl);
- gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
+ shb_inf = wtap_file_get_shb(cfile.provider.wth);
+ if (shb_inf != NULL) {
+ char *str;
+
+ if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS &&
+ str[0] != '\0') {
+ /* truncate the string to a reasonable length */
+ g_snprintf(string_buff, SUM_STR_MAX, INDENT "Capture HW: %s\n", str);
+ gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
+ }
+ if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS &&
+ str[0] != '\0') {
+ /* truncate the strings to a reasonable length */
+ g_snprintf(string_buff, SUM_STR_MAX, INDENT "OS: %s\n", str);
+ gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
+ }
+ if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS &&
+ str[0] != '\0') {
+ /* truncate the string to a reasonable length */
+ g_snprintf(string_buff, SUM_STR_MAX, INDENT "Capture application: %s\n", str);
+ gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
+ }
}
/* Add empty line */
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
/* Trace file comments from SHB */
- if(summary.opt_comment != NULL) {
- buf_str = g_strdup_printf("%s", summary.opt_comment);
- gtk_text_buffer_insert_at_cursor(buffer, buf_str, -1);
- g_free(buf_str);
+ shb_inf = wtap_file_get_shb(cfile.provider.wth);
+ if (shb_inf != NULL) {
+ char *opt_comment;
+
+ for (i = 0; wtap_block_get_nth_string_option_value(shb_inf, OPT_COMMENT, i, &opt_comment) == WTAP_OPTTYPE_SUCCESS; i++) {
+ /* XXX - separator between comments? */
+ if (opt_comment[0] != '\0')
+ gtk_text_buffer_insert_at_cursor(buffer, opt_comment, -1);
+ }
}