Changeset 91ea76c for libwandio/wandio.c


Ignore:
Timestamp:
05/28/12 14:07:07 (9 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
16c598d
Parents:
b3edbe9
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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libwandio/wandio.c

    r60f3c4c r91ea76c  
    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.