aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dfilter
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-08-21 17:12:39 -0700
committerGerald Combs <gerald@wireshark.org>2015-08-22 01:51:04 +0000
commitee80be6dac02979bc10b7c1ccc8735525a983f63 (patch)
tree6958bf9fda0fca462da8e1b316ebbc46bcae78fd /epan/dfilter
parent97014f6d6b1b3994f44421fc28ed2c151977f6a0 (diff)
Add the display filter macros dialog.
Add some missing functionality to UatDialog. Remove what appears to be unused dfilter macro code. Change-Id: I8a8d6358523f24d5ddfe953d7741fe9af25d98eb Reviewed-on: https://code.wireshark.org/review/10187 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan/dfilter')
-rw-r--r--epan/dfilter/dfilter-macro.c66
-rw-r--r--epan/dfilter/dfilter-macro.h22
2 files changed, 14 insertions, 74 deletions
diff --git a/epan/dfilter/dfilter-macro.c b/epan/dfilter/dfilter-macro.c
index 443124cf94..cd33b50a7e 100644
--- a/epan/dfilter/dfilter-macro.c
+++ b/epan/dfilter/dfilter-macro.c
@@ -90,62 +90,6 @@ void dfilter_macro_build_ftv_cache(void* tree_root) {
proto_tree_traverse_post_order((proto_tree *)tree_root, fvt_cache_cb, NULL);
}
-void dfilter_macro_foreach(dfilter_macro_cb_t cb, void* data) {
- guint i;
-
- for (i = 0; i < num_macros; i++) {
- cb(&(macros[i]),data);
- }
- return;
-}
-
-static void macro_fprint(dfilter_macro_t* m, void* ud) {
- FILE* f = (FILE*)ud;
-
- fprintf(f,"%s\t%s\n",m->name,m->text);
-}
-
-void dfilter_macro_save(const gchar* filename, gchar** error) {
- FILE* f = ws_fopen(filename,"w");
-
- if (!f) {
- if (error != NULL)
- *error = g_strdup_printf("Could not open file: '%s', error: %s\n", filename, g_strerror(errno) );
- return;
- }
-
- dfilter_macro_foreach(macro_fprint, f);
-
- fclose(f);
-
- return;
-}
-
-#ifdef DUMP_MACROS
-static void macro_dump(dfilter_macro_t* m _U_, void* ud _U_) {
- gchar** part = m->parts;
- int* args_pos = m->args_pos;
-
- printf("\n->%s\t%s\t%d [%d]\n\t'%s'\n",
- m->name, m->text, m->argc, m->usable, *(part++));
-
- while (*part) {
- printf("\t$%d '%s'\n",*args_pos,*part);
-
- args_pos++;
- part++;
- }
-}
-#else
-#define macro_dump(a,b)
-#endif
-
-void dfilter_macro_dump(void) {
-#ifdef DUMP_MACROS
- dfilter_macro_foreach(macro_dump, NULL);
-#endif
-}
-
static gchar* dfilter_macro_resolve(gchar* name, gchar** args, gchar** error) {
GString* text;
int argc = 0;
@@ -488,8 +432,6 @@ done:
m->usable = TRUE;
- macro_dump(m,NULL);
-
DUMP_MACRO(m);
return TRUE;
@@ -601,11 +543,11 @@ static gboolean macro_name_chk(void *mp, const char *in_name, guint name_len,
* different name, check for uniqueness. NOTE: if a duplicate already
* exists (because the user manually edited the file), then this will
* not trigger a warning. */
- if (!m->name || !g_str_equal(m->name, in_name)) {
+ if (!m->name || g_strcmp0(m->name, in_name)) {
for (i = 0; i < num_macros; i++) {
/* This a string field which is always NUL-terminated,
* so no need to check name_len. */
- if (g_str_equal(in_name, macros[i].name)) {
+ if (!g_strcmp0(in_name, macros[i].name)) {
*error = g_strdup_printf("macro '%s' already exists",
in_name);
return FALSE;
@@ -646,8 +588,8 @@ void dfilter_macro_init(void) {
fvt_cache = g_hash_table_new(g_str_hash,g_str_equal);
}
-void dfilter_macro_get_uat(void** p) {
- *p = dfilter_macro_uat;
+void dfilter_macro_get_uat(uat_t **dfmu_ptr_ptr) {
+ *dfmu_ptr_ptr = dfilter_macro_uat;
}
#ifdef DUMP_DFILTER_MACRO
diff --git a/epan/dfilter/dfilter-macro.h b/epan/dfilter/dfilter-macro.h
index 68462529ac..89622529ab 100644
--- a/epan/dfilter/dfilter-macro.h
+++ b/epan/dfilter/dfilter-macro.h
@@ -27,6 +27,9 @@
#define DFILTER_MACRO_FILENAME "dfilter_macros"
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
typedef struct _dfilter_macro_t {
gchar* name; /* the macro id */
@@ -38,26 +41,21 @@ typedef struct _dfilter_macro_t {
void* priv; /* a copy of text that contains every c-string in parts */
} dfilter_macro_t;
-/* loop over the macros list */
-typedef void (*dfilter_macro_cb_t)(dfilter_macro_t*, void*);
-WS_DLL_PUBLIC
-void dfilter_macro_foreach(dfilter_macro_cb_t, void*);
-
-/* save dfilter macros to a file */
-void dfilter_macro_save(const gchar*, gchar**);
-
-/* dumps the macros in the list (debug info, not formated as in the macros file) */
-void dfilter_macro_dump(void);
-
/* applies all macros to the given text and returns the resulting string or NULL on failure */
const gchar* dfilter_macro_apply(const gchar* text, gchar** error);
void dfilter_macro_init(void);
+struct epan_uat;
+
WS_DLL_PUBLIC
-void dfilter_macro_get_uat(void**);
+void dfilter_macro_get_uat(struct epan_uat **dfmu_ptr_ptr);
WS_DLL_PUBLIC
void dfilter_macro_build_ftv_cache(void* tree_root);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
#endif /* _DFILTER_MACRO_H */