From Niels Widger via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7725
authorEvan Huus <eapache@gmail.com>
Sat, 15 Sep 2012 13:58:57 +0000 (13:58 -0000)
committerEvan Huus <eapache@gmail.com>
Sat, 15 Sep 2012 13:58:57 +0000 (13:58 -0000)
Add get_filter method to Wireshark's Lua interface (to correspond with the
already-exposed set_filter method).

svn path=/trunk/; revision=44916

AUTHORS
epan/funnel.h
epan/wslua/wslua_gui.c
ui/cli/tap-funnel.c
ui/gtk/funnel_stat.c

diff --git a/AUTHORS b/AUTHORS
index bd63249dc3fb0b6368a1a1a8baaed5d7588c3dcf..23cbc883b84585a21fa00d73bb2bb06c4c6c4bad 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -3673,6 +3673,7 @@ Ben Bowen         <bbowen[AT]godaddy.com>
 Bodo Petermann         <bp245[AT]hotmail.com>
 Martin Kupec           <martin.kupec[AT]kupson.cz>
 Litao Gao              <ltgao[AT]juniper.net>
+Niels Widger           <niels[AT]qacafe.com>
 
 Dan Lasley <dlasley[AT]promus.com> gave permission for his
 dumpit() hex-dump routine to be used.
index 53b7220b473cfdbd5a37d4fded47cf34276712e2..5208d8868544fb4349cd39cbdc5616eed77d3d47 100644 (file)
@@ -77,6 +77,7 @@ typedef struct _funnel_ops_t {
        void (*retap_packets)(void);
        void (*copy_to_clipboard)(GString *str);
     
+       gchar * (*get_filter)(void);
        void (*set_filter)(const char*);
         void (*set_color_filter_slot)(guint8 flit_nr, const gchar* filter);
        gboolean (*open_file)(const char* fname, const char* filter, const char** error);
index 7ba46eb1ca2e6a7041263a56b52c00d24d4958a1..0c6888f5a156dc5a5877e01a05a36909cd7cbbde 100644 (file)
@@ -792,6 +792,19 @@ WSLUA_FUNCTION wslua_open_capture_file(lua_State* L) { /* Open and display a cap
     }
 }
 
+WSLUA_FUNCTION wslua_get_filter(lua_State* L) { /* Get the main filter text */
+    const char *filter_str = NULL;
+
+    if (!ops->get_filter) {
+        WSLUA_ERROR(get_filter, "GUI not available");
+    }
+
+    filter_str = ops->get_filter();
+    lua_pushstring(L,filter_str);
+
+    return 1;
+}
+
 WSLUA_FUNCTION wslua_set_filter(lua_State* L) { /* Set the main filter text */
 #define WSLUA_ARG_set_filter_TEXT 1 /* The filter's text. */
     const char* filter_str = luaL_checkstring(L,WSLUA_ARG_set_filter_TEXT);
index 79d6ef33c8c9ac33467c456f442a3292b5d11e0b..0326ca874d6121311fbcb6260017451e1b447faf 100644 (file)
 #include "config.h"
 #endif
 
+#include <glib.h>
+#include <wiretap/wtap.h>
+#include <epan/nstime.h>
+#include <epan/proto.h>
+
 #include <epan/funnel.h>
 #include <stdio.h>
 #include <epan/stat_cmd_args.h>
@@ -112,6 +117,7 @@ static const funnel_ops_t funnel_ops = {
     NULL,
     NULL,
     NULL,
+    NULL,
     NULL
 };
 
index 083899390d03abb53d6baa90f9289d4f716af75c..03795efbecdea7c99b5f3eedd8015624226f04d0 100644 (file)
@@ -468,6 +468,10 @@ static void funnel_new_dialog(const gchar* title,
     gtk_widget_show(win);
 }
 
+static gchar * funnel_get_filter(void) {
+    return (gchar *)gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
+}
+
 static void funnel_set_filter(const char* filter_string) {
     gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), filter_string);
 }
@@ -571,6 +575,7 @@ static const funnel_ops_t funnel_ops = {
     funnel_logger,
     funnel_retap_packets,
     copy_to_clipboard,
+    funnel_get_filter,
     funnel_set_filter,
     funnel_set_color_filter_slot,
     funnel_open_file,