Add relative start time, duration, and average data rate (bps) columns
[obnox/wireshark/wip.git] / epan / nstime.h
index 2cadd521d107850c9a8bfd4938873651939e4892..ea97ea5924cb030eb8740d5e5683517d1793e51c 100644 (file)
@@ -1,10 +1,10 @@
 /* nstime.h
  * Definition of data structure to hold time values with nanosecond resolution
  *
- * $Id: nstime.h,v 1.2 2002/08/28 20:40:44 jmayer Exp $
+ * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
 
 #include <time.h>
 
+#include <wiretap/wtap.h>
+
 typedef struct {
        time_t  secs;
        int     nsecs;
 } nstime_t;
 
+/* functions */
+
+/* set the given nstime_t to zero */
+extern void nstime_set_zero(nstime_t *nstime);
+
+/* is the given nstime_t currently zero? */
+extern gboolean nstime_is_zero(nstime_t *nstime);
+
+/* set the given nstime_t to (0,maxint) to mark it as "unset"
+ * That way we can find the first frame even when a timestamp
+ * is zero (fix for bug 1056)
+ */
+extern void nstime_set_unset(nstime_t *nstime);
+
+/* is the given nstime_t currently (0,maxint)? */
+extern gboolean nstime_is_unset(nstime_t *nstime);
+
+/* calculate the delta between two times (can be negative!)
+ *
+ * delta = b-a
+ *
+ * Note that it is acceptable for two or more of the arguments to point at the
+ * same structure.
+ */
+extern void nstime_delta(nstime_t *delta, const nstime_t *b, const nstime_t *a );
+
+/* calculate the sum of two times
+ *
+ * sum = a+b
+ *
+ * Note that it is acceptable for two or more of the arguments to point at the
+ * same structure.
+ */
+extern void nstime_sum(nstime_t *sum, const nstime_t *b, const nstime_t *a );
+
+/* sum += a */
+#define nstime_add(sum, a) nstime_sum(sum, sum, a)
+
+/* compare two times are return a value similar to memcmp() or strcmp().
+ *
+ * a > b : > 0
+ * a = b : 0
+ * a < b : < 0
+ */
+extern int nstime_cmp(nstime_t *a, const nstime_t *b );
+
+/* converts nstime to double, time base is milli seconds */
+extern double nstime_to_msec(const nstime_t *time);
+
+/* converts nstime to double, time base is seconds */
+extern double nstime_to_sec(const nstime_t *time);
+
+/* converts wtap_nstime to double, time base is seconds */
+extern double wtap_nstime_to_sec(const struct wtap_nstime *time);
+
 #endif /* __NSTIME_H__  */