@ -198,50 +198,29 @@ slice(fvalue_t *fv, GByteArray *bytes, guint offset, guint length)
}
}
static gboolean
cmp_eq ( const fvalue_t * fv_a , const fvalue _t * fv_ b)
static int
_tvbcmp ( tvbuff_t * a , tvbuff _t * b )
{
const protocol_value_t * a = ( const protocol_value_t * ) & fv_a - > value . protocol ;
const protocol_value_t * b = ( const protocol_value_t * ) & fv_b - > value . protocol ;
volatile gboolean eq = FALSE ;
TRY {
if ( ( a - > tvb ! = NULL ) & & ( b - > tvb ! = NULL ) ) {
guint a_len = tvb_captured_length ( a - > tvb ) ;
guint a_len = tvb_captured_length ( a ) ;
guint b_len = tvb_captured_length ( b ) ;
if ( a_len = = tvb_captured_length ( b - > tvb ) )
eq = ( memcmp ( tvb_get_ptr ( a - > tvb , 0 , a_len ) , tvb_get_ptr ( b - > tvb , 0 , a_len ) , a_len ) = = 0 ) ;
} else {
eq = ( strcmp ( a - > proto_string , b - > proto_string ) = = 0 ) ;
}
}
CATCH_ALL {
/* nothing */
}
ENDTRY ;
return eq ;
if ( a_len ! = b_len )
return a_len < b_len ? - 1 : 1 ;
return memcmp ( tvb_get_ptr ( a , 0 , a_len ) , tvb_get_ptr ( b , 0 , a_len ) , a_len ) ;
}
static gboolean
cmp_lt ( const fvalue_t * fv_a , const fvalue_t * fv_b )
static int
cmp_order ( const fvalue_t * fv_a , const fvalue_t * fv_b )
{
const protocol_value_t * a = ( const protocol_value_t * ) & fv_a - > value . protocol ;
const protocol_value_t * b = ( const protocol_value_t * ) & fv_b - > value . protocol ;
volatile gboolean lt = FALSE ;
volatile int c = 0 ;
TRY {
if ( ( a - > tvb ! = NULL ) & & ( b - > tvb ! = NULL ) ) {
guint a_len = tvb_captured_length ( a - > tvb ) ;
guint b_len = tvb_captured_length ( b - > tvb ) ;
if ( a_len < b_len ) {
lt = TRUE ;
} else if ( a_len = = b_len ) {
lt = ( memcmp ( tvb_get_ptr ( a - > tvb , 0 , a_len ) , tvb_get_ptr ( b - > tvb , 0 , a_len ) , a_len ) < 0 ) ;
}
c = _tvbcmp ( a - > tvb , b - > tvb ) ;
} else {
lt = ( strcmp ( a - > proto_string , b - > proto_string ) < 0 ) ;
c = strcmp ( a - > proto_string , b - > proto_string ) ;
}
}
CATCH_ALL {
@ -249,17 +228,7 @@ cmp_lt(const fvalue_t *fv_a, const fvalue_t *fv_b)
}
ENDTRY ;
return lt ;
}
static int
cmp_order ( const fvalue_t * fv_a , const fvalue_t * fv_b )
{
if ( cmp_lt ( fv_a , fv_b ) )
return - 1 ;
if ( cmp_eq ( fv_a , fv_b ) )
return 0 ;
return 1 ;
return c ;
}
static gboolean