diff options
author | Anders Broman <anders.broman@ericsson.com> | 2009-07-22 08:09:22 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2009-07-22 08:09:22 +0000 |
commit | f186fba577c0f38b62efbcde2f530cb07b5d2e74 (patch) | |
tree | 1d6eacd5bc01beaef464503b7da30db764b0f2cd /gtk | |
parent | 203fb3f25f328f3b80d68965ecdd4ab6e00657e8 (diff) |
From Jakub Zawadzki:
This patch is cut&paste code from gtk/main_packet_list.c:packet_list_compare()
to new function frame_data_compare()
+ it make use of new function inside packet_list_compare() and
packet_list_compare_records()
svn path=/trunk/; revision=29164
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/main_packet_list.c | 64 | ||||
-rw-r--r-- | gtk/packet_list_store.c | 16 |
2 files changed, 16 insertions, 64 deletions
diff --git a/gtk/main_packet_list.c b/gtk/main_packet_list.c index 9644fc0631..8e0a502075 100644 --- a/gtk/main_packet_list.c +++ b/gtk/main_packet_list.c @@ -73,27 +73,6 @@ static gboolean last_at_end = FALSE; /* GtkClist compare routine, overrides default to allow numeric comparison */ -#define COMPARE_FRAME_NUM() ((fdata1->num < fdata2->num) ? -1 : \ - (fdata1->num > fdata2->num) ? 1 : \ - 0) - -#define COMPARE_NUM(f) ((fdata1->f < fdata2->f) ? -1 : \ - (fdata1->f > fdata2->f) ? 1 : \ - COMPARE_FRAME_NUM()) - -/* Compare time stamps. - A packet whose time is a reference time is considered to have - a lower time stamp than any frame with a non-reference time; - if both packets' times are reference times, we compare the - times of the packets. */ -#define COMPARE_TS(ts) \ - ((fdata1->flags.ref_time && !fdata2->flags.ref_time) ? -1 : \ - (!fdata1->flags.ref_time && fdata2->flags.ref_time) ? 1 : \ - (fdata1->ts.secs < fdata2->ts.secs) ? -1 : \ - (fdata1->ts.secs > fdata2->ts.secs) ? 1 : \ - (fdata1->ts.nsecs < fdata2->ts.nsecs) ? -1 :\ - (fdata1->ts.nsecs > fdata2->ts.nsecs) ? 1 : \ - COMPARE_FRAME_NUM()) static gint packet_list_compare(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2) { @@ -124,53 +103,20 @@ packet_list_compare(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2) switch (col_fmt) { case COL_NUMBER: - return COMPARE_FRAME_NUM(); - case COL_CLS_TIME: - switch (timestamp_get_type()) { - - case TS_ABSOLUTE: - case TS_ABSOLUTE_WITH_DATE: - case TS_EPOCH: - return COMPARE_TS(abs_ts); - - case TS_RELATIVE: - return COMPARE_TS(rel_ts); - - case TS_DELTA: - return COMPARE_TS(del_cap_ts); - - case TS_DELTA_DIS: - return COMPARE_TS(del_dis_ts); - - case TS_NOT_SET: - return 0; - } - return 0; - case COL_ABS_TIME: case COL_ABS_DATE_TIME: - return COMPARE_TS(abs_ts); - case COL_REL_TIME: - return COMPARE_TS(rel_ts); - case COL_DELTA_TIME: - return COMPARE_TS(del_cap_ts); - case COL_DELTA_TIME_DIS: - return COMPARE_TS(del_dis_ts); - case COL_PACKET_LENGTH: - return COMPARE_NUM(pkt_len); - case COL_CUMULATIVE_BYTES: - return COMPARE_NUM(cum_bytes); + return frame_data_compare(fdata1, fdata2, col_fmt); case COL_CUSTOM: hfi = proto_registrar_get_byname(cfile.cinfo.col_custom_field[clist->sort_column]); if (hfi == NULL) { - return COMPARE_FRAME_NUM(); + return frame_data_compare(fdata1, fdata2, COL_NUMBER); } else if ((hfi->strings == NULL) && (((IS_FT_INT(hfi->type) || IS_FT_UINT(hfi->type)) && ((hfi->display == BASE_DEC) || (hfi->display == BASE_DEC_HEX) || @@ -200,7 +146,7 @@ packet_list_compare(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2) else if (num1 > num2) return 1; else - return COMPARE_FRAME_NUM(); + return frame_data_compare(fdata1, fdata2, COL_NUMBER); } else { @@ -210,7 +156,7 @@ packet_list_compare(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2) if (text1) return 1; else - return COMPARE_FRAME_NUM(); + return frame_data_compare(fdata1, fdata2, COL_NUMBER); } if (!text1) @@ -218,7 +164,7 @@ packet_list_compare(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2) ret = strcmp(text1, text2); if (ret == 0) - return COMPARE_FRAME_NUM(); + return frame_data_compare(fdata1, fdata2, COL_NUMBER); else return ret; } diff --git a/gtk/packet_list_store.c b/gtk/packet_list_store.c index 139f2dcd33..1b11470f41 100644 --- a/gtk/packet_list_store.c +++ b/gtk/packet_list_store.c @@ -638,11 +638,17 @@ packet_list_compare_records(gint sort_id, PacketListRecord *a, /* XXX If we want to store other things than text, we need other sort functions */ - /* Get the frame number from frame data - * Is this a bit hackish?? - */ - if( cfile.cinfo.col_fmt[sort_id]==COL_NUMBER){ - return (b->fdata->num - a->fdata->num); + switch (cfile.cinfo.col_fmt[sort_id]) { + case COL_NUMBER: + case COL_CLS_TIME: + case COL_ABS_TIME: + case COL_ABS_DATE_TIME: + case COL_REL_TIME: + case COL_DELTA_TIME: + case COL_DELTA_TIME_DIS: + case COL_PACKET_LENGTH: + case COL_CUMULATIVE_BYTES: + return frame_data_compare(a->fdata, b->fdata, cfile.cinfo.col_fmt[sort_id]); } if((a->col_text[sort_id]) && (b->col_text[sort_id])) |