Changeset 1762


Ignore:
Timestamp:
05/28/12 14:07:07 (13 months ago)
Author:
salcock
Message:
  • Detect if a user is attempting to read a compressed format that their libtrace build does not support and provide an appropriate error. Previously, we'd just try to read the trace with a stdout reader, resulting in some very confusing results.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/format_helper.c

    r1700 r1762  
    266266        io_t *io=wandio_create(trace->uridata); 
    267267        if (!io) { 
    268                 trace_set_err(trace,errno,"Unable to open %s",trace->uridata); 
     268                if (errno != 0) { 
     269                        trace_set_err(trace,errno,"Unable to open %s",trace->uridata); 
     270                } else { 
     271                        trace_set_err(trace,TRACE_ERR_UNSUPPORTED_COMPRESS,"Unsupported compression error: %s", trace->uridata); 
     272                } 
    269273        } 
    270274        return io; 
  • trunk/lib/libtrace.h.in

    r1759 r1762  
    226226        TRACE_ERR_BAD_FILTER    = -9, 
    227227        /** RT communication breakdown */ 
    228         TRACE_ERR_RT_FAILURE    = -10 
     228        TRACE_ERR_RT_FAILURE    = -10, 
     229        /** Compression format unsupported */ 
     230        TRACE_ERR_UNSUPPORTED_COMPRESS  = -11 
    229231}; 
    230232 
     
    744746        LT_BITFIELD32      to_ds:1;     /**< Packet to Distribution Service */ 
    745747#endif 
     748         
    746749        uint16_t     duration;  /**< Duration value for NAV calculation */ 
    747750        uint8_t      mac1[6];   /**< MAC Address 1 */ 
  • trunk/libwandio/wandio.c

    r1757 r1762  
    141141                return NULL; 
    142142        len = wandio_peek(io, buffer, sizeof(buffer)); 
    143 #if HAVE_LIBZ 
    144143        /* Auto detect gzip compressed data */ 
    145144        if (len>=2 && buffer[0] == '\037' && buffer[1] == '\213') {  
     145#if HAVE_LIBZ 
    146146                DEBUG_PIPELINE("zlib"); 
    147147                io = zlib_open(io); 
     148#else 
     149                fprintf(stderr, "File %s is gzip compressed but libtrace has not been built with zlib support!\n", filename); 
     150                return NULL; 
     151#endif 
    148152        } 
    149153        /* Auto detect compress(1) compressed data (gzip can read this) */ 
    150154        if (len>=2 && buffer[0] == '\037' && buffer[1] == '\235') { 
     155#if HAVE_LIBZ 
    151156                DEBUG_PIPELINE("zlib"); 
    152157                io = zlib_open(io); 
    153         } 
    154 #endif 
    155 #if HAVE_LIBBZ2 
     158#else 
     159                fprintf(stderr, "File %s is compress(1) compressed but libtrace has not been built with zlib support!\n", filename); 
     160                return NULL; 
     161#endif 
     162        } 
     163 
    156164        /* Auto detect bzip compressed data */ 
    157165        if (len>=3 && buffer[0] == 'B' && buffer[1] == 'Z' && buffer[2] == 'h') {  
     166#if HAVE_LIBBZ2 
    158167                DEBUG_PIPELINE("bzip"); 
    159168                io = bz_open(io); 
    160         } 
    161 #endif 
     169#else 
     170                fprintf(stderr, "File %s is bzip compressed but libtrace has not been built with bzip2 support!\n", filename); 
     171                return NULL; 
     172#endif 
     173        } 
    162174         
    163175        /* Now open a threaded, peekable reader using the appropriate module 
     
    218230DLLEXPORT void wandio_destroy(io_t *io) 
    219231{  
     232        if (!io) 
     233                return; 
     234         
    220235        if (keep_stats)  
    221236                fprintf(stderr,"LIBTRACEIO STATS: %"PRIu64" blocks on read\n", read_waits); 
Note: See TracChangeset for help on using the changeset viewer.