From Lars Roland: Move timestamp_type into libethereal and provide accessor
authorOlivier Biot <obiot.ethereal@gmail.com>
Thu, 18 Mar 2004 19:04:33 +0000 (19:04 -0000)
committerOlivier Biot <obiot.ethereal@gmail.com>
Thu, 18 Mar 2004 19:04:33 +0000 (19:04 -0000)
methods for getting and setting the timestamp type.

This is a move towards a real libethereal shared library.

svn path=/trunk/; revision=10402

column.c
dftest.c
epan/Makefile.am
epan/Makefile.nmake
epan/column-utils.c
epan/timestamp.h
globals.h
gtk/main.c
gtk/menu.c
gtk/packet_list.c
tethereal.c

index c92b392acd6676b0612e41eda801cad252e022b3..125ba546bf6bf0ffcb6cfcd26cbe1a3d8d970044 100644 (file)
--- a/column.c
+++ b/column.c
@@ -1,7 +1,7 @@
 /* column.c
  * Routines for handling column preferences
  *
- * $Id: column.c,v 1.46 2004/01/31 04:10:04 guy Exp $
+ * $Id: column.c,v 1.47 2004/03/18 19:04:30 obiot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -212,9 +212,9 @@ get_column_longest_string(gint format)
       return "0000000";
       break;
     case COL_CLS_TIME:
-      if (timestamp_type == TS_ABSOLUTE)
+      if (get_timestamp_setting() == TS_ABSOLUTE)
         return "00:00:00.000000";
-      else if (timestamp_type == TS_ABSOLUTE_WITH_DATE)
+      else if (get_timestamp_setting() == TS_ABSOLUTE_WITH_DATE)
         return "0000-00-00 00:00:00.000000";
       else
         return "0000.000000";
index c384f74cf6ef6b30e3c09e6dd076bba1726d1ea2..751086f7af7418b793774fa9473bf04ccbb566b9 100644 (file)
--- a/dftest.c
+++ b/dftest.c
@@ -1,6 +1,6 @@
 /* dftest.c.c
  *
- * $Id: dftest.c,v 1.8 2004/02/21 22:00:46 guy Exp $
+ * $Id: dftest.c,v 1.9 2004/03/18 19:04:31 obiot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -49,7 +49,6 @@
 #include "register.h"
 
 packet_info    pi;
-ts_type                timestamp_type = TS_RELATIVE;
 
 int
 main(int argc, char **argv)
@@ -61,6 +60,8 @@ main(int argc, char **argv)
        e_prefs         *prefs;
        dfilter_t       *df;
 
+       set_timestamp_setting(TS_RELATIVE);
+
        /* register all dissectors; we must do this before checking for the
        "-g" flag, as the "-g" flag dumps a list of fields registered
        by the dissectors, and we must do it before we read the preferences,
index 5340ac4d986ab53766603e5b2de4cd5df41fe0f8..3c5e07aa40267f15dbea609ab962978c63a8c0d3 100644 (file)
@@ -2,7 +2,7 @@
 # Automake file for the EPAN library
 # (Ethereal Protocol ANalyzer Library)
 #
-# $Id: Makefile.am,v 1.41 2004/03/17 17:46:40 jmayer Exp $
+# $Id: Makefile.am,v 1.42 2004/03/18 19:04:31 obiot Exp $
 #
 # Ethereal - Network traffic analyzer
 # By Gerald Combs <gerald@ethereal.com>
@@ -84,6 +84,7 @@ libethereal_la_SOURCES = \
        sna-utils.h             \
        strutil.c               \
        strutil.h               \
+       timestamp.c             \
        timestamp.h             \
        to_str.c                \
        to_str.h                \
index 9fe26533b2236b86c6aba6d677614b750c639a0a..f772b81b3590808504646cd41e497d5ba780fdd0 100644 (file)
@@ -1,7 +1,7 @@
 ## Makefile for building ethereal.exe with Microsoft C and nmake
 ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
 #
-# $Id: Makefile.nmake,v 1.36 2004/03/06 03:25:10 guy Exp $
+# $Id: Makefile.nmake,v 1.37 2004/03/18 19:04:31 obiot Exp $
 
 include ..\config.nmake
 
@@ -57,6 +57,7 @@ OBJECTS=addr_and_mask.obj \
        resolv.obj       \
        sna-utils.obj   \
        strutil.obj      \
+       timestamp.obj \
        to_str.obj      \
        tvbuff.obj       \
        value_string.obj 
index 57a907b2126ada1148332ff886b8857049bccfd3..53e151b38f52bbc517ab929bffd4b2b236f85208 100644 (file)
@@ -1,7 +1,7 @@
 /* column-utils.c
  * Routines for column utilities.
  *
- * $Id: column-utils.c,v 1.46 2004/02/29 08:47:11 guy Exp $
+ * $Id: column-utils.c,v 1.47 2004/03/18 19:04:32 obiot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -523,7 +523,7 @@ col_set_abs_time(frame_data *fd, column_info *cinfo, int col)
 void
 col_set_cls_time(frame_data *fd, column_info *cinfo, int col)
 {
-  switch (timestamp_type) {
+  switch (get_timestamp_setting()) {
     case TS_ABSOLUTE:
       col_set_abs_time(fd, cinfo, col);
       break;
index 38f28ac507c5dd390500e80d5e49bec1f72dc1a1..60bbd8d3e5859950f9ef27ffa283b1e35aa7cea0 100644 (file)
@@ -1,7 +1,7 @@
 /* timestamp.h
  * Defines for packet timestamps
  *
- * $Id: timestamp.h,v 1.4 2004/01/19 23:03:19 guy Exp $
+ * $Id: timestamp.h,v 1.5 2004/03/18 19:04:32 obiot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -41,6 +41,7 @@ typedef enum {
  */
 #define TS_NOT_SET     ((ts_type)-1)
 
-extern ts_type timestamp_type;
+extern ts_type get_timestamp_setting(void);
+extern void set_timestamp_setting(ts_type);
 
 #endif /* timestamp.h */
index 2632006bf9dd73355649e0cbb43da3737e3e83b9..de1590b261f940331679d851a418a6c9d69a85b0 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -1,7 +1,7 @@
 /* globals.h
  * Global defines, etc.
  *
- * $Id: globals.h,v 1.32 2003/11/01 02:30:14 guy Exp $
+ * $Id: globals.h,v 1.33 2004/03/18 19:04:31 obiot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -35,6 +35,4 @@ extern gchar       *last_open_dir;
 extern gboolean     auto_scroll_live;
 #endif
 
-extern ts_type timestamp_type;
-
 #endif
index 1911ed74788117979c883b6133bb1445ca9a2078..c66c0dcb34697badcb59ae6d7fa15715108b910e 100644 (file)
@@ -1,6 +1,6 @@
 /* main.c
  *
- * $Id: main.c,v 1.416 2004/03/17 08:59:28 guy Exp $
+ * $Id: main.c,v 1.417 2004/03/18 19:04:32 obiot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 #include "packet_list.h"
 #include "recent.h"
 #include "follow_dlg.h"
+#include <epan/timestamp.h>
 
 #ifdef WIN32
 #include "capture-wpcap.h"
@@ -148,10 +149,6 @@ gchar       *ethereal_path = NULL;
 gchar       *last_open_dir = NULL;
 static gboolean updated_last_open_dir = FALSE;
 
-/* init with an invalid value, so that "recent" can detect this and */
-/* distinguish it from a command line value */
-ts_type timestamp_type = TS_NOT_SET;
-
 #if GTK_MAJOR_VERSION < 2
 GtkStyle *item_style;
 #endif
@@ -2258,13 +2255,13 @@ main(int argc, char *argv[])
         break;
       case 't':        /* Time stamp type */
         if (strcmp(optarg, "r") == 0)
-          timestamp_type = TS_RELATIVE;
+          set_timestamp_setting(TS_RELATIVE);
         else if (strcmp(optarg, "a") == 0)
-          timestamp_type = TS_ABSOLUTE;
+          set_timestamp_setting(TS_ABSOLUTE);
         else if (strcmp(optarg, "ad") == 0)
-          timestamp_type = TS_ABSOLUTE_WITH_DATE;
+          set_timestamp_setting(TS_ABSOLUTE_WITH_DATE);
         else if (strcmp(optarg, "d") == 0)
-          timestamp_type = TS_DELTA;
+          set_timestamp_setting(TS_DELTA);
         else {
           fprintf(stderr, "ethereal: Invalid time stamp type \"%s\"\n",
             optarg);
index 0d0ab485a6df83f83bf8f0e8b4c34d8e12c3f415..8df5f8173f25baa8ba2ea902d027dfdf8c0e53e1 100644 (file)
@@ -1,7 +1,7 @@
 /* menu.c
  * Menu routines
  *
- * $Id: menu.c,v 1.177 2004/03/13 17:50:23 ulfl Exp $
+ * $Id: menu.c,v 1.178 2004/03/18 19:04:33 obiot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -68,6 +68,7 @@
 #include "../ui_util.h"
 #include "proto_draw.h"
 #include "simple_dialog.h"
+#include <epan/timestamp.h>
 
 GtkWidget *popup_menu_object;
 
@@ -1179,8 +1180,8 @@ static void
 timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_)
 {
     if (recent.gui_time_format != TS_ABSOLUTE) {
-        timestamp_type          = TS_ABSOLUTE;
-        recent.gui_time_format  = timestamp_type;
+        set_timestamp_setting(TS_ABSOLUTE);
+        recent.gui_time_format  = TS_ABSOLUTE;
         change_time_formats(&cfile);
     }
 }
@@ -1189,8 +1190,8 @@ static void
 timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_)
 {
     if (recent.gui_time_format != TS_ABSOLUTE_WITH_DATE) {
-        timestamp_type          = TS_ABSOLUTE_WITH_DATE;
-        recent.gui_time_format  = timestamp_type;
+        set_timestamp_setting(TS_ABSOLUTE_WITH_DATE);
+        recent.gui_time_format  = TS_ABSOLUTE_WITH_DATE;
         change_time_formats(&cfile);
     }
 }
@@ -1199,8 +1200,8 @@ static void
 timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_)
 {
     if (recent.gui_time_format != TS_RELATIVE) {
-        timestamp_type          = TS_RELATIVE;
-        recent.gui_time_format  = timestamp_type;
+        set_timestamp_setting(TS_RELATIVE);
+        recent.gui_time_format  = TS_RELATIVE;
         change_time_formats(&cfile);
     }
 }
@@ -1209,8 +1210,8 @@ static void
 timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_)
 {
     if (recent.gui_time_format != TS_DELTA) {
-        timestamp_type          = TS_DELTA;
-        recent.gui_time_format  = timestamp_type;
+        set_timestamp_setting(TS_DELTA);
+        recent.gui_time_format  = TS_DELTA;
         change_time_formats(&cfile);
     }
 }
@@ -1293,8 +1294,8 @@ menu_recent_read_finished(void) {
     main_widgets_rearrange();
 
     /* don't change the time format, if we had a command line value */
-    if (timestamp_type != TS_NOT_SET) {
-        recent.gui_time_format = timestamp_type;
+    if (get_timestamp_setting() != TS_NOT_SET) {
+        recent.gui_time_format = get_timestamp_setting();
     }
 
     switch(recent.gui_time_format) {
index 07e0d17efb5d21b315ef73123549b7a9070fac69..c42b203d1206e4e836e8251e66c71b6a2dd71a0e 100644 (file)
@@ -1,7 +1,7 @@
 /* packet_list.c
  * packet list related functions   2002 Olivier Abad
  *
- * $Id: packet_list.c,v 1.18 2004/02/06 19:19:10 ulfl Exp $
+ * $Id: packet_list.c,v 1.19 2004/03/18 19:04:33 obiot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -45,6 +45,7 @@
 #include "file_dlg.h"
 #include "packet_list.h"
 #include "keys.h"
+#include <epan/timestamp.h>
 
 #include "image/clist_ascend.xpm"
 #include "image/clist_descend.xpm"
@@ -148,7 +149,7 @@ packet_list_compare(EthCList *clist, gconstpointer  ptr1, gconstpointer  ptr2)
     return COMPARE_FRAME_NUM();
 
   case COL_CLS_TIME:
-    switch (timestamp_type) {
+    switch (get_timestamp_setting()) {
 
     case TS_ABSOLUTE:
     case TS_ABSOLUTE_WITH_DATE:
index 2e5776ecca57eb10e029045f84fba86d11f5dec7..d92e77ab41ebf96adfa7881552656e1d9dfb3f6f 100644 (file)
@@ -1,6 +1,6 @@
 /* tethereal.c
  *
- * $Id: tethereal.c,v 1.231 2004/02/23 16:12:51 gerald Exp $
+ * $Id: tethereal.c,v 1.232 2004/03/18 19:04:31 obiot Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -97,6 +97,7 @@
 #include <epan/epan_dissect.h>
 #include "tap.h"
 #include "report_err.h"
+#include <epan/timestamp.h>
 
 #ifdef HAVE_LIBPCAP
 #include <wiretap/wtap-capture.h>
@@ -186,7 +187,6 @@ static int pipe_dispatch(int, loop_data *, struct pcap_hdr *, \
 #endif
 
 capture_file cfile;
-ts_type timestamp_type = TS_RELATIVE;
 #ifdef HAVE_LIBPCAP
 typedef struct {
        int snaplen;                    /* Maximum captured packet length */
@@ -830,6 +830,8 @@ main(int argc, char *argv[])
   char                 badopt;
   ethereal_tap_list *tli;
 
+  set_timestamp_setting(TS_RELATIVE);
+
   /* Register all dissectors; we must do this before checking for the
      "-G" flag, as the "-G" flag dumps information registered by the
      dissectors, and we must do it before we read the preferences, in
@@ -1182,13 +1184,13 @@ main(int argc, char *argv[])
         break;
       case 't':        /* Time stamp type */
         if (strcmp(optarg, "r") == 0)
-          timestamp_type = TS_RELATIVE;
+          set_timestamp_setting(TS_RELATIVE);
         else if (strcmp(optarg, "a") == 0)
-          timestamp_type = TS_ABSOLUTE;
+          set_timestamp_setting(TS_ABSOLUTE);
         else if (strcmp(optarg, "ad") == 0)
-          timestamp_type = TS_ABSOLUTE_WITH_DATE;
+          set_timestamp_setting(TS_ABSOLUTE_WITH_DATE);
         else if (strcmp(optarg, "d") == 0)
-          timestamp_type = TS_DELTA;
+          set_timestamp_setting(TS_DELTA);
         else {
           fprintf(stderr, "tethereal: Invalid time stamp type \"%s\"\n",
             optarg);