From 77cad8561cec1699d7a4317e34c5590d566c9eb8 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 8 Apr 2017 21:24:45 -0700 Subject: Move the filter file reading code to libui. It doesn't belong in libwireshark, as it doesn't affect dissection, but it *does* belong in libui, as it's helper code for the UIs. Change-Id: I8a5e0640a299a08e9ec1917dd253197438ebfdbc Reviewed-on: https://code.wireshark.org/review/20974 Reviewed-by: Guy Harris --- CMakeLists.txt | 5 +- Makefile.am | 6 +- capture_opts.c | 2 +- filter_files.c | 662 ---------------------------------------- filter_files.h | 114 ------- sharkd.c | 2 +- tshark.c | 2 +- ui/CMakeLists.txt | 1 + ui/Makefile.am | 2 + ui/filter_files.c | 662 ++++++++++++++++++++++++++++++++++++++++ ui/filter_files.h | 114 +++++++ ui/gtk/filter_dlg.c | 2 +- ui/gtk/main.c | 2 +- ui/qt/capture_filter_edit.cpp | 2 +- ui/qt/display_filter_edit.cpp | 2 +- ui/qt/field_filter_edit.cpp | 2 +- ui/qt/filter_dialog.cpp | 2 +- ui/qt/wireshark_application.cpp | 2 +- 18 files changed, 791 insertions(+), 795 deletions(-) delete mode 100644 filter_files.c delete mode 100644 filter_files.h create mode 100644 ui/filter_files.c create mode 100644 ui/filter_files.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 583f2b68d1..992b0cf572 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1875,7 +1875,6 @@ if( (BUILD_wireshark AND QT_FOUND) OR (BUILD_wireshark_gtk AND GTK_FOUND) ) capture_opts.c file.c fileset.c - filter_files.c summary.c ${SHARK_COMMON_SRC} ${PLATFORM_UI_SRC} @@ -2243,7 +2242,6 @@ if(BUILD_tshark) ) set(tshark_FILES capture_opts.c - filter_files.c tshark-tap-register.c tshark.c ${TSHARK_TAP_SRC} @@ -2305,7 +2303,6 @@ if(BUILD_sharkd) ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} ) set(sharkd_FILES - filter_files.c sharkd.c sharkd_daemon.c sharkd_session.c @@ -2478,6 +2475,7 @@ if(BUILD_dumpcap AND PCAP_FOUND) writecap wsutil caputils + ui ${PCAP_LIBRARIES} ${CAP_LIBRARIES} ${GLIB2_LIBRARIES} @@ -2492,7 +2490,6 @@ if(BUILD_dumpcap AND PCAP_FOUND) capture_stop_conditions.c conditions.c dumpcap.c - filter_files.c ringbuffer.c sync_pipe_write.c ws_version_info.c diff --git a/Makefile.am b/Makefile.am index ab43234aef..150dcb2f1e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -419,7 +419,6 @@ WIRESHARK_COMMON_SRC = \ capture_opts.c \ file.c \ fileset.c \ - filter_files.c \ summary.c \ ws_version_info.c @@ -427,7 +426,6 @@ WIRESHARK_COMMON_SRC = \ WIRESHARK_COMMON_INCLUDES = \ capture_info.h \ capture_opts.h \ - filter_files.h \ globals.h \ log.h \ summary.h \ @@ -508,7 +506,6 @@ endif tshark_SOURCES = \ $(SHARK_COMMON_SRC) \ capture_opts.c \ - filter_files.c \ tshark.c \ ws_version_info.c @@ -580,7 +577,6 @@ rawshark_LDADD = \ sharkd_SOURCES = \ $(SHARK_COMMON_SRC) \ - filter_files.c \ sharkd.c \ sharkd.h \ sharkd_daemon.c \ @@ -722,7 +718,6 @@ dumpcap_SOURCES = \ capture_stop_conditions.c \ conditions.c \ dumpcap.c \ - filter_files.c \ ringbuffer.c \ sync_pipe_write.c \ ws_version_info.c @@ -736,6 +731,7 @@ dumpcap_LDFLAGS = $(AM_LDFLAGS) $(PIE_LDFLAGS) # Libraries with which to link dumpcap. dumpcap_LDADD = \ caputils/libcaputils.a \ + ui/libui.a \ writecap/libwritecap.a \ wsutil/libwsutil.la \ @GLIB_LIBS@ \ diff --git a/capture_opts.c b/capture_opts.c index 3b0f77c99e..69a24579c2 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -43,7 +43,7 @@ #include "caputils/capture_ifinfo.h" #include "caputils/capture-pcap-util.h" -#include "filter_files.h" +#include "ui/filter_files.h" static gboolean capture_opts_output_to_pipe(const char *save_file, gboolean *is_pipe); diff --git a/filter_files.c b/filter_files.c deleted file mode 100644 index c5e8818194..0000000000 --- a/filter_files.c +++ /dev/null @@ -1,662 +0,0 @@ -/* filters.c - * Code for reading and writing the filters file. - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include "filter_files.h" - -/* - * Old filter file name. - */ -#define FILTER_FILE_NAME "filters" - -/* - * Capture filter file name. - */ -#define CFILTER_FILE_NAME "cfilters" - -/* - * Display filter file name. - */ -#define DFILTER_FILE_NAME "dfilters" - -/* - * List of capture filters - saved. - */ -static GList *capture_filters = NULL; - -/* - * List of display filters - saved. - */ -static GList *display_filters = NULL; - -/* - * List of capture filters - currently edited. - */ -static GList *capture_edited_filters = NULL; - -/* - * List of display filters - currently edited. - */ -static GList *display_edited_filters = NULL; - -/* - * Read in a list of filters. - * - * On success, "*pref_path_return" is set to NULL. - * On error, "*pref_path_return" is set to point to the pathname of - * the file we tried to read - it should be freed by our caller - - * and "*errno_return" is set to the error. - */ - -#define INIT_BUF_SIZE 128 - -static GList * -add_filter_entry(GList *fl, const char *filt_name, const char *filt_expr) -{ - filter_def *filt; - - filt = (filter_def *) g_malloc(sizeof(filter_def)); - filt->name = g_strdup(filt_name); - filt->strval = g_strdup(filt_expr); - return g_list_append(fl, filt); -} - -static void -free_filter_entry(gpointer data) -{ - filter_def *filt = (filter_def*)data; - g_free(filt->name); - g_free(filt->strval); - g_free(filt); -} - -void free_filter_lists(void) -{ - if (capture_filters) { - g_list_free_full(capture_filters, free_filter_entry); - capture_filters = NULL; - } - if (display_filters) { - g_list_free_full(display_filters, free_filter_entry); - display_filters = NULL; - } - if (capture_edited_filters) { - g_list_free_full(capture_edited_filters, free_filter_entry); - capture_edited_filters = NULL; - } - if (display_edited_filters) { - g_list_free_full(display_edited_filters, free_filter_entry); - display_edited_filters = NULL; - } -} - -static GList * -remove_filter_entry(GList *fl, GList *fl_entry) -{ - filter_def *filt; - - filt = (filter_def *) fl_entry->data; - g_free(filt->name); - g_free(filt->strval); - g_free(filt); - return g_list_remove_link(fl, fl_entry); -} - -static int -skip_whitespace(FILE *ff) -{ - int c; - - while ((c = getc(ff)) != EOF && c != '\n' && g_ascii_isspace(c)) - ; - return c; -} - -static int -getc_crlf(FILE *ff) -{ - int c; - - c = getc(ff); - if (c == '\r') { - /* Treat CR-LF at the end of a line like LF, so that if we're reading - * a Windows-format file on UN*X, we handle it the same way we'd handle - * a UN*X-format file. */ - c = getc(ff); - if (c != EOF && c != '\n') { - /* Put back the character after the CR, and process the CR normally. */ - ungetc(c, ff); - c = '\r'; - } - } - return c; -} - -void -read_filter_list(filter_list_type_t list_type, char **pref_path_return, - int *errno_return) -{ - const char *ff_name; - char *ff_path; - FILE *ff; - GList **flpp; - int c; - char *filt_name, *filt_expr; - int filt_name_len, filt_expr_len; - int filt_name_index, filt_expr_index; - int line = 1; - - *pref_path_return = NULL; /* assume no error */ - - switch (list_type) { - - case CFILTER_LIST: - ff_name = CFILTER_FILE_NAME; - flpp = &capture_filters; - break; - - case DFILTER_LIST: - ff_name = DFILTER_FILE_NAME; - flpp = &display_filters; - break; - - default: - g_assert_not_reached(); - return; - } - - /* try to open personal "cfilters"/"dfilters" file */ - ff_path = get_persconffile_path(ff_name, TRUE); - if ((ff = ws_fopen(ff_path, "r")) == NULL) { - /* - * Did that fail because the file didn't exist? - */ - if (errno != ENOENT) { - /* - * No. Just give up. - */ - *pref_path_return = ff_path; - *errno_return = errno; - return; - } - - /* - * Yes. See if there's an "old style" personal "filters" file; if so, read it. - * This means that a user will start out with their capture and - * display filter lists being identical; each list may contain - * filters that don't belong in that list. The user can edit - * the filter lists, and delete the ones that don't belong in - * a particular list. - */ - g_free(ff_path); - ff_path = get_persconffile_path(FILTER_FILE_NAME, FALSE); - if ((ff = ws_fopen(ff_path, "r")) == NULL) { - /* - * Did that fail because the file didn't exist? - */ - if (errno != ENOENT) { - /* - * No. Just give up. - */ - *pref_path_return = ff_path; - *errno_return = errno; - return; - } - - /* - * Try to open the global "cfilters/dfilters" file */ - g_free(ff_path); - ff_path = get_datafile_path(ff_name); - if ((ff = ws_fopen(ff_path, "r")) == NULL) { - - /* - * Well, that didn't work, either. Just give up. - * Return an error if the file existed but we couldn't open it. - */ - if (errno != ENOENT) { - *pref_path_return = ff_path; - *errno_return = errno; - } else { - g_free(ff_path); - } - return; - } - } - } - - /* If we already have a list of filters, discard it. */ - /* this should never happen - this function is called only once for each list! */ - while(*flpp) { - *flpp = remove_filter_entry(*flpp, g_list_first(*flpp)); - } - - /* Allocate the filter name buffer. */ - filt_name_len = INIT_BUF_SIZE; - filt_name = (char *)g_malloc(filt_name_len + 1); - filt_expr_len = INIT_BUF_SIZE; - filt_expr = (char *)g_malloc(filt_expr_len + 1); - - for (line = 1; ; line++) { - /* Lines in a filter file are of the form - - "name" expression - - where "name" is a name, in quotes - backslashes in the name - escape the next character, so quotes and backslashes can appear - in the name - and "expression" is a filter expression, not in - quotes, running to the end of the line. */ - - /* Skip over leading white space, if any. */ - c = skip_whitespace(ff); - - if (c == EOF) - break; /* Nothing more to read */ - if (c == '\n') - continue; /* Blank line. */ - - /* "c" is the first non-white-space character. - If it's not a quote, it's an error. */ - if (c != '"') { - g_warning("'%s' line %d doesn't have a quoted filter name.", ff_path, - line); - while (c != '\n') - c = getc(ff); /* skip to the end of the line */ - continue; - } - - /* Get the name of the filter. */ - filt_name_index = 0; - for (;;) { - c = getc_crlf(ff); - if (c == EOF || c == '\n') - break; /* End of line - or end of file */ - if (c == '"') { - /* Closing quote. */ - if (filt_name_index >= filt_name_len) { - /* Filter name buffer isn't long enough; double its length. */ - filt_name_len *= 2; - filt_name = (char *)g_realloc(filt_name, filt_name_len + 1); - } - filt_name[filt_name_index] = '\0'; - break; - } - if (c == '\\') { - /* Next character is escaped */ - c = getc_crlf(ff); - if (c == EOF || c == '\n') - break; /* End of line - or end of file */ - } - /* Add this character to the filter name string. */ - if (filt_name_index >= filt_name_len) { - /* Filter name buffer isn't long enough; double its length. */ - filt_name_len *= 2; - filt_name = (char *)g_realloc(filt_name, filt_name_len + 1); - } - filt_name[filt_name_index] = c; - filt_name_index++; - } - - if (c == EOF) { - if (!ferror(ff)) { - /* EOF, not error; no newline seen before EOF */ - g_warning("'%s' line %d doesn't have a newline.", ff_path, - line); - } - break; /* nothing more to read */ - } - - if (c != '"') { - /* No newline seen before end-of-line */ - g_warning("'%s' line %d doesn't have a closing quote.", ff_path, - line); - continue; - } - - /* Skip over separating white space, if any. */ - c = skip_whitespace(ff); - - if (c == EOF) { - if (!ferror(ff)) { - /* EOF, not error; no newline seen before EOF */ - g_warning("'%s' line %d doesn't have a newline.", ff_path, - line); - } - break; /* nothing more to read */ - } - - if (c == '\n') { - /* No filter expression */ - g_warning("'%s' line %d doesn't have a filter expression.", ff_path, - line); - continue; - } - - /* "c" is the first non-white-space character; it's the first - character of the filter expression. */ - filt_expr_index = 0; - for (;;) { - /* Add this character to the filter expression string. */ - if (filt_expr_index >= filt_expr_len) { - /* Filter expressioin buffer isn't long enough; double its length. */ - filt_expr_len *= 2; - filt_expr = (char *)g_realloc(filt_expr, filt_expr_len + 1); - } - filt_expr[filt_expr_index] = c; - filt_expr_index++; - - /* Get the next character. */ - c = getc_crlf(ff); - if (c == EOF || c == '\n') - break; - } - - if (c == EOF) { - if (!ferror(ff)) { - /* EOF, not error; no newline seen before EOF */ - g_warning("'%s' line %d doesn't have a newline.", ff_path, - line); - } - break; /* nothing more to read */ - } - - /* We saw the ending newline; terminate the filter expression string */ - if (filt_expr_index >= filt_expr_len) { - /* Filter expressioin buffer isn't long enough; double its length. */ - filt_expr_len *= 2; - filt_expr = (char *)g_realloc(filt_expr, filt_expr_len + 1); - } - filt_expr[filt_expr_index] = '\0'; - - /* Add the new filter to the list of filters */ - *flpp = add_filter_entry(*flpp, filt_name, filt_expr); - } - if (ferror(ff)) { - *pref_path_return = ff_path; - *errno_return = errno; - } else - g_free(ff_path); - fclose(ff); - g_free(filt_name); - g_free(filt_expr); - - /* init the corresponding edited list */ - switch (list_type) { - case CFILTER_LIST: - copy_filter_list(CFILTER_EDITED_LIST, CFILTER_LIST); - break; - case DFILTER_LIST: - copy_filter_list(DFILTER_EDITED_LIST, DFILTER_LIST); - break; - default: - g_assert_not_reached(); - return; - } -} - -/* - * Get a pointer to a list of filters. - */ -static GList ** -get_filter_list(filter_list_type_t list_type) -{ - GList **flpp; - - switch (list_type) { - - case CFILTER_LIST: - flpp = &capture_filters; - break; - - case DFILTER_LIST: - flpp = &display_filters; - break; - - case CFILTER_EDITED_LIST: - flpp = &capture_edited_filters; - break; - - case DFILTER_EDITED_LIST: - flpp = &display_edited_filters; - break; - - default: - g_assert_not_reached(); - flpp = NULL; - } - return flpp; -} - -/* - * Get a pointer to the first entry in a filter list. - */ -GList * -get_filter_list_first(filter_list_type_t list_type) -{ - GList **flpp; - - flpp = get_filter_list(list_type); - return g_list_first(*flpp); -} - -/* - * Add a new filter to the end of a list. - * Returns a pointer to the newly-added entry. - */ -GList * -add_to_filter_list(filter_list_type_t list_type, const char *name, - const char *expression) -{ - GList **flpp; - - flpp = get_filter_list(list_type); - *flpp = add_filter_entry(*flpp, name, expression); - - return g_list_last(*flpp); -} - -/* - * Remove a filter from a list. - */ -void -remove_from_filter_list(filter_list_type_t list_type, GList *fl_entry) -{ - GList **flpp; - - flpp = get_filter_list(list_type); - *flpp = remove_filter_entry(*flpp, fl_entry); -} - -/* - * Write out a list of filters. - * - * On success, "*pref_path_return" is set to NULL. - * On error, "*pref_path_return" is set to point to the pathname of - * the file we tried to read - it should be freed by our caller - - * and "*errno_return" is set to the error. - */ -void -save_filter_list(filter_list_type_t list_type, char **pref_path_return, - int *errno_return) -{ - const gchar *ff_name; - gchar *ff_path, *ff_path_new; - GList *fl; - GList *flpp; - filter_def *filt; - FILE *ff; - guchar *p, c; - - *pref_path_return = NULL; /* assume no error */ - - switch (list_type) { - - case CFILTER_LIST: - ff_name = CFILTER_FILE_NAME; - fl = capture_filters; - break; - - case DFILTER_LIST: - ff_name = DFILTER_FILE_NAME; - fl = display_filters; - break; - - default: - g_assert_not_reached(); - return; - } - - ff_path = get_persconffile_path(ff_name, TRUE); - - /* Write to "XXX.new", and rename if that succeeds. - That means we don't trash the file if we fail to write it out - completely. */ - ff_path_new = g_strdup_printf("%s.new", ff_path); - - if ((ff = ws_fopen(ff_path_new, "w")) == NULL) { - *pref_path_return = ff_path; - *errno_return = errno; - g_free(ff_path_new); - return; - } - flpp = g_list_first(fl); - while (flpp) { - filt = (filter_def *) flpp->data; - - /* Write out the filter name as a quoted string; escape any quotes - or backslashes. */ - putc('"', ff); - for (p = (guchar *)filt->name; (c = *p) != '\0'; p++) { - if (c == '"' || c == '\\') - putc('\\', ff); - putc(c, ff); - } - putc('"', ff); - - /* Separate the filter name and value with a space. */ - putc(' ', ff); - - /* Write out the filter expression and a newline. */ - fprintf(ff, "%s\n", filt->strval); - if (ferror(ff)) { - *pref_path_return = ff_path; - *errno_return = errno; - fclose(ff); - ws_unlink(ff_path_new); - g_free(ff_path_new); - return; - } - flpp = flpp->next; - } - if (fclose(ff) == EOF) { - *pref_path_return = ff_path; - *errno_return = errno; - ws_unlink(ff_path_new); - g_free(ff_path_new); - return; - } - -#ifdef _WIN32 - /* ANSI C doesn't say whether "rename()" removes the target if it - exists; the Win32 call to rename files doesn't do so, which I - infer is the reason why the MSVC++ "rename()" doesn't do so. - We must therefore remove the target file first, on Windows. - - XXX - ws_rename() should be ws_stdio_rename() on Windows, - and ws_stdio_rename() uses MoveFileEx() with MOVEFILE_REPLACE_EXISTING, - so it should remove the target if it exists, so this stuff - shouldn't be necessary. Perhaps it dates back to when we were - calling rename(), with that being a wrapper around Microsoft's - _rename(), which didn't remove the target. */ - if (ws_remove(ff_path) < 0 && errno != ENOENT) { - /* It failed for some reason other than "it's not there"; if - it's not there, we don't need to remove it, so we just - drive on. */ - *pref_path_return = ff_path; - *errno_return = errno; - ws_unlink(ff_path_new); - g_free(ff_path_new); - return; - } -#endif - - if (ws_rename(ff_path_new, ff_path) < 0) { - *pref_path_return = ff_path; - *errno_return = errno; - ws_unlink(ff_path_new); - g_free(ff_path_new); - return; - } - g_free(ff_path_new); - g_free(ff_path); -} - -/* - * Copy a filter list into another. - */ -void copy_filter_list(filter_list_type_t dest_type, filter_list_type_t src_type) -{ - GList **flpp_dest; - GList **flpp_src; - GList *flp_src; - filter_def *filt; - - g_assert(dest_type != src_type); - - flpp_dest = get_filter_list(dest_type); - flpp_src = get_filter_list(src_type); - /* throw away the "old" destination list - a NULL list is ok here */ - while(*flpp_dest) { - *flpp_dest = remove_filter_entry(*flpp_dest, g_list_first(*flpp_dest)); - } - g_assert(g_list_length(*flpp_dest) == 0); - - /* copy the list entries */ - for(flp_src = g_list_first(*flpp_src); flp_src; flp_src = g_list_next(flp_src)) { - filt = (filter_def *)(flp_src->data); - - *flpp_dest = add_filter_entry(*flpp_dest, filt->name, filt->strval); - } -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local Variables: - * c-basic-offset: 2 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * ex: set shiftwidth=2 tabstop=8 expandtab: - * :indentSize=2:tabSize=8:noTabs=true: - */ diff --git a/filter_files.h b/filter_files.h deleted file mode 100644 index 9907fe7513..0000000000 --- a/filter_files.h +++ /dev/null @@ -1,114 +0,0 @@ -/* filters.h - * Declarations of routines for reading and writing the filters file. - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __UI_FILTERS_H__ -#define __UI_FILTERS_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * Filter lists. - */ -typedef enum { - CFILTER_LIST, /* capture filter list - saved */ - DFILTER_LIST, /* display filter list - saved */ - CFILTER_EDITED_LIST, /* capture filter list - currently edited. GTK+ only. */ - DFILTER_EDITED_LIST /* display filter list - currently edited. GTK+ only. */ -} filter_list_type_t; - -/* - * Item in a list of filters. - */ -typedef struct { - char *name; /* filter name */ - char *strval; /* filter expression */ -} filter_def; - -/* - * Read in a list of filters. - * - * On success, "*pref_path_return" is set to NULL. - * On error, "*pref_path_return" is set to point to the pathname of - * the file we tried to read - it should be freed by our caller - - * and "*errno_return" is set to the error. - */ -void read_filter_list(filter_list_type_t list_type, char **pref_path_return, - int *errno_return); - -/* - * Get a pointer to the first entry in a filter list. - */ -GList *get_filter_list_first(filter_list_type_t list); - -/* - * Add a new filter to the end of a list. - * Returns a pointer to the newly-added entry. - */ -GList *add_to_filter_list(filter_list_type_t list, const char *name, - const char *expression); - -/* - * Remove a filter from a list. - */ -void remove_from_filter_list(filter_list_type_t list, GList *fl_entry); - -/* - * Write out a list of filters. - * - * On success, "*pref_path_return" is set to NULL. - * On error, "*pref_path_return" is set to point to the pathname of - * the file we tried to read - it should be freed by our caller - - * and "*errno_return" is set to the error. - */ -void save_filter_list(filter_list_type_t list_type, char **pref_path_return, - int *errno_return); - -/* - * Clone the filter list so it can be edited. GTK+ only. - */ -void copy_filter_list(filter_list_type_t dest_type, filter_list_type_t src_type); - -/* - * Free all filter lists - */ -void free_filter_lists(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __UI_FILTERS_H__ */ - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local Variables: - * c-basic-offset: 2 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=2 tabstop=8 expandtab: - * :indentSize=2:tabSize=8:noTabs=true: - */ diff --git a/sharkd.c b/sharkd.c index 3b10167338..30df444d84 100644 --- a/sharkd.c +++ b/sharkd.c @@ -59,9 +59,9 @@ #include "ui/util.h" #include "ui/ui_util.h" #include "ui/decode_as_utils.h" +#include "ui/filter_files.h" #include "ui/tap_export_pdu.h" #include "register.h" -#include "filter_files.h" #include #include diff --git a/tshark.c b/tshark.c index b3149cb6a3..19af646675 100644 --- a/tshark.c +++ b/tshark.c @@ -84,6 +84,7 @@ #include "ui/util.h" #include "ui/ui_util.h" #include "ui/decode_as_utils.h" +#include "ui/filter_files.h" #include "ui/cli/tshark-tap.h" #include "ui/cli/tap-exportobject.h" #include "ui/tap_export_pdu.h" @@ -95,7 +96,6 @@ #include "epan/geoip_db.h" #endif #include "register.h" -#include "filter_files.h" #include #include #include diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index 5bd5ec051c..b15a4dcf21 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -31,6 +31,7 @@ set(COMMON_UI_SRC export_object_ui.c export_pdu_ui_utils.c help_url.c + filter_files.c firewall_rules.c iface_lists.c io_graph_item.c diff --git a/ui/Makefile.am b/ui/Makefile.am index 3507f9acbd..58166e1812 100644 --- a/ui/Makefile.am +++ b/ui/Makefile.am @@ -57,6 +57,7 @@ WIRESHARK_UI_SRC = \ dissect_opts.c \ export_object_ui.c \ export_pdu_ui_utils.c \ + filter_files.c \ firewall_rules.c \ iface_lists.c \ io_graph_item.c \ @@ -101,6 +102,7 @@ WIRESHARK_UI_INCLUDES = \ export_pdu_ui_utils.h \ last_open_dir.h \ file_dialog.h \ + filter_files.h \ help_url.h \ packet_list_utils.h \ firewall_rules.h \ diff --git a/ui/filter_files.c b/ui/filter_files.c new file mode 100644 index 0000000000..e58072221b --- /dev/null +++ b/ui/filter_files.c @@ -0,0 +1,662 @@ +/* filter_files.c + * Code for reading and writing the filters file. + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include "ui/filter_files.h" + +/* + * Old filter file name. + */ +#define FILTER_FILE_NAME "filters" + +/* + * Capture filter file name. + */ +#define CFILTER_FILE_NAME "cfilters" + +/* + * Display filter file name. + */ +#define DFILTER_FILE_NAME "dfilters" + +/* + * List of capture filters - saved. + */ +static GList *capture_filters = NULL; + +/* + * List of display filters - saved. + */ +static GList *display_filters = NULL; + +/* + * List of capture filters - currently edited. + */ +static GList *capture_edited_filters = NULL; + +/* + * List of display filters - currently edited. + */ +static GList *display_edited_filters = NULL; + +/* + * Read in a list of filters. + * + * On success, "*pref_path_return" is set to NULL. + * On error, "*pref_path_return" is set to point to the pathname of + * the file we tried to read - it should be freed by our caller - + * and "*errno_return" is set to the error. + */ + +#define INIT_BUF_SIZE 128 + +static GList * +add_filter_entry(GList *fl, const char *filt_name, const char *filt_expr) +{ + filter_def *filt; + + filt = (filter_def *) g_malloc(sizeof(filter_def)); + filt->name = g_strdup(filt_name); + filt->strval = g_strdup(filt_expr); + return g_list_append(fl, filt); +} + +static void +free_filter_entry(gpointer data) +{ + filter_def *filt = (filter_def*)data; + g_free(filt->name); + g_free(filt->strval); + g_free(filt); +} + +void free_filter_lists(void) +{ + if (capture_filters) { + g_list_free_full(capture_filters, free_filter_entry); + capture_filters = NULL; + } + if (display_filters) { + g_list_free_full(display_filters, free_filter_entry); + display_filters = NULL; + } + if (capture_edited_filters) { + g_list_free_full(capture_edited_filters, free_filter_entry); + capture_edited_filters = NULL; + } + if (display_edited_filters) { + g_list_free_full(display_edited_filters, free_filter_entry); + display_edited_filters = NULL; + } +} + +static GList * +remove_filter_entry(GList *fl, GList *fl_entry) +{ + filter_def *filt; + + filt = (filter_def *) fl_entry->data; + g_free(filt->name); + g_free(filt->strval); + g_free(filt); + return g_list_remove_link(fl, fl_entry); +} + +static int +skip_whitespace(FILE *ff) +{ + int c; + + while ((c = getc(ff)) != EOF && c != '\n' && g_ascii_isspace(c)) + ; + return c; +} + +static int +getc_crlf(FILE *ff) +{ + int c; + + c = getc(ff); + if (c == '\r') { + /* Treat CR-LF at the end of a line like LF, so that if we're reading + * a Windows-format file on UN*X, we handle it the same way we'd handle + * a UN*X-format file. */ + c = getc(ff); + if (c != EOF && c != '\n') { + /* Put back the character after the CR, and process the CR normally. */ + ungetc(c, ff); + c = '\r'; + } + } + return c; +} + +void +read_filter_list(filter_list_type_t list_type, char **pref_path_return, + int *errno_return) +{ + const char *ff_name; + char *ff_path; + FILE *ff; + GList **flpp; + int c; + char *filt_name, *filt_expr; + int filt_name_len, filt_expr_len; + int filt_name_index, filt_expr_index; + int line = 1; + + *pref_path_return = NULL; /* assume no error */ + + switch (list_type) { + + case CFILTER_LIST: + ff_name = CFILTER_FILE_NAME; + flpp = &capture_filters; + break; + + case DFILTER_LIST: + ff_name = DFILTER_FILE_NAME; + flpp = &display_filters; + break; + + default: + g_assert_not_reached(); + return; + } + + /* try to open personal "cfilters"/"dfilters" file */ + ff_path = get_persconffile_path(ff_name, TRUE); + if ((ff = ws_fopen(ff_path, "r")) == NULL) { + /* + * Did that fail because the file didn't exist? + */ + if (errno != ENOENT) { + /* + * No. Just give up. + */ + *pref_path_return = ff_path; + *errno_return = errno; + return; + } + + /* + * Yes. See if there's an "old style" personal "filters" file; if so, read it. + * This means that a user will start out with their capture and + * display filter lists being identical; each list may contain + * filters that don't belong in that list. The user can edit + * the filter lists, and delete the ones that don't belong in + * a particular list. + */ + g_free(ff_path); + ff_path = get_persconffile_path(FILTER_FILE_NAME, FALSE); + if ((ff = ws_fopen(ff_path, "r")) == NULL) { + /* + * Did that fail because the file didn't exist? + */ + if (errno != ENOENT) { + /* + * No. Just give up. + */ + *pref_path_return = ff_path; + *errno_return = errno; + return; + } + + /* + * Try to open the global "cfilters/dfilters" file */ + g_free(ff_path); + ff_path = get_datafile_path(ff_name); + if ((ff = ws_fopen(ff_path, "r")) == NULL) { + + /* + * Well, that didn't work, either. Just give up. + * Return an error if the file existed but we couldn't open it. + */ + if (errno != ENOENT) { + *pref_path_return = ff_path; + *errno_return = errno; + } else { + g_free(ff_path); + } + return; + } + } + } + + /* If we already have a list of filters, discard it. */ + /* this should never happen - this function is called only once for each list! */ + while(*flpp) { + *flpp = remove_filter_entry(*flpp, g_list_first(*flpp)); + } + + /* Allocate the filter name buffer. */ + filt_name_len = INIT_BUF_SIZE; + filt_name = (char *)g_malloc(filt_name_len + 1); + filt_expr_len = INIT_BUF_SIZE; + filt_expr = (char *)g_malloc(filt_expr_len + 1); + + for (line = 1; ; line++) { + /* Lines in a filter file are of the form + + "name" expression + + where "name" is a name, in quotes - backslashes in the name + escape the next character, so quotes and backslashes can appear + in the name - and "expression" is a filter expression, not in + quotes, running to the end of the line. */ + + /* Skip over leading white space, if any. */ + c = skip_whitespace(ff); + + if (c == EOF) + break; /* Nothing more to read */ + if (c == '\n') + continue; /* Blank line. */ + + /* "c" is the first non-white-space character. + If it's not a quote, it's an error. */ + if (c != '"') { + g_warning("'%s' line %d doesn't have a quoted filter name.", ff_path, + line); + while (c != '\n') + c = getc(ff); /* skip to the end of the line */ + continue; + } + + /* Get the name of the filter. */ + filt_name_index = 0; + for (;;) { + c = getc_crlf(ff); + if (c == EOF || c == '\n') + break; /* End of line - or end of file */ + if (c == '"') { + /* Closing quote. */ + if (filt_name_index >= filt_name_len) { + /* Filter name buffer isn't long enough; double its length. */ + filt_name_len *= 2; + filt_name = (char *)g_realloc(filt_name, filt_name_len + 1); + } + filt_name[filt_name_index] = '\0'; + break; + } + if (c == '\\') { + /* Next character is escaped */ + c = getc_crlf(ff); + if (c == EOF || c == '\n') + break; /* End of line - or end of file */ + } + /* Add this character to the filter name string. */ + if (filt_name_index >= filt_name_len) { + /* Filter name buffer isn't long enough; double its length. */ + filt_name_len *= 2; + filt_name = (char *)g_realloc(filt_name, filt_name_len + 1); + } + filt_name[filt_name_index] = c; + filt_name_index++; + } + + if (c == EOF) { + if (!ferror(ff)) { + /* EOF, not error; no newline seen before EOF */ + g_warning("'%s' line %d doesn't have a newline.", ff_path, + line); + } + break; /* nothing more to read */ + } + + if (c != '"') { + /* No newline seen before end-of-line */ + g_warning("'%s' line %d doesn't have a closing quote.", ff_path, + line); + continue; + } + + /* Skip over separating white space, if any. */ + c = skip_whitespace(ff); + + if (c == EOF) { + if (!ferror(ff)) { + /* EOF, not error; no newline seen before EOF */ + g_warning("'%s' line %d doesn't have a newline.", ff_path, + line); + } + break; /* nothing more to read */ + } + + if (c == '\n') { + /* No filter expression */ + g_warning("'%s' line %d doesn't have a filter expression.", ff_path, + line); + continue; + } + + /* "c" is the first non-white-space character; it's the first + character of the filter expression. */ + filt_expr_index = 0; + for (;;) { + /* Add this character to the filter expression string. */ + if (filt_expr_index >= filt_expr_len) { + /* Filter expressioin buffer isn't long enough; double its length. */ + filt_expr_len *= 2; + filt_expr = (char *)g_realloc(filt_expr, filt_expr_len + 1); + } + filt_expr[filt_expr_index] = c; + filt_expr_index++; + + /* Get the next character. */ + c = getc_crlf(ff); + if (c == EOF || c == '\n') + break; + } + + if (c == EOF) { + if (!ferror(ff)) { + /* EOF, not error; no newline seen before EOF */ + g_warning("'%s' line %d doesn't have a newline.", ff_path, + line); + } + break; /* nothing more to read */ + } + + /* We saw the ending newline; terminate the filter expression string */ + if (filt_expr_index >= filt_expr_len) { + /* Filter expressioin buffer isn't long enough; double its length. */ + filt_expr_len *= 2; + filt_expr = (char *)g_realloc(filt_expr, filt_expr_len + 1); + } + filt_expr[filt_expr_index] = '\0'; + + /* Add the new filter to the list of filters */ + *flpp = add_filter_entry(*flpp, filt_name, filt_expr); + } + if (ferror(ff)) { + *pref_path_return = ff_path; + *errno_return = errno; + } else + g_free(ff_path); + fclose(ff); + g_free(filt_name); + g_free(filt_expr); + + /* init the corresponding edited list */ + switch (list_type) { + case CFILTER_LIST: + copy_filter_list(CFILTER_EDITED_LIST, CFILTER_LIST); + break; + case DFILTER_LIST: + copy_filter_list(DFILTER_EDITED_LIST, DFILTER_LIST); + break; + default: + g_assert_not_reached(); + return; + } +} + +/* + * Get a pointer to a list of filters. + */ +static GList ** +get_filter_list(filter_list_type_t list_type) +{ + GList **flpp; + + switch (list_type) { + + case CFILTER_LIST: + flpp = &capture_filters; + break; + + case DFILTER_LIST: + flpp = &display_filters; + break; + + case CFILTER_EDITED_LIST: + flpp = &capture_edited_filters; + break; + + case DFILTER_EDITED_LIST: + flpp = &display_edited_filters; + break; + + default: + g_assert_not_reached(); + flpp = NULL; + } + return flpp; +} + +/* + * Get a pointer to the first entry in a filter list. + */ +GList * +get_filter_list_first(filter_list_type_t list_type) +{ + GList **flpp; + + flpp = get_filter_list(list_type); + return g_list_first(*flpp); +} + +/* + * Add a new filter to the end of a list. + * Returns a pointer to the newly-added entry. + */ +GList * +add_to_filter_list(filter_list_type_t list_type, const char *name, + const char *expression) +{ + GList **flpp; + + flpp = get_filter_list(list_type); + *flpp = add_filter_entry(*flpp, name, expression); + + return g_list_last(*flpp); +} + +/* + * Remove a filter from a list. + */ +void +remove_from_filter_list(filter_list_type_t list_type, GList *fl_entry) +{ + GList **flpp; + + flpp = get_filter_list(list_type); + *flpp = remove_filter_entry(*flpp, fl_entry); +} + +/* + * Write out a list of filters. + * + * On success, "*pref_path_return" is set to NULL. + * On error, "*pref_path_return" is set to point to the pathname of + * the file we tried to read - it should be freed by our caller - + * and "*errno_return" is set to the error. + */ +void +save_filter_list(filter_list_type_t list_type, char **pref_path_return, + int *errno_return) +{ + const gchar *ff_name; + gchar *ff_path, *ff_path_new; + GList *fl; + GList *flpp; + filter_def *filt; + FILE *ff; + guchar *p, c; + + *pref_path_return = NULL; /* assume no error */ + + switch (list_type) { + + case CFILTER_LIST: + ff_name = CFILTER_FILE_NAME; + fl = capture_filters; + break; + + case DFILTER_LIST: + ff_name = DFILTER_FILE_NAME; + fl = display_filters; + break; + + default: + g_assert_not_reached(); + return; + } + + ff_path = get_persconffile_path(ff_name, TRUE); + + /* Write to "XXX.new", and rename if that succeeds. + That means we don't trash the file if we fail to write it out + completely. */ + ff_path_new = g_strdup_printf("%s.new", ff_path); + + if ((ff = ws_fopen(ff_path_new, "w")) == NULL) { + *pref_path_return = ff_path; + *errno_return = errno; + g_free(ff_path_new); + return; + } + flpp = g_list_first(fl); + while (flpp) { + filt = (filter_def *) flpp->data; + + /* Write out the filter name as a quoted string; escape any quotes + or backslashes. */ + putc('"', ff); + for (p = (guchar *)filt->name; (c = *p) != '\0'; p++) { + if (c == '"' || c == '\\') + putc('\\', ff); + putc(c, ff); + } + putc('"', ff); + + /* Separate the filter name and value with a space. */ + putc(' ', ff); + + /* Write out the filter expression and a newline. */ + fprintf(ff, "%s\n", filt->strval); + if (ferror(ff)) { + *pref_path_return = ff_path; + *errno_return = errno; + fclose(ff); + ws_unlink(ff_path_new); + g_free(ff_path_new); + return; + } + flpp = flpp->next; + } + if (fclose(ff) == EOF) { + *pref_path_return = ff_path; + *errno_return = errno; + ws_unlink(ff_path_new); + g_free(ff_path_new); + return; + } + +#ifdef _WIN32 + /* ANSI C doesn't say whether "rename()" removes the target if it + exists; the Win32 call to rename files doesn't do so, which I + infer is the reason why the MSVC++ "rename()" doesn't do so. + We must therefore remove the target file first, on Windows. + + XXX - ws_rename() should be ws_stdio_rename() on Windows, + and ws_stdio_rename() uses MoveFileEx() with MOVEFILE_REPLACE_EXISTING, + so it should remove the target if it exists, so this stuff + shouldn't be necessary. Perhaps it dates back to when we were + calling rename(), with that being a wrapper around Microsoft's + _rename(), which didn't remove the target. */ + if (ws_remove(ff_path) < 0 && errno != ENOENT) { + /* It failed for some reason other than "it's not there"; if + it's not there, we don't need to remove it, so we just + drive on. */ + *pref_path_return = ff_path; + *errno_return = errno; + ws_unlink(ff_path_new); + g_free(ff_path_new); + return; + } +#endif + + if (ws_rename(ff_path_new, ff_path) < 0) { + *pref_path_return = ff_path; + *errno_return = errno; + ws_unlink(ff_path_new); + g_free(ff_path_new); + return; + } + g_free(ff_path_new); + g_free(ff_path); +} + +/* + * Copy a filter list into another. + */ +void copy_filter_list(filter_list_type_t dest_type, filter_list_type_t src_type) +{ + GList **flpp_dest; + GList **flpp_src; + GList *flp_src; + filter_def *filt; + + g_assert(dest_type != src_type); + + flpp_dest = get_filter_list(dest_type); + flpp_src = get_filter_list(src_type); + /* throw away the "old" destination list - a NULL list is ok here */ + while(*flpp_dest) { + *flpp_dest = remove_filter_entry(*flpp_dest, g_list_first(*flpp_dest)); + } + g_assert(g_list_length(*flpp_dest) == 0); + + /* copy the list entries */ + for(flp_src = g_list_first(*flpp_src); flp_src; flp_src = g_list_next(flp_src)) { + filt = (filter_def *)(flp_src->data); + + *flpp_dest = add_filter_entry(*flpp_dest, filt->name, filt->strval); + } +} + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local Variables: + * c-basic-offset: 2 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=2 tabstop=8 expandtab: + * :indentSize=2:tabSize=8:noTabs=true: + */ diff --git a/ui/filter_files.h b/ui/filter_files.h new file mode 100644 index 0000000000..f953b2f506 --- /dev/null +++ b/ui/filter_files.h @@ -0,0 +1,114 @@ +/* filter_filess.h + * Declarations of routines for reading and writing the filters file. + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __UI_FILTERS_H__ +#define __UI_FILTERS_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Filter lists. + */ +typedef enum { + CFILTER_LIST, /* capture filter list - saved */ + DFILTER_LIST, /* display filter list - saved */ + CFILTER_EDITED_LIST, /* capture filter list - currently edited. GTK+ only. */ + DFILTER_EDITED_LIST /* display filter list - currently edited. GTK+ only. */ +} filter_list_type_t; + +/* + * Item in a list of filters. + */ +typedef struct { + char *name; /* filter name */ + char *strval; /* filter expression */ +} filter_def; + +/* + * Read in a list of filters. + * + * On success, "*pref_path_return" is set to NULL. + * On error, "*pref_path_return" is set to point to the pathname of + * the file we tried to read - it should be freed by our caller - + * and "*errno_return" is set to the error. + */ +void read_filter_list(filter_list_type_t list_type, char **pref_path_return, + int *errno_return); + +/* + * Get a pointer to the first entry in a filter list. + */ +GList *get_filter_list_first(filter_list_type_t list); + +/* + * Add a new filter to the end of a list. + * Returns a pointer to the newly-added entry. + */ +GList *add_to_filter_list(filter_list_type_t list, const char *name, + const char *expression); + +/* + * Remove a filter from a list. + */ +void remove_from_filter_list(filter_list_type_t list, GList *fl_entry); + +/* + * Write out a list of filters. + * + * On success, "*pref_path_return" is set to NULL. + * On error, "*pref_path_return" is set to point to the pathname of + * the file we tried to read - it should be freed by our caller - + * and "*errno_return" is set to the error. + */ +void save_filter_list(filter_list_type_t list_type, char **pref_path_return, + int *errno_return); + +/* + * Clone the filter list so it can be edited. GTK+ only. + */ +void copy_filter_list(filter_list_type_t dest_type, filter_list_type_t src_type); + +/* + * Free all filter lists + */ +void free_filter_lists(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __UI_FILTERS_H__ */ + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local Variables: + * c-basic-offset: 2 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=2 tabstop=8 expandtab: + * :indentSize=2:tabSize=8:noTabs=true: + */ diff --git a/ui/gtk/filter_dlg.c b/ui/gtk/filter_dlg.c index 9c5ec4c335..7604f078e7 100644 --- a/ui/gtk/filter_dlg.c +++ b/ui/gtk/filter_dlg.c @@ -30,7 +30,7 @@ #include #include -#include "filter_files.h" +#include "ui/filter_files.h" #include "ui/simple_dialog.h" #include "ui/main_statusbar.h" diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 197610f769..2e0d53a6f7 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -101,7 +101,7 @@ #include "ui/alert_box.h" #include "ui/console.h" #include "ui/decode_as_utils.h" -#include "filter_files.h" +#include "ui/filter_files.h" #include "ui/main_statusbar.h" #include "ui/persfilepath_opt.h" #include "ui/preference_utils.h" diff --git a/ui/qt/capture_filter_edit.cpp b/ui/qt/capture_filter_edit.cpp index 4539e86f03..89e2bd8df4 100644 --- a/ui/qt/capture_filter_edit.cpp +++ b/ui/qt/capture_filter_edit.cpp @@ -28,7 +28,7 @@ #include "capture_opts.h" #include -#include +#include #include #include "capture_filter_edit.h" diff --git a/ui/qt/display_filter_edit.cpp b/ui/qt/display_filter_edit.cpp index 15fec4aab5..97b035fc5d 100644 --- a/ui/qt/display_filter_edit.cpp +++ b/ui/qt/display_filter_edit.cpp @@ -25,7 +25,7 @@ #include -#include +#include #include diff --git a/ui/qt/field_filter_edit.cpp b/ui/qt/field_filter_edit.cpp index 8a67f67825..21e2bd8a5a 100644 --- a/ui/qt/field_filter_edit.cpp +++ b/ui/qt/field_filter_edit.cpp @@ -25,7 +25,7 @@ #include -#include +#include #include diff --git a/ui/qt/filter_dialog.cpp b/ui/qt/filter_dialog.cpp index 0c211d0ce4..9652a327dc 100644 --- a/ui/qt/filter_dialog.cpp +++ b/ui/qt/filter_dialog.cpp @@ -25,7 +25,7 @@ #include -#include +#include #include diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index a9428d534f..7f25a2138f 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -65,7 +65,7 @@ #endif #include "ui/capture.h" -#include "filter_files.h" +#include "ui/filter_files.h" #include "ui/capture_globals.h" #include "ui/software_update.h" #include "ui/last_open_dir.h" -- cgit v1.2.3