diff options
author | Guy Harris <guy@alum.mit.edu> | 2005-10-31 02:42:22 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2005-10-31 02:42:22 +0000 |
commit | cbce856e9ec5f7641f382260742404d4652dad26 (patch) | |
tree | f49c5e1975c7f6c638bd5a54423fbb5c26511080 /epan/ftypes/ftype-pcre.c | |
parent | 552ee02a937362eb3a1039b348d800d35635bd4f (diff) |
When printing the code for a display filter:
print register numbers as unsigned (they're guint32);
when printing a PUT_FVALUE instruction, show the value as well
as the type of the value.
That requires that a bunch of types get to_repr methods; add them for
PCRE (FTREPR_DFILTER-only - show the regular expression as text),
tvbuffs (FTREPR_DFILTER_only - show the data as a hex string), integral
types, string types other than FT_STRING, and FT_IPv6.
That means we can use fvalue_to_string_repr() for FT_IPXNET and FT_IPv6
in proto_construct_dfilter_string(), and that we don't need to handle
integer and floating types specially in MATE.
Fix some problems with the PCRE execution code for tvbuff types.
svn path=/trunk/; revision=16369
Diffstat (limited to 'epan/ftypes/ftype-pcre.c')
-rw-r--r-- | epan/ftypes/ftype-pcre.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/epan/ftypes/ftype-pcre.c b/epan/ftypes/ftype-pcre.c index fa0e6258f5..a35932a465 100644 --- a/epan/ftypes/ftype-pcre.c +++ b/epan/ftypes/ftype-pcre.c @@ -5,7 +5,6 @@ * By Gerald Combs <gerald@ethereal.com> * Copyright 2001 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 @@ -35,6 +34,9 @@ #include <ftypes-int.h> #ifdef HAVE_LIBPCRE + +#include <string.h> + #include <pcre.h> /* Create a pcre_tuple_t object based on the given string pattern */ @@ -138,6 +140,20 @@ val_from_unparsed(fvalue_t *fv, char *pattern, gboolean allow_partial_value _U_, return TRUE; } +static int +pcre_repr_len(fvalue_t *fv, ftrepr_t rtype) +{ + g_assert(rtype == FTREPR_DFILTER); + return strlen(fv->value.re->string); +} + +static void +pcre_to_repr(fvalue_t *fv, ftrepr_t rtype, char *buf) +{ + g_assert(rtype == FTREPR_DFILTER); + strcpy(buf, fv->value.re->string); +} + /* BEHOLD - value contains the string representation of the regular expression, * and we want to store the compiled PCRE RE object into the value. */ static void @@ -167,8 +183,8 @@ ftype_register_pcre(void) pcre_fvalue_free, /* free_value */ val_from_unparsed, /* val_from_unparsed */ val_from_string, /* val_from_string */ - NULL, /* val_to_string_repr */ - NULL, /* len_string_repr */ + pcre_to_repr, /* val_to_string_repr */ + pcre_repr_len, /* len_string_repr */ pcre_fvalue_set, /* set_value */ NULL, /* set_value_integer */ |