Changeset baef9df for lib/wandio.c


Ignore:
Timestamp:
04/20/10 14:08:27 (11 years ago)
Author:
Perry Lorier <perry@…>
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:
5b8f9ee
Parents:
8ed31c2
Message:

Add back support for opening files for write with arbitary flags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/wandio.c

    rb5af22c rbaef9df  
    112112#define READ_TRACE 0
    113113#define WRITE_TRACE 0
     114#define PIPELINE_TRACE 0
     115
     116#if PIPELINE_TRACE
     117#define DEBUG_PIPELINE(x) fprintf(stderr,"PIPELINE: %s\n",x)
     118#else
     119#define DEBUG_PIPELINE(x)
     120#endif
    114121
    115122io_t *wandio_create(const char *filename)
     
    121128         * the file */
    122129
     130        DEBUG_PIPELINE("stdio");
     131        DEBUG_PIPELINE("peek");
    123132        io_t *io = peek_open(stdio_open(filename));
    124133        char buffer[1024];
     
    130139        /* Auto detect gzip compressed data */
    131140        if (len>=2 && buffer[0] == '\037' && buffer[1] == '\213') {
     141                DEBUG_PIPELINE("zlib");
    132142                io = zlib_open(io);
    133143        }
    134144        /* Auto detect compress(1) compressed data (gzip can read this) */
    135145        if (len>=2 && buffer[0] == '\037' && buffer[1] == '\235') {
     146                DEBUG_PIPELINE("zlib");
    136147                io = zlib_open(io);
    137148        }
     
    140151        /* Auto detect bzip compressed data */
    141152        if (len>=3 && buffer[0] == 'B' && buffer[1] == 'Z' && buffer[2] == 'h') {
     153                DEBUG_PIPELINE("bzip");
    142154                io = bz_open(io);
    143155        }
     
    147159         * to read the data */
    148160
    149         if (use_threads)
     161        if (use_threads) {
     162                DEBUG_PIPELINE("thread");
    150163                io = thread_open(io);
     164        }
    151165       
     166        DEBUG_PIPELINE("peek");
    152167        return peek_open(io);
    153168}
     
    174189{
    175190        off_t ret;
     191        ret=io->source->read(io,buffer,len);
    176192#if READ_TRACE
    177         fprintf(stderr,"read(%s): %d bytes\n",io->source->name, (int)len);
    178 #endif
    179         ret=io->source->read(io,buffer,len);
     193        fprintf(stderr,"%p: read(%s): %d bytes = %d\n",io,io->source->name, (int)len,(int)ret);
     194#endif
    180195        return ret;
    181196}
     
    207222        assert ( compression_level >= 0 && compression_level <= 9 );
    208223
    209         iow=stdio_wopen(filename);
     224        iow=stdio_wopen(filename, flags);
    210225
    211226        /* We prefer zlib if available, otherwise we'll use bzip. If neither
Note: See TracChangeset for help on using the changeset viewer.