summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2006-10-03 12:07:10 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2006-10-03 12:07:10 +0000
commit161b9a55eaecb0acac3751bb944bb93551406c4a (patch)
treea6c0d2ffbc11271dd3103fb35164112ba3cda3f6 /epan
parent179039652b0c64691f9f13d2ae3451fca3252700 (diff)
downloadwireshark-161b9a55eaecb0acac3751bb944bb93551406c4a.tar.gz
more Lua APIs:
- set_filter() : sets the main window filter - reload() : reloads the current capture file - copy_to_clipboard() : copies its first arfg to the clipboard - open_capture_file() : opens a capture file for viewing (still broken) svn path=/trunk/; revision=19404
Diffstat (limited to 'epan')
-rw-r--r--epan/funnel.h4
-rw-r--r--epan/wslua/wslua_gui.c69
2 files changed, 73 insertions, 0 deletions
diff --git a/epan/funnel.h b/epan/funnel.h
index 3cd7eb22ea..65264a896a 100644
--- a/epan/funnel.h
+++ b/epan/funnel.h
@@ -83,6 +83,10 @@ typedef struct _funnel_ops_t {
gpointer user_data);
void (*retap_packets)(void);
+ void (*copy_to_clipboard)(GString *str);
+ void (*set_filter)(const char*);
+ gboolean (*open_file)(const char* fname, const char* filter, char** error);
+ void (*reload)(void);
} funnel_ops_t;
diff --git a/epan/wslua/wslua_gui.c b/epan/wslua/wslua_gui.c
index bd174041b8..0db396b313 100644
--- a/epan/wslua/wslua_gui.c
+++ b/epan/wslua/wslua_gui.c
@@ -503,3 +503,72 @@ WSLUA_FUNCTION wslua_retap_packets(lua_State* L) {
}
+WSLUA_FUNCTION wslua_copy_to_clipboard(lua_State* L) { /* copy a string into the clipboard */
+#define WSLUA_ARG_copy_to_clipboard_TEXT 1 /* The string to be copied into the clipboard. */
+ const char* copied_str = luaL_checkstring(L,WSLUA_ARG_copy_to_clipboard_TEXT);
+ GString* gstr;
+ if (!ops->copy_to_clipboard) {
+ WSLUA_ERROR(wslua_copy_to_clipboard, "does not work on TShark");
+ }
+
+ if (!copied_str) {
+ WSLUA_ARG_ERROR(copy_to_clipboard,TEXT,"must be a string");
+ }
+
+ gstr = g_string_new(copied_str);
+
+ ops->copy_to_clipboard(gstr);
+
+ g_string_free(gstr,TRUE);
+
+ return 0;
+}
+
+WSLUA_FUNCTION wslua_open_capture_file(lua_State* L) {
+#define WSLUA_ARG_open_capture_file_FILENAME 1 /* The name of the file to be opened. */
+#define WSLUA_ARG_open_capture_file_FILTER 2 /* A filter tgo be applied as the file gets opened. */
+
+ const char* fname = luaL_checkstring(L,WSLUA_ARG_open_capture_file_FILENAME);
+ const char* filter = luaL_optstring(L,WSLUA_ARG_open_capture_file_FILTER,NULL);
+ char* error = NULL;
+
+ if (!ops->open_file) {
+ WSLUA_ERROR(wslua_open_capture_file, "does not work on TShark");
+ }
+
+ if (!fname) {
+ WSLUA_ARG_ERROR(open_capture_file,FILENAME,"must be a string");
+ }
+
+ if (! ops->open_file(fname,filter,&error) ) {
+ lua_pushboolean(L,FALSE);
+
+ if (error)
+ lua_pushstring(L,error);
+ else
+ lua_pushnil(L);
+
+ return 2;
+ } else {
+ lua_pushboolean(L,TRUE);
+ 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);
+
+ if (!ops->set_filter) {
+ WSLUA_ERROR(wslua_set_filter, "does not work on TShark");
+ }
+
+ if (!filter_str) {
+ WSLUA_ARG_ERROR(set_filter,TEXT,"must be a string");
+ }
+
+ ops->set_filter(filter_str);
+
+ return 0;
+}
+