2001-02-01 20:31:21 +00:00
|
|
|
/*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-02-01 20:31:21 +00:00
|
|
|
* Copyright 2001 Gerald Combs
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-02-01 20:31:21 +00:00
|
|
|
* 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.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-02-01 20:31:21 +00:00
|
|
|
* 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.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2001-02-01 20:31:21 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2001-02-01 20:31:21 +00:00
|
|
|
*/
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2009-08-26 19:27:49 +00:00
|
|
|
#include <stdio.h>
|
2013-11-10 15:59:37 +00:00
|
|
|
#include <stdlib.h>
|
2001-07-13 00:55:58 +00:00
|
|
|
#include <string.h>
|
2001-05-31 06:48:00 +00:00
|
|
|
|
2001-06-18 01:42:24 +00:00
|
|
|
/*
|
|
|
|
* Just make sure we include the prototype for strptime as well
|
2007-04-22 20:04:34 +00:00
|
|
|
* (needed for glibc 2.2) but make sure we do this only if not
|
|
|
|
* yet defined.
|
2001-06-18 01:42:24 +00:00
|
|
|
*/
|
2007-04-22 20:04:34 +00:00
|
|
|
#ifndef __USE_XOPEN
|
|
|
|
# define __USE_XOPEN
|
|
|
|
#endif
|
2001-06-18 01:42:24 +00:00
|
|
|
|
2001-05-31 05:01:06 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
#include <ftypes-int.h>
|
2013-11-09 13:41:10 +00:00
|
|
|
#include <epan/to_str.h>
|
2001-02-01 20:21:25 +00:00
|
|
|
|
Clean up handling of missing functions.
With autotools, CMake, and nmake, if we have a function, #define
HAVE_{function_name_in_all_caps}, otherwise don't #define it.
If we provide our own version of a function in libwsutil, make sure we
have a header that declares it, and *ONLY* include that header if
HAVE_{function_name_in_all_caps} is *NOT* defined, so that we don't have
the system declaration and our declaration colliding.
Check for inet_aton, strncasecmp, and strptime with CMake, just as we do
with autotools.
Simplify the addition of {function_name_in_all_caps}_LO to libwsutil in
autotools.
Change-Id: Id5be5c73f79f81919a3a865324e400eca7b88889
Reviewed-on: https://code.wireshark.org/review/2903
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-06 21:02:39 +00:00
|
|
|
#ifndef HAVE_STRPTIME
|
2010-05-28 20:19:55 +00:00
|
|
|
#include "wsutil/strptime.h"
|
2001-06-02 06:21:14 +00:00
|
|
|
#endif
|
|
|
|
|
2001-05-31 05:01:06 +00:00
|
|
|
static gboolean
|
2012-11-06 13:28:59 +00:00
|
|
|
cmp_eq(const fvalue_t *a, const fvalue_t *b)
|
2001-05-31 05:01:06 +00:00
|
|
|
{
|
2001-09-14 07:10:13 +00:00
|
|
|
return ((a->value.time.secs) ==(b->value.time.secs))
|
|
|
|
&&((a->value.time.nsecs)==(b->value.time.nsecs));
|
2001-05-31 05:01:06 +00:00
|
|
|
}
|
|
|
|
static gboolean
|
2012-11-06 13:28:59 +00:00
|
|
|
cmp_ne(const fvalue_t *a, const fvalue_t *b)
|
2001-05-31 05:01:06 +00:00
|
|
|
{
|
2001-09-14 07:10:13 +00:00
|
|
|
return (a->value.time.secs !=b->value.time.secs)
|
|
|
|
||(a->value.time.nsecs!=b->value.time.nsecs);
|
2001-05-31 05:01:06 +00:00
|
|
|
}
|
|
|
|
static gboolean
|
2012-11-06 13:28:59 +00:00
|
|
|
cmp_gt(const fvalue_t *a, const fvalue_t *b)
|
2001-05-31 05:01:06 +00:00
|
|
|
{
|
2001-09-14 07:10:13 +00:00
|
|
|
if (a->value.time.secs > b->value.time.secs) {
|
2001-05-31 05:01:06 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-09-14 07:10:13 +00:00
|
|
|
if (a->value.time.secs < b->value.time.secs) {
|
2001-05-31 05:01:06 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
return a->value.time.nsecs > b->value.time.nsecs;
|
2001-05-31 05:01:06 +00:00
|
|
|
}
|
|
|
|
static gboolean
|
2012-11-06 13:28:59 +00:00
|
|
|
cmp_ge(const fvalue_t *a, const fvalue_t *b)
|
2001-05-31 05:01:06 +00:00
|
|
|
{
|
2001-09-14 07:10:13 +00:00
|
|
|
if (a->value.time.secs > b->value.time.secs) {
|
2001-05-31 05:01:06 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-09-14 07:10:13 +00:00
|
|
|
if (a->value.time.secs < b->value.time.secs) {
|
2001-05-31 05:01:06 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
return a->value.time.nsecs >= b->value.time.nsecs;
|
2001-05-31 05:01:06 +00:00
|
|
|
}
|
|
|
|
static gboolean
|
2012-11-06 13:28:59 +00:00
|
|
|
cmp_lt(const fvalue_t *a, const fvalue_t *b)
|
2001-05-31 05:01:06 +00:00
|
|
|
{
|
2001-09-14 07:10:13 +00:00
|
|
|
if (a->value.time.secs < b->value.time.secs) {
|
2001-05-31 05:01:06 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-09-14 07:10:13 +00:00
|
|
|
if (a->value.time.secs > b->value.time.secs) {
|
2001-05-31 05:01:06 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
return a->value.time.nsecs < b->value.time.nsecs;
|
2001-05-31 05:01:06 +00:00
|
|
|
}
|
|
|
|
static gboolean
|
2012-11-06 13:28:59 +00:00
|
|
|
cmp_le(const fvalue_t *a, const fvalue_t *b)
|
2001-05-31 05:01:06 +00:00
|
|
|
{
|
2001-09-14 07:10:13 +00:00
|
|
|
if (a->value.time.secs < b->value.time.secs) {
|
2001-05-31 05:01:06 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-09-14 07:10:13 +00:00
|
|
|
if (a->value.time.secs > b->value.time.secs) {
|
2001-05-31 05:01:06 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
return a->value.time.nsecs <= b->value.time.nsecs;
|
2001-05-31 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-28 21:30:34 +00:00
|
|
|
/*
|
|
|
|
* Get a nanoseconds value, starting at "p".
|
|
|
|
*
|
|
|
|
* Returns true on success, false on failure.
|
|
|
|
*/
|
|
|
|
static gboolean
|
2014-01-15 01:05:03 +00:00
|
|
|
get_nsecs(const char *startp, int *nsecs)
|
2001-12-28 21:30:34 +00:00
|
|
|
{
|
|
|
|
int ndigits;
|
|
|
|
int scale;
|
2014-01-15 01:05:03 +00:00
|
|
|
const char *p;
|
2001-12-28 21:30:34 +00:00
|
|
|
int val;
|
|
|
|
int digit;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* How many characters are in the string?
|
|
|
|
*/
|
2009-03-15 02:57:16 +00:00
|
|
|
ndigits = (int)strlen(startp);
|
2001-12-28 21:30:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If there are N characters in the string, the last of the
|
|
|
|
* characters would be the digit corresponding to 10^(9-N)
|
|
|
|
* nanoseconds.
|
|
|
|
*/
|
|
|
|
scale = 9 - ndigits;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start at the last character, and work backwards.
|
|
|
|
*/
|
|
|
|
p = startp + ndigits;
|
|
|
|
val = 0;
|
|
|
|
while (p != startp) {
|
|
|
|
p--;
|
|
|
|
|
2014-10-17 01:26:03 +00:00
|
|
|
if (!g_ascii_isdigit(*p)) {
|
2001-12-28 21:30:34 +00:00
|
|
|
/*
|
|
|
|
* Not a digit - error.
|
|
|
|
*/
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
digit = *p - '0';
|
|
|
|
if (digit != 0) {
|
|
|
|
/*
|
|
|
|
* Non-zero digit corresponding to that number
|
|
|
|
* of (10^scale) units.
|
|
|
|
*
|
|
|
|
* If scale is less than zero, this digit corresponds
|
|
|
|
* to a value less than a nanosecond, so this number
|
|
|
|
* isn't valid.
|
|
|
|
*/
|
|
|
|
if (scale < 0)
|
|
|
|
return FALSE;
|
|
|
|
for (i = 0; i < scale; i++)
|
|
|
|
digit *= 10;
|
|
|
|
val += digit;
|
|
|
|
}
|
|
|
|
scale++;
|
|
|
|
}
|
|
|
|
*nsecs = val;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-05-31 05:01:06 +00:00
|
|
|
static gboolean
|
2015-01-18 10:22:19 +00:00
|
|
|
relative_val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, gchar **err_msg)
|
2001-05-31 05:01:06 +00:00
|
|
|
{
|
2014-01-15 01:05:03 +00:00
|
|
|
const char *curptr;
|
|
|
|
char *endptr;
|
2005-08-18 12:55:01 +00:00
|
|
|
gboolean negative = FALSE;
|
2010-05-28 20:19:55 +00:00
|
|
|
|
2001-05-31 06:20:10 +00:00
|
|
|
curptr = s;
|
|
|
|
|
2005-08-18 12:55:01 +00:00
|
|
|
if(*curptr == '-') {
|
|
|
|
negative = TRUE;
|
|
|
|
curptr++;
|
|
|
|
}
|
2010-05-28 20:19:55 +00:00
|
|
|
|
2001-05-31 06:20:10 +00:00
|
|
|
/*
|
|
|
|
* If it doesn't begin with ".", it should contain a seconds
|
|
|
|
* value.
|
|
|
|
*/
|
|
|
|
if (*curptr != '.') {
|
|
|
|
/*
|
|
|
|
* Get the seconds value.
|
|
|
|
*/
|
2001-09-14 07:10:13 +00:00
|
|
|
fv->value.time.secs = strtoul(curptr, &endptr, 10);
|
2001-05-31 06:48:00 +00:00
|
|
|
if (endptr == curptr || (*endptr != '\0' && *endptr != '.'))
|
|
|
|
goto fail;
|
2001-05-31 06:20:10 +00:00
|
|
|
curptr = endptr;
|
|
|
|
if (*curptr == '.')
|
|
|
|
curptr++; /* skip the decimal point */
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* No seconds value - it's 0.
|
|
|
|
*/
|
2001-09-14 07:10:13 +00:00
|
|
|
fv->value.time.secs = 0;
|
2001-05-31 06:20:10 +00:00
|
|
|
curptr++; /* skip the decimal point */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there's more stuff left in the string, it should be the
|
2001-09-14 07:10:13 +00:00
|
|
|
* nanoseconds value.
|
2001-05-31 06:20:10 +00:00
|
|
|
*/
|
2001-12-28 21:30:34 +00:00
|
|
|
if (*curptr != '\0') {
|
2001-05-31 06:20:10 +00:00
|
|
|
/*
|
2001-09-14 07:10:13 +00:00
|
|
|
* Get the nanoseconds value.
|
2001-05-31 06:20:10 +00:00
|
|
|
*/
|
2001-12-28 21:30:34 +00:00
|
|
|
if (!get_nsecs(curptr, &fv->value.time.nsecs))
|
2001-05-31 06:48:00 +00:00
|
|
|
goto fail;
|
2001-05-31 06:20:10 +00:00
|
|
|
} else {
|
|
|
|
/*
|
2001-09-14 07:10:13 +00:00
|
|
|
* No nanoseconds value - it's 0.
|
2001-05-31 06:20:10 +00:00
|
|
|
*/
|
2001-09-14 07:10:13 +00:00
|
|
|
fv->value.time.nsecs = 0;
|
2001-05-31 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2005-08-18 12:55:01 +00:00
|
|
|
if(negative) {
|
|
|
|
fv->value.time.secs = -fv->value.time.secs;
|
|
|
|
fv->value.time.nsecs = -fv->value.time.nsecs;
|
|
|
|
}
|
2001-05-31 05:01:06 +00:00
|
|
|
return TRUE;
|
2001-05-31 06:48:00 +00:00
|
|
|
|
|
|
|
fail:
|
2015-01-18 10:22:19 +00:00
|
|
|
if (err_msg != NULL)
|
|
|
|
*err_msg = g_strdup_printf("\"%s\" is not a valid time.", s);
|
2001-05-31 06:48:00 +00:00
|
|
|
return FALSE;
|
2001-05-31 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2015-01-18 10:22:19 +00:00
|
|
|
absolute_val_from_string(fvalue_t *fv, const char *s, gchar **err_msg)
|
2001-05-31 05:01:06 +00:00
|
|
|
{
|
|
|
|
struct tm tm;
|
2001-12-28 21:30:34 +00:00
|
|
|
char *curptr;
|
2001-05-31 06:48:00 +00:00
|
|
|
|
2011-07-28 05:49:47 +00:00
|
|
|
memset(&tm, 0, sizeof(tm));
|
2001-05-31 06:48:00 +00:00
|
|
|
curptr = strptime(s,"%b %d, %Y %H:%M:%S", &tm);
|
2011-07-28 05:49:47 +00:00
|
|
|
if (curptr == NULL)
|
|
|
|
curptr = strptime(s,"%Y-%m-%dT%H:%M:%S", &tm);
|
|
|
|
if (curptr == NULL)
|
|
|
|
curptr = strptime(s,"%Y-%m-%d %H:%M:%S", &tm);
|
|
|
|
if (curptr == NULL)
|
|
|
|
curptr = strptime(s,"%Y-%m-%d %H:%M", &tm);
|
|
|
|
if (curptr == NULL)
|
|
|
|
curptr = strptime(s,"%Y-%m-%d %H", &tm);
|
|
|
|
if (curptr == NULL)
|
|
|
|
curptr = strptime(s,"%Y-%m-%d", &tm);
|
2001-05-31 06:48:00 +00:00
|
|
|
if (curptr == NULL)
|
|
|
|
goto fail;
|
|
|
|
tm.tm_isdst = -1; /* let the computer figure out if it's DST */
|
2001-09-14 07:10:13 +00:00
|
|
|
fv->value.time.secs = mktime(&tm);
|
2001-05-31 06:48:00 +00:00
|
|
|
if (*curptr != '\0') {
|
|
|
|
/*
|
|
|
|
* Something came after the seconds field; it must be
|
2001-09-14 07:10:13 +00:00
|
|
|
* a nanoseconds field.
|
2001-05-31 06:48:00 +00:00
|
|
|
*/
|
|
|
|
if (*curptr != '.')
|
|
|
|
goto fail; /* it's not */
|
|
|
|
curptr++; /* skip the "." */
|
2014-10-17 01:26:03 +00:00
|
|
|
if (!g_ascii_isdigit((unsigned char)*curptr))
|
2001-05-31 06:48:00 +00:00
|
|
|
goto fail; /* not a digit, so not valid */
|
2001-12-28 21:30:34 +00:00
|
|
|
if (!get_nsecs(curptr, &fv->value.time.nsecs))
|
2001-05-31 06:48:00 +00:00
|
|
|
goto fail;
|
|
|
|
} else {
|
|
|
|
/*
|
2001-09-14 07:10:13 +00:00
|
|
|
* No nanoseconds value - it's 0.
|
2001-05-31 06:48:00 +00:00
|
|
|
*/
|
2001-09-14 07:10:13 +00:00
|
|
|
fv->value.time.nsecs = 0;
|
2001-05-31 06:48:00 +00:00
|
|
|
}
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
if (fv->value.time.secs == -1) {
|
2001-05-31 06:48:00 +00:00
|
|
|
/*
|
|
|
|
* XXX - should we supply an error message that mentions
|
|
|
|
* that the time specified might be syntactically valid
|
|
|
|
* but might not actually have occurred, e.g. a time in
|
|
|
|
* the non-existent time range after the clocks are
|
|
|
|
* set forward during daylight savings time (or possibly
|
|
|
|
* that it's in the time range after the clocks are set
|
|
|
|
* backward, so that there are two different times that
|
|
|
|
* it could be)?
|
|
|
|
*/
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2001-05-31 05:01:06 +00:00
|
|
|
return TRUE;
|
2001-05-31 06:48:00 +00:00
|
|
|
|
|
|
|
fail:
|
2015-01-18 10:22:19 +00:00
|
|
|
if (err_msg != NULL)
|
|
|
|
*err_msg = g_strdup_printf("\"%s\" is not a valid absolute time. Example: \"Nov 12, 1999 08:55:44.123\" or \"2011-07-04 12:34:56\"",
|
2001-05-31 06:48:00 +00:00
|
|
|
s);
|
|
|
|
return FALSE;
|
2001-05-31 05:01:06 +00:00
|
|
|
}
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2003-08-27 15:23:11 +00:00
|
|
|
static gboolean
|
2015-01-18 10:22:19 +00:00
|
|
|
absolute_val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, gchar **err_msg)
|
2003-08-27 15:23:11 +00:00
|
|
|
{
|
2015-01-18 10:22:19 +00:00
|
|
|
return absolute_val_from_string(fv, s, err_msg);
|
2003-08-27 15:23:11 +00:00
|
|
|
}
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
static void
|
|
|
|
time_fvalue_new(fvalue_t *fv)
|
|
|
|
{
|
2001-09-14 07:10:13 +00:00
|
|
|
fv->value.time.secs = 0;
|
|
|
|
fv->value.time.nsecs = 0;
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-15 01:05:03 +00:00
|
|
|
time_fvalue_set(fvalue_t *fv, const nstime_t *value)
|
2001-02-01 20:21:25 +00:00
|
|
|
{
|
2014-01-15 01:05:03 +00:00
|
|
|
fv->value.time = *value;
|
2001-02-01 20:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
value_get(fvalue_t *fv)
|
|
|
|
{
|
|
|
|
return &(fv->value.time);
|
|
|
|
}
|
2010-05-28 20:19:55 +00:00
|
|
|
|
2003-07-30 22:50:39 +00:00
|
|
|
static int
|
2015-01-04 02:56:16 +00:00
|
|
|
absolute_val_repr_len(fvalue_t *fv, ftrepr_t rtype, int field_display _U_)
|
2003-07-30 22:50:39 +00:00
|
|
|
{
|
|
|
|
gchar *rep;
|
2014-08-16 01:32:57 +00:00
|
|
|
int ret;
|
2003-07-30 22:50:39 +00:00
|
|
|
|
2014-06-16 06:42:14 +00:00
|
|
|
rep = abs_time_to_str(NULL, &fv->value.time, ABSOLUTE_TIME_LOCAL,
|
2014-08-16 01:32:57 +00:00
|
|
|
rtype == FTREPR_DISPLAY);
|
2014-06-16 06:42:14 +00:00
|
|
|
|
2014-08-16 01:32:57 +00:00
|
|
|
ret = (int)strlen(rep) + ((rtype == FTREPR_DFILTER) ? 2 : 0); /* 2 for opening and closing quotes */
|
2014-06-16 06:42:14 +00:00
|
|
|
|
2014-08-16 01:32:57 +00:00
|
|
|
wmem_free(NULL, rep);
|
2014-06-16 06:42:14 +00:00
|
|
|
|
|
|
|
return ret;
|
2003-07-30 22:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-01-04 02:56:16 +00:00
|
|
|
absolute_val_to_repr(fvalue_t *fv, ftrepr_t rtype, int field_display _U_, char *buf)
|
2003-07-30 22:50:39 +00:00
|
|
|
{
|
2014-06-16 06:42:14 +00:00
|
|
|
gchar *rep = abs_time_to_str(NULL, &fv->value.time, ABSOLUTE_TIME_LOCAL,
|
2014-08-16 01:32:57 +00:00
|
|
|
rtype == FTREPR_DISPLAY);
|
|
|
|
if (rtype == FTREPR_DFILTER) {
|
2015-03-07 15:02:08 +00:00
|
|
|
*buf++ = '\"';
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(buf, rep);
|
|
|
|
|
|
|
|
if (rtype == FTREPR_DFILTER) {
|
|
|
|
buf += strlen(rep);
|
|
|
|
*buf++ = '\"';
|
|
|
|
*buf++ = '\0';
|
2014-08-16 01:32:57 +00:00
|
|
|
}
|
|
|
|
wmem_free(NULL, rep);
|
2003-07-30 22:50:39 +00:00
|
|
|
}
|
2010-05-28 20:19:55 +00:00
|
|
|
|
2003-07-30 22:50:39 +00:00
|
|
|
static int
|
2015-01-04 02:56:16 +00:00
|
|
|
relative_val_repr_len(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_)
|
2003-07-30 22:50:39 +00:00
|
|
|
{
|
|
|
|
gchar *rep;
|
2014-06-16 17:54:20 +00:00
|
|
|
int ret;
|
2003-07-30 22:50:39 +00:00
|
|
|
|
2014-06-16 17:54:20 +00:00
|
|
|
rep = rel_time_to_secs_str(NULL, &fv->value.time);
|
|
|
|
ret = (int)strlen(rep);
|
|
|
|
wmem_free(NULL, rep);
|
|
|
|
|
|
|
|
return ret;
|
2003-07-30 22:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-01-04 02:56:16 +00:00
|
|
|
relative_val_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf)
|
2003-07-30 22:50:39 +00:00
|
|
|
{
|
2014-06-16 17:54:20 +00:00
|
|
|
gchar *rep;
|
|
|
|
rep = rel_time_to_secs_str(NULL, &fv->value.time);
|
|
|
|
strcpy(buf, rep);
|
|
|
|
wmem_free(NULL, rep);
|
2003-07-30 22:50:39 +00:00
|
|
|
}
|
2001-02-01 20:21:25 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
ftype_register_time(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
static ftype_t abstime_type = {
|
2006-05-02 14:26:17 +00:00
|
|
|
FT_ABSOLUTE_TIME, /* ftype */
|
2004-08-22 00:31:58 +00:00
|
|
|
"FT_ABSOLUTE_TIME", /* name */
|
2011-12-27 20:35:41 +00:00
|
|
|
"Date and time", /* pretty_name */
|
2004-08-22 00:31:58 +00:00
|
|
|
0, /* wire_size */
|
|
|
|
time_fvalue_new, /* new_value */
|
|
|
|
NULL, /* free_value */
|
2003-08-27 15:23:11 +00:00
|
|
|
absolute_val_from_unparsed, /* val_from_unparsed */
|
2003-07-25 03:44:05 +00:00
|
|
|
absolute_val_from_string, /* val_from_string */
|
2003-07-30 22:50:39 +00:00
|
|
|
absolute_val_to_repr, /* val_to_string_repr */
|
|
|
|
absolute_val_repr_len, /* len_string_repr */
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2014-01-15 01:05:03 +00:00
|
|
|
NULL, /* set_value_byte_array */
|
|
|
|
NULL, /* set_value_bytes */
|
|
|
|
NULL, /* set_value_guid */
|
|
|
|
time_fvalue_set, /* set_value_time */
|
|
|
|
NULL, /* set_value_string */
|
|
|
|
NULL, /* set_value_tvbuff */
|
2007-01-18 11:02:26 +00:00
|
|
|
NULL, /* set_value_uinteger */
|
|
|
|
NULL, /* set_value_sinteger */
|
2014-12-17 20:19:20 +00:00
|
|
|
NULL, /* set_value_uinteger64 */
|
|
|
|
NULL, /* set_value_sinteger64 */
|
2004-08-22 00:31:58 +00:00
|
|
|
NULL, /* set_value_floating */
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2004-08-22 00:31:58 +00:00
|
|
|
value_get, /* get_value */
|
2007-01-18 11:02:26 +00:00
|
|
|
NULL, /* get_value_uinteger */
|
|
|
|
NULL, /* get_value_sinteger */
|
2014-12-17 20:19:20 +00:00
|
|
|
NULL, /* get_value_uinteger64 */
|
|
|
|
NULL, /* get_value_sinteger64 */
|
2004-08-22 00:31:58 +00:00
|
|
|
NULL, /* get_value_floating */
|
2001-05-31 05:01:06 +00:00
|
|
|
|
|
|
|
cmp_eq,
|
|
|
|
cmp_ne,
|
|
|
|
cmp_gt,
|
|
|
|
cmp_ge,
|
|
|
|
cmp_lt,
|
|
|
|
cmp_le,
|
2004-02-27 12:00:32 +00:00
|
|
|
NULL, /* cmp_bitwise_and */
|
2003-08-27 15:23:11 +00:00
|
|
|
NULL, /* cmp_contains */
|
2003-12-06 16:35:20 +00:00
|
|
|
NULL, /* cmp_matches */
|
2003-08-27 15:23:11 +00:00
|
|
|
|
2001-06-19 23:08:57 +00:00
|
|
|
NULL,
|
|
|
|
NULL
|
2001-02-01 20:21:25 +00:00
|
|
|
};
|
|
|
|
static ftype_t reltime_type = {
|
2006-05-02 14:26:17 +00:00
|
|
|
FT_RELATIVE_TIME, /* ftype */
|
2004-08-22 00:31:58 +00:00
|
|
|
"FT_RELATIVE_TIME", /* name */
|
2011-12-27 20:35:41 +00:00
|
|
|
"Time offset", /* pretty_name */
|
2004-08-22 00:31:58 +00:00
|
|
|
0, /* wire_size */
|
|
|
|
time_fvalue_new, /* new_value */
|
|
|
|
NULL, /* free_value */
|
2003-07-25 03:44:05 +00:00
|
|
|
relative_val_from_unparsed, /* val_from_unparsed */
|
|
|
|
NULL, /* val_from_string */
|
2003-07-30 22:50:39 +00:00
|
|
|
relative_val_to_repr, /* val_to_string_repr */
|
|
|
|
relative_val_repr_len, /* len_string_repr */
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2014-01-15 01:05:03 +00:00
|
|
|
NULL, /* set_value_byte_array */
|
|
|
|
NULL, /* set_value_bytes */
|
|
|
|
NULL, /* set_value_guid */
|
|
|
|
time_fvalue_set, /* set_value_time */
|
|
|
|
NULL, /* set_value_string */
|
|
|
|
NULL, /* set_value_tvbuff */
|
2007-01-18 11:02:26 +00:00
|
|
|
NULL, /* set_value_uinteger */
|
|
|
|
NULL, /* set_value_sinteger */
|
2014-12-17 20:19:20 +00:00
|
|
|
NULL, /* set_value_uinteger64 */
|
|
|
|
NULL, /* set_value_sinteger64 */
|
2004-08-22 00:31:58 +00:00
|
|
|
NULL, /* set_value_floating */
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2004-08-22 00:31:58 +00:00
|
|
|
value_get, /* get_value */
|
2007-01-18 11:02:26 +00:00
|
|
|
NULL, /* get_value_uinteger */
|
|
|
|
NULL, /* get_value_sinteger */
|
2014-12-17 20:19:20 +00:00
|
|
|
NULL, /* get_value_uinteger64 */
|
|
|
|
NULL, /* get_value_sinteger64 */
|
2004-08-22 00:31:58 +00:00
|
|
|
NULL, /* get_value_floating */
|
2001-05-31 05:01:06 +00:00
|
|
|
|
|
|
|
cmp_eq,
|
|
|
|
cmp_ne,
|
|
|
|
cmp_gt,
|
|
|
|
cmp_ge,
|
|
|
|
cmp_lt,
|
|
|
|
cmp_le,
|
2004-02-27 12:00:32 +00:00
|
|
|
NULL, /* cmp_bitwise_and */
|
2003-08-27 15:23:11 +00:00
|
|
|
NULL, /* cmp_contains */
|
2003-12-06 16:35:20 +00:00
|
|
|
NULL, /* cmp_matches */
|
2003-08-27 15:23:11 +00:00
|
|
|
|
2001-06-19 23:08:57 +00:00
|
|
|
NULL,
|
|
|
|
NULL
|
2001-02-01 20:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ftype_register(FT_ABSOLUTE_TIME, &abstime_type);
|
|
|
|
ftype_register(FT_RELATIVE_TIME, &reltime_type);
|
|
|
|
}
|
2014-06-16 17:54:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|