Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 38782: /trunk/gtk/ /trunk/gtk/: main

From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Mon, 29 Aug 2011 22:37:30 +0200
On Mon, Aug 29, 2011 at 10:09:01PM +0200, Joerg Mayer wrote:
> On Mon, Aug 29, 2011 at 07:47:53PM +0000, sfisher@xxxxxxxxxxxxx wrote:
> > http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=38782
> > 
> > User: sfisher
> > Date: 2011/08/29 12:47 PM
> > 
> > Log:
> >  Fix compilation when compiling without libpcap (configure script parameter
> >  "--without-pcap")
> ...  
> >   Changes    Path              Action
> >   +6 -2      main_menubar.c    Modified
> >   +6 -0      stock_icons.c     Modified
> 
> Adding back to #ifdef HAVE_LIBPCAP is not the nicest way. We have way too
> many places with #ifdef somethingorother. IIRC the intention of the patch
> that caused the problem was to always have all features in the menu, some
> of them just not visible/selectable(?).

Something like the attached patch - compile tested only!

 ciao
      Joerg
-- 
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.
Index: globals.h
===================================================================
--- globals.h	(revision 38783)
+++ globals.h	(working copy)
@@ -33,10 +33,8 @@
 #include <epan/timestamp.h>
 
 extern capture_file cfile;
-#ifdef HAVE_LIBPCAP
 /** @todo move this to the gtk dir */
 extern gboolean     auto_scroll_live;
-#endif
 
 #ifdef __cplusplus
 }
Index: gtk/stock_icons.c
===================================================================
--- gtk/stock_icons.c	(revision 38783)
+++ gtk/stock_icons.c	(working copy)
@@ -32,7 +32,6 @@
 #include "gtk/stock_icons.h"
 
 /* these icons are derived from the original stock icons */
-#ifdef HAVE_LIBPCAP
 #include "../image/toolbar/capture_interfaces_24.xpm"
 #include "../image/toolbar/capture_options_24.xpm"
 #include "../image/toolbar/capture_start_24.xpm"
@@ -40,7 +39,6 @@
 #include "../image/toolbar/capture_restart_24.xpm"
 #include "../image/toolbar/capture_filter_24.xpm"
 #include "../image/toolbar/capture_details_24.xpm"
-#endif /* HAVE_LIBICAP */
 #include "../image/toolbar/display_filter_24.xpm"
 #include "../image/wsicon16.xpm"
 #include "../image/toolbar/colorize_24.xpm"
@@ -93,7 +91,6 @@
 
     /* register non-standard pixmaps with the gtk-stock engine */
     static const GtkStockItem stock_items[] = {
-#ifdef HAVE_LIBPCAP
         { WIRESHARK_STOCK_CAPTURE_INTERFACES,    "_Interfaces",    0, 0, NULL },
         { WIRESHARK_STOCK_CAPTURE_OPTIONS,       "_Options",       0, 0, NULL },
         { WIRESHARK_STOCK_CAPTURE_START,         "_Start",         0, 0, NULL },
@@ -102,7 +99,6 @@
         { WIRESHARK_STOCK_CAPTURE_FILTER,        "_Capture Filter",   0, 0, NULL },
         { WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY,  "_Capture Filter:",  0, 0, NULL },
         { WIRESHARK_STOCK_CAPTURE_DETAILS,       "_Details",       0, 0, NULL },
-#endif /* HAVE_LIBPCAP */
 #ifdef HAVE_GEOIP
         { WIRESHARK_STOCK_MAP,                   "Map",                   0, 0, NULL },
 #endif
@@ -162,7 +158,6 @@
     };
 
     static const stock_pixmap_t pixmaps[] = {
-#ifdef HAVE_LIBPCAP
         { WIRESHARK_STOCK_CAPTURE_INTERFACES,    capture_interfaces_24_xpm },
         { WIRESHARK_STOCK_CAPTURE_OPTIONS,       capture_options_24_xpm },
         { WIRESHARK_STOCK_CAPTURE_START,         capture_start_24_xpm },
@@ -171,7 +166,6 @@
         { WIRESHARK_STOCK_CAPTURE_FILTER,        capture_filter_24_xpm },
         { WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY,  capture_filter_24_xpm },
         { WIRESHARK_STOCK_CAPTURE_DETAILS,       capture_details_24_xpm },
-#endif /* HAVE_LIBPCAP */
 #ifdef HAVE_GEOIP
         { WIRESHARK_STOCK_MAP,                   internet_24_xpm},
 #endif
Index: gtk/stock_icons.h
===================================================================
--- gtk/stock_icons.h	(revision 38783)
+++ gtk/stock_icons.h	(working copy)
@@ -27,7 +27,6 @@
 #define __STOCK_ICONS_H__
 
 
-#ifdef HAVE_LIBPCAP
 #define WIRESHARK_STOCK_CAPTURE_INTERFACES       "Wireshark_Stock_CaptureInterfaces"
 #define WIRESHARK_STOCK_CAPTURE_OPTIONS          "Wireshark_Stock_CaptureOptionss"
 #define WIRESHARK_STOCK_CAPTURE_START            "Wireshark_Stock_CaptureStart"
@@ -36,7 +35,6 @@
 #define WIRESHARK_STOCK_CAPTURE_FILTER           "Wireshark_Stock_CaptureFilter"
 #define WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY     "Wireshark_Stock_CaptureFilter_Entry"
 #define WIRESHARK_STOCK_CAPTURE_DETAILS          "Wireshark_Stock_CaptureDetails"
-#endif
 #ifdef HAVE_GEOIP
 #define WIRESHARK_STOCK_MAP                      "Wireshark_Stock_Map"
 #endif
Index: gtk/capture_if_dlg.h
===================================================================
--- gtk/capture_if_dlg.h	(revision 38783)
+++ gtk/capture_if_dlg.h	(working copy)
@@ -32,10 +32,6 @@
 void
 set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress);
 
-#ifdef HAVE_LIBPCAP
-
-#include "capture_ifinfo.h"	/* for if_info_t */
-
 /** User requested the "Capture Interfaces" dialog box by menu or toolbar.
  *
  * @param widget parent widget (unused)
@@ -44,6 +40,10 @@
 void
 capture_if_cb(GtkWidget *widget, gpointer data);
 
+#ifdef HAVE_LIBPCAP
+
+#include "capture_ifinfo.h"	/* for if_info_t */
+
 /*
  * Used to retrieve the interface icon
  */
Index: gtk/main_menubar.c
===================================================================
--- gtk/main_menubar.c	(revision 38783)
+++ gtk/main_menubar.c	(working copy)
@@ -1576,14 +1576,13 @@
    { "/Go/LastPacket",				GTK_STOCK_GOTO_BOTTOM,	"_Last Packet",						"<control>End",					NULL,				G_CALLBACK(goto_bottom_frame_cb) },
    { "/Go/PreviousPacketInConversation",			GTK_STOCK_GO_UP,		"Previous Packet In Conversation",					"<control>comma",					NULL,				G_CALLBACK(goto_previous_frame_conversation_cb) },
    { "/Go/NextPacketInConversation",				GTK_STOCK_GO_DOWN,		"Next Packet In Conversation",						"<control>period",				NULL,				G_CALLBACK(goto_next_frame_conversation_cb) },
-#ifdef HAVE_LIBPCAP
+
    { "/Capture/Interfaces",			WIRESHARK_STOCK_CAPTURE_INTERFACES,	"_Interfaces...",		"<control>I",					NULL,				G_CALLBACK(capture_if_cb) },
    { "/Capture/Options",			WIRESHARK_STOCK_CAPTURE_OPTIONS,	"_Options...",			"<control>K",					NULL,				G_CALLBACK(capture_prep_cb) },
    { "/Capture/Start",				WIRESHARK_STOCK_CAPTURE_START,		"_Start",				"<control>E",					NULL,				G_CALLBACK(capture_start_cb) },
    { "/Capture/Stop",				WIRESHARK_STOCK_CAPTURE_STOP,		"S_top",				"<control>E",					NULL,				G_CALLBACK(capture_stop_cb) },
    { "/Capture/Restart",			WIRESHARK_STOCK_CAPTURE_RESTART,	"_Restart",				"<control>R",					NULL,				G_CALLBACK(capture_restart_cb) },
    { "/Capture/CaptureFilters",		WIRESHARK_STOCK_CAPTURE_FILTER,		"Capture _Filters...",	NULL,							NULL,				G_CALLBACK(cfilter_dialog_cb) },
-#endif /* HAVE_LIBPCAP */
 
    { "/Analyze/DisplayFilters",		WIRESHARK_STOCK_DISPLAY_FILTER,		"_Display Filters...",	NULL,							NULL,				G_CALLBACK(dfilter_dialog_cb) },
 
@@ -4284,12 +4283,12 @@
 #ifdef HAVE_LIBPCAP
     /* tell toolbar about it */
     toolbar_auto_scroll_live_changed(auto_scroll_live_in);
+#endif /*HAVE_LIBPCAP */
 
     /* change auto scroll */
     if(auto_scroll_live_in != auto_scroll_live) {
         auto_scroll_live  = auto_scroll_live_in;
     }
-#endif /*HAVE_LIBPCAP */
 }
 
 
@@ -4391,15 +4390,12 @@
 
     menu_name_resolution_changed();
 
-
-#ifdef HAVE_LIBPCAP
     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/AutoScrollinLiveCapture");
     if(!menu){
         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/AutoScrollinLiveCapture");
     }else{
         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live);
     }
-#endif /* HAVE_LIBPCAP */
 
     main_widgets_rearrange();