(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/hostlist_table.c) |
| |
| 746 | | | init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, tap_packet_cb packet_func) |
| 747 | | | { |
| 748 | | | guint i; |
| 749 | | | column_arrows *col_arrows; |
| 750 | | | GtkStyle *win_style; |
| 751 | | | GtkWidget *column_lb; |
| 752 | | | GString *error_string; |
| 753 | | | char title[256]; |
| 754 | | | |
| 755 | | | hosttable->num_columns=NUM_HOSTLIST_COLS; |
| 756 | | | hosttable->default_titles[0] = "Address"; |
| 757 | | | hosttable->default_titles[1] = "Port"; |
| 758 | | | hosttable->default_titles[2] = "Packets"; |
| 759 | | | hosttable->default_titles[3] = "Bytes"; |
| 760 | | | hosttable->default_titles[4] = "Tx Packets"; |
| 761 | | | hosttable->default_titles[5] = "Tx Bytes"; |
| 762 | | | hosttable->default_titles[6] = "Rx Packets"; |
| 763 | | | hosttable->default_titles[7] = "Rx Bytes"; |
| 764 | | | |
| 765 | | | #ifdef HAVE_GEOIP |
| 766 | | | for (i = 0; i < NUM_GEOIP_COLS; i++) { |
| 767 | | | if (i < geoip_db_num_dbs()) { |
| 768 | | | hosttable->default_titles[NUM_BUILTIN_COLS + i] = geoip_db_name(i); |
| 769 | | | } else { |
| 770 | | | hosttable->default_titles[NUM_BUILTIN_COLS + i] = ""; |
| 771 | | | } |
| 772 | | | } |
| 773 | | | #endif |
| 774 | | | |
| 775 | | | if (strcmp(table_name, "NCP")==0) { |
| 776 | | | hosttable->default_titles[1] = "Connection"; |
| 777 | | | } |
| 778 | | | |
| 779 | | | hosttable->has_ports=!hide_ports; |
| 780 | | | hosttable->num_hosts = 0; |
| 781 | | | hosttable->resolve_names=TRUE; |
| 782 | | | hosttable->page_lb = NULL; |
| 783 | | | |
| 784 | | | g_snprintf(title, sizeof(title), "%s Endpoints", table_name); |
| 785 | | | hosttable->name_lb = gtk_label_new(title); |
| 786 | | | gtk_box_pack_start(GTK_BOX(vbox), hosttable->name_lb, FALSE, FALSE, 0);
x /usr/include/gtk-2.0/gtk/gtkbox.h |
| |
42 | #define GTK_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BOX, GtkBox)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
482 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
1678 | # define _G_TYPE_CIC(ip, gt, ct) \ |
1679 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) |
| |
x /usr/include/gtk-2.0/gtk/gtkbox.h |
| |
41 | #define GTK_TYPE_BOX (gtk_box_get_type ()) |
| |
|
| 787 | | | |
| 788 | | | hosttable->scrolled_window=scrolled_window_new(NULL, NULL); |
| 789 | | | gtk_box_pack_start(GTK_BOX(vbox), hosttable->scrolled_window, TRUE, TRUE, 0);
x /usr/include/gtk-2.0/gtk/gtkbox.h |
| |
42 | #define GTK_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BOX, GtkBox)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
482 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
1678 | # define _G_TYPE_CIC(ip, gt, ct) \ |
1679 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) |
| |
x /usr/include/gtk-2.0/gtk/gtkbox.h |
| |
41 | #define GTK_TYPE_BOX (gtk_box_get_type ()) |
| |
|
| 790 | | | |
| 791 | | | hosttable->table=(GtkCList *)gtk_clist_new(NUM_HOSTLIST_COLS); |
| 792 | | | |
| 793 | | | col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * NUM_HOSTLIST_COLS); |
| 794 | | | win_style = gtk_widget_get_style(hosttable->scrolled_window); |
| 795 | | | for (i = 0; i < NUM_HOSTLIST_COLS; i++) { |
| 796 | | | col_arrows[i].table = gtk_table_new(2, 2, FALSE); |
| 797 | | | gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
x /usr/include/gtk-2.0/gtk/gtktable.h |
| |
41 | #define GTK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TABLE, GtkTable)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
482 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
1678 | # define _G_TYPE_CIC(ip, gt, ct) \ |
1679 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) |
| |
x /usr/include/gtk-2.0/gtk/gtktable.h |
| |
40 | #define GTK_TYPE_TABLE (gtk_table_get_type ()) |
| |
|
| 798 | | | column_lb = gtk_label_new(hosttable->default_titles[i]); |
| 799 | | | gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
x /usr/include/gtk-2.0/gtk/gtktable.h |
| |
41 | #define GTK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TABLE, GtkTable)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
482 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
1678 | # define _G_TYPE_CIC(ip, gt, ct) \ |
1679 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) |
| |
x /usr/include/gtk-2.0/gtk/gtktable.h |
| |
40 | #define GTK_TYPE_TABLE (gtk_table_get_type ()) |
| |
|
| 800 | | | gtk_widget_show(column_lb); |
| 801 | | | |
| 802 | | | col_arrows[i].ascend_pm = xpm_to_widget((const char **) clist_ascend_xpm); |
| 803 | | | gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
x /usr/include/gtk-2.0/gtk/gtktable.h |
| |
41 | #define GTK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TABLE, GtkTable)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
482 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
1678 | # define _G_TYPE_CIC(ip, gt, ct) \ |
1679 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) |
| |
x /usr/include/gtk-2.0/gtk/gtktable.h |
| |
40 | #define GTK_TYPE_TABLE (gtk_table_get_type ()) |
| |
|
| 804 | | | col_arrows[i].descend_pm = xpm_to_widget((const char **) clist_descend_xpm); |
| 805 | | | gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
x /usr/include/gtk-2.0/gtk/gtktable.h |
| |
41 | #define GTK_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TABLE, GtkTable)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
482 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
1678 | # define _G_TYPE_CIC(ip, gt, ct) \ |
1679 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) |
| |
x /usr/include/gtk-2.0/gtk/gtktable.h |
| |
40 | #define GTK_TYPE_TABLE (gtk_table_get_type ()) |
| |
|
| 806 | | | |
| 807 | | | if (i == 4) { |
| 808 | | | gtk_widget_show(col_arrows[i].descend_pm); |
| 809 | | | } |
| 810 | | | gtk_clist_set_column_widget(GTK_CLIST(hosttable->table), i, col_arrows[i].table);
x /usr/include/gtk-2.0/gtk/gtkclist.h |
| |
87 | #define GTK_CLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CLIST, GtkCList)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
482 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
1678 | # define _G_TYPE_CIC(ip, gt, ct) \ |
1679 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) |
| |
x /usr/include/gtk-2.0/gtk/gtkclist.h |
| |
86 | #define GTK_TYPE_CLIST (gtk_clist_get_type ()) |
| |
|
| 811 | | | gtk_widget_show(col_arrows[i].table); |
| 812 | | | } |
| 813 | | | gtk_clist_column_titles_show(GTK_CLIST(hosttable->table));
x /usr/include/gtk-2.0/gtk/gtkclist.h |
| |
87 | #define GTK_CLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CLIST, GtkCList)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
482 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
1678 | # define _G_TYPE_CIC(ip, gt, ct) \ |
1679 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) |
| |
x /usr/include/gtk-2.0/gtk/gtkclist.h |
| |
86 | #define GTK_TYPE_CLIST (gtk_clist_get_type ()) |
| |
|
| 814 | | | |
| 815 | | | gtk_clist_set_compare_func(hosttable->table, hostlist_sort_column); |
| 816 | | | gtk_clist_set_sort_column(hosttable->table, 4); |
| 817 | | | gtk_clist_set_sort_type(hosttable->table, GTK_SORT_DESCENDING); |
| 818 | | | |
| 819 | | | for (i = 0; i < NUM_HOSTLIST_COLS; i++) { |
| 820 | | | gtk_clist_set_column_auto_resize(hosttable->table, i, TRUE); |
| 821 | | | } |
| 822 | | | |
| 823 | | | gtk_clist_set_shadow_type(hosttable->table, GTK_SHADOW_IN); |
| 824 | | | gtk_clist_column_titles_show(hosttable->table); |
| 825 | | | gtk_container_add(GTK_CONTAINER(hosttable->scrolled_window), (GtkWidget *)hosttable->table);
x /usr/include/gtk-2.0/gtk/gtkcontainer.h |
| |
42 | #define GTK_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CONTAINER, GtkContainer)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
482 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) |
| |
x /usr/include/glib-2.0/gobject/gtype.h |
| |
1678 | # define _G_TYPE_CIC(ip, gt, ct) \ |
1679 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) |
| |
x /usr/include/gtk-2.0/gtk/gtkcontainer.h |
| |
41 | #define GTK_TYPE_CONTAINER (gtk_container_get_type ()) |
| |
|
| 826 | | | |
| 827 | | | g_signal_connect(hosttable->table, "click-column", G_CALLBACK(hostlist_click_column_cb), col_arrows);
x /usr/include/glib-2.0/gobject/gsignal.h |
| |
421 | #define g_signal_connect(instance, detailed_signal, c_handler, data) \ |
422 | g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0) |
| |
x /usr/include/glib-2.0/gobject/gclosure.h |
| |
72 | #define G_CALLBACK(f) ((GCallback) (f)) |
| |
|
| 828 | | | |
| 829 | | | hosttable->num_hosts=0; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 830 | | | hosttable->hosts=NULL; |
| 831 | | | |
| 832 | | | |
| 833 | | | if(hide_ports){ |
| 834 | | | gtk_clist_set_column_visibility(hosttable->table, 1, FALSE); |
| 835 | | | } |
| 836 | | | |
| 837 | | | #ifdef HAVE_GEOIP |
| 838 | | | |
| 839 | | | for (i = 0; i < NUM_GEOIP_COLS; i++) { |
| 840 | | | gtk_clist_set_column_visibility(hosttable->table, NUM_BUILTIN_COLS + i, FALSE); |
| 841 | | | } |
| 842 | | | #endif |
| 843 | | | |
| 844 | | | |
| 845 | | | (hosttable); |
| 846 | | | |
| 847 | | | |
| 848 | | | error_string=register_tap_listener(tap_name, hosttable, filter, reset_hostlist_table_data_cb, packet_func, draw_hostlist_table_data_cb); |
| 849 | | | if(error_string){ |
| 850 | | | simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); |
| 851 | | | g_string_free(error_string, TRUE); |
| 852 | | | g_free(hosttable); |
| 853 | | | return FALSE; |
| 854 | | | } |
| 855 | | | |
| 856 | | | return TRUE; |
| 857 | | | } |
| |