diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2006-10-03 12:07:10 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2006-10-03 12:07:10 +0000 |
commit | 161b9a55eaecb0acac3751bb944bb93551406c4a (patch) | |
tree | a6c0d2ffbc11271dd3103fb35164112ba3cda3f6 /gtk | |
parent | 179039652b0c64691f9f13d2ae3451fca3252700 (diff) |
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 'gtk')
-rw-r--r-- | gtk/funnel_stat.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/gtk/funnel_stat.c b/gtk/funnel_stat.c index 506a549cd9..be4d2347b7 100644 --- a/gtk/funnel_stat.c +++ b/gtk/funnel_stat.c @@ -59,6 +59,7 @@ #include <epan/prefs.h> #include "column_prefs.h" #include "prefs_dlg.h" +#include "file.h" #include "gtkglobals.h" @@ -499,6 +500,9 @@ static void funnel_new_dialog(const gchar* title, gtk_widget_show(win); } +static void funnel_set_filter(const char* filter_string) { + gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), filter_string); +} /* XXX: finish this */ static void funnel_logger(const gchar *log_domain _U_, @@ -512,6 +516,55 @@ static void funnel_retap_packets(void) { cf_retap_packets(&cfile, FALSE); } +static gboolean funnel_open_file(const char* fname, const char* filter, char** error) { + int err = 0; + dfilter_t *rfcode = NULL; + + *error = "no error"; + + switch (cfile.state) { + case FILE_CLOSED: + break; + case FILE_READ_DONE: + case FILE_READ_ABORTED: + cf_close(&cfile); + break; + case FILE_READ_IN_PROGRESS: + *error = "file read in progress"; + return FALSE; + } + + if (filter) { + if (!dfilter_compile(filter, &rfcode)) { + *error = dfilter_error_msg ? dfilter_error_msg : "cannot compile filter"; + return FALSE; + } + } + + + if (cf_open(&cfile, fname, FALSE, &err) != CF_OK) { + *error = strerror(err); + if (rfcode != NULL) dfilter_free(rfcode); + return FALSE; + } + + cfile.rfcode = rfcode; + + switch (cf_read(&cfile)) { + case CF_READ_OK: + case CF_READ_ERROR: + break; + default: + *error = "problem while reading file"; + return FALSE; + } + + return TRUE; +} + +static void funnel_reload() { + if (cfile.state == FILE_READ_DONE) cf_reload(&cfile); +} static const funnel_ops_t funnel_ops = { new_text_window, @@ -527,7 +580,11 @@ static const funnel_ops_t funnel_ops = { /*...,*/ funnel_new_dialog, funnel_logger, - funnel_retap_packets + funnel_retap_packets, + copy_to_clipboard, + funnel_set_filter, + funnel_open_file, + funnel_reload }; |