Skip to content

Commit

Permalink
timestamp display precision:
Browse files Browse the repository at this point in the history
- automatic adjustment depending on file format
- manual adjustment through menu items

save the setting in the recent file

svn path=/trunk/; revision=15534
  • Loading branch information
ulflulfl committed Aug 25, 2005
1 parent bd42437 commit 723c80e
Show file tree
Hide file tree
Showing 44 changed files with 658 additions and 70 deletions.
8 changes: 4 additions & 4 deletions cfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ typedef struct _capture_file {
int displayed_count; /* Number of displayed frames */
int marked_count; /* Number of marked frames */
gboolean drops_known; /* TRUE if we know how many packets were dropped */
guint32 drops; /* Dropped packets */
nstime_t elapsed_time;/* Elapsed time (see: tsaccur below!) */
guint32 drops; /* Dropped packets */
nstime_t elapsed_time;/* Elapsed time */
gboolean has_snap; /* TRUE if maximum capture packet length is known */
int snap; /* Maximum captured packet length */
wtap *wth; /* Wiretap session */
dfilter_t *rfcode; /* Compiled read (display) filter program */
gchar *dfilter; /* Display filter string */
dfilter_t *dfcode; /* Compiled display filter program */
/* search */
gchar *sfilter; /* Search filter string */
gboolean sbackward; /* TRUE if search is backward, FALSE if forward */
gboolean hex; /* TRUE is raw data search is being performed */
Expand All @@ -70,6 +71,7 @@ typedef struct _capture_file {
gboolean case_type; /* TRUE if case-insensitive text search */
gboolean decode_data; /* TRUE if searching protocol tree text */
gboolean summary_data; /* TRUE if searching Info column text */
/* packet data */
union wtap_pseudo_header pseudo_header; /* Packet pseudo_header */
guint8 pd[WTAP_MAX_PACKET_SIZE]; /* Packet data */
GMemChunk *plist_chunk; /* Memory chunk for frame_data structures */
Expand All @@ -82,8 +84,6 @@ typedef struct _capture_file {
epan_dissect_t *edt; /* Protocol dissection for currently selected packet */
field_info *finfo_selected; /* Field info for currently selected field */
struct ph_stats_s* pstats; /* accumulated stats (reset on redisplay in GUI)*/
int tsprecision; /* timestamp precision
(WTAP_FILE_TSPREC_USEC or WTAP_FILE_TSPREC_NSEC) */
} capture_file;

void init_cap_file(capture_file *);
Expand Down
2 changes: 1 addition & 1 deletion dftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ main(int argc, char **argv)
e_prefs *prefs;
dfilter_t *df;

set_timestamp_setting(TS_RELATIVE);
timestamp_set_type(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
Expand Down
200 changes: 191 additions & 9 deletions epan/column-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,81 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col)
then = fd->abs_ts.secs;
tmp = localtime(&then);
if (tmp != NULL) {
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
switch(timestamp_get_precision()) {
case(TS_PREC_FIXED_SEC):
case(TS_PREC_AUTO_SEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%04d-%02d-%02d %02d:%02d:%02d",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
tmp->tm_mday,
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec);
break;
case(TS_PREC_FIXED_DSEC):
case(TS_PREC_AUTO_DSEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%04d-%02d-%02d %02d:%02d:%02d.%01ld",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
tmp->tm_mday,
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs / 100000000);
break;
case(TS_PREC_FIXED_CSEC):
case(TS_PREC_AUTO_CSEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%04d-%02d-%02d %02d:%02d:%02d.%02ld",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
tmp->tm_mday,
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs / 10000000);
break;
case(TS_PREC_FIXED_MSEC):
case(TS_PREC_AUTO_MSEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%04d-%02d-%02d %02d:%02d:%02d.%03ld",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
tmp->tm_mday,
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs / 1000000);
break;
case(TS_PREC_FIXED_USEC):
case(TS_PREC_AUTO_USEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%04d-%02d-%02d %02d:%02d:%02d.%06ld",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
tmp->tm_mday,
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs / 1000); /* XXX - this has to be improved */
(long)fd->abs_ts.nsecs / 1000);
break;
case(TS_PREC_FIXED_NSEC):
case(TS_PREC_AUTO_NSEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%04d-%02d-%02d %02d:%02d:%02d.%09ld",
tmp->tm_year + 1900,
tmp->tm_mon + 1,
tmp->tm_mday,
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs);
break;
default:
g_assert_not_reached();
}
} else {
cinfo->col_buf[col][0] = '\0';
}
Expand All @@ -496,8 +562,40 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col)
static void
col_set_rel_time(frame_data *fd, column_info *cinfo, int col)
{
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->rel_ts.secs, fd->rel_ts.nsecs / 1000, USECS); /* XXX - this has to be improved */
switch(timestamp_get_precision()) {
case(TS_PREC_FIXED_SEC):
case(TS_PREC_AUTO_SEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000000, SECS);
break;
case(TS_PREC_FIXED_DSEC):
case(TS_PREC_AUTO_DSEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->rel_ts.secs, fd->rel_ts.nsecs / 100000000, DSECS);
break;
case(TS_PREC_FIXED_CSEC):
case(TS_PREC_AUTO_CSEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->rel_ts.secs, fd->rel_ts.nsecs / 10000000, CSECS);
break;
case(TS_PREC_FIXED_MSEC):
case(TS_PREC_AUTO_MSEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000, MSECS);
break;
case(TS_PREC_FIXED_USEC):
case(TS_PREC_AUTO_USEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->rel_ts.secs, fd->rel_ts.nsecs / 1000, USECS);
break;
case(TS_PREC_FIXED_NSEC):
case(TS_PREC_AUTO_NSEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->rel_ts.secs, fd->rel_ts.nsecs, NSECS);
break;
default:
g_assert_not_reached();
}
cinfo->col_data[col] = cinfo->col_buf[col];
strcpy(cinfo->col_expr[col],"frame.time_relative");
strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
Expand All @@ -506,8 +604,40 @@ col_set_rel_time(frame_data *fd, column_info *cinfo, int col)
static void
col_set_delta_time(frame_data *fd, column_info *cinfo, int col)
{
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->del_ts.secs, fd->del_ts.nsecs / 1000, USECS);
switch(timestamp_get_precision()) {
case(TS_PREC_FIXED_SEC):
case(TS_PREC_AUTO_SEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->del_ts.secs, fd->del_ts.nsecs / 1000000000, SECS);
break;
case(TS_PREC_FIXED_DSEC):
case(TS_PREC_AUTO_DSEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->del_ts.secs, fd->del_ts.nsecs / 100000000, DSECS);
break;
case(TS_PREC_FIXED_CSEC):
case(TS_PREC_AUTO_CSEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->del_ts.secs, fd->del_ts.nsecs / 10000000, CSECS);
break;
case(TS_PREC_FIXED_MSEC):
case(TS_PREC_AUTO_MSEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->del_ts.secs, fd->del_ts.nsecs / 1000000, MSECS);
break;
case(TS_PREC_FIXED_USEC):
case(TS_PREC_AUTO_USEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->del_ts.secs, fd->del_ts.nsecs / 1000, USECS);
break;
case(TS_PREC_FIXED_NSEC):
case(TS_PREC_AUTO_NSEC):
display_signed_time(cinfo->col_buf[col], COL_MAX_LEN,
fd->del_ts.secs, fd->del_ts.nsecs, NSECS);
break;
default:
g_assert_not_reached();
}
cinfo->col_data[col] = cinfo->col_buf[col];
strcpy(cinfo->col_expr[col],"frame.time_delta");
strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]);
Expand All @@ -524,11 +654,63 @@ col_set_abs_time(frame_data *fd, column_info *cinfo, int col)
then = fd->abs_ts.secs;
tmp = localtime(&then);
if (tmp != NULL) {
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%06ld",
switch(timestamp_get_precision()) {
case(TS_PREC_FIXED_SEC):
case(TS_PREC_AUTO_SEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%02d:%02d:%02d",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec);
break;
case(TS_PREC_FIXED_DSEC):
case(TS_PREC_AUTO_DSEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%02d:%02d:%02d.%01ld",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs / 100000000);
break;
case(TS_PREC_FIXED_CSEC):
case(TS_PREC_AUTO_CSEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%02d:%02d:%02d.%02ld",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs / 10000000);
break;
case(TS_PREC_FIXED_MSEC):
case(TS_PREC_AUTO_MSEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%02d:%02d:%02d.%03ld",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs / 1000000);
break;
case(TS_PREC_FIXED_USEC):
case(TS_PREC_AUTO_USEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%02d:%02d:%02d.%06ld",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs / 1000);
break;
case(TS_PREC_FIXED_NSEC):
case(TS_PREC_AUTO_NSEC):
g_snprintf(cinfo->col_buf[col], COL_MAX_LEN,
"%02d:%02d:%02d.%09ld",
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_ts.nsecs / 1000); /* XXX - this has to be improved */
(long)fd->abs_ts.nsecs);
break;
default:
g_assert_not_reached();
}
} else {
cinfo->col_buf[col][0] = '\0';
}
Expand All @@ -547,7 +729,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 (get_timestamp_setting()) {
switch (timestamp_get_type()) {
case TS_ABSOLUTE:
col_set_abs_time(fd, cinfo, col);
break;
Expand Down
Loading

0 comments on commit 723c80e

Please sign in to comment.