From Lars Roland: Move timestamp_type into libethereal and provide accessor

methods for getting and setting the timestamp type.

This is a move towards a real libethereal shared library.

svn path=/trunk/; revision=10402
This commit is contained in:
Olivier Biot 2004-03-18 19:04:33 +00:00
parent d714f1153f
commit 11f9232336
11 changed files with 45 additions and 42 deletions

View File

@ -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";

View File

@ -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,

View 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 \

View 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

View 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;

View 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 */

View File

@ -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

View 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>
@ -122,6 +122,7 @@
#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);

View 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) {

View 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:

View 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);