Changeset f66a4933 for lib/format_erf.c


Ignore:
Timestamp:
11/24/05 11:30:11 (16 years ago)
Author:
Daniel Lawson <dlawson@…>
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:
9cecdb2
Parents:
187a6d6
Message:

moved LIBTRACE_READ etc defines into common.h

if we don't have zlib, use read,open etc. We were using fread,fopen, but these take different parameters, and i couldn't make them work nicely.

stdin doesn't seem to work for non-zlib paths however

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    rf3ed52a rf66a4933  
    6565/*
    6666 gzread (gzFile, buf, len)
     67 gzdopen(path, mode)
     68 gzopen(path, mode)
     69 gzclose(gzFile)
    6770 gzwrite(gzFile, buf, len)
    68  gzdopen(path, mode)
    69  gzclose(gzFile)
    7071
    7172 fread(ptr, size, num, FILE)
     73 fdopen(filedes,mode)
     74 fopen(path, mode)
     75 fclose(FILE)
    7276 fwrite(ptr, size, num, FILE)
    73  fopen(path, mode)
    74  fdopen(fildes, mode)
    75 */
     77*/
     78/*
    7679#if HAVE_ZLIB
    7780#  include <zlib.h>
    78 #  define LIBTRACE_READ gzread
    79 #  define LIBTRACE_OPEN gzopen
    80 #  define LIBTRACE_FDOPEN gzdopen
    81 #  define LIBTRACE_CLOSE gzclose
    82 #  define LIBTRACE_WRITE gzwrite
     81#  define LIBTRACE_READ(file,buf,len) gzread(file,buf,len)
     82#  define LIBTRACE_FDOPEN(fd,mode) gzdopen(fd,mode)
     83#  define LIBTRACE_OPEN(path,mode) gzopen(path,mode)
     84#  define LIBTRACE_CLOSE(file) gzclose(file)
     85#  define LIBTRACE_WRITE(file,buf,len) gzwrite(file,buf,len)
    8386#else
    84 #  define LIBTRACE_READ fread
    85 #  define LIBTRACE_OPEN fopen
    86 #  define LIBTRACE_FDOPEN fdopen
    87 #  define LIBTRACE_CLOSE fclose
    88 #  define LIBTRACE_WRITE fwrite
    89 #endif
    90 
     87#  define LIBTRACE_READ(file,buf,len) fread(buf,len,1,file)
     88#  define LIBTRACE_FDOPEN(fd,mode) fdopen(fd,mode)
     89#  define LIBTRACE_OPEN(path,mode) fopen(path,mode)
     90#  define LIBTRACE_CLOSE(file) fclose(file)
     91#  define LIBTRACE_WRITE(file,buf,len) fwrite(buf,len,1,file)
     92#endif
     93*/
    9194#define COLLECTOR_PORT 3435
    9295
     
    126129                gzFile *file;
    127130#else   
    128                 FILE  *file;
     131                //FILE  *file;
     132                int file;
    129133#endif
    130134        } input;
     
    164168                gzFile *file;
    165169#else
    166                 FILE *file;
     170                //FILE *file;
     171                int file;
    167172#endif
    168173        } output;
     
    264269                // STDIN
    265270                libtrace->sourcetype = STDIN;
    266                 INPUT.file = LIBTRACE_FDOPEN(STDIN, "r");
     271                if ((INPUT.file = LIBTRACE_FDOPEN(stdin, "r")) < 0) {
     272                        perror("libtrace_fdopen:");
     273                        return 0;
     274                }
     275               
    267276
    268277        } else {
     
    373382        if (!strncmp(libtrace->uridata,"-",1)) {
    374383                // STDOUT
    375                 OUTPUT.file = LIBTRACE_FDOPEN(dup(1),filemode);
     384                OUTPUT.file = LIBTRACE_FDOPEN(stdout,filemode);
    376385        }
    377386        else {
Note: See TracChangeset for help on using the changeset viewer.