aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/ftypes/ftype-time.c40
-rw-r--r--epan/proto.c36
2 files changed, 39 insertions, 37 deletions
diff --git a/epan/ftypes/ftype-time.c b/epan/ftypes/ftype-time.c
index 818467a380..dd04fa6cb9 100644
--- a/epan/ftypes/ftype-time.c
+++ b/epan/ftypes/ftype-time.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-time.c,v 1.19 2003/07/25 03:44:03 gram Exp $
+ * $Id: ftype-time.c,v 1.20 2003/07/30 22:50:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -296,6 +296,36 @@ value_get(fvalue_t *fv)
{
return &(fv->value.time);
}
+
+static int
+absolute_val_repr_len(fvalue_t *fv, ftrepr_t rtype _U_)
+{
+ gchar *rep;
+
+ rep = abs_time_to_str(&fv->value.time);
+ return strlen(rep) + 2; /* 2 for opening and closing quotes */
+}
+
+static void
+absolute_val_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)
+{
+ sprintf(buf, "\"%s\"", abs_time_to_str(&fv->value.time));
+}
+
+static int
+relative_val_repr_len(fvalue_t *fv, ftrepr_t rtype _U_)
+{
+ gchar *rep;
+
+ rep = rel_time_to_secs_str(&fv->value.time);
+ return strlen(rep);
+}
+
+static void
+relative_val_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)
+{
+ strcpy(buf, rel_time_to_secs_str(&fv->value.time));
+}
void
ftype_register_time(void)
@@ -309,8 +339,8 @@ ftype_register_time(void)
NULL,
absolute_val_from_string, /* val_from_unparsed */
absolute_val_from_string, /* val_from_string */
- NULL, /* val_to_string_repr */
- NULL, /* len_string_repr */
+ absolute_val_to_repr, /* val_to_string_repr */
+ absolute_val_repr_len, /* len_string_repr */
time_fvalue_set,
NULL,
@@ -337,8 +367,8 @@ ftype_register_time(void)
NULL,
relative_val_from_unparsed, /* val_from_unparsed */
NULL, /* val_from_string */
- NULL, /* val_to_string_repr */
- NULL, /* len_string_repr */
+ relative_val_to_repr, /* val_to_string_repr */
+ relative_val_repr_len, /* len_string_repr */
time_fvalue_set,
NULL,
diff --git a/epan/proto.c b/epan/proto.c
index 716cf0de1b..c411918621 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.95 2003/07/07 20:29:45 guy Exp $
+ * $Id: proto.c,v 1.96 2003/07/30 22:50:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -3481,7 +3481,7 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt)
{
header_field_info *hfinfo;
int abbrev_len;
- char *buf, *stringified, *format, *ptr, *value_str;
+ char *buf, *stringified, *format, *ptr;
int dfilter_len, i;
gint start, length;
guint8 c;
@@ -3644,42 +3644,14 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt)
fvalue_get_floating(finfo->value));
break;
- case FT_ABSOLUTE_TIME:
- /*
- * 4 bytes for " == ".
- * N bytes for the string for the time.
- * 2 bytes for the opening and closing quotes.
- * 1 byte for the trailing '\0'.
- */
- value_str =
- abs_time_to_str((nstime_t *)fvalue_get(finfo->value));
- dfilter_len = abbrev_len + strlen(value_str) + 4 + 2 + 1;
- buf = g_malloc0(dfilter_len);
- snprintf(buf, dfilter_len, "%s == \"%s\"",
- hfinfo->abbrev, value_str);
- break;
-
- case FT_RELATIVE_TIME:
- /*
- * 4 bytes for " == ".
- * N bytes for the string for the time.
- * 1 byte for the trailing '\0'.
- */
- value_str =
- rel_time_to_secs_str((nstime_t *)fvalue_get(finfo->value));
- dfilter_len = abbrev_len + strlen(value_str) + 4 + 1;
- buf = g_malloc0(dfilter_len);
- snprintf(buf, dfilter_len, "%s == %s",
- hfinfo->abbrev, value_str);
- break;
-
-
/* These use the fvalue's "to_string_repr" method. */
case FT_BOOLEAN:
case FT_STRING:
case FT_ETHER:
case FT_BYTES:
case FT_UINT_BYTES:
+ case FT_ABSOLUTE_TIME:
+ case FT_RELATIVE_TIME:
/* Figure out the string length needed.
* The ft_repr length.
* 4 bytes for " == ".